2025-11-24 22:52:51 +03:00

56 lines
2.4 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package net.minecraft.client.model;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.client.renderer.entity.state.EntityRenderState;
import net.minecraft.util.Mth;
public class EndermiteModel
extends EntityModel<EntityRenderState> {
private static final int BODY_COUNT = 4;
private static final int[][] BODY_SIZES = new int[][]{{4, 3, 2}, {6, 4, 5}, {3, 3, 1}, {1, 2, 1}};
private static final int[][] BODY_TEXS = new int[][]{{0, 0}, {0, 5}, {0, 14}, {0, 18}};
private final ModelPart[] bodyParts = new ModelPart[4];
public EndermiteModel(ModelPart root) {
super(root);
for (int i = 0; i < 4; ++i) {
this.bodyParts[i] = root.getChild(EndermiteModel.createSegmentName(i));
}
}
private static String createSegmentName(int i) {
return "segment" + i;
}
public static LayerDefinition createBodyLayer() {
MeshDefinition mesh = new MeshDefinition();
PartDefinition root = mesh.getRoot();
float placement = -3.5f;
for (int i = 0; i < 4; ++i) {
root.addOrReplaceChild(EndermiteModel.createSegmentName(i), CubeListBuilder.create().texOffs(BODY_TEXS[i][0], BODY_TEXS[i][1]).addBox((float)BODY_SIZES[i][0] * -0.5f, 0.0f, (float)BODY_SIZES[i][2] * -0.5f, BODY_SIZES[i][0], BODY_SIZES[i][1], BODY_SIZES[i][2]), PartPose.offset(0.0f, 24 - BODY_SIZES[i][1], placement));
if (i >= 3) continue;
placement += (float)(BODY_SIZES[i][2] + BODY_SIZES[i + 1][2]) * 0.5f;
}
return LayerDefinition.create(mesh, 64, 32);
}
@Override
public void setupAnim(EntityRenderState state) {
super.setupAnim(state);
for (int i = 0; i < this.bodyParts.length; ++i) {
this.bodyParts[i].yRot = Mth.cos(state.ageInTicks * 0.9f + (float)i * 0.15f * (float)Math.PI) * (float)Math.PI * 0.01f * (float)(1 + Math.abs(i - 2));
this.bodyParts[i].x = Mth.sin(state.ageInTicks * 0.9f + (float)i * 0.15f * (float)Math.PI) * (float)Math.PI * 0.1f * (float)Math.abs(i - 2);
}
}
}