| 1 | package net.minecraft.client.model.animal.dolphin;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.model.EntityModel;
|
| 6 | import net.minecraft.client.model.geom.ModelPart;
|
| 7 | import net.minecraft.client.model.geom.PartPose;
|
| 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.MeshTransformer;
|
| 12 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 13 | import net.minecraft.client.renderer.entity.state.DolphinRenderState;
|
| 14 | import net.minecraft.util.Mth;
|
| 15 |
|
| 16 | @Environment(EnvType.CLIENT)
|
| 17 | public class DolphinModel extends EntityModel<DolphinRenderState> {
|
| 18 | public static final MeshTransformer BABY_TRANSFORMER = MeshTransformer.scaling(0.5F);
|
| 19 | private final ModelPart body;
|
| 20 | private final ModelPart tail;
|
| 21 | private final ModelPart tailFin;
|
| 22 |
|
| 23 | public DolphinModel(final ModelPart root) {
|
| 24 | super(root);
|
| 25 | this.body = root.getChild("body");
|
| 26 | this.tail = this.body.getChild("tail");
|
| 27 | this.tailFin = this.tail.getChild("tail_fin");
|
| 28 | }
|
| 29 |
|
| 30 | public static LayerDefinition createBodyLayer() {
|
| 31 | MeshDefinition mesh = new MeshDefinition();
|
| 32 | PartDefinition root = mesh.getRoot();
|
| 33 | float offY = 18.0F;
|
| 34 | float offZ = -8.0F;
|
| 35 | PartDefinition body = root.addOrReplaceChild(
|
| 36 | "body", CubeListBuilder.create().texOffs(22, 0).addBox(-4.0F, -7.0F, 0.0F, 8.0F, 7.0F, 13.0F), PartPose.offset(0.0F, 22.0F, -5.0F)
|
| 37 | );
|
| 38 | body.addOrReplaceChild(
|
| 39 | "back_fin", CubeListBuilder.create().texOffs(51, 0).addBox(-0.5F, 0.0F, 8.0F, 1.0F, 4.0F, 5.0F), PartPose.rotation((float) (Math.PI / 3), 0.0F, 0.0F)
|
| 40 | );
|
| 41 | body.addOrReplaceChild(
|
| 42 | "left_fin",
|
| 43 | CubeListBuilder.create().texOffs(48, 20).mirror().addBox(-0.5F, -4.0F, 0.0F, 1.0F, 4.0F, 7.0F),
|
| 44 | PartPose.offsetAndRotation(2.0F, -2.0F, 4.0F, (float) (Math.PI / 3), 0.0F, (float) (Math.PI * 2.0 / 3.0))
|
| 45 | );
|
| 46 | body.addOrReplaceChild(
|
| 47 | "right_fin",
|
| 48 | CubeListBuilder.create().texOffs(48, 20).addBox(-0.5F, -4.0F, 0.0F, 1.0F, 4.0F, 7.0F),
|
| 49 | PartPose.offsetAndRotation(-2.0F, -2.0F, 4.0F, (float) (Math.PI / 3), 0.0F, (float) (-Math.PI * 2.0 / 3.0))
|
| 50 | );
|
| 51 | PartDefinition tail = body.addOrReplaceChild(
|
| 52 | "tail",
|
| 53 | CubeListBuilder.create().texOffs(0, 19).addBox(-2.0F, -2.5F, 0.0F, 4.0F, 5.0F, 11.0F),
|
| 54 | PartPose.offsetAndRotation(0.0F, -2.5F, 11.0F, -0.10471976F, 0.0F, 0.0F)
|
| 55 | );
|
| 56 | tail.addOrReplaceChild("tail_fin", CubeListBuilder.create().texOffs(19, 20).addBox(-5.0F, -0.5F, 0.0F, 10.0F, 1.0F, 6.0F), PartPose.offset(0.0F, 0.0F, 9.0F));
|
| 57 | PartDefinition head = body.addOrReplaceChild(
|
| 58 | "head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -3.0F, -3.0F, 8.0F, 7.0F, 6.0F), PartPose.offset(0.0F, -4.0F, -3.0F)
|
| 59 | );
|
| 60 | head.addOrReplaceChild("nose", CubeListBuilder.create().texOffs(0, 13).addBox(-1.0F, 2.0F, -7.0F, 2.0F, 2.0F, 4.0F), PartPose.ZERO);
|
| 61 | return LayerDefinition.create(mesh, 64, 64);
|
| 62 | }
|
| 63 |
|
| 64 | public void setupAnim(final DolphinRenderState state) {
|
| 65 | super.setupAnim(state);
|
| 66 | this.body.xRot = state.xRot * (float) (Math.PI / 180.0);
|
| 67 | this.body.yRot = state.yRot * (float) (Math.PI / 180.0);
|
| 68 | if (state.isMoving) {
|
| 69 | this.body.xRot = this.body.xRot + (-0.05F - 0.05F * Mth.cos(state.ageInTicks * 0.3F));
|
| 70 | this.tail.xRot = -0.1F * Mth.cos(state.ageInTicks * 0.3F);
|
| 71 | this.tailFin.xRot = -0.2F * Mth.cos(state.ageInTicks * 0.3F);
|
| 72 | }
|
| 73 | }
|
| 74 | }
|
| 75 |
|