| 1 | package net.minecraft.client.model.object.equipment;
|
| 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.CubeDeformation;
|
| 9 | import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
| 10 | import net.minecraft.client.model.geom.builders.LayerDefinition;
|
| 11 | import net.minecraft.client.model.geom.builders.MeshDefinition;
|
| 12 | import net.minecraft.client.model.geom.builders.MeshTransformer;
|
| 13 | import net.minecraft.client.model.geom.builders.PartDefinition;
|
| 14 | import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
|
| 15 |
|
| 16 | @Environment(EnvType.CLIENT)
|
| 17 | public class ElytraModel extends EntityModel<HumanoidRenderState> {
|
| 18 | public static final MeshTransformer BABY_TRANSFORMER = MeshTransformer.scaling(0.5F);
|
| 19 | private final ModelPart rightWing;
|
| 20 | private final ModelPart leftWing;
|
| 21 |
|
| 22 | public ElytraModel(final ModelPart root) {
|
| 23 | super(root);
|
| 24 | this.leftWing = root.getChild("left_wing");
|
| 25 | this.rightWing = root.getChild("right_wing");
|
| 26 | }
|
| 27 |
|
| 28 | public static LayerDefinition createLayer() {
|
| 29 | MeshDefinition mesh = new MeshDefinition();
|
| 30 | PartDefinition root = mesh.getRoot();
|
| 31 | CubeDeformation windDeformation = new CubeDeformation(1.0F);
|
| 32 | root.addOrReplaceChild(
|
| 33 | "left_wing",
|
| 34 | CubeListBuilder.create().texOffs(22, 0).addBox(-10.0F, 0.0F, 0.0F, 10.0F, 20.0F, 2.0F, windDeformation),
|
| 35 | PartPose.offsetAndRotation(5.0F, 0.0F, 0.0F, (float) (Math.PI / 12), 0.0F, (float) (-Math.PI / 12))
|
| 36 | );
|
| 37 | root.addOrReplaceChild(
|
| 38 | "right_wing",
|
| 39 | CubeListBuilder.create().texOffs(22, 0).mirror().addBox(0.0F, 0.0F, 0.0F, 10.0F, 20.0F, 2.0F, windDeformation),
|
| 40 | PartPose.offsetAndRotation(-5.0F, 0.0F, 0.0F, (float) (Math.PI / 12), 0.0F, (float) (Math.PI / 12))
|
| 41 | );
|
| 42 | return LayerDefinition.create(mesh, 64, 32);
|
| 43 | }
|
| 44 |
|
| 45 | public void setupAnim(final HumanoidRenderState state) {
|
| 46 | super.setupAnim(state);
|
| 47 | this.leftWing.y = state.isCrouching ? 3.0F : 0.0F;
|
| 48 | this.leftWing.xRot = state.elytraRotX;
|
| 49 | this.leftWing.zRot = state.elytraRotZ;
|
| 50 | this.leftWing.yRot = state.elytraRotY;
|
| 51 | this.rightWing.yRot = -this.leftWing.yRot;
|
| 52 | this.rightWing.y = this.leftWing.y;
|
| 53 | this.rightWing.xRot = this.leftWing.xRot;
|
| 54 | this.rightWing.zRot = -this.leftWing.zRot;
|
| 55 | }
|
| 56 | }
|
| 57 |
|