| 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.CubeDeformation;
|
| 8 | import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
| 9 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 10 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 11 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 12 | import net.minecraft.util.Mth;
|
| 13 |
|
| 14 | @Environment(EnvType.CLIENT)
|
| 15 | public class BabyStriderModel extends StriderModel {
|
| 16 | private static final String FRONT_BRISTLE = "bristle2";
|
| 17 | private static final String MIDDLE_BRISTLE = "bristle1";
|
| 18 | private static final String BACK_BRISTLE = "bristle0";
|
| 19 | private final ModelPart frontBristle = this.body.getChild("bristle2");
|
| 20 | private final ModelPart middleBristle = this.body.getChild("bristle1");
|
| 21 | private final ModelPart bottomBristle = this.body.getChild("bristle0");
|
| 22 |
|
| 23 | public BabyStriderModel(final ModelPart root) {
|
| 24 | super(root);
|
| 25 | }
|
| 26 |
|
| 27 | @Override
|
| 28 | protected void customAnimations(final float animationPos, final float animationSpeed, final float ageInTicks) {
|
| 29 | this.body.y = 17.25F;
|
| 30 | this.body.y = this.body.y - 1.0F * Mth.cos(animationPos * 1.5F) * 2.0F * animationSpeed;
|
| 31 | this.leftLeg.y = 20.0F + 2.0F * Mth.sin(animationPos * 1.5F * 0.5F + (float) Math.PI) * 2.0F * animationSpeed;
|
| 32 | this.rightLeg.y = 20.0F + 2.0F * Mth.sin(animationPos * 1.5F * 0.5F) * 2.0F * animationSpeed;
|
| 33 | float bristleFlow = Mth.cos(animationPos * 1.5F + (float) Math.PI) * animationSpeed;
|
| 34 | this.animateBristle(
|
| 35 | ageInTicks, bristleFlow, this.frontBristle, this.middleBristle, this.bottomBristle, (modelPart, rotation) -> modelPart.xRot = modelPart.xRot + rotation
|
| 36 | );
|
| 37 | }
|
| 38 |
|
| 39 | public static LayerDefinition createBodyLayer() {
|
| 40 | MeshDefinition mesh = new MeshDefinition();
|
| 41 | PartDefinition root = mesh.getRoot();
|
| 42 | PartDefinition body = root.addOrReplaceChild(
|
| 43 | "body",
|
| 44 | CubeListBuilder.create().texOffs(0, 0).addBox(-3.5F, -3.75F, -4.0F, 7.0F, 7.0F, 8.0F, new CubeDeformation(0.0F)),
|
| 45 | PartPose.offset(0.0F, 16.75F, 0.0F)
|
| 46 | );
|
| 47 | root.addOrReplaceChild(
|
| 48 | "right_leg",
|
| 49 | CubeListBuilder.create().texOffs(0, 24).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)),
|
| 50 | PartPose.offset(-1.5F, 20.0F, 0.0F)
|
| 51 | );
|
| 52 | root.addOrReplaceChild(
|
| 53 | "left_leg",
|
| 54 | CubeListBuilder.create().texOffs(8, 24).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)),
|
| 55 | PartPose.offset(1.5F, 20.0F, 0.0F)
|
| 56 | );
|
| 57 | body.addOrReplaceChild(
|
| 58 | "bristle0",
|
| 59 | CubeListBuilder.create().texOffs(0, 21).addBox(-3.5F, -2.5F, 0.0F, 7.0F, 3.0F, 0.0F, new CubeDeformation(0.0F)),
|
| 60 | PartPose.offset(0.0F, -4.25F, 2.0F)
|
| 61 | );
|
| 62 | body.addOrReplaceChild(
|
| 63 | "bristle1",
|
| 64 | CubeListBuilder.create().texOffs(0, 18).addBox(-3.5F, -2.5F, 0.0F, 7.0F, 3.0F, 0.0F, new CubeDeformation(0.0F)),
|
| 65 | PartPose.offset(0.0F, -4.25F, 0.0F)
|
| 66 | );
|
| 67 | body.addOrReplaceChild(
|
| 68 | "bristle2",
|
| 69 | CubeListBuilder.create().texOffs(0, 15).addBox(-3.5F, -2.5F, 0.0F, 7.0F, 3.0F, 0.0F, new CubeDeformation(0.0F)),
|
| 70 | PartPose.offset(0.0F, -4.25F, -2.0F)
|
| 71 | );
|
| 72 | return LayerDefinition.create(mesh, 32, 32);
|
| 73 | }
|
| 74 | }
|
| 75 |
|