ItemFeatureRenderer.java
net.minecraft.client.renderer.feature.ItemFeatureRenderer
信息
- 全限定名:net.minecraft.client.renderer.feature.ItemFeatureRenderer
- 类型:public class
- 包:net.minecraft.client.renderer.feature
- 源码路径:src/main/java/net/minecraft/client/renderer/feature/ItemFeatureRenderer.java
- 起始行号:L26
- 职责:
TODO
字段/常量
-
ENCHANTED_GLINT_ARMOR- 类型:
Identifier - 修饰符:
public static final - 源码定位:
L27 - 说明:
TODO
- 类型:
-
ENCHANTED_GLINT_ITEM- 类型:
Identifier - 修饰符:
public static final - 源码定位:
L28 - 说明:
TODO
- 类型:
-
SPECIAL_FOIL_UI_SCALE- 类型:
float - 修饰符:
private static final - 源码定位:
L29 - 说明:
TODO
- 类型:
-
SPECIAL_FOIL_FIRST_PERSON_SCALE- 类型:
float - 修饰符:
private static final - 源码定位:
L30 - 说明:
TODO
- 类型:
-
SPECIAL_FOIL_TEXTURE_SCALE- 类型:
float - 修饰符:
private static final - 源码定位:
L31 - 说明:
TODO
- 类型:
-
NO_TINT- 类型:
int - 修饰符:
public static final - 源码定位:
L32 - 说明:
TODO
- 类型:
-
quadInstance- 类型:
QuadInstance - 修饰符:
private final - 源码定位:
L33 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public void renderSolid(SubmitNodeCollection nodeCollection, MultiBufferSource.BufferSource bufferSource, OutlineBufferSource outlineBufferSource) @ L35
- 方法名:renderSolid
- 源码定位:L35
- 返回类型:void
- 修饰符:public
参数:
- nodeCollection: SubmitNodeCollection
- bufferSource: MultiBufferSource.BufferSource
- outlineBufferSource: OutlineBufferSource
说明:
TODO
public void renderTranslucent(SubmitNodeCollection nodeCollection, MultiBufferSource.BufferSource bufferSource, OutlineBufferSource outlineBufferSource) @ L43
- 方法名:renderTranslucent
- 源码定位:L43
- 返回类型:void
- 修饰符:public
参数:
- nodeCollection: SubmitNodeCollection
- bufferSource: MultiBufferSource.BufferSource
- outlineBufferSource: OutlineBufferSource
说明:
TODO
private static boolean hasTranslucency(SubmitNodeStorage.ItemSubmit submit) @ L51
- 方法名:hasTranslucency
- 源码定位:L51
- 返回类型:boolean
- 修饰符:private static
参数:
- submit: SubmitNodeStorage.ItemSubmit
说明:
TODO
private void renderItem(MultiBufferSource.BufferSource bufferSource, OutlineBufferSource outlineBufferSource, SubmitNodeStorage.ItemSubmit submit) @ L61
- 方法名:renderItem
- 源码定位:L61
- 返回类型:void
- 修饰符:private
参数:
- bufferSource: MultiBufferSource.BufferSource
- outlineBufferSource: OutlineBufferSource
- submit: SubmitNodeStorage.ItemSubmit
说明:
TODO
private static VertexConsumer getFoilBuffer(MultiBufferSource bufferSource, RenderType renderType, PoseStack.Pose foilDecalPose) @ L88
- 方法名:getFoilBuffer
- 源码定位:L88
- 返回类型:VertexConsumer
- 修饰符:private static
参数:
- bufferSource: MultiBufferSource
- renderType: RenderType
- foilDecalPose: PoseStack.Pose
说明:
TODO
private static PoseStack.Pose computeFoilDecalPose(ItemDisplayContext type, PoseStack.Pose pose) @ L97
- 方法名:computeFoilDecalPose
- 源码定位:L97
- 返回类型:PoseStack.Pose
- 修饰符:private static
参数:
- type: ItemDisplayContext
- pose: PoseStack.Pose
说明:
TODO
public static VertexConsumer getFoilBuffer(MultiBufferSource bufferSource, RenderType renderType, boolean sheeted, boolean hasFoil) @ L108
- 方法名:getFoilBuffer
- 源码定位:L108
- 返回类型:VertexConsumer
- 修饰符:public static
参数:
- bufferSource: MultiBufferSource
- renderType: RenderType
- sheeted: boolean
- hasFoil: boolean
说明:
TODO
public static RenderType getFoilRenderType(RenderType baseRenderType, boolean sheeted) @ L114
- 方法名:getFoilRenderType
- 源码定位:L114
- 返回类型:RenderType
- 修饰符:public static
参数:
- baseRenderType: RenderType
- sheeted: boolean
说明:
TODO
private static boolean useTransparentGlint(RenderType renderType) @ L122
- 方法名:useTransparentGlint
- 源码定位:L122
- 返回类型:boolean
- 修饰符:private static
参数:
- renderType: RenderType
说明:
TODO
private static int getLayerColorSafe(int[] layers, int layer) @ L126
- 方法名:getLayerColorSafe
- 源码定位:L126
- 返回类型:int
- 修饰符:private static
参数:
- layers: int[]
- layer: int
说明:
TODO
private static int getLayerColorSafe(int[] tintLayers, BakedQuad.MaterialInfo material) @ L130
- 方法名:getLayerColorSafe
- 源码定位:L130
- 返回类型:int
- 修饰符:private static
参数:
- tintLayers: int[]
- material: BakedQuad.MaterialInfo
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class ItemFeatureRenderer {
public static final Identifier ENCHANTED_GLINT_ARMOR = Identifier.withDefaultNamespace("textures/misc/enchanted_glint_armor.png");
public static final Identifier ENCHANTED_GLINT_ITEM = Identifier.withDefaultNamespace("textures/misc/enchanted_glint_item.png");
private static final float SPECIAL_FOIL_UI_SCALE = 0.5F;
private static final float SPECIAL_FOIL_FIRST_PERSON_SCALE = 0.75F;
private static final float SPECIAL_FOIL_TEXTURE_SCALE = 0.0078125F;
public static final int NO_TINT = -1;
private final QuadInstance quadInstance = new QuadInstance();
public void renderSolid(SubmitNodeCollection nodeCollection, MultiBufferSource.BufferSource bufferSource, OutlineBufferSource outlineBufferSource) {
for (SubmitNodeStorage.ItemSubmit submit : nodeCollection.getItemSubmits()) {
if (!hasTranslucency(submit)) {
this.renderItem(bufferSource, outlineBufferSource, submit);
}
}
}
public void renderTranslucent(SubmitNodeCollection nodeCollection, MultiBufferSource.BufferSource bufferSource, OutlineBufferSource outlineBufferSource) {
for (SubmitNodeStorage.ItemSubmit submit : nodeCollection.getItemSubmits()) {
if (hasTranslucency(submit)) {
this.renderItem(bufferSource, outlineBufferSource, submit);
}
}
}
private static boolean hasTranslucency(SubmitNodeStorage.ItemSubmit submit) {
for (BakedQuad quad : submit.quads()) {
if (quad.materialInfo().itemRenderType().hasBlending()) {
return true;
}
}
return false;
}
private void renderItem(MultiBufferSource.BufferSource bufferSource, OutlineBufferSource outlineBufferSource, SubmitNodeStorage.ItemSubmit submit) {
PoseStack.Pose pose = submit.pose();
ItemStackRenderState.FoilType foilType = submit.foilType();
PoseStack.Pose foilDecalPose = foilType == ItemStackRenderState.FoilType.SPECIAL ? computeFoilDecalPose(submit.displayContext(), pose) : null;
this.quadInstance.setLightCoords(submit.lightCoords());
this.quadInstance.setOverlayCoords(submit.overlayCoords());
if (submit.outlineColor() != 0) {
outlineBufferSource.setColor(submit.outlineColor());
}
for (BakedQuad quad : submit.quads()) {
BakedQuad.MaterialInfo material = quad.materialInfo();
RenderType renderType = material.itemRenderType();
this.quadInstance.setColor(getLayerColorSafe(submit.tintLayers(), material));
if (foilType != ItemStackRenderState.FoilType.NONE) {
VertexConsumer foilBuffer = getFoilBuffer(bufferSource, renderType, foilDecalPose);
foilBuffer.putBakedQuad(pose, quad, this.quadInstance);
}
if (submit.outlineColor() != 0) {
outlineBufferSource.getBuffer(renderType).putBakedQuad(pose, quad, this.quadInstance);
}
bufferSource.getBuffer(renderType).putBakedQuad(pose, quad, this.quadInstance);
}
}
private static VertexConsumer getFoilBuffer(MultiBufferSource bufferSource, RenderType renderType, PoseStack.@Nullable Pose foilDecalPose) {
VertexConsumer foilBuffer = bufferSource.getBuffer(getFoilRenderType(renderType, true));
if (foilDecalPose != null) {
foilBuffer = new SheetedDecalTextureGenerator(foilBuffer, foilDecalPose, 0.0078125F);
}
return foilBuffer;
}
private static PoseStack.Pose computeFoilDecalPose(ItemDisplayContext type, PoseStack.Pose pose) {
PoseStack.Pose foilDecalPose = pose.copy();
if (type == ItemDisplayContext.GUI) {
MatrixUtil.mulComponentWise(foilDecalPose.pose(), 0.5F);
} else if (type.firstPerson()) {
MatrixUtil.mulComponentWise(foilDecalPose.pose(), 0.75F);
}
return foilDecalPose;
}
public static VertexConsumer getFoilBuffer(MultiBufferSource bufferSource, RenderType renderType, boolean sheeted, boolean hasFoil) {
return hasFoil
? VertexMultiConsumer.create(bufferSource.getBuffer(getFoilRenderType(renderType, sheeted)), bufferSource.getBuffer(renderType))
: bufferSource.getBuffer(renderType);
}
public static RenderType getFoilRenderType(RenderType baseRenderType, boolean sheeted) {
if (useTransparentGlint(baseRenderType)) {
return RenderTypes.glintTranslucent();
} else {
return sheeted ? RenderTypes.glint() : RenderTypes.entityGlint();
}
}
private static boolean useTransparentGlint(RenderType renderType) {
return Minecraft.useShaderTransparency() && renderType.outputTarget() == OutputTarget.ITEM_ENTITY_TARGET;
}
private static int getLayerColorSafe(int[] layers, int layer) {
return layer >= 0 && layer < layers.length ? layers[layer] : -1;
}
private static int getLayerColorSafe(int[] tintLayers, BakedQuad.MaterialInfo material) {
return material.isTinted() ? getLayerColorSafe(tintLayers, material.tintIndex()) : -1;
}
}引用的其他类
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
QuadInstance()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
SheetedDecalTextureGenerator()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
VertexMultiConsumer.create()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
MatrixUtil.mulComponentWise()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Minecraft.useShaderTransparency()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RenderTypes.entityGlint(), RenderTypes.glint(), RenderTypes.glintTranslucent()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: