| 1 | package net.minecraft.client.model.animal.polarbear;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.model.QuadrupedModel;
|
| 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.PolarBearRenderState;
|
| 14 |
|
| 15 | @Environment(EnvType.CLIENT)
|
| 16 | public class PolarBearModel extends QuadrupedModel<PolarBearRenderState> {
|
| 17 | public PolarBearModel(final ModelPart root) {
|
| 18 | super(root);
|
| 19 | }
|
| 20 |
|
| 21 | public static LayerDefinition createBodyLayer() {
|
| 22 | MeshDefinition mesh = new MeshDefinition();
|
| 23 | PartDefinition root = mesh.getRoot();
|
| 24 | root.addOrReplaceChild(
|
| 25 | "head",
|
| 26 | CubeListBuilder.create()
|
| 27 | .texOffs(0, 0)
|
| 28 | .addBox(-3.5F, -3.0F, -3.0F, 7.0F, 7.0F, 7.0F)
|
| 29 | .texOffs(0, 44)
|
| 30 | .addBox("mouth", -2.5F, 1.0F, -6.0F, 5.0F, 3.0F, 3.0F)
|
| 31 | .texOffs(26, 0)
|
| 32 | .addBox("right_ear", -4.5F, -4.0F, -1.0F, 2.0F, 2.0F, 1.0F)
|
| 33 | .texOffs(26, 0)
|
| 34 | .mirror()
|
| 35 | .addBox("left_ear", 2.5F, -4.0F, -1.0F, 2.0F, 2.0F, 1.0F),
|
| 36 | PartPose.offset(0.0F, 10.0F, -16.0F)
|
| 37 | );
|
| 38 | root.addOrReplaceChild(
|
| 39 | "body",
|
| 40 | CubeListBuilder.create().texOffs(0, 19).addBox(-5.0F, -13.0F, -7.0F, 14.0F, 14.0F, 11.0F).texOffs(39, 0).addBox(-4.0F, -25.0F, -7.0F, 12.0F, 12.0F, 10.0F),
|
| 41 | PartPose.offsetAndRotation(-2.0F, 9.0F, 12.0F, (float) (Math.PI / 2), 0.0F, 0.0F)
|
| 42 | );
|
| 43 | int legSize = 10;
|
| 44 | CubeListBuilder hindLeg = CubeListBuilder.create().texOffs(50, 22).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 10.0F, 8.0F);
|
| 45 | root.addOrReplaceChild("right_hind_leg", hindLeg, PartPose.offset(-4.5F, 14.0F, 6.0F));
|
| 46 | root.addOrReplaceChild("left_hind_leg", hindLeg, PartPose.offset(4.5F, 14.0F, 6.0F));
|
| 47 | CubeListBuilder frontLeg = CubeListBuilder.create().texOffs(50, 40).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 10.0F, 6.0F);
|
| 48 | root.addOrReplaceChild("right_front_leg", frontLeg, PartPose.offset(-3.5F, 14.0F, -8.0F));
|
| 49 | root.addOrReplaceChild("left_front_leg", frontLeg, PartPose.offset(3.5F, 14.0F, -8.0F));
|
| 50 | return LayerDefinition.create(mesh, 128, 64).apply(MeshTransformer.scaling(1.2F));
|
| 51 | }
|
| 52 |
|
| 53 | public void setupAnim(final PolarBearRenderState state) {
|
| 54 | super.setupAnim(state);
|
| 55 | float standScale = state.standScale * state.standScale;
|
| 56 | float bodyAgeScale = state.ageScale;
|
| 57 | this.body.xRot -= standScale * (float) Math.PI * 0.35F;
|
| 58 | this.body.y += standScale * bodyAgeScale * 2.0F;
|
| 59 | this.rightFrontLeg.y -= standScale * bodyAgeScale * 20.0F;
|
| 60 | this.rightFrontLeg.z += standScale * bodyAgeScale * 4.0F;
|
| 61 | this.rightFrontLeg.xRot -= standScale * (float) Math.PI * 0.45F;
|
| 62 | this.leftFrontLeg.y = this.rightFrontLeg.y;
|
| 63 | this.leftFrontLeg.z = this.rightFrontLeg.z;
|
| 64 | this.leftFrontLeg.xRot -= standScale * (float) Math.PI * 0.45F;
|
| 65 | this.head.y -= standScale * 24.0F;
|
| 66 | this.head.z += standScale * 13.0F;
|
| 67 | this.head.xRot += standScale * (float) Math.PI * 0.15F;
|
| 68 | }
|
| 69 | }
|
| 70 |
|