| 1 | package net.minecraft.client.model.monster.strider;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.model.geom.ModelPart;
|
| 6 | import net.minecraft.client.model.geom.PartPose;
|
| 7 | import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
| 8 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 9 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 10 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 11 | import net.minecraft.util.Mth;
|
| 12 |
|
| 13 | @Environment(EnvType.CLIENT)
|
| 14 | public class AdultStriderModel extends StriderModel {
|
| 15 | private static final String RIGHT_BOTTOM_BRISTLE = "right_bottom_bristle";
|
| 16 | private static final String RIGHT_MIDDLE_BRISTLE = "right_middle_bristle";
|
| 17 | private static final String RIGHT_TOP_BRISTLE = "right_top_bristle";
|
| 18 | private static final String LEFT_TOP_BRISTLE = "left_top_bristle";
|
| 19 | private static final String LEFT_MIDDLE_BRISTLE = "left_middle_bristle";
|
| 20 | private static final String LEFT_BOTTOM_BRISTLE = "left_bottom_bristle";
|
| 21 | private final ModelPart rightBottomBristle = this.body.getChild("right_bottom_bristle");
|
| 22 | private final ModelPart rightMiddleBristle = this.body.getChild("right_middle_bristle");
|
| 23 | private final ModelPart rightTopBristle = this.body.getChild("right_top_bristle");
|
| 24 | private final ModelPart leftTopBristle = this.body.getChild("left_top_bristle");
|
| 25 | private final ModelPart leftMiddleBristle = this.body.getChild("left_middle_bristle");
|
| 26 | private final ModelPart leftBottomBristle = this.body.getChild("left_bottom_bristle");
|
| 27 |
|
| 28 | public AdultStriderModel(final ModelPart root) {
|
| 29 | super(root);
|
| 30 | }
|
| 31 |
|
| 32 | @Override
|
| 33 | protected void customAnimations(final float animationPos, final float animationSpeed, final float ageInTicks) {
|
| 34 | this.rightBottomBristle.zRot = -1.2217305F;
|
| 35 | this.rightMiddleBristle.zRot = -1.134464F;
|
| 36 | this.rightTopBristle.zRot = -0.87266463F;
|
| 37 | this.leftTopBristle.zRot = 0.87266463F;
|
| 38 | this.leftMiddleBristle.zRot = 1.134464F;
|
| 39 | this.leftBottomBristle.zRot = 1.2217305F;
|
| 40 | float bristleFlow = Mth.cos(animationPos * 1.5F + (float) Math.PI) * animationSpeed;
|
| 41 | this.animateBristle(
|
| 42 | ageInTicks,
|
| 43 | bristleFlow,
|
| 44 | this.rightTopBristle,
|
| 45 | this.rightMiddleBristle,
|
| 46 | this.rightBottomBristle,
|
| 47 | (modelPart, rotation) -> modelPart.zRot = modelPart.zRot + rotation
|
| 48 | );
|
| 49 | this.animateBristle(
|
| 50 | ageInTicks,
|
| 51 | bristleFlow,
|
| 52 | this.leftTopBristle,
|
| 53 | this.leftMiddleBristle,
|
| 54 | this.leftBottomBristle,
|
| 55 | (modelPart, rotation) -> modelPart.zRot = modelPart.zRot + rotation
|
| 56 | );
|
| 57 | this.body.y = 2.0F;
|
| 58 | this.body.y = this.body.y - 2.0F * Mth.cos(animationPos * 1.5F) * 2.0F * animationSpeed;
|
| 59 | this.leftLeg.y = 8.0F + 2.0F * Mth.sin(animationPos * 1.5F * 0.5F + (float) Math.PI) * 2.0F * animationSpeed;
|
| 60 | this.rightLeg.y = 8.0F + 2.0F * Mth.sin(animationPos * 1.5F * 0.5F) * 2.0F * animationSpeed;
|
| 61 | }
|
| 62 |
|
| 63 | public static LayerDefinition createBodyLayer() {
|
| 64 | MeshDefinition mesh = new MeshDefinition();
|
| 65 | PartDefinition root = mesh.getRoot();
|
| 66 | root.addOrReplaceChild("right_leg", CubeListBuilder.create().texOffs(0, 32).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 16.0F, 4.0F), PartPose.offset(-4.0F, 8.0F, 0.0F));
|
| 67 | root.addOrReplaceChild("left_leg", CubeListBuilder.create().texOffs(0, 55).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 16.0F, 4.0F), PartPose.offset(4.0F, 8.0F, 0.0F));
|
| 68 | PartDefinition body = root.addOrReplaceChild(
|
| 69 | "body", CubeListBuilder.create().texOffs(0, 0).addBox(-8.0F, -6.0F, -8.0F, 16.0F, 14.0F, 16.0F), PartPose.offset(0.0F, 1.0F, 0.0F)
|
| 70 | );
|
| 71 | body.addOrReplaceChild(
|
| 72 | "right_bottom_bristle",
|
| 73 | CubeListBuilder.create().texOffs(16, 65).addBox(-12.0F, 0.0F, 0.0F, 12.0F, 0.0F, 16.0F, true),
|
| 74 | PartPose.offsetAndRotation(-8.0F, 4.0F, -8.0F, 0.0F, 0.0F, -1.2217305F)
|
| 75 | );
|
| 76 | body.addOrReplaceChild(
|
| 77 | "right_middle_bristle",
|
| 78 | CubeListBuilder.create().texOffs(16, 49).addBox(-12.0F, 0.0F, 0.0F, 12.0F, 0.0F, 16.0F, true),
|
| 79 | PartPose.offsetAndRotation(-8.0F, -1.0F, -8.0F, 0.0F, 0.0F, -1.134464F)
|
| 80 | );
|
| 81 | body.addOrReplaceChild(
|
| 82 | "right_top_bristle",
|
| 83 | CubeListBuilder.create().texOffs(16, 33).addBox(-12.0F, 0.0F, 0.0F, 12.0F, 0.0F, 16.0F, true),
|
| 84 | PartPose.offsetAndRotation(-8.0F, -5.0F, -8.0F, 0.0F, 0.0F, -0.87266463F)
|
| 85 | );
|
| 86 | body.addOrReplaceChild(
|
| 87 | "left_top_bristle",
|
| 88 | CubeListBuilder.create().texOffs(16, 33).addBox(0.0F, 0.0F, 0.0F, 12.0F, 0.0F, 16.0F),
|
| 89 | PartPose.offsetAndRotation(8.0F, -6.0F, -8.0F, 0.0F, 0.0F, 0.87266463F)
|
| 90 | );
|
| 91 | body.addOrReplaceChild(
|
| 92 | "left_middle_bristle",
|
| 93 | CubeListBuilder.create().texOffs(16, 49).addBox(0.0F, 0.0F, 0.0F, 12.0F, 0.0F, 16.0F),
|
| 94 | PartPose.offsetAndRotation(8.0F, -2.0F, -8.0F, 0.0F, 0.0F, 1.134464F)
|
| 95 | );
|
| 96 | body.addOrReplaceChild(
|
| 97 | "left_bottom_bristle",
|
| 98 | CubeListBuilder.create().texOffs(16, 65).addBox(0.0F, 0.0F, 0.0F, 12.0F, 0.0F, 16.0F),
|
| 99 | PartPose.offsetAndRotation(8.0F, 3.0F, -8.0F, 0.0F, 0.0F, 1.2217305F)
|
| 100 | );
|
| 101 | return LayerDefinition.create(mesh, 64, 128);
|
| 102 | }
|
| 103 | }
|
| 104 |
|