| 1 | package net.minecraft.client.model.object.boat;
|
| 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.CubeListBuilder;
|
| 8 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 9 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 10 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 11 |
|
| 12 | @Environment(EnvType.CLIENT)
|
| 13 | public class BoatModel extends AbstractBoatModel {
|
| 14 | private static final int BOTTOM_WIDTH = 28;
|
| 15 | private static final int WIDTH = 32;
|
| 16 | private static final int DEPTH = 6;
|
| 17 | private static final int LENGTH = 20;
|
| 18 | private static final int Y_OFFSET = 4;
|
| 19 | private static final String WATER_PATCH = "water_patch";
|
| 20 | private static final String BACK = "back";
|
| 21 | private static final String FRONT = "front";
|
| 22 | private static final String RIGHT = "right";
|
| 23 | private static final String LEFT = "left";
|
| 24 |
|
| 25 | public BoatModel(final ModelPart root) {
|
| 26 | super(root);
|
| 27 | }
|
| 28 |
|
| 29 | private static void addCommonParts(final PartDefinition root) {
|
| 30 | int halfWidth = 16;
|
| 31 | int halfBottomWidth = 14;
|
| 32 | int halfLength = 10;
|
| 33 | root.addOrReplaceChild(
|
| 34 | "bottom",
|
| 35 | CubeListBuilder.create().texOffs(0, 0).addBox(-14.0F, -9.0F, -3.0F, 28.0F, 16.0F, 3.0F),
|
| 36 | PartPose.offsetAndRotation(0.0F, 3.0F, 1.0F, (float) (Math.PI / 2), 0.0F, 0.0F)
|
| 37 | );
|
| 38 | root.addOrReplaceChild(
|
| 39 | "back",
|
| 40 | CubeListBuilder.create().texOffs(0, 19).addBox(-13.0F, -7.0F, -1.0F, 18.0F, 6.0F, 2.0F),
|
| 41 | PartPose.offsetAndRotation(-15.0F, 4.0F, 4.0F, 0.0F, (float) (Math.PI * 3.0 / 2.0), 0.0F)
|
| 42 | );
|
| 43 | root.addOrReplaceChild(
|
| 44 | "front",
|
| 45 | CubeListBuilder.create().texOffs(0, 27).addBox(-8.0F, -7.0F, -1.0F, 16.0F, 6.0F, 2.0F),
|
| 46 | PartPose.offsetAndRotation(15.0F, 4.0F, 0.0F, 0.0F, (float) (Math.PI / 2), 0.0F)
|
| 47 | );
|
| 48 | root.addOrReplaceChild(
|
| 49 | "right",
|
| 50 | CubeListBuilder.create().texOffs(0, 35).addBox(-14.0F, -7.0F, -1.0F, 28.0F, 6.0F, 2.0F),
|
| 51 | PartPose.offsetAndRotation(0.0F, 4.0F, -9.0F, 0.0F, (float) Math.PI, 0.0F)
|
| 52 | );
|
| 53 | root.addOrReplaceChild("left", CubeListBuilder.create().texOffs(0, 43).addBox(-14.0F, -7.0F, -1.0F, 28.0F, 6.0F, 2.0F), PartPose.offset(0.0F, 4.0F, 9.0F));
|
| 54 | int totalLength = 20;
|
| 55 | int bladeLength = 7;
|
| 56 | int bladeWidth = 6;
|
| 57 | float pivot = -5.0F;
|
| 58 | root.addOrReplaceChild(
|
| 59 | "left_paddle",
|
| 60 | CubeListBuilder.create().texOffs(62, 0).addBox(-1.0F, 0.0F, -5.0F, 2.0F, 2.0F, 18.0F).addBox(-1.001F, -3.0F, 8.0F, 1.0F, 6.0F, 7.0F),
|
| 61 | PartPose.offsetAndRotation(3.0F, -5.0F, 9.0F, 0.0F, 0.0F, (float) (Math.PI / 16))
|
| 62 | );
|
| 63 | root.addOrReplaceChild(
|
| 64 | "right_paddle",
|
| 65 | CubeListBuilder.create().texOffs(62, 20).addBox(-1.0F, 0.0F, -5.0F, 2.0F, 2.0F, 18.0F).addBox(0.001F, -3.0F, 8.0F, 1.0F, 6.0F, 7.0F),
|
| 66 | PartPose.offsetAndRotation(3.0F, -5.0F, -9.0F, 0.0F, (float) Math.PI, (float) (Math.PI / 16))
|
| 67 | );
|
| 68 | }
|
| 69 |
|
| 70 | public static LayerDefinition createBoatModel() {
|
| 71 | MeshDefinition mesh = new MeshDefinition();
|
| 72 | PartDefinition root = mesh.getRoot();
|
| 73 | addCommonParts(root);
|
| 74 | return LayerDefinition.create(mesh, 128, 64);
|
| 75 | }
|
| 76 |
|
| 77 | public static LayerDefinition createChestBoatModel() {
|
| 78 | MeshDefinition mesh = new MeshDefinition();
|
| 79 | PartDefinition root = mesh.getRoot();
|
| 80 | addCommonParts(root);
|
| 81 | root.addOrReplaceChild(
|
| 82 | "chest_bottom",
|
| 83 | CubeListBuilder.create().texOffs(0, 76).addBox(0.0F, 0.0F, 0.0F, 12.0F, 8.0F, 12.0F),
|
| 84 | PartPose.offsetAndRotation(-2.0F, -5.0F, -6.0F, 0.0F, (float) (-Math.PI / 2), 0.0F)
|
| 85 | );
|
| 86 | root.addOrReplaceChild(
|
| 87 | "chest_lid",
|
| 88 | CubeListBuilder.create().texOffs(0, 59).addBox(0.0F, 0.0F, 0.0F, 12.0F, 4.0F, 12.0F),
|
| 89 | PartPose.offsetAndRotation(-2.0F, -9.0F, -6.0F, 0.0F, (float) (-Math.PI / 2), 0.0F)
|
| 90 | );
|
| 91 | root.addOrReplaceChild(
|
| 92 | "chest_lock",
|
| 93 | CubeListBuilder.create().texOffs(0, 59).addBox(0.0F, 0.0F, 0.0F, 2.0F, 4.0F, 1.0F),
|
| 94 | PartPose.offsetAndRotation(-1.0F, -6.0F, -1.0F, 0.0F, (float) (-Math.PI / 2), 0.0F)
|
| 95 | );
|
| 96 | return LayerDefinition.create(mesh, 128, 128);
|
| 97 | }
|
| 98 |
|
| 99 | public static LayerDefinition createWaterPatch() {
|
| 100 | MeshDefinition mesh = new MeshDefinition();
|
| 101 | PartDefinition root = mesh.getRoot();
|
| 102 | root.addOrReplaceChild(
|
| 103 | "water_patch",
|
| 104 | CubeListBuilder.create().texOffs(0, 0).addBox(-14.0F, -9.0F, -3.0F, 28.0F, 16.0F, 3.0F),
|
| 105 | PartPose.offsetAndRotation(0.0F, -3.0F, 1.0F, (float) (Math.PI / 2), 0.0F, 0.0F)
|
| 106 | );
|
| 107 | return LayerDefinition.create(mesh, 0, 0);
|
| 108 | }
|
| 109 | }
|
| 110 |
|