StuckInBodyLayer.java
net.minecraft.client.renderer.entity.layers.StuckInBodyLayer
信息
- 全限定名:net.minecraft.client.renderer.entity.layers.StuckInBodyLayer
- 类型:public abstract class
- 包:net.minecraft.client.renderer.entity.layers
- 源码路径:src/main/java/net/minecraft/client/renderer/entity/layers/StuckInBodyLayer.java
- 起始行号:L19
- 继承:RenderLayer<AvatarRenderState,M>
- 职责:
TODO
字段/常量
-
model- 类型:
Model<S> - 修饰符:
private final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
modelState- 类型:
S - 修饰符:
private final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
texture- 类型:
Identifier - 修饰符:
private final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
placementStyle- 类型:
StuckInBodyLayer.PlacementStyle - 修饰符:
private final - 源码定位:
L23 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.renderer.entity.layers.StuckInBodyLayer.PlacementStyle- 类型:
enum - 修饰符:
public static - 源码定位:
L95 - 说明:
TODO
- 类型:
构造器
public StuckInBodyLayer(LivingEntityRenderer<?,AvatarRenderState,M> renderer, Model<S> model, S modelState, Identifier texture, StuckInBodyLayer.PlacementStyle placementStyle) @ L25
- 构造器名:StuckInBodyLayer
- 源码定位:L25
- 修饰符:public
参数:
- renderer: LivingEntityRenderer<?,AvatarRenderState,M>
- model: Model
- modelState: S
- texture: Identifier
- placementStyle: StuckInBodyLayer.PlacementStyle
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected abstract int numStuck(AvatarRenderState state) @ L39
- 方法名:numStuck
- 源码定位:L39
- 返回类型:int
- 修饰符:protected abstract
参数:
- state: AvatarRenderState
说明:
TODO
private void submitStuckItem(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, float directionX, float directionY, float directionZ, int outlineColor) @ L41
- 方法名:submitStuckItem
- 源码定位:L41
- 返回类型:void
- 修饰符:private
参数:
- poseStack: PoseStack
- submitNodeCollector: SubmitNodeCollector
- lightCoords: int
- directionX: float
- directionY: float
- directionZ: float
- outlineColor: int
说明:
TODO
public void submit(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, AvatarRenderState state, float yRot, float xRot) @ L52
- 方法名:submit
- 源码定位:L52
- 返回类型:void
- 修饰符:public
参数:
- poseStack: PoseStack
- submitNodeCollector: SubmitNodeCollector
- lightCoords: int
- state: AvatarRenderState
- yRot: float
- xRot: float
说明:
TODO
private static float snapToFace(float value) @ L90
- 方法名:snapToFace
- 源码定位:L90
- 返回类型:float
- 修饰符:private static
参数:
- value: float
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public abstract class StuckInBodyLayer<M extends PlayerModel, S> extends RenderLayer<AvatarRenderState, M> {
private final Model<S> model;
private final S modelState;
private final Identifier texture;
private final StuckInBodyLayer.PlacementStyle placementStyle;
public StuckInBodyLayer(
LivingEntityRenderer<?, AvatarRenderState, M> renderer,
Model<S> model,
S modelState,
Identifier texture,
StuckInBodyLayer.PlacementStyle placementStyle
) {
super(renderer);
this.model = model;
this.modelState = modelState;
this.texture = texture;
this.placementStyle = placementStyle;
}
protected abstract int numStuck(final AvatarRenderState state);
private void submitStuckItem(
PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, float directionX, float directionY, float directionZ, int outlineColor
) {
float directionXZ = Mth.sqrt(directionX * directionX + directionZ * directionZ);
float yRot = (float)(Math.atan2(directionX, directionZ) * 180.0F / (float)Math.PI);
float xRot = (float)(Math.atan2(directionY, directionXZ) * 180.0F / (float)Math.PI);
poseStack.mulPose(Axis.YP.rotationDegrees(yRot - 90.0F));
poseStack.mulPose(Axis.ZP.rotationDegrees(xRot));
submitNodeCollector.submitModel(this.model, this.modelState, poseStack, this.texture, lightCoords, OverlayTexture.NO_OVERLAY, outlineColor, null);
}
public void submit(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, AvatarRenderState state, float yRot, float xRot) {
int count = this.numStuck(state);
if (count > 0) {
RandomSource random = RandomSource.createThreadLocalInstance(state.id);
for (int i = 0; i < count; i++) {
poseStack.pushPose();
ModelPart modelPart = this.getParentModel().getRandomBodyPart(random);
ModelPart.Cube cube = modelPart.getRandomCube(random);
modelPart.translateAndRotate(poseStack);
float midX = random.nextFloat();
float midY = random.nextFloat();
float midZ = random.nextFloat();
if (this.placementStyle == StuckInBodyLayer.PlacementStyle.ON_SURFACE) {
int plane = random.nextInt(3);
switch (plane) {
case 0:
midX = snapToFace(midX);
break;
case 1:
midY = snapToFace(midY);
break;
default:
midZ = snapToFace(midZ);
}
}
poseStack.translate(
Mth.lerp(midX, cube.minX, cube.maxX) / 16.0F, Mth.lerp(midY, cube.minY, cube.maxY) / 16.0F, Mth.lerp(midZ, cube.minZ, cube.maxZ) / 16.0F
);
this.submitStuckItem(
poseStack, submitNodeCollector, lightCoords, -(midX * 2.0F - 1.0F), -(midY * 2.0F - 1.0F), -(midZ * 2.0F - 1.0F), state.outlineColor
);
poseStack.popPose();
}
}
}
private static float snapToFace(float value) {
return value > 0.5F ? 1.0F : 0.5F;
}
@OnlyIn(Dist.CLIENT)
public static enum PlacementStyle {
IN_CUBE,
ON_SURFACE;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.lerp(), Mth.sqrt()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RandomSource.createThreadLocalInstance()
- 引用位置: