| 1 | package net.minecraft.client.model.animal.fish;
|
| 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.SalmonRenderState;
|
| 14 | import net.minecraft.util.Mth;
|
| 15 |
|
| 16 | @Environment(EnvType.CLIENT)
|
| 17 | public class SalmonModel extends EntityModel<SalmonRenderState> {
|
| 18 | public static final MeshTransformer SMALL_TRANSFORMER = MeshTransformer.scaling(0.5F);
|
| 19 | public static final MeshTransformer LARGE_TRANSFORMER = MeshTransformer.scaling(1.5F);
|
| 20 | private static final String BODY_FRONT = "body_front";
|
| 21 | private static final String BODY_BACK = "body_back";
|
| 22 | private static final float Z_OFFSET = -7.2F;
|
| 23 | private final ModelPart bodyBack;
|
| 24 |
|
| 25 | public SalmonModel(final ModelPart root) {
|
| 26 | super(root);
|
| 27 | this.bodyBack = root.getChild("body_back");
|
| 28 | }
|
| 29 |
|
| 30 | public static LayerDefinition createBodyLayer() {
|
| 31 | MeshDefinition mesh = new MeshDefinition();
|
| 32 | PartDefinition root = mesh.getRoot();
|
| 33 | int yo = 20;
|
| 34 | PartDefinition bodyFront = root.addOrReplaceChild(
|
| 35 | "body_front", CubeListBuilder.create().texOffs(0, 0).addBox(-1.5F, -2.5F, 0.0F, 3.0F, 5.0F, 8.0F), PartPose.offset(0.0F, 20.0F, -7.2F)
|
| 36 | );
|
| 37 | PartDefinition bodyBack = root.addOrReplaceChild(
|
| 38 | "body_back", CubeListBuilder.create().texOffs(0, 13).addBox(-1.5F, -2.5F, 0.0F, 3.0F, 5.0F, 8.0F), PartPose.offset(0.0F, 20.0F, 0.8000002F)
|
| 39 | );
|
| 40 | root.addOrReplaceChild("head", CubeListBuilder.create().texOffs(22, 0).addBox(-1.0F, -2.0F, -3.0F, 2.0F, 4.0F, 3.0F), PartPose.offset(0.0F, 20.0F, -7.2F));
|
| 41 | bodyBack.addOrReplaceChild(
|
| 42 | "back_fin", CubeListBuilder.create().texOffs(20, 10).addBox(0.0F, -2.5F, 0.0F, 0.0F, 5.0F, 6.0F), PartPose.offset(0.0F, 0.0F, 8.0F)
|
| 43 | );
|
| 44 | bodyFront.addOrReplaceChild(
|
| 45 | "top_front_fin", CubeListBuilder.create().texOffs(2, 1).addBox(0.0F, 0.0F, 0.0F, 0.0F, 2.0F, 3.0F), PartPose.offset(0.0F, -4.5F, 5.0F)
|
| 46 | );
|
| 47 | bodyBack.addOrReplaceChild(
|
| 48 | "top_back_fin", CubeListBuilder.create().texOffs(0, 2).addBox(0.0F, 0.0F, 0.0F, 0.0F, 2.0F, 4.0F), PartPose.offset(0.0F, -4.5F, -1.0F)
|
| 49 | );
|
| 50 | root.addOrReplaceChild(
|
| 51 | "right_fin",
|
| 52 | CubeListBuilder.create().texOffs(-4, 0).addBox(-2.0F, 0.0F, 0.0F, 2.0F, 0.0F, 2.0F),
|
| 53 | PartPose.offsetAndRotation(-1.5F, 21.5F, -7.2F, 0.0F, 0.0F, (float) (-Math.PI / 4))
|
| 54 | );
|
| 55 | root.addOrReplaceChild(
|
| 56 | "left_fin",
|
| 57 | CubeListBuilder.create().texOffs(0, 0).addBox(0.0F, 0.0F, 0.0F, 2.0F, 0.0F, 2.0F),
|
| 58 | PartPose.offsetAndRotation(1.5F, 21.5F, -7.2F, 0.0F, 0.0F, (float) (Math.PI / 4))
|
| 59 | );
|
| 60 | return LayerDefinition.create(mesh, 32, 32);
|
| 61 | }
|
| 62 |
|
| 63 | public void setupAnim(final SalmonRenderState state) {
|
| 64 | super.setupAnim(state);
|
| 65 | float amplitudeMultiplier = 1.0F;
|
| 66 | float angleMultiplier = 1.0F;
|
| 67 | if (!state.isInWater) {
|
| 68 | amplitudeMultiplier = 1.3F;
|
| 69 | angleMultiplier = 1.7F;
|
| 70 | }
|
| 71 |
|
| 72 | this.bodyBack.yRot = -amplitudeMultiplier * 0.25F * Mth.sin(angleMultiplier * 0.6F * state.ageInTicks);
|
| 73 | }
|
| 74 | }
|
| 75 |
|