| 1 | package net.minecraft.client.model.animal.axolotl;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.animation.KeyframeAnimation;
|
| 6 | import net.minecraft.client.animation.definitions.BabyAxolotlAnimation;
|
| 7 | import net.minecraft.client.model.EntityModel;
|
| 8 | import net.minecraft.client.model.geom.ModelPart;
|
| 9 | import net.minecraft.client.model.geom.PartPose;
|
| 10 | import net.minecraft.client.model.geom.builders.CubeDeformation;
|
| 11 | import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
| 12 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 13 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 14 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 15 | import net.minecraft.client.renderer.entity.state.AxolotlRenderState;
|
| 16 |
|
| 17 | @Environment(EnvType.CLIENT)
|
| 18 | public class BabyAxolotlModel extends EntityModel<AxolotlRenderState> {
|
| 19 | private static final float MAX_WALK_ANIMATION_SPEED = 15.0F;
|
| 20 | private static final float WALK_ANIMATION_SCALE_FACTOR = 30.0F;
|
| 21 | private final KeyframeAnimation walkAnimation;
|
| 22 | private final KeyframeAnimation walkUnderwaterAnimation;
|
| 23 | private final KeyframeAnimation swimAnimation;
|
| 24 | private final KeyframeAnimation idleOnGroundAnimation;
|
| 25 | private final KeyframeAnimation idleOnGroundUnderWaterAnimation;
|
| 26 | private final KeyframeAnimation idleUnderWaterAnimation;
|
| 27 | private final KeyframeAnimation playDeadAnimation;
|
| 28 |
|
| 29 | public BabyAxolotlModel(final ModelPart root) {
|
| 30 | super(root);
|
| 31 | this.swimAnimation = BabyAxolotlAnimation.BABY_AXOLOTL_SWIM.bake(root);
|
| 32 | this.walkAnimation = BabyAxolotlAnimation.AXOLOTL_WALK_FLOOR.bake(root);
|
| 33 | this.walkUnderwaterAnimation = BabyAxolotlAnimation.WALK_FLOOR_UNDERWATER.bake(root);
|
| 34 | this.idleUnderWaterAnimation = BabyAxolotlAnimation.IDLE_UNDERWATER.bake(root);
|
| 35 | this.idleOnGroundUnderWaterAnimation = BabyAxolotlAnimation.IDLE_FLOOR_UNDERWATER.bake(root);
|
| 36 | this.idleOnGroundAnimation = BabyAxolotlAnimation.BABY_AXOLOTL_IDLE_FLOOR.bake(root);
|
| 37 | this.playDeadAnimation = BabyAxolotlAnimation.BABY_AXOLOTL_PLAY_DEAD.bake(root);
|
| 38 | }
|
| 39 |
|
| 40 | public static LayerDefinition createBodyLayer() {
|
| 41 | MeshDefinition meshdefinition = new MeshDefinition();
|
| 42 | PartDefinition partdefinition = meshdefinition.getRoot();
|
| 43 | PartDefinition root = partdefinition.addOrReplaceChild("root", CubeListBuilder.create(), PartPose.offset(0.0F, 24.0F, 0.0F));
|
| 44 | PartDefinition body = root.addOrReplaceChild(
|
| 45 | "body",
|
| 46 | CubeListBuilder.create()
|
| 47 | .texOffs(0, 0)
|
| 48 | .addBox(-2.0F, -0.75F, -2.75F, 4.0F, 2.0F, 6.0F, new CubeDeformation(0.0F))
|
| 49 | .texOffs(0, 12)
|
| 50 | .addBox(0.0F, -1.75F, -2.75F, 0.0F, 3.0F, 5.0F, new CubeDeformation(0.0F)),
|
| 51 | PartPose.offset(0.0F, -1.25F, 1.75F)
|
| 52 | );
|
| 53 | body.addOrReplaceChild(
|
| 54 | "right_front_leg",
|
| 55 | CubeListBuilder.create().texOffs(20, 16).addBox(-3.0F, 0.0F, -0.5F, 3.0F, 0.0F, 1.0F, new CubeDeformation(0.0F)),
|
| 56 | PartPose.offset(-2.0F, 0.25F, -1.25F)
|
| 57 | );
|
| 58 | PartDefinition right_leg = body.addOrReplaceChild(
|
| 59 | "right_hind_leg", CubeListBuilder.create(), PartPose.offsetAndRotation(-2.0F, 0.25F, 1.75F, 0.0F, 1.5708F, 1.5708F)
|
| 60 | );
|
| 61 | right_leg.addOrReplaceChild(
|
| 62 | "right_leg_r1",
|
| 63 | CubeListBuilder.create().texOffs(20, 14).addBox(0.0F, 0.0F, -0.5F, 3.0F, 0.0F, 1.0F, new CubeDeformation(0.0F)),
|
| 64 | PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, -1.5708F, 0.0F, 1.5708F)
|
| 65 | );
|
| 66 | body.addOrReplaceChild(
|
| 67 | "left_front_leg",
|
| 68 | CubeListBuilder.create().texOffs(20, 13).addBox(0.0F, 0.0F, -0.5F, 3.0F, 0.0F, 1.0F, new CubeDeformation(0.0F)),
|
| 69 | PartPose.offset(2.0F, 0.25F, -1.25F)
|
| 70 | );
|
| 71 | body.addOrReplaceChild(
|
| 72 | "left_hind_leg",
|
| 73 | CubeListBuilder.create().texOffs(20, 14).addBox(0.0F, 0.0F, -0.5F, 3.0F, 0.0F, 1.0F, new CubeDeformation(0.0F)),
|
| 74 | PartPose.offset(2.0F, 0.25F, 1.75F)
|
| 75 | );
|
| 76 | body.addOrReplaceChild(
|
| 77 | "tail",
|
| 78 | CubeListBuilder.create().texOffs(10, 9).addBox(0.0F, -1.5F, -1.0F, 0.0F, 3.0F, 8.0F, new CubeDeformation(0.0F)),
|
| 79 | PartPose.offset(0.0F, -0.25F, 3.25F)
|
| 80 | );
|
| 81 | PartDefinition head = body.addOrReplaceChild(
|
| 82 | "head",
|
| 83 | CubeListBuilder.create().texOffs(0, 8).addBox(-3.0F, -2.0F, -4.0F, 6.0F, 3.0F, 4.0F, new CubeDeformation(0.0F)),
|
| 84 | PartPose.offset(0.0F, 0.25F, -2.75F)
|
| 85 | );
|
| 86 | head.addOrReplaceChild(
|
| 87 | "left_gills",
|
| 88 | CubeListBuilder.create().texOffs(20, 8).addBox(0.0F, -3.5F, 0.0F, 3.0F, 5.0F, 0.0F, new CubeDeformation(0.0F)),
|
| 89 | PartPose.offset(3.0F, -0.5F, -2.0F)
|
| 90 | );
|
| 91 | head.addOrReplaceChild(
|
| 92 | "right_gills",
|
| 93 | CubeListBuilder.create().texOffs(20, 3).addBox(-3.0F, -3.5F, 0.0F, 3.0F, 5.0F, 0.0F, new CubeDeformation(0.0F)),
|
| 94 | PartPose.offset(-3.0F, -0.5F, -2.0F)
|
| 95 | );
|
| 96 | head.addOrReplaceChild(
|
| 97 | "top_gills",
|
| 98 | CubeListBuilder.create().texOffs(20, 0).addBox(-3.0F, -3.0F, 0.0F, 6.0F, 3.0F, 0.0F, new CubeDeformation(0.0F)),
|
| 99 | PartPose.offset(0.0F, -2.0F, -2.0F)
|
| 100 | );
|
| 101 | return LayerDefinition.create(meshdefinition, 32, 32);
|
| 102 | }
|
| 103 |
|
| 104 | public void setupAnim(final AxolotlRenderState state) {
|
| 105 | super.setupAnim(state);
|
| 106 | if (state.walkAnimationState.isStarted()) {
|
| 107 | this.walkAnimation.applyWalk(state.walkAnimationPos, state.walkAnimationSpeed, 15.0F, 30.0F);
|
| 108 | }
|
| 109 |
|
| 110 | this.swimAnimation.apply(state.swimAnimation, state.ageInTicks);
|
| 111 | this.walkUnderwaterAnimation.apply(state.walkAnimationState, state.ageInTicks);
|
| 112 | this.idleOnGroundAnimation.apply(state.idleOnGroundAnimationState, state.ageInTicks);
|
| 113 | this.idleUnderWaterAnimation.apply(state.idleUnderWaterAnimationState, state.ageInTicks);
|
| 114 | this.idleOnGroundUnderWaterAnimation.apply(state.idleUnderWaterOnGroundAnimationState, state.ageInTicks);
|
| 115 | this.playDeadAnimation.apply(state.playDeadAnimationState, state.ageInTicks);
|
| 116 | }
|
| 117 | }
|
| 118 |
|