114 lines
6.2 KiB
Java
114 lines
6.2 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.client.model;
|
|
|
|
import java.util.Set;
|
|
import net.minecraft.client.model.BabyModelTransform;
|
|
import net.minecraft.client.model.EntityModel;
|
|
import net.minecraft.client.model.geom.ModelPart;
|
|
import net.minecraft.client.model.geom.PartPose;
|
|
import net.minecraft.client.model.geom.builders.CubeDeformation;
|
|
import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
|
import net.minecraft.client.model.geom.builders.MeshDefinition;
|
|
import net.minecraft.client.model.geom.builders.MeshTransformer;
|
|
import net.minecraft.client.model.geom.builders.PartDefinition;
|
|
import net.minecraft.client.renderer.entity.state.WolfRenderState;
|
|
import net.minecraft.util.Mth;
|
|
|
|
public class WolfModel
|
|
extends EntityModel<WolfRenderState> {
|
|
public static final MeshTransformer BABY_TRANSFORMER = new BabyModelTransform(Set.of("head"));
|
|
private static final String REAL_HEAD = "real_head";
|
|
private static final String UPPER_BODY = "upper_body";
|
|
private static final String REAL_TAIL = "real_tail";
|
|
private final ModelPart head;
|
|
private final ModelPart realHead;
|
|
private final ModelPart body;
|
|
private final ModelPart rightHindLeg;
|
|
private final ModelPart leftHindLeg;
|
|
private final ModelPart rightFrontLeg;
|
|
private final ModelPart leftFrontLeg;
|
|
private final ModelPart tail;
|
|
private final ModelPart realTail;
|
|
private final ModelPart upperBody;
|
|
private static final int LEG_SIZE = 8;
|
|
|
|
public WolfModel(ModelPart root) {
|
|
super(root);
|
|
this.head = root.getChild("head");
|
|
this.realHead = this.head.getChild(REAL_HEAD);
|
|
this.body = root.getChild("body");
|
|
this.upperBody = root.getChild(UPPER_BODY);
|
|
this.rightHindLeg = root.getChild("right_hind_leg");
|
|
this.leftHindLeg = root.getChild("left_hind_leg");
|
|
this.rightFrontLeg = root.getChild("right_front_leg");
|
|
this.leftFrontLeg = root.getChild("left_front_leg");
|
|
this.tail = root.getChild("tail");
|
|
this.realTail = this.tail.getChild(REAL_TAIL);
|
|
}
|
|
|
|
public static MeshDefinition createMeshDefinition(CubeDeformation g) {
|
|
MeshDefinition mesh = new MeshDefinition();
|
|
PartDefinition root = mesh.getRoot();
|
|
float headHeight = 13.5f;
|
|
PartDefinition head = root.addOrReplaceChild("head", CubeListBuilder.create(), PartPose.offset(-1.0f, 13.5f, -7.0f));
|
|
head.addOrReplaceChild(REAL_HEAD, CubeListBuilder.create().texOffs(0, 0).addBox(-2.0f, -3.0f, -2.0f, 6.0f, 6.0f, 4.0f, g).texOffs(16, 14).addBox(-2.0f, -5.0f, 0.0f, 2.0f, 2.0f, 1.0f, g).texOffs(16, 14).addBox(2.0f, -5.0f, 0.0f, 2.0f, 2.0f, 1.0f, g).texOffs(0, 10).addBox(-0.5f, -0.001f, -5.0f, 3.0f, 3.0f, 4.0f, g), PartPose.ZERO);
|
|
root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(18, 14).addBox(-3.0f, -2.0f, -3.0f, 6.0f, 9.0f, 6.0f, g), PartPose.offsetAndRotation(0.0f, 14.0f, 2.0f, 1.5707964f, 0.0f, 0.0f));
|
|
root.addOrReplaceChild(UPPER_BODY, CubeListBuilder.create().texOffs(21, 0).addBox(-3.0f, -3.0f, -3.0f, 8.0f, 6.0f, 7.0f, g), PartPose.offsetAndRotation(-1.0f, 14.0f, -3.0f, 1.5707964f, 0.0f, 0.0f));
|
|
CubeListBuilder leftLeg = CubeListBuilder.create().texOffs(0, 18).addBox(0.0f, 0.0f, -1.0f, 2.0f, 8.0f, 2.0f, g);
|
|
CubeListBuilder rightLeg = CubeListBuilder.create().mirror().texOffs(0, 18).addBox(0.0f, 0.0f, -1.0f, 2.0f, 8.0f, 2.0f, g);
|
|
root.addOrReplaceChild("right_hind_leg", rightLeg, PartPose.offset(-2.5f, 16.0f, 7.0f));
|
|
root.addOrReplaceChild("left_hind_leg", leftLeg, PartPose.offset(0.5f, 16.0f, 7.0f));
|
|
root.addOrReplaceChild("right_front_leg", rightLeg, PartPose.offset(-2.5f, 16.0f, -4.0f));
|
|
root.addOrReplaceChild("left_front_leg", leftLeg, PartPose.offset(0.5f, 16.0f, -4.0f));
|
|
PartDefinition tail = root.addOrReplaceChild("tail", CubeListBuilder.create(), PartPose.offsetAndRotation(-1.0f, 12.0f, 8.0f, 0.62831855f, 0.0f, 0.0f));
|
|
tail.addOrReplaceChild(REAL_TAIL, CubeListBuilder.create().texOffs(9, 18).addBox(0.0f, 0.0f, -1.0f, 2.0f, 8.0f, 2.0f, g), PartPose.ZERO);
|
|
return mesh;
|
|
}
|
|
|
|
@Override
|
|
public void setupAnim(WolfRenderState state) {
|
|
super.setupAnim(state);
|
|
float animationPos = state.walkAnimationPos;
|
|
float animationSpeed = state.walkAnimationSpeed;
|
|
this.tail.yRot = state.isAngry ? 0.0f : Mth.cos(animationPos * 0.6662f) * 1.4f * animationSpeed;
|
|
if (state.isSitting) {
|
|
float ageScale = state.ageScale;
|
|
this.upperBody.y += 2.0f * ageScale;
|
|
this.upperBody.xRot = 1.2566371f;
|
|
this.upperBody.yRot = 0.0f;
|
|
this.body.y += 4.0f * ageScale;
|
|
this.body.z -= 2.0f * ageScale;
|
|
this.body.xRot = 0.7853982f;
|
|
this.tail.y += 9.0f * ageScale;
|
|
this.tail.z -= 2.0f * ageScale;
|
|
this.rightHindLeg.y += 6.7f * ageScale;
|
|
this.rightHindLeg.z -= 5.0f * ageScale;
|
|
this.rightHindLeg.xRot = 4.712389f;
|
|
this.leftHindLeg.y += 6.7f * ageScale;
|
|
this.leftHindLeg.z -= 5.0f * ageScale;
|
|
this.leftHindLeg.xRot = 4.712389f;
|
|
this.rightFrontLeg.xRot = 5.811947f;
|
|
this.rightFrontLeg.x += 0.01f * ageScale;
|
|
this.rightFrontLeg.y += 1.0f * ageScale;
|
|
this.leftFrontLeg.xRot = 5.811947f;
|
|
this.leftFrontLeg.x -= 0.01f * ageScale;
|
|
this.leftFrontLeg.y += 1.0f * ageScale;
|
|
} else {
|
|
this.rightHindLeg.xRot = Mth.cos(animationPos * 0.6662f) * 1.4f * animationSpeed;
|
|
this.leftHindLeg.xRot = Mth.cos(animationPos * 0.6662f + (float)Math.PI) * 1.4f * animationSpeed;
|
|
this.rightFrontLeg.xRot = Mth.cos(animationPos * 0.6662f + (float)Math.PI) * 1.4f * animationSpeed;
|
|
this.leftFrontLeg.xRot = Mth.cos(animationPos * 0.6662f) * 1.4f * animationSpeed;
|
|
}
|
|
this.realHead.zRot = state.headRollAngle + state.getBodyRollAngle(0.0f);
|
|
this.upperBody.zRot = state.getBodyRollAngle(-0.08f);
|
|
this.body.zRot = state.getBodyRollAngle(-0.16f);
|
|
this.realTail.zRot = state.getBodyRollAngle(-0.2f);
|
|
this.head.xRot = state.xRot * ((float)Math.PI / 180);
|
|
this.head.yRot = state.yRot * ((float)Math.PI / 180);
|
|
this.tail.xRot = state.tailAngle;
|
|
}
|
|
}
|
|
|