ItemEntityRenderer.java
net.minecraft.client.renderer.entity.ItemEntityRenderer
信息
- 全限定名:net.minecraft.client.renderer.entity.ItemEntityRenderer
- 类型:public class
- 包:net.minecraft.client.renderer.entity
- 源码路径:src/main/java/net/minecraft/client/renderer/entity/ItemEntityRenderer.java
- 起始行号:L20
- 继承:EntityRenderer<ItemEntity,ItemEntityRenderState>
- 职责:
TODO
字段/常量
-
ITEM_MIN_HOVER_HEIGHT- 类型:
float - 修饰符:
private static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
ITEM_BUNDLE_OFFSET_SCALE- 类型:
float - 修饰符:
private static final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
FLAT_ITEM_DEPTH_THRESHOLD- 类型:
float - 修饰符:
private static final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
itemModelResolver- 类型:
ItemModelResolver - 修饰符:
private final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
random- 类型:
RandomSource - 修饰符:
private final - 源码定位:
L25 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public ItemEntityRenderer(EntityRendererProvider.Context context) @ L27
- 构造器名:ItemEntityRenderer
- 源码定位:L27
- 修饰符:public
参数:
- context: EntityRendererProvider.Context
说明:
TODO
方法
下面的方法块按源码顺序生成。
public ItemEntityRenderState createRenderState() @ L34
- 方法名:createRenderState
- 源码定位:L34
- 返回类型:ItemEntityRenderState
- 修饰符:public
参数:
- 无
说明:
TODO
public void extractRenderState(ItemEntity entity, ItemEntityRenderState state, float partialTicks) @ L38
- 方法名:extractRenderState
- 源码定位:L38
- 返回类型:void
- 修饰符:public
参数:
- entity: ItemEntity
- state: ItemEntityRenderState
- partialTicks: float
说明:
TODO
public void submit(ItemEntityRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera) @ L44
- 方法名:submit
- 源码定位:L44
- 返回类型:void
- 修饰符:public
参数:
- state: ItemEntityRenderState
- poseStack: PoseStack
- submitNodeCollector: SubmitNodeCollector
- camera: CameraRenderState
说明:
TODO
public static void submitMultipleFromCount(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, ItemClusterRenderState state, RandomSource random) @ L59
- 方法名:submitMultipleFromCount
- 源码定位:L59
- 返回类型:void
- 修饰符:public static
参数:
- poseStack: PoseStack
- submitNodeCollector: SubmitNodeCollector
- lightCoords: int
- state: ItemClusterRenderState
- random: RandomSource
说明:
TODO
public static void submitMultipleFromCount(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, ItemClusterRenderState state, RandomSource random, AABB modelBoundingBox) @ L65
- 方法名:submitMultipleFromCount
- 源码定位:L65
- 返回类型:void
- 修饰符:public static
参数:
- poseStack: PoseStack
- submitNodeCollector: SubmitNodeCollector
- lightCoords: int
- state: ItemClusterRenderState
- random: RandomSource
- modelBoundingBox: AABB
说明:
TODO
public static void renderMultipleFromCount(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, ItemClusterRenderState state, RandomSource random) @ L104
- 方法名:renderMultipleFromCount
- 源码定位:L104
- 返回类型:void
- 修饰符:public static
参数:
- poseStack: PoseStack
- submitNodeCollector: SubmitNodeCollector
- lightCoords: int
- state: ItemClusterRenderState
- random: RandomSource
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class ItemEntityRenderer extends EntityRenderer<ItemEntity, ItemEntityRenderState> {
private static final float ITEM_MIN_HOVER_HEIGHT = 0.0625F;
private static final float ITEM_BUNDLE_OFFSET_SCALE = 0.15F;
private static final float FLAT_ITEM_DEPTH_THRESHOLD = 0.0625F;
private final ItemModelResolver itemModelResolver;
private final RandomSource random = RandomSource.create();
public ItemEntityRenderer(EntityRendererProvider.Context context) {
super(context);
this.itemModelResolver = context.getItemModelResolver();
this.shadowRadius = 0.15F;
this.shadowStrength = 0.75F;
}
public ItemEntityRenderState createRenderState() {
return new ItemEntityRenderState();
}
public void extractRenderState(ItemEntity entity, ItemEntityRenderState state, float partialTicks) {
super.extractRenderState(entity, state, partialTicks);
state.bobOffset = entity.bobOffs;
state.extractItemGroupRenderState(entity, entity.getItem(), this.itemModelResolver);
}
public void submit(ItemEntityRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera) {
if (!state.item.isEmpty()) {
poseStack.pushPose();
AABB boundingBox = state.item.getModelBoundingBox();
float minOffsetY = -((float)boundingBox.minY) + 0.0625F;
float bob = Mth.sin(state.ageInTicks / 10.0F + state.bobOffset) * 0.1F + 0.1F;
poseStack.translate(0.0F, bob + minOffsetY, 0.0F);
float spin = ItemEntity.getSpin(state.ageInTicks, state.bobOffset);
poseStack.mulPose(Axis.YP.rotation(spin));
submitMultipleFromCount(poseStack, submitNodeCollector, state.lightCoords, state, this.random, boundingBox);
poseStack.popPose();
super.submit(state, poseStack, submitNodeCollector, camera);
}
}
public static void submitMultipleFromCount(
PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, ItemClusterRenderState state, RandomSource random
) {
submitMultipleFromCount(poseStack, submitNodeCollector, lightCoords, state, random, state.item.getModelBoundingBox());
}
public static void submitMultipleFromCount(
PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, ItemClusterRenderState state, RandomSource random, AABB modelBoundingBox
) {
int amount = state.count;
if (amount != 0) {
random.setSeed(state.seed);
ItemStackRenderState item = state.item;
float modelDepth = (float)modelBoundingBox.getZsize();
if (modelDepth > 0.0625F) {
item.submit(poseStack, submitNodeCollector, lightCoords, OverlayTexture.NO_OVERLAY, state.outlineColor);
for (int i = 1; i < amount; i++) {
poseStack.pushPose();
float xo = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
float yo = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
float zo = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
poseStack.translate(xo, yo, zo);
item.submit(poseStack, submitNodeCollector, lightCoords, OverlayTexture.NO_OVERLAY, state.outlineColor);
poseStack.popPose();
}
} else {
float offsetZ = modelDepth * 1.5F;
poseStack.translate(0.0F, 0.0F, -(offsetZ * (amount - 1) / 2.0F));
item.submit(poseStack, submitNodeCollector, lightCoords, OverlayTexture.NO_OVERLAY, state.outlineColor);
poseStack.translate(0.0F, 0.0F, offsetZ);
for (int i = 1; i < amount; i++) {
poseStack.pushPose();
float xo = (random.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F;
float yo = (random.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F;
poseStack.translate(xo, yo, 0.0F);
item.submit(poseStack, submitNodeCollector, lightCoords, OverlayTexture.NO_OVERLAY, state.outlineColor);
poseStack.popPose();
poseStack.translate(0.0F, 0.0F, offsetZ);
}
}
}
}
public static void renderMultipleFromCount(
PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, ItemClusterRenderState state, RandomSource random
) {
AABB modelBoundingBox = state.item.getModelBoundingBox();
int amount = state.count;
if (amount != 0) {
random.setSeed(state.seed);
ItemStackRenderState item = state.item;
float modelDepth = (float)modelBoundingBox.getZsize();
if (modelDepth > 0.0625F) {
item.submit(poseStack, submitNodeCollector, lightCoords, OverlayTexture.NO_OVERLAY, state.outlineColor);
for (int i = 1; i < amount; i++) {
poseStack.pushPose();
float xo = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
float yo = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
float zo = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
poseStack.translate(xo, yo, zo);
item.submit(poseStack, submitNodeCollector, lightCoords, OverlayTexture.NO_OVERLAY, state.outlineColor);
poseStack.popPose();
}
} else {
float offsetZ = modelDepth * 1.5F;
poseStack.translate(0.0F, 0.0F, -(offsetZ * (amount - 1) / 2.0F));
item.submit(poseStack, submitNodeCollector, lightCoords, OverlayTexture.NO_OVERLAY, state.outlineColor);
poseStack.translate(0.0F, 0.0F, offsetZ);
for (int i = 1; i < amount; i++) {
poseStack.pushPose();
float xo = (random.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F;
float yo = (random.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F;
poseStack.translate(xo, yo, 0.0F);
item.submit(poseStack, submitNodeCollector, lightCoords, OverlayTexture.NO_OVERLAY, state.outlineColor);
poseStack.popPose();
poseStack.translate(0.0F, 0.0F, offsetZ);
}
}
}
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/构造调用/返回值 - 关联成员:
ItemEntityRenderState()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.sin()
- 引用位置:
-
- 引用位置:
参数/字段/方法调用 - 关联成员:
RandomSource.create()
- 引用位置:
-
- 引用位置:
参数/方法调用 - 关联成员:
ItemEntity.getSpin()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: