| 1 | package net.minecraft.client.model.animal.ghast;
|
| 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.PartNames;
|
| 8 | import net.minecraft.client.model.geom.PartPose;
|
| 9 | import net.minecraft.client.model.geom.builders.CubeDeformation;
|
| 10 | import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
| 11 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 12 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 13 | import net.minecraft.client.model.geom.builders.MeshTransformer;
|
| 14 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 15 | import net.minecraft.client.model.monster.ghast.GhastModel;
|
| 16 | import net.minecraft.client.renderer.entity.state.HappyGhastRenderState;
|
| 17 |
|
| 18 | @Environment(EnvType.CLIENT)
|
| 19 | public class HappyGhastModel extends EntityModel<HappyGhastRenderState> {
|
| 20 | public static final MeshTransformer BABY_TRANSFORMER = MeshTransformer.scaling(0.2375F);
|
| 21 | private static final float BODY_SQUEEZE = 0.9375F;
|
| 22 | private final ModelPart[] tentacles = new ModelPart[9];
|
| 23 | private final ModelPart body;
|
| 24 |
|
| 25 | public HappyGhastModel(final ModelPart root) {
|
| 26 | super(root);
|
| 27 | this.body = root.getChild("body");
|
| 28 |
|
| 29 | for (int i = 0; i < this.tentacles.length; i++) {
|
| 30 | this.tentacles[i] = this.body.getChild(PartNames.tentacle(i));
|
| 31 | }
|
| 32 | }
|
| 33 |
|
| 34 | public static LayerDefinition createBodyLayer(final boolean isBaby, final CubeDeformation deformation) {
|
| 35 | MeshDefinition mesh = new MeshDefinition();
|
| 36 | PartDefinition root = mesh.getRoot();
|
| 37 | PartDefinition body = root.addOrReplaceChild(
|
| 38 | "body", CubeListBuilder.create().texOffs(0, 0).addBox(-8.0F, -8.0F, -8.0F, 16.0F, 16.0F, 16.0F, deformation), PartPose.offset(0.0F, 16.0F, 0.0F)
|
| 39 | );
|
| 40 | if (isBaby) {
|
| 41 | body.addOrReplaceChild(
|
| 42 | "inner_body",
|
| 43 | CubeListBuilder.create().texOffs(0, 32).addBox(-8.0F, -16.0F, -8.0F, 16.0F, 16.0F, 16.0F, deformation.extend(-0.5F)),
|
| 44 | PartPose.offset(0.0F, 8.0F, 0.0F)
|
| 45 | );
|
| 46 | }
|
| 47 |
|
| 48 | body.addOrReplaceChild(
|
| 49 | PartNames.tentacle(0),
|
| 50 | CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 5.0F, 2.0F, deformation),
|
| 51 | PartPose.offset(-3.75F, 7.0F, -5.0F)
|
| 52 | );
|
| 53 | body.addOrReplaceChild(
|
| 54 | PartNames.tentacle(1), CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 7.0F, 2.0F, deformation), PartPose.offset(1.25F, 7.0F, -5.0F)
|
| 55 | );
|
| 56 | body.addOrReplaceChild(
|
| 57 | PartNames.tentacle(2), CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 4.0F, 2.0F, deformation), PartPose.offset(6.25F, 7.0F, -5.0F)
|
| 58 | );
|
| 59 | body.addOrReplaceChild(
|
| 60 | PartNames.tentacle(3), CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 5.0F, 2.0F, deformation), PartPose.offset(-6.25F, 7.0F, 0.0F)
|
| 61 | );
|
| 62 | body.addOrReplaceChild(
|
| 63 | PartNames.tentacle(4), CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 5.0F, 2.0F, deformation), PartPose.offset(-1.25F, 7.0F, 0.0F)
|
| 64 | );
|
| 65 | body.addOrReplaceChild(
|
| 66 | PartNames.tentacle(5), CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 7.0F, 2.0F, deformation), PartPose.offset(3.75F, 7.0F, 0.0F)
|
| 67 | );
|
| 68 | body.addOrReplaceChild(
|
| 69 | PartNames.tentacle(6), CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 8.0F, 2.0F, deformation), PartPose.offset(-3.75F, 7.0F, 5.0F)
|
| 70 | );
|
| 71 | body.addOrReplaceChild(
|
| 72 | PartNames.tentacle(7), CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 8.0F, 2.0F, deformation), PartPose.offset(1.25F, 7.0F, 5.0F)
|
| 73 | );
|
| 74 | body.addOrReplaceChild(
|
| 75 | PartNames.tentacle(8), CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, 0.0F, -1.0F, 2.0F, 5.0F, 2.0F, deformation), PartPose.offset(6.25F, 7.0F, 5.0F)
|
| 76 | );
|
| 77 | return LayerDefinition.create(mesh, 64, 64).apply(MeshTransformer.scaling(4.0F));
|
| 78 | }
|
| 79 |
|
| 80 | public void setupAnim(final HappyGhastRenderState state) {
|
| 81 | super.setupAnim(state);
|
| 82 | if (!state.bodyItem.isEmpty()) {
|
| 83 | this.body.xScale = 0.9375F;
|
| 84 | this.body.yScale = 0.9375F;
|
| 85 | this.body.zScale = 0.9375F;
|
| 86 | }
|
| 87 |
|
| 88 | GhastModel.animateTentacles(state, this.tentacles);
|
| 89 | }
|
| 90 | }
|
| 91 |
|