| 1 | package net.minecraft.client.model.monster.witch;
|
| 2 |
|
| 3 | import com.mojang.blaze3d.vertex.PoseStack;
|
| 4 | import net.fabricmc.api.EnvType;
|
| 5 | import net.fabricmc.api.Environment;
|
| 6 | import net.minecraft.client.model.EntityModel;
|
| 7 | import net.minecraft.client.model.HeadedModel;
|
| 8 | import net.minecraft.client.model.VillagerLikeModel;
|
| 9 | import net.minecraft.client.model.geom.ModelPart;
|
| 10 | import net.minecraft.client.model.geom.PartPose;
|
| 11 | import net.minecraft.client.model.geom.builders.CubeDeformation;
|
| 12 | import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
| 13 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 14 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 15 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 16 | import net.minecraft.client.model.npc.VillagerModel;
|
| 17 | import net.minecraft.client.renderer.entity.state.WitchRenderState;
|
| 18 | import net.minecraft.util.Mth;
|
| 19 |
|
| 20 | @Environment(EnvType.CLIENT)
|
| 21 | public class WitchModel extends EntityModel<WitchRenderState> implements HeadedModel, VillagerLikeModel<WitchRenderState> {
|
| 22 | protected final ModelPart nose;
|
| 23 | private final ModelPart head;
|
| 24 | private final ModelPart rightLeg;
|
| 25 | private final ModelPart leftLeg;
|
| 26 | private final ModelPart arms;
|
| 27 |
|
| 28 | public WitchModel(final ModelPart root) {
|
| 29 | super(root);
|
| 30 | this.head = root.getChild("head");
|
| 31 | this.nose = this.head.getChild("nose");
|
| 32 | this.rightLeg = root.getChild("right_leg");
|
| 33 | this.leftLeg = root.getChild("left_leg");
|
| 34 | this.arms = root.getChild("arms");
|
| 35 | }
|
| 36 |
|
| 37 | public static LayerDefinition createBodyLayer() {
|
| 38 | MeshDefinition mesh = VillagerModel.createBodyModel();
|
| 39 | PartDefinition root = mesh.getRoot();
|
| 40 | PartDefinition head = root.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -10.0F, -4.0F, 8.0F, 10.0F, 8.0F), PartPose.ZERO);
|
| 41 | PartDefinition hat = head.addOrReplaceChild(
|
| 42 | "hat", CubeListBuilder.create().texOffs(0, 64).addBox(0.0F, 0.0F, 0.0F, 10.0F, 2.0F, 10.0F), PartPose.offset(-5.0F, -10.03125F, -5.0F)
|
| 43 | );
|
| 44 | PartDefinition hat2 = hat.addOrReplaceChild(
|
| 45 | "hat2",
|
| 46 | CubeListBuilder.create().texOffs(0, 76).addBox(0.0F, 0.0F, 0.0F, 7.0F, 4.0F, 7.0F),
|
| 47 | PartPose.offsetAndRotation(1.75F, -4.0F, 2.0F, -0.05235988F, 0.0F, 0.02617994F)
|
| 48 | );
|
| 49 | PartDefinition hat3 = hat2.addOrReplaceChild(
|
| 50 | "hat3",
|
| 51 | CubeListBuilder.create().texOffs(0, 87).addBox(0.0F, 0.0F, 0.0F, 4.0F, 4.0F, 4.0F),
|
| 52 | PartPose.offsetAndRotation(1.75F, -4.0F, 2.0F, -0.10471976F, 0.0F, 0.05235988F)
|
| 53 | );
|
| 54 | hat3.addOrReplaceChild(
|
| 55 | "hat4",
|
| 56 | CubeListBuilder.create().texOffs(0, 95).addBox(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F, new CubeDeformation(0.25F)),
|
| 57 | PartPose.offsetAndRotation(1.75F, -2.0F, 2.0F, (float) (-Math.PI / 15), 0.0F, 0.10471976F)
|
| 58 | );
|
| 59 | PartDefinition nose = head.getChild("nose");
|
| 60 | nose.addOrReplaceChild(
|
| 61 | "mole", CubeListBuilder.create().texOffs(0, 0).addBox(0.0F, 3.0F, -6.75F, 1.0F, 1.0F, 1.0F, new CubeDeformation(-0.25F)), PartPose.offset(0.0F, -2.0F, 0.0F)
|
| 62 | );
|
| 63 | return LayerDefinition.create(mesh, 64, 128);
|
| 64 | }
|
| 65 |
|
| 66 | public void setupAnim(final WitchRenderState state) {
|
| 67 | super.setupAnim(state);
|
| 68 | this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
|
| 69 | this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
|
| 70 | this.rightLeg.xRot = Mth.cos(state.walkAnimationPos * 0.6662F) * 1.4F * state.walkAnimationSpeed * 0.5F;
|
| 71 | this.leftLeg.xRot = Mth.cos(state.walkAnimationPos * 0.6662F + (float) Math.PI) * 1.4F * state.walkAnimationSpeed * 0.5F;
|
| 72 | float speed = 0.01F * (state.entityId % 10);
|
| 73 | this.nose.xRot = Mth.sin(state.ageInTicks * speed) * 4.5F * (float) (Math.PI / 180.0);
|
| 74 | this.nose.zRot = Mth.cos(state.ageInTicks * speed) * 2.5F * (float) (Math.PI / 180.0);
|
| 75 | if (state.isHoldingItem) {
|
| 76 | this.nose.setPos(0.0F, 1.0F, -1.5F);
|
| 77 | this.nose.xRot = -0.9F;
|
| 78 | }
|
| 79 | }
|
| 80 |
|
| 81 | public ModelPart getNose() {
|
| 82 | return this.nose;
|
| 83 | }
|
| 84 |
|
| 85 | @Override
|
| 86 | public ModelPart getHead() {
|
| 87 | return this.head;
|
| 88 | }
|
| 89 |
|
| 90 | public void translateToArms(final WitchRenderState state, final PoseStack outputPoseStack) {
|
| 91 | this.root.translateAndRotate(outputPoseStack);
|
| 92 | this.arms.translateAndRotate(outputPoseStack);
|
| 93 | }
|
| 94 | }
|
| 95 |
|