Spaces:
Build error
Build error
File size: 2,962 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
package net.minecraft.client.model;
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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
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 p_170545_) {
super(p_170545_);
for (int i = 0; i < 4; i++) {
this.bodyParts[i] = p_170545_.getChild(createSegmentName(i));
}
}
private static String createSegmentName(int p_170548_) {
return "segment" + p_170548_;
}
public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();
float f = -3.5F;
for (int i = 0; i < 4; i++) {
partdefinition.addOrReplaceChild(
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,
(float)BODY_SIZES[i][0],
(float)BODY_SIZES[i][1],
(float)BODY_SIZES[i][2]
),
PartPose.offset(0.0F, (float)(24 - BODY_SIZES[i][1]), f)
);
if (i < 3) {
f += (float)(BODY_SIZES[i][2] + BODY_SIZES[i + 1][2]) * 0.5F;
}
}
return LayerDefinition.create(meshdefinition, 64, 32);
}
@Override
public void setupAnim(EntityRenderState p_363690_) {
super.setupAnim(p_363690_);
for (int i = 0; i < this.bodyParts.length; i++) {
this.bodyParts[i].yRot = Mth.cos(p_363690_.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(p_363690_.ageInTicks * 0.9F + (float)i * 0.15F * (float) Math.PI)
* (float) Math.PI
* 0.1F
* (float)Math.abs(i - 2);
}
}
} |