| 1 | package net.minecraft.client.model.animal.equine;
|
| 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.MeshTransformer;
|
| 11 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 12 | import net.minecraft.client.renderer.entity.state.DonkeyRenderState;
|
| 13 |
|
| 14 | @Environment(EnvType.CLIENT)
|
| 15 | public class DonkeyModel extends AbstractEquineModel<DonkeyRenderState> {
|
| 16 | public static final float DONKEY_SCALE = 0.87F;
|
| 17 | public static final float MULE_SCALE = 0.92F;
|
| 18 | private static final MeshTransformer DONKEY_TRANSFORMER = mesh -> {
|
| 19 | modifyMesh(mesh.getRoot());
|
| 20 | return mesh;
|
| 21 | };
|
| 22 | private final ModelPart leftChest = this.body.getChild("left_chest");
|
| 23 | private final ModelPart rightChest = this.body.getChild("right_chest");
|
| 24 |
|
| 25 | public DonkeyModel(final ModelPart root) {
|
| 26 | super(root);
|
| 27 | }
|
| 28 |
|
| 29 | public DonkeyModel(
|
| 30 | final ModelPart root,
|
| 31 | final ModelPart headParts,
|
| 32 | final ModelPart rightHindLeg,
|
| 33 | final ModelPart rightFrontLeg,
|
| 34 | final ModelPart leftHindLeg,
|
| 35 | final ModelPart leftFrontLeg,
|
| 36 | final ModelPart tail
|
| 37 | ) {
|
| 38 | super(root, headParts, rightHindLeg, rightFrontLeg, leftHindLeg, leftFrontLeg, tail);
|
| 39 | }
|
| 40 |
|
| 41 | public static LayerDefinition createBodyLayer(final float scale) {
|
| 42 | return LayerDefinition.create(AbstractEquineModel.createBodyMesh(CubeDeformation.NONE), 64, 64)
|
| 43 | .apply(DONKEY_TRANSFORMER)
|
| 44 | .apply(MeshTransformer.scaling(scale));
|
| 45 | }
|
| 46 |
|
| 47 | public static LayerDefinition createSaddleLayer(final float scale) {
|
| 48 | return EquineSaddleModel.createSaddleLayer().apply(DONKEY_TRANSFORMER).apply(MeshTransformer.scaling(scale));
|
| 49 | }
|
| 50 |
|
| 51 | private static void modifyMesh(final PartDefinition root) {
|
| 52 | PartDefinition body = root.getChild("body");
|
| 53 | CubeListBuilder chest = CubeListBuilder.create().texOffs(26, 21).addBox(-4.0F, 0.0F, -2.0F, 8.0F, 8.0F, 3.0F);
|
| 54 | body.addOrReplaceChild("left_chest", chest, PartPose.offsetAndRotation(6.0F, -8.0F, 0.0F, 0.0F, (float) (-Math.PI / 2), 0.0F));
|
| 55 | body.addOrReplaceChild("right_chest", chest, PartPose.offsetAndRotation(-6.0F, -8.0F, 0.0F, 0.0F, (float) (Math.PI / 2), 0.0F));
|
| 56 | PartDefinition head = root.getChild("head_parts").getChild("head");
|
| 57 | CubeListBuilder ear = CubeListBuilder.create().texOffs(0, 12).addBox(-1.0F, -7.0F, 0.0F, 2.0F, 7.0F, 1.0F);
|
| 58 | head.addOrReplaceChild("left_ear", ear, PartPose.offsetAndRotation(1.25F, -10.0F, 4.0F, (float) (Math.PI / 12), 0.0F, (float) (Math.PI / 12)));
|
| 59 | head.addOrReplaceChild("right_ear", ear, PartPose.offsetAndRotation(-1.25F, -10.0F, 4.0F, (float) (Math.PI / 12), 0.0F, (float) (-Math.PI / 12)));
|
| 60 | }
|
| 61 |
|
| 62 | public void setupAnim(final DonkeyRenderState state) {
|
| 63 | super.setupAnim(state);
|
| 64 | this.leftChest.visible = state.hasChest;
|
| 65 | this.rightChest.visible = state.hasChest;
|
| 66 | }
|
| 67 | }
|
| 68 |
|