| 1 | package net.minecraft.client.model.monster.breeze;
|
| 2 |
|
| 3 | import java.util.Set;
|
| 4 | import net.fabricmc.api.EnvType;
|
| 5 | import net.fabricmc.api.Environment;
|
| 6 | import net.minecraft.client.animation.KeyframeAnimation;
|
| 7 | import net.minecraft.client.animation.definitions.BreezeAnimation;
|
| 8 | import net.minecraft.client.model.EntityModel;
|
| 9 | import net.minecraft.client.model.geom.ModelPart;
|
| 10 | import net.minecraft.client.model.geom.PartPose;
|
| 11 | import net.minecraft.client.model.geom.builders.CubeDeformation;
|
| 12 | import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
| 13 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 14 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 15 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 16 | import net.minecraft.client.renderer.entity.state.BreezeRenderState;
|
| 17 | import net.minecraft.client.renderer.rendertype.RenderTypes;
|
| 18 |
|
| 19 | @Environment(EnvType.CLIENT)
|
| 20 | public class BreezeModel extends EntityModel<BreezeRenderState> {
|
| 21 | private static final float WIND_TOP_SPEED = 0.6F;
|
| 22 | private static final float WIND_MIDDLE_SPEED = 0.8F;
|
| 23 | private static final float WIND_BOTTOM_SPEED = 1.0F;
|
| 24 | private final ModelPart head;
|
| 25 | private final ModelPart eyes;
|
| 26 | private final ModelPart wind;
|
| 27 | private final ModelPart windTop;
|
| 28 | private final ModelPart windMid;
|
| 29 | private final ModelPart windBottom;
|
| 30 | private final ModelPart rods;
|
| 31 | private final KeyframeAnimation idleAnimation;
|
| 32 | private final KeyframeAnimation shootAnimation;
|
| 33 | private final KeyframeAnimation slideAnimation;
|
| 34 | private final KeyframeAnimation slideBackAnimation;
|
| 35 | private final KeyframeAnimation inhaleAnimation;
|
| 36 | private final KeyframeAnimation jumpAnimation;
|
| 37 |
|
| 38 | public BreezeModel(final ModelPart root) {
|
| 39 | super(root, RenderTypes::entityTranslucent);
|
| 40 | this.wind = root.getChild("wind_body");
|
| 41 | this.windBottom = this.wind.getChild("wind_bottom");
|
| 42 | this.windMid = this.windBottom.getChild("wind_mid");
|
| 43 | this.windTop = this.windMid.getChild("wind_top");
|
| 44 | this.head = root.getChild("body").getChild("head");
|
| 45 | this.eyes = this.head.getChild("eyes");
|
| 46 | this.rods = root.getChild("body").getChild("rods");
|
| 47 | this.idleAnimation = BreezeAnimation.IDLE.bake(root);
|
| 48 | this.shootAnimation = BreezeAnimation.SHOOT.bake(root);
|
| 49 | this.slideAnimation = BreezeAnimation.SLIDE.bake(root);
|
| 50 | this.slideBackAnimation = BreezeAnimation.SLIDE_BACK.bake(root);
|
| 51 | this.inhaleAnimation = BreezeAnimation.INHALE.bake(root);
|
| 52 | this.jumpAnimation = BreezeAnimation.JUMP.bake(root);
|
| 53 | }
|
| 54 |
|
| 55 | private static MeshDefinition createBaseMesh() {
|
| 56 | MeshDefinition meshdefinition = new MeshDefinition();
|
| 57 | PartDefinition partdefinition = meshdefinition.getRoot();
|
| 58 | PartDefinition body = partdefinition.addOrReplaceChild("body", CubeListBuilder.create(), PartPose.offset(0.0F, 0.0F, 0.0F));
|
| 59 | PartDefinition rods = body.addOrReplaceChild("rods", CubeListBuilder.create(), PartPose.offset(0.0F, 8.0F, 0.0F));
|
| 60 | rods.addOrReplaceChild(
|
| 61 | "rod_1",
|
| 62 | CubeListBuilder.create().texOffs(0, 17).addBox(-1.0F, 0.0F, -3.0F, 2.0F, 8.0F, 2.0F, new CubeDeformation(0.0F)),
|
| 63 | PartPose.offsetAndRotation(2.5981F, -3.0F, 1.5F, -2.7489F, -1.0472F, 3.1416F)
|
| 64 | );
|
| 65 | rods.addOrReplaceChild(
|
| 66 | "rod_2",
|
| 67 | CubeListBuilder.create().texOffs(0, 17).addBox(-1.0F, 0.0F, -3.0F, 2.0F, 8.0F, 2.0F, new CubeDeformation(0.0F)),
|
| 68 | PartPose.offsetAndRotation(-2.5981F, -3.0F, 1.5F, -2.7489F, 1.0472F, 3.1416F)
|
| 69 | );
|
| 70 | rods.addOrReplaceChild(
|
| 71 | "rod_3",
|
| 72 | CubeListBuilder.create().texOffs(0, 17).addBox(-1.0F, 0.0F, -3.0F, 2.0F, 8.0F, 2.0F, new CubeDeformation(0.0F)),
|
| 73 | PartPose.offsetAndRotation(0.0F, -3.0F, -3.0F, 0.3927F, 0.0F, 0.0F)
|
| 74 | );
|
| 75 | PartDefinition head = body.addOrReplaceChild(
|
| 76 | "head",
|
| 77 | CubeListBuilder.create()
|
| 78 | .texOffs(4, 24)
|
| 79 | .addBox(-5.0F, -5.0F, -4.2F, 10.0F, 3.0F, 4.0F, new CubeDeformation(0.0F))
|
| 80 | .texOffs(0, 0)
|
| 81 | .addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, new CubeDeformation(0.0F)),
|
| 82 | PartPose.offset(0.0F, 4.0F, 0.0F)
|
| 83 | );
|
| 84 | head.addOrReplaceChild(
|
| 85 | "eyes",
|
| 86 | CubeListBuilder.create()
|
| 87 | .texOffs(4, 24)
|
| 88 | .addBox(-5.0F, -5.0F, -4.2F, 10.0F, 3.0F, 4.0F, new CubeDeformation(0.0F))
|
| 89 | .texOffs(0, 0)
|
| 90 | .addBox(-4.0F, -8.0F, -4.0F, 8.0F, 8.0F, 8.0F, new CubeDeformation(0.0F)),
|
| 91 | PartPose.offset(0.0F, 0.0F, 0.0F)
|
| 92 | );
|
| 93 | PartDefinition windBody = partdefinition.addOrReplaceChild("wind_body", CubeListBuilder.create(), PartPose.offset(0.0F, 0.0F, 0.0F));
|
| 94 | PartDefinition windBottom = windBody.addOrReplaceChild(
|
| 95 | "wind_bottom",
|
| 96 | CubeListBuilder.create().texOffs(1, 83).addBox(-2.5F, -7.0F, -2.5F, 5.0F, 7.0F, 5.0F, new CubeDeformation(0.0F)),
|
| 97 | PartPose.offset(0.0F, 24.0F, 0.0F)
|
| 98 | );
|
| 99 | PartDefinition windMid = windBottom.addOrReplaceChild(
|
| 100 | "wind_mid",
|
| 101 | CubeListBuilder.create()
|
| 102 | .texOffs(74, 28)
|
| 103 | .addBox(-6.0F, -6.0F, -6.0F, 12.0F, 6.0F, 12.0F, new CubeDeformation(0.0F))
|
| 104 | .texOffs(78, 32)
|
| 105 | .addBox(-4.0F, -6.0F, -4.0F, 8.0F, 6.0F, 8.0F, new CubeDeformation(0.0F))
|
| 106 | .texOffs(49, 71)
|
| 107 | .addBox(-2.5F, -6.0F, -2.5F, 5.0F, 6.0F, 5.0F, new CubeDeformation(0.0F)),
|
| 108 | PartPose.offset(0.0F, -7.0F, 0.0F)
|
| 109 | );
|
| 110 | windMid.addOrReplaceChild(
|
| 111 | "wind_top",
|
| 112 | CubeListBuilder.create()
|
| 113 | .texOffs(0, 0)
|
| 114 | .addBox(-9.0F, -8.0F, -9.0F, 18.0F, 8.0F, 18.0F, new CubeDeformation(0.0F))
|
| 115 | .texOffs(6, 6)
|
| 116 | .addBox(-6.0F, -8.0F, -6.0F, 12.0F, 8.0F, 12.0F, new CubeDeformation(0.0F))
|
| 117 | .texOffs(105, 57)
|
| 118 | .addBox(-2.5F, -8.0F, -2.5F, 5.0F, 8.0F, 5.0F, new CubeDeformation(0.0F)),
|
| 119 | PartPose.offset(0.0F, -6.0F, 0.0F)
|
| 120 | );
|
| 121 | return meshdefinition;
|
| 122 | }
|
| 123 |
|
| 124 | public static LayerDefinition createBodyLayer() {
|
| 125 | MeshDefinition mesh = createBaseMesh();
|
| 126 | mesh.getRoot().retainPartsAndChildren(Set.of("head", "rods"));
|
| 127 | return LayerDefinition.create(mesh, 32, 32);
|
| 128 | }
|
| 129 |
|
| 130 | public static LayerDefinition createWindLayer() {
|
| 131 | MeshDefinition mesh = createBaseMesh();
|
| 132 | mesh.getRoot().retainPartsAndChildren(Set.of("wind_body"));
|
| 133 | return LayerDefinition.create(mesh, 128, 128);
|
| 134 | }
|
| 135 |
|
| 136 | public static LayerDefinition createEyesLayer() {
|
| 137 | MeshDefinition mesh = createBaseMesh();
|
| 138 | mesh.getRoot().retainPartsAndChildren(Set.of("eyes"));
|
| 139 | return LayerDefinition.create(mesh, 32, 32);
|
| 140 | }
|
| 141 |
|
| 142 | public void setupAnim(final BreezeRenderState state) {
|
| 143 | super.setupAnim(state);
|
| 144 | this.idleAnimation.apply(state.idle, state.ageInTicks);
|
| 145 | this.shootAnimation.apply(state.shoot, state.ageInTicks);
|
| 146 | this.slideAnimation.apply(state.slide, state.ageInTicks);
|
| 147 | this.slideBackAnimation.apply(state.slideBack, state.ageInTicks);
|
| 148 | this.inhaleAnimation.apply(state.inhale, state.ageInTicks);
|
| 149 | this.jumpAnimation.apply(state.longJump, state.ageInTicks);
|
| 150 | }
|
| 151 |
|
| 152 | public ModelPart head() {
|
| 153 | return this.head;
|
| 154 | }
|
| 155 |
|
| 156 | public ModelPart eyes() {
|
| 157 | return this.eyes;
|
| 158 | }
|
| 159 |
|
| 160 | public ModelPart rods() {
|
| 161 | return this.rods;
|
| 162 | }
|
| 163 |
|
| 164 | public ModelPart wind() {
|
| 165 | return this.wind;
|
| 166 | }
|
| 167 | }
|
| 168 |
|