ItemDisplayWidget.java
net.minecraft.client.gui.components.ItemDisplayWidget
信息
- 全限定名:net.minecraft.client.gui.components.ItemDisplayWidget
- 类型:public class
- 包:net.minecraft.client.gui.components
- 源码路径:src/main/java/net/minecraft/client/gui/components/ItemDisplayWidget.java
- 起始行号:L13
- 继承:AbstractWidget
- 职责:
TODO
字段/常量
-
minecraft- 类型:
Minecraft - 修饰符:
private final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
offsetX- 类型:
int - 修饰符:
private final - 源码定位:
L15 - 说明:
TODO
- 类型:
-
offsetY- 类型:
int - 修饰符:
private final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
itemStack- 类型:
ItemStack - 修饰符:
private final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
decorations- 类型:
boolean - 修饰符:
private final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
tooltip- 类型:
boolean - 修饰符:
private final - 源码定位:
L19 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public ItemDisplayWidget(Minecraft minecraft, int offsetX, int offsetY, int width, int height, Component message, ItemStack itemStack, boolean decorations, boolean tooltip) @ L21
- 构造器名:ItemDisplayWidget
- 源码定位:L21
- 修饰符:public
参数:
- minecraft: Minecraft
- offsetX: int
- offsetY: int
- width: int
- height: int
- message: Component
- itemStack: ItemStack
- decorations: boolean
- tooltip: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected void extractWidgetRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L33
- 方法名:extractWidgetRenderState
- 源码定位:L33
- 返回类型:void
- 修饰符:protected
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
protected void extractTooltip(GuiGraphicsExtractor graphics, int x, int y) @ L49
- 方法名:extractTooltip
- 源码定位:L49
- 返回类型:void
- 修饰符:protected
参数:
- graphics: GuiGraphicsExtractor
- x: int
- y: int
说明:
TODO
protected void updateWidgetNarration(NarrationElementOutput output) @ L53
- 方法名:updateWidgetNarration
- 源码定位:L53
- 返回类型:void
- 修饰符:protected
参数:
- output: NarrationElementOutput
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class ItemDisplayWidget extends AbstractWidget {
private final Minecraft minecraft;
private final int offsetX;
private final int offsetY;
private final ItemStack itemStack;
private final boolean decorations;
private final boolean tooltip;
public ItemDisplayWidget(
Minecraft minecraft, int offsetX, int offsetY, int width, int height, Component message, ItemStack itemStack, boolean decorations, boolean tooltip
) {
super(0, 0, width, height, message);
this.minecraft = minecraft;
this.offsetX = offsetX;
this.offsetY = offsetY;
this.itemStack = itemStack;
this.decorations = decorations;
this.tooltip = tooltip;
}
@Override
protected void extractWidgetRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
graphics.item(this.itemStack, this.getX() + this.offsetX, this.getY() + this.offsetY, 0);
if (this.decorations) {
graphics.itemDecorations(this.minecraft.font, this.itemStack, this.getX() + this.offsetX, this.getY() + this.offsetY, null);
}
if (this.isFocused()) {
graphics.outline(this.getX(), this.getY(), this.getWidth(), this.getHeight(), -1);
}
if (this.tooltip && this.isHovered()) {
this.extractTooltip(graphics, mouseX, mouseY);
}
}
protected void extractTooltip(GuiGraphicsExtractor graphics, int x, int y) {
graphics.setTooltipForNextFrame(this.minecraft.font, this.itemStack, x, y);
}
@Override
protected void updateWidgetNarration(NarrationElementOutput output) {
output.add(NarratedElementType.TITLE, Component.translatable("narration.item", this.itemStack.getHoverName()));
}
}引用的其他类
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置: