Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions src/main/java/twilightforest/client/model/armor/TFArmorModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@

import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.entity.state.ArmorStandRenderState;
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.decoration.ArmorStand;

public class TFArmorModel extends HumanoidModel<LivingEntity> {
public class TFArmorModel extends HumanoidModel<HumanoidRenderState> {

public TFArmorModel(ModelPart root) {
super(root);
}

@Override
public void setupAnim(LivingEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
public void setupAnim(HumanoidRenderState humanoidRenderState) {
// [VanillaCopy] ArmorStandArmorModel
// this prevents helmets from always facing south, and the armor "breathing" on the stand
if (entity instanceof ArmorStand stand) {
this.head.xRot = Mth.DEG_TO_RAD * stand.getHeadPose().getX();
this.head.yRot = Mth.DEG_TO_RAD * stand.getHeadPose().getY();
this.head.zRot = Mth.DEG_TO_RAD * stand.getHeadPose().getZ();
this.body.xRot = Mth.DEG_TO_RAD * stand.getBodyPose().getX();
this.body.yRot = Mth.DEG_TO_RAD * stand.getBodyPose().getY();
this.body.zRot = Mth.DEG_TO_RAD * stand.getBodyPose().getZ();
this.leftArm.xRot = Mth.DEG_TO_RAD * stand.getLeftArmPose().getX();
this.leftArm.yRot = Mth.DEG_TO_RAD * stand.getLeftArmPose().getY();
this.leftArm.zRot = Mth.DEG_TO_RAD * stand.getLeftArmPose().getZ();
this.rightArm.xRot = Mth.DEG_TO_RAD * stand.getRightArmPose().getX();
this.rightArm.yRot = Mth.DEG_TO_RAD * stand.getRightArmPose().getY();
this.rightArm.zRot = Mth.DEG_TO_RAD * stand.getRightArmPose().getZ();
this.leftLeg.xRot = Mth.DEG_TO_RAD * stand.getLeftLegPose().getX();
this.leftLeg.yRot = Mth.DEG_TO_RAD * stand.getLeftLegPose().getY();
this.leftLeg.zRot = Mth.DEG_TO_RAD * stand.getLeftLegPose().getZ();
this.rightLeg.xRot = Mth.DEG_TO_RAD * stand.getRightLegPose().getX();
this.rightLeg.yRot = Mth.DEG_TO_RAD * stand.getRightLegPose().getY();
this.rightLeg.zRot = Mth.DEG_TO_RAD * stand.getRightLegPose().getZ();
this.hat.copyFrom(this.head);
if (humanoidRenderState instanceof ArmorStandRenderState state) {
this.head.xRot = Mth.DEG_TO_RAD * state.headPose.x();
this.head.yRot = Mth.DEG_TO_RAD * state.headPose.y();
this.head.zRot = Mth.DEG_TO_RAD * state.headPose.z();
this.body.xRot = Mth.DEG_TO_RAD * state.bodyPose.x();
this.body.yRot = Mth.DEG_TO_RAD * state.bodyPose.y();
this.body.zRot = Mth.DEG_TO_RAD * state.bodyPose.z();
this.leftArm.xRot = Mth.DEG_TO_RAD * state.leftArmPose.x();
this.leftArm.yRot = Mth.DEG_TO_RAD * state.leftArmPose.y();
this.leftArm.zRot = Mth.DEG_TO_RAD * state.leftArmPose.z();
this.rightArm.xRot = Mth.DEG_TO_RAD * state.rightArmPose.x();
this.rightArm.yRot = Mth.DEG_TO_RAD * state.rightArmPose.y();
this.rightArm.zRot = Mth.DEG_TO_RAD * state.rightArmPose.z();
this.leftLeg.xRot = Mth.DEG_TO_RAD * state.leftLegPose.x();
this.leftLeg.yRot = Mth.DEG_TO_RAD * state.leftLegPose.y();
this.leftLeg.zRot = Mth.DEG_TO_RAD * state.leftLegPose.z();
this.rightLeg.xRot = Mth.DEG_TO_RAD * state.rightLegPose.x();
this.rightLeg.yRot = Mth.DEG_TO_RAD * state.rightLegPose.y();
this.rightLeg.zRot = Mth.DEG_TO_RAD * state.rightLegPose.z();
this.hat.loadPose(this.head.storePose());
} else {
super.setupAnim(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
super.setupAnim(humanoidRenderState);
} // TF - Defer to super otherwise
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.*;
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity;
import org.joml.Vector3f;
Expand All @@ -15,10 +16,9 @@
import twilightforest.init.TFDataAttachments;
import twilightforest.util.TFMathUtil;

import java.util.Collections;
import java.util.List;

public class TravellersWingsModel extends HumanoidModel<LivingEntity> {
public class TravellersWingsModel extends HumanoidModel<HumanoidRenderState> {
private static final double TAU = 4; // Time (in ticks) in which distance reduces in e times
private static final float ANGLE_10_DEG = Mth.PI / 18;
private static final Vector3f SMALL_SWING = new Vector3f(8.0F, 8.0F, 8.0F);
Expand Down Expand Up @@ -167,9 +167,21 @@ protected static void createBelt(PartDefinition root, float deformation) {
);
}

public void setupModelAnimations(LivingEntity entity, float f, float f1, double ageInTicks, float netHeadYaw, float headPitch) {
// [VanillaCopy] this method should be removed when IClientItemExtensions fully switches to HumanoidRenderState
private HumanoidRenderState createRendererState(LivingEntity entity, float walkAnimationPos, float walkAnimationSpeed, double ageInTicks, float netHeadYaw, float headPitch) {
HumanoidRenderState state = new HumanoidRenderState();
state.entityType = entity.getType();
state.walkAnimationPos = walkAnimationPos;
state.walkAnimationSpeed = walkAnimationSpeed;
state.ageInTicks = (float) ageInTicks;
state.yRot = netHeadYaw;
state.xRot = headPitch;
return state;
}

public void setupModelAnimations(LivingEntity entity, float walkAnimationPos, float walkAnimationSpeed, double ageInTicks, float netHeadYaw, float headPitch) {
this.bodyParts().forEach(modelPart -> modelPart.getAllParts().forEach(ModelPart::resetPose));
super.setupAnim(entity, f, f1, (float) ageInTicks, netHeadYaw, headPitch);
super.setupAnim(createRendererState(entity, walkAnimationPos, walkAnimationSpeed, ageInTicks, netHeadYaw, headPitch));
TravellersWingsAnimAttachment animAttachment = entity.getData(TFDataAttachments.TRAVELLERS_WINGS_ANIM);
TravellersWingsAttachment attachment = entity.getData(TFDataAttachments.TRAVELLERS_WINGS);

Expand Down Expand Up @@ -220,7 +232,7 @@ public void setupModelAnimations(LivingEntity entity, float f, float f1, double
animAttachment.zRotOld = this.wingBaseRight.zRot;

// If the wing model keeps a non-changing offset then looking at it with a spyglass even 4 chunks away will reveal Z-fighting.
float distance = (float) (Math.sqrt(entity.distanceToSqr(this.mainCamera.getPosition())) * PART_OFFSET);
float distance = (float) (Math.sqrt(entity.distanceToSqr(this.mainCamera.position())) * PART_OFFSET);
// The below solution is to animate its offset based off of camera distance. The animation is not time-based.
int partCount = Math.min(this.wingPartsLeft.size(), this.wingPartsRight.size());
for (int partIndex = 0; partIndex < partCount; partIndex++) {
Expand All @@ -240,12 +252,6 @@ private Vector3f calculateRotations(TravellersWingsAnimAttachment attachment, do
);
}

@Override
protected Iterable<ModelPart> headParts() {
return Collections.emptyList();
}

@Override
protected Iterable<ModelPart> bodyParts() {
return ImmutableList.of(body, leftLeg, rightLeg);
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import net.neoforged.neoforge.client.model.geometry.IGeometryLoader;
import net.neoforged.neoforge.client.model.UnbakedModelLoader;

public class RoyalRagsModelLoader implements IGeometryLoader<UnbakedRoyalRagsModel> {
public class RoyalRagsModelLoader implements UnbakedModelLoader<UnbakedRoyalRagsModel> {
@Deprecated // FIXME: Generalize alongside with CastleDoor models
public static final RoyalRagsModelLoader INSTANCE = new RoyalRagsModelLoader();

Expand Down
Loading