ItemStackRenderState.java
net.minecraft.client.renderer.item.ItemStackRenderState
信息
- 全限定名:net.minecraft.client.renderer.item.ItemStackRenderState
- 类型:public class
- 包:net.minecraft.client.renderer.item
- 源码路径:src/main/java/net/minecraft/client/renderer/item/ItemStackRenderState.java
- 起始行号:L30
- 职责:
TODO
字段/常量
-
displayContext- 类型:
ItemDisplayContext - 修饰符:
package-private - 源码定位:
L31 - 说明:
TODO
- 类型:
-
activeLayerCount- 类型:
int - 修饰符:
private - 源码定位:
L32 - 说明:
TODO
- 类型:
-
animated- 类型:
boolean - 修饰符:
private - 源码定位:
L33 - 说明:
TODO
- 类型:
-
oversizedInGui- 类型:
boolean - 修饰符:
private - 源码定位:
L34 - 说明:
TODO
- 类型:
-
cachedModelBoundingBox- 类型:
AABB - 修饰符:
private - 源码定位:
L35 - 说明:
TODO
- 类型:
-
layers- 类型:
ItemStackRenderState.LayerRenderState[] - 修饰符:
private - 源码定位:
L36 - 说明:
TODO
- 类型:
内部类/嵌套类型
-
net.minecraft.client.renderer.item.ItemStackRenderState.FoilType- 类型:
enum - 修饰符:
public static - 源码定位:
L140 - 说明:
TODO
- 类型:
-
net.minecraft.client.renderer.item.ItemStackRenderState.LayerRenderState- 类型:
class - 修饰符:
public - 源码定位:
L147 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
public void ensureCapacity(int requestedCount) @ L38
- 方法名:ensureCapacity
- 源码定位:L38
- 返回类型:void
- 修饰符:public
参数:
- requestedCount: int
说明:
TODO
public ItemStackRenderState.LayerRenderState newLayer() @ L50
- 方法名:newLayer
- 源码定位:L50
- 返回类型:ItemStackRenderState.LayerRenderState
- 修饰符:public
参数:
- 无
说明:
TODO
public void clear() @ L55
- 方法名:clear
- 源码定位:L55
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void setAnimated() @ L68
- 方法名:setAnimated
- 源码定位:L68
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isAnimated() @ L72
- 方法名:isAnimated
- 源码定位:L72
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public void appendModelIdentityElement(Object element) @ L76
- 方法名:appendModelIdentityElement
- 源码定位:L76
- 返回类型:void
- 修饰符:public
参数:
- element: Object
说明:
TODO
private ItemStackRenderState.LayerRenderState firstLayer() @ L79
- 方法名:firstLayer
- 源码定位:L79
- 返回类型:ItemStackRenderState.LayerRenderState
- 修饰符:private
参数:
- 无
说明:
TODO
public boolean isEmpty() @ L83
- 方法名:isEmpty
- 源码定位:L83
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean usesBlockLight() @ L87
- 方法名:usesBlockLight
- 源码定位:L87
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public Material.Baked pickParticleMaterial(RandomSource randomSource) @ L91
- 方法名:pickParticleMaterial
- 源码定位:L91
- 返回类型:Material.Baked
- 修饰符:public
参数:
- randomSource: RandomSource
说明:
TODO
public void visitExtents(Consumer<Vector3fc> output) @ L95
- 方法名:visitExtents
- 源码定位:L95
- 返回类型:void
- 修饰符:public
参数:
- output: Consumer
说明:
TODO
public void submit(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, int overlayCoords, int outlineColor) @ L113
- 方法名:submit
- 源码定位:L113
- 返回类型:void
- 修饰符:public
参数:
- poseStack: PoseStack
- submitNodeCollector: SubmitNodeCollector
- lightCoords: int
- overlayCoords: int
- outlineColor: int
说明:
TODO
public AABB getModelBoundingBox() @ L119
- 方法名:getModelBoundingBox
- 源码定位:L119
- 返回类型:AABB
- 修饰符:public
参数:
- 无
说明:
TODO
public void setOversizedInGui(boolean oversizedInGui) @ L131
- 方法名:setOversizedInGui
- 源码定位:L131
- 返回类型:void
- 修饰符:public
参数:
- oversizedInGui: boolean
说明:
TODO
public boolean isOversizedInGui() @ L135
- 方法名:isOversizedInGui
- 源码定位:L135
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class ItemStackRenderState {
ItemDisplayContext displayContext = ItemDisplayContext.NONE;
private int activeLayerCount;
private boolean animated;
private boolean oversizedInGui;
private @Nullable AABB cachedModelBoundingBox;
private ItemStackRenderState.LayerRenderState[] layers = new ItemStackRenderState.LayerRenderState[]{new ItemStackRenderState.LayerRenderState()};
public void ensureCapacity(int requestedCount) {
int currentCapacity = this.layers.length;
int requiredNewCapacity = this.activeLayerCount + requestedCount;
if (requiredNewCapacity > currentCapacity) {
this.layers = Arrays.copyOf(this.layers, requiredNewCapacity);
for (int i = currentCapacity; i < requiredNewCapacity; i++) {
this.layers[i] = new ItemStackRenderState.LayerRenderState();
}
}
}
public ItemStackRenderState.LayerRenderState newLayer() {
this.ensureCapacity(1);
return this.layers[this.activeLayerCount++];
}
public void clear() {
this.displayContext = ItemDisplayContext.NONE;
for (int i = 0; i < this.activeLayerCount; i++) {
this.layers[i].clear();
}
this.activeLayerCount = 0;
this.animated = false;
this.oversizedInGui = false;
this.cachedModelBoundingBox = null;
}
public void setAnimated() {
this.animated = true;
}
public boolean isAnimated() {
return this.animated;
}
public void appendModelIdentityElement(Object element) {
}
private ItemStackRenderState.LayerRenderState firstLayer() {
return this.layers[0];
}
public boolean isEmpty() {
return this.activeLayerCount == 0;
}
public boolean usesBlockLight() {
return this.firstLayer().usesBlockLight;
}
public Material.@Nullable Baked pickParticleMaterial(RandomSource randomSource) {
return this.activeLayerCount == 0 ? null : this.layers[randomSource.nextInt(this.activeLayerCount)].particleMaterial;
}
public void visitExtents(Consumer<Vector3fc> output) {
Vector3f scratch = new Vector3f();
PoseStack.Pose pose = new PoseStack.Pose();
for (int i = 0; i < this.activeLayerCount; i++) {
ItemStackRenderState.LayerRenderState layer = this.layers[i];
layer.applyTransform(pose);
Matrix4f poseTransform = pose.pose();
Vector3fc[] layerExtents = layer.extents.get();
for (Vector3fc extent : layerExtents) {
output.accept(scratch.set(extent).mulPosition(poseTransform));
}
pose.setIdentity();
}
}
public void submit(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, int overlayCoords, int outlineColor) {
for (int i = 0; i < this.activeLayerCount; i++) {
this.layers[i].submit(poseStack, submitNodeCollector, lightCoords, overlayCoords, outlineColor);
}
}
public AABB getModelBoundingBox() {
if (this.cachedModelBoundingBox != null) {
return this.cachedModelBoundingBox;
} else {
AABB.Builder collector = new AABB.Builder();
this.visitExtents(collector::include);
AABB aabb = collector.isDefined() ? collector.build() : AABB.ofSize(Vec3.ZERO, 0.0, 0.0, 0.0);
this.cachedModelBoundingBox = aabb;
return aabb;
}
}
public void setOversizedInGui(boolean oversizedInGui) {
this.oversizedInGui = oversizedInGui;
}
public boolean isOversizedInGui() {
return this.oversizedInGui;
}
@OnlyIn(Dist.CLIENT)
public static enum FoilType {
NONE,
STANDARD,
SPECIAL;
}
@OnlyIn(Dist.CLIENT)
public class LayerRenderState {
private static final Vector3fc[] NO_EXTENTS = new Vector3fc[0];
public static final Supplier<Vector3fc[]> NO_EXTENTS_SUPPLIER = () -> NO_EXTENTS;
public static final int[] EMPTY_TINTS = new int[0];
private final List<BakedQuad> quads;
private boolean usesBlockLight;
private Material.@Nullable Baked particleMaterial;
private ItemTransform itemTransform;
private final Matrix4f localTransform;
private ItemStackRenderState.FoilType foilType;
private @Nullable IntList tintLayers;
private @Nullable SpecialModelRenderer<Object> specialRenderer;
private @Nullable Object argumentForSpecialRendering;
private Supplier<Vector3fc[]> extents;
public LayerRenderState() {
Objects.requireNonNull(ItemStackRenderState.this);
super();
this.quads = new ArrayList<>();
this.itemTransform = ItemTransform.NO_TRANSFORM;
this.localTransform = new Matrix4f();
this.foilType = ItemStackRenderState.FoilType.NONE;
this.extents = NO_EXTENTS_SUPPLIER;
}
public void clear() {
this.quads.clear();
this.foilType = ItemStackRenderState.FoilType.NONE;
this.specialRenderer = null;
this.argumentForSpecialRendering = null;
if (this.tintLayers != null) {
this.tintLayers.clear();
}
this.usesBlockLight = false;
this.particleMaterial = null;
this.itemTransform = ItemTransform.NO_TRANSFORM;
this.localTransform.identity();
this.extents = NO_EXTENTS_SUPPLIER;
}
public List<BakedQuad> prepareQuadList() {
return this.quads;
}
public void setUsesBlockLight(boolean usesBlockLight) {
this.usesBlockLight = usesBlockLight;
}
public void setExtents(Supplier<Vector3fc[]> extents) {
this.extents = extents;
}
public void setParticleMaterial(Material.Baked particleMaterial) {
this.particleMaterial = particleMaterial;
}
public void setItemTransform(ItemTransform transform) {
this.itemTransform = transform;
}
public void setLocalTransform(Matrix4fc transform) {
this.localTransform.set(transform);
}
public <T> void setupSpecialModel(SpecialModelRenderer<T> renderer, @Nullable T argument) {
this.specialRenderer = eraseSpecialRenderer(renderer);
this.argumentForSpecialRendering = argument;
}
private static SpecialModelRenderer<Object> eraseSpecialRenderer(SpecialModelRenderer<?> renderer) {
return (SpecialModelRenderer<Object>)renderer;
}
public void setFoilType(ItemStackRenderState.FoilType foilType) {
this.foilType = foilType;
}
public IntList tintLayers() {
if (this.tintLayers == null) {
this.tintLayers = new IntArrayList();
}
return this.tintLayers;
}
private void submit(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, int overlayCoords, int outlineColor) {
poseStack.pushPose();
this.applyTransform(poseStack.last());
if (this.specialRenderer != null) {
this.specialRenderer
.submit(
this.argumentForSpecialRendering,
poseStack,
submitNodeCollector,
lightCoords,
overlayCoords,
this.foilType != ItemStackRenderState.FoilType.NONE,
outlineColor
);
} else {
int[] tints = this.tintLayers != null ? this.tintLayers.toArray(EMPTY_TINTS) : EMPTY_TINTS;
submitNodeCollector.submitItem(
poseStack, ItemStackRenderState.this.displayContext, lightCoords, overlayCoords, outlineColor, tints, this.quads, this.foilType
);
}
poseStack.popPose();
}
private void applyTransform(PoseStack.Pose localPose) {
this.itemTransform.apply(ItemStackRenderState.this.displayContext.leftHand(), localPose);
localPose.mulPose(this.localTransform);
}
}
}引用的其他类
-
- 引用位置:
参数/方法调用/构造调用 - 关联成员:
Pose(), PoseStack.Pose()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
字段/方法调用/构造调用/返回值 - 关联成员:
AABB.Builder(), AABB.ofSize(), Builder()
- 引用位置: