VillagerModel.java
net.minecraft.client.model.npc.VillagerModel
信息
- 全限定名:net.minecraft.client.model.npc.VillagerModel
- 类型:public class
- 包:net.minecraft.client.model.npc
- 源码路径:src/main/java/net/minecraft/client/model/npc/VillagerModel.java
- 起始行号:L19
- 继承:EntityModel
- 实现:HeadedModel, VillagerLikeModel
- 职责:
TODO
字段/常量
-
head- 类型:
ModelPart - 修饰符:
private final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
rightLeg- 类型:
ModelPart - 修饰符:
private final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
leftLeg- 类型:
ModelPart - 修饰符:
private final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
arms- 类型:
ModelPart - 修饰符:
private final - 源码定位:
L23 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public VillagerModel(ModelPart root) @ L25
- 构造器名:VillagerModel
- 源码定位:L25
- 修饰符:public
参数:
- root: ModelPart
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static MeshDefinition createBodyModel() @ L33
- 方法名:createBodyModel
- 源码定位:L33
- 返回类型:MeshDefinition
- 修饰符:public static
参数:
- 无
说明:
TODO
public static MeshDefinition createNoHatModel() @ L77
- 方法名:createNoHatModel
- 源码定位:L77
- 返回类型:MeshDefinition
- 修饰符:public static
参数:
- 无
说明:
TODO
public void setupAnim(VillagerRenderState state) @ L83
- 方法名:setupAnim
- 源码定位:L83
- 返回类型:void
- 修饰符:public
参数:
- state: VillagerRenderState
说明:
TODO
public ModelPart getHead() @ L100
- 方法名:getHead
- 源码定位:L100
- 返回类型:ModelPart
- 修饰符:public
参数:
- 无
说明:
TODO
public void translateToArms(VillagerRenderState state, PoseStack outputPoseStack) @ L105
- 方法名:translateToArms
- 源码定位:L105
- 返回类型:void
- 修饰符:public
参数:
- state: VillagerRenderState
- outputPoseStack: PoseStack
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class VillagerModel extends EntityModel<VillagerRenderState> implements HeadedModel, VillagerLikeModel<VillagerRenderState> {
private final ModelPart head;
private final ModelPart rightLeg;
private final ModelPart leftLeg;
private final ModelPart arms;
public VillagerModel(ModelPart root) {
super(root);
this.head = root.getChild("head");
this.rightLeg = root.getChild("right_leg");
this.leftLeg = root.getChild("left_leg");
this.arms = root.getChild("arms");
}
public static MeshDefinition createBodyModel() {
MeshDefinition mesh = new MeshDefinition();
PartDefinition root = mesh.getRoot();
float offset = 0.5F;
PartDefinition head = root.addOrReplaceChild(
"head", CubeListBuilder.create().texOffs(0, 0).addBox(-4.0F, -10.0F, -4.0F, 8.0F, 10.0F, 8.0F), PartPose.ZERO
);
PartDefinition hat = head.addOrReplaceChild(
"hat", CubeListBuilder.create().texOffs(32, 0).addBox(-4.0F, -10.0F, -4.0F, 8.0F, 10.0F, 8.0F, new CubeDeformation(0.51F)), PartPose.ZERO
);
hat.addOrReplaceChild(
"hat_rim",
CubeListBuilder.create().texOffs(30, 47).addBox(-8.0F, -8.0F, -6.0F, 16.0F, 16.0F, 1.0F),
PartPose.rotation((float) (-Math.PI / 2), 0.0F, 0.0F)
);
head.addOrReplaceChild(
"nose", CubeListBuilder.create().texOffs(24, 0).addBox(-1.0F, -1.0F, -6.0F, 2.0F, 4.0F, 2.0F), PartPose.offset(0.0F, -2.0F, 0.0F)
);
PartDefinition body = root.addOrReplaceChild(
"body", CubeListBuilder.create().texOffs(16, 20).addBox(-4.0F, 0.0F, -3.0F, 8.0F, 12.0F, 6.0F), PartPose.ZERO
);
body.addOrReplaceChild(
"jacket", CubeListBuilder.create().texOffs(0, 38).addBox(-4.0F, 0.0F, -3.0F, 8.0F, 20.0F, 6.0F, new CubeDeformation(0.5F)), PartPose.ZERO
);
root.addOrReplaceChild(
"arms",
CubeListBuilder.create()
.texOffs(44, 22)
.addBox(-8.0F, -2.0F, -2.0F, 4.0F, 8.0F, 4.0F)
.texOffs(44, 22)
.addBox(4.0F, -2.0F, -2.0F, 4.0F, 8.0F, 4.0F, true)
.texOffs(40, 38)
.addBox(-4.0F, 2.0F, -2.0F, 8.0F, 4.0F, 4.0F),
PartPose.offsetAndRotation(0.0F, 3.0F, -1.0F, -0.75F, 0.0F, 0.0F)
);
root.addOrReplaceChild(
"right_leg", CubeListBuilder.create().texOffs(0, 22).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F), PartPose.offset(-2.0F, 12.0F, 0.0F)
);
root.addOrReplaceChild(
"left_leg", CubeListBuilder.create().texOffs(0, 22).mirror().addBox(-2.0F, 0.0F, -2.0F, 4.0F, 12.0F, 4.0F), PartPose.offset(2.0F, 12.0F, 0.0F)
);
return mesh;
}
public static MeshDefinition createNoHatModel() {
MeshDefinition mesh = createBodyModel();
mesh.getRoot().clearChild("head").clearRecursively();
return mesh;
}
public void setupAnim(VillagerRenderState state) {
super.setupAnim(state);
this.head.yRot = state.yRot * (float) (Math.PI / 180.0);
this.head.xRot = state.xRot * (float) (Math.PI / 180.0);
if (state.isUnhappy) {
this.head.zRot = 0.3F * Mth.sin(0.45F * state.ageInTicks);
this.head.xRot = 0.4F;
} else {
this.head.zRot = 0.0F;
}
this.rightLeg.xRot = Mth.cos(state.walkAnimationPos * 0.6662F) * 1.4F * state.walkAnimationSpeed * 0.5F;
this.leftLeg.xRot = Mth.cos(state.walkAnimationPos * 0.6662F + (float) Math.PI) * 1.4F * state.walkAnimationSpeed * 0.5F;
this.rightLeg.yRot = 0.0F;
this.leftLeg.yRot = 0.0F;
}
@Override
public ModelPart getHead() {
return this.head;
}
public void translateToArms(VillagerRenderState state, PoseStack outputPoseStack) {
this.root.translateAndRotate(outputPoseStack);
this.arms.translateAndRotate(outputPoseStack);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
PartPose.offset(), PartPose.offsetAndRotation(), PartPose.rotation()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
CubeDeformation()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
CubeListBuilder.create()
- 引用位置:
-
- 引用位置:
构造调用/返回值 - 关联成员:
MeshDefinition()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.cos(), Mth.sin()
- 引用位置: