SilverfishModel.java
net.minecraft.client.model.monster.silverfish.SilverfishModel
信息
- 全限定名:net.minecraft.client.model.monster.silverfish.SilverfishModel
- 类型:public class
- 包:net.minecraft.client.model.monster.silverfish
- 源码路径:src/main/java/net/minecraft/client/model/monster/silverfish/SilverfishModel.java
- 起始行号:L17
- 继承:EntityModel
- 职责:
TODO
字段/常量
-
BODY_COUNT- 类型:
int - 修饰符:
private static final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
bodyParts- 类型:
ModelPart[] - 修饰符:
private final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
bodyLayers- 类型:
ModelPart[] - 修饰符:
private final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
BODY_SIZES- 类型:
int[][] - 修饰符:
private static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
BODY_TEXS- 类型:
int[][] - 修饰符:
private static final - 源码定位:
L22 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public SilverfishModel(ModelPart root) @ L24
- 构造器名:SilverfishModel
- 源码定位:L24
- 修饰符:public
参数:
- root: ModelPart
说明:
TODO
方法
下面的方法块按源码顺序生成。
private static String getLayerName(int i) @ L30
- 方法名:getLayerName
- 源码定位:L30
- 返回类型:String
- 修饰符:private static
参数:
- i: int
说明:
TODO
private static String getSegmentName(int i) @ L34
- 方法名:getSegmentName
- 源码定位:L34
- 返回类型:String
- 修饰符:private static
参数:
- i: int
说明:
TODO
public static LayerDefinition createBodyLayer() @ L38
- 方法名:createBodyLayer
- 源码定位:L38
- 返回类型:LayerDefinition
- 修饰符:public static
参数:
- 无
说明:
TODO
public void setupAnim(EntityRenderState state) @ L76
- 方法名:setupAnim
- 源码定位:L76
- 返回类型:void
- 修饰符:public
参数:
- state: EntityRenderState
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class SilverfishModel extends EntityModel<EntityRenderState> {
private static final int BODY_COUNT = 7;
private final ModelPart[] bodyParts = new ModelPart[7];
private final ModelPart[] bodyLayers = new ModelPart[3];
private static final int[][] BODY_SIZES = new int[][]{{3, 2, 2}, {4, 3, 2}, {6, 4, 3}, {3, 3, 3}, {2, 2, 3}, {2, 1, 2}, {1, 1, 2}};
private static final int[][] BODY_TEXS = new int[][]{{0, 0}, {0, 4}, {0, 9}, {0, 16}, {0, 22}, {11, 0}, {13, 4}};
public SilverfishModel(ModelPart root) {
super(root);
Arrays.setAll(this.bodyParts, i -> root.getChild(getSegmentName(i)));
Arrays.setAll(this.bodyLayers, i -> root.getChild(getLayerName(i)));
}
private static String getLayerName(int i) {
return "layer" + i;
}
private static String getSegmentName(int i) {
return "segment" + i;
}
public static LayerDefinition createBodyLayer() {
MeshDefinition mesh = new MeshDefinition();
PartDefinition root = mesh.getRoot();
float[] zPlacement = new float[7];
float placement = -3.5F;
for (int i = 0; i < 7; i++) {
root.addOrReplaceChild(
getSegmentName(i),
CubeListBuilder.create()
.texOffs(BODY_TEXS[i][0], BODY_TEXS[i][1])
.addBox(BODY_SIZES[i][0] * -0.5F, 0.0F, 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)
);
zPlacement[i] = placement;
if (i < 6) {
placement += (BODY_SIZES[i][2] + BODY_SIZES[i + 1][2]) * 0.5F;
}
}
root.addOrReplaceChild(
getLayerName(0),
CubeListBuilder.create().texOffs(20, 0).addBox(-5.0F, 0.0F, BODY_SIZES[2][2] * -0.5F, 10.0F, 8.0F, BODY_SIZES[2][2]),
PartPose.offset(0.0F, 16.0F, zPlacement[2])
);
root.addOrReplaceChild(
getLayerName(1),
CubeListBuilder.create().texOffs(20, 11).addBox(-3.0F, 0.0F, BODY_SIZES[4][2] * -0.5F, 6.0F, 4.0F, BODY_SIZES[4][2]),
PartPose.offset(0.0F, 20.0F, zPlacement[4])
);
root.addOrReplaceChild(
getLayerName(2),
CubeListBuilder.create().texOffs(20, 18).addBox(-3.0F, 0.0F, BODY_SIZES[4][2] * -0.5F, 6.0F, 5.0F, BODY_SIZES[1][2]),
PartPose.offset(0.0F, 19.0F, zPlacement[1])
);
return LayerDefinition.create(mesh, 64, 32);
}
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 + i * 0.15F * (float) Math.PI) * (float) Math.PI * 0.05F * (1 + Math.abs(i - 2));
this.bodyParts[i].x = Mth.sin(state.ageInTicks * 0.9F + i * 0.15F * (float) Math.PI) * (float) Math.PI * 0.2F * Math.abs(i - 2);
}
this.bodyLayers[0].yRot = this.bodyParts[2].yRot;
this.bodyLayers[1].yRot = this.bodyParts[4].yRot;
this.bodyLayers[1].x = this.bodyParts[4].x;
this.bodyLayers[2].yRot = this.bodyParts[1].yRot;
this.bodyLayers[2].x = this.bodyParts[1].x;
}
}引用的其他类
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
PartPose.offset()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
CubeListBuilder.create()
- 引用位置:
-
- 引用位置:
方法调用/返回值 - 关联成员:
LayerDefinition.create()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
MeshDefinition()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.cos(), Mth.sin()
- 引用位置: