| 1 | package net.minecraft.client.model.monster.enderman;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.model.HumanoidModel;
|
| 6 | import net.minecraft.client.model.geom.ModelPart;
|
| 7 | import net.minecraft.client.model.geom.PartPose;
|
| 8 | import net.minecraft.client.model.geom.builders.CubeDeformation;
|
| 9 | import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
| 10 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 11 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 12 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 13 | import net.minecraft.client.renderer.entity.state.EndermanRenderState;
|
| 14 | import net.minecraft.util.Mth;
|
| 15 |
|
| 16 | @Environment(EnvType.CLIENT)
|
| 17 | public class EndermanModel<T extends EndermanRenderState> extends HumanoidModel<T> {
|
| 18 | public EndermanModel(final ModelPart root) {
|
| 19 | super(root);
|
| 20 | }
|
| 21 |
|
| 22 | public static LayerDefinition createBodyLayer() {
|
| 23 | float yOffset = -14.0F;
|
| 24 | MeshDefinition mesh = HumanoidModel.createMesh(CubeDeformation.NONE, -14.0F);
|
| 25 | PartDefinition root = mesh.getRoot();
|
| 26 | PartDefinition head = root.addOrReplaceChild(
|
| 27 | "head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F), PartPose.offset(0.0F, -13.0F, 0.0F)
|
| 28 | );
|
| 29 | head.addOrReplaceChild(
|
| 30 | "hat", CubeListBuilder.create().texOffs(0, 16).addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, new CubeDeformation(-0.5F)), PartPose.ZERO
|
| 31 | );
|
| 32 | root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(32, 16).addBox(-4.0F, 0.0F, -2.0F, 8.0F, 12.0F, 4.0F), PartPose.offset(0.0F, -14.0F, 0.0F));
|
| 33 | root.addOrReplaceChild(
|
| 34 | "right_arm", CubeListBuilder.create().texOffs(56, 0).addBox(-1.0F, -2.0F, -1.0F, 2.0F, 30.0F, 2.0F), PartPose.offset(-5.0F, -12.0F, 0.0F)
|
| 35 | );
|
| 36 | root.addOrReplaceChild(
|
| 37 | "left_arm", CubeListBuilder.create().texOffs(56, 0).mirror().addBox(-1.0F, -2.0F, -1.0F, 2.0F, 30.0F, 2.0F), PartPose.offset(5.0F, -12.0F, 0.0F)
|
| 38 | );
|
| 39 | root.addOrReplaceChild(
|
| 40 | "right_leg", CubeListBuilder.create().texOffs(56, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 30.0F, 2.0F), PartPose.offset(-2.0F, -5.0F, 0.0F)
|
| 41 | );
|
| 42 | root.addOrReplaceChild(
|
| 43 | "left_leg", CubeListBuilder.create().texOffs(56, 0).mirror().addBox(-1.0F, 0.0F, -1.0F, 2.0F, 30.0F, 2.0F), PartPose.offset(2.0F, -5.0F, 0.0F)
|
| 44 | );
|
| 45 | return LayerDefinition.create(mesh, 64, 32);
|
| 46 | }
|
| 47 |
|
| 48 | public void setupAnim(final T state) {
|
| 49 | super.setupAnim(state);
|
| 50 | this.head.visible = true;
|
| 51 | this.rightArm.xRot *= 0.5F;
|
| 52 | this.leftArm.xRot *= 0.5F;
|
| 53 | this.rightLeg.xRot *= 0.5F;
|
| 54 | this.leftLeg.xRot *= 0.5F;
|
| 55 | float max = 0.4F;
|
| 56 | this.rightArm.xRot = Mth.clamp(this.rightArm.xRot, -0.4F, 0.4F);
|
| 57 | this.leftArm.xRot = Mth.clamp(this.leftArm.xRot, -0.4F, 0.4F);
|
| 58 | this.rightLeg.xRot = Mth.clamp(this.rightLeg.xRot, -0.4F, 0.4F);
|
| 59 | this.leftLeg.xRot = Mth.clamp(this.leftLeg.xRot, -0.4F, 0.4F);
|
| 60 | if (!state.carriedBlock.isEmpty()) {
|
| 61 | this.rightArm.xRot = -0.5F;
|
| 62 | this.leftArm.xRot = -0.5F;
|
| 63 | this.rightArm.zRot = 0.05F;
|
| 64 | this.leftArm.zRot = -0.05F;
|
| 65 | }
|
| 66 |
|
| 67 | if (state.isCreepy) {
|
| 68 | float amt = 5.0F;
|
| 69 | this.head.y -= 5.0F;
|
| 70 | this.hat.y += 5.0F;
|
| 71 | }
|
| 72 | }
|
| 73 | }
|
| 74 |
|