SmithingScreen.java
net.minecraft.client.gui.screens.inventory.SmithingScreen
信息
- 全限定名:net.minecraft.client.gui.screens.inventory.SmithingScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens.inventory
- 源码路径:src/main/java/net/minecraft/client/gui/screens/inventory/SmithingScreen.java
- 起始行号:L28
- 继承:ItemCombinerScreen
- 职责:
TODO
字段/常量
-
ERROR_SPRITE- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L29 - 说明:
TODO
- 类型:
-
EMPTY_SLOT_SMITHING_TEMPLATE_ARMOR_TRIM- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L30 - 说明:
TODO
- 类型:
-
EMPTY_SLOT_SMITHING_TEMPLATE_NETHERITE_UPGRADE- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L31 - 说明:
TODO
- 类型:
-
MISSING_TEMPLATE_TOOLTIP- 类型:
Component - 修饰符:
private static final - 源码定位:
L34 - 说明:
TODO
- 类型:
-
ERROR_TOOLTIP- 类型:
Component - 修饰符:
private static final - 源码定位:
L35 - 说明:
TODO
- 类型:
-
EMPTY_SLOT_SMITHING_TEMPLATES- 类型:
List<Identifier> - 修饰符:
private static final - 源码定位:
L36 - 说明:
TODO
- 类型:
-
TITLE_LABEL_X- 类型:
int - 修饰符:
private static final - 源码定位:
L39 - 说明:
TODO
- 类型:
-
TITLE_LABEL_Y- 类型:
int - 修饰符:
private static final - 源码定位:
L40 - 说明:
TODO
- 类型:
-
ERROR_ICON_WIDTH- 类型:
int - 修饰符:
private static final - 源码定位:
L41 - 说明:
TODO
- 类型:
-
ERROR_ICON_HEIGHT- 类型:
int - 修饰符:
private static final - 源码定位:
L42 - 说明:
TODO
- 类型:
-
ERROR_ICON_X- 类型:
int - 修饰符:
private static final - 源码定位:
L43 - 说明:
TODO
- 类型:
-
ERROR_ICON_Y- 类型:
int - 修饰符:
private static final - 源码定位:
L44 - 说明:
TODO
- 类型:
-
TOOLTIP_WIDTH- 类型:
int - 修饰符:
private static final - 源码定位:
L45 - 说明:
TODO
- 类型:
-
ARMOR_STAND_Y_ROT- 类型:
int - 修饰符:
private static final - 源码定位:
L46 - 说明:
TODO
- 类型:
-
ARMOR_STAND_X_ROT- 类型:
int - 修饰符:
private static final - 源码定位:
L47 - 说明:
TODO
- 类型:
-
ARMOR_STAND_TRANSLATION- 类型:
Vector3f - 修饰符:
private static final - 源码定位:
L48 - 说明:
TODO
- 类型:
-
ARMOR_STAND_ANGLE- 类型:
Quaternionf - 修饰符:
private static final - 源码定位:
L49 - 说明:
TODO
- 类型:
-
ARMOR_STAND_SCALE- 类型:
int - 修饰符:
private static final - 源码定位:
L50 - 说明:
TODO
- 类型:
-
ARMOR_STAND_LEFT- 类型:
int - 修饰符:
private static final - 源码定位:
L51 - 说明:
TODO
- 类型:
-
ARMOR_STAND_TOP- 类型:
int - 修饰符:
private static final - 源码定位:
L52 - 说明:
TODO
- 类型:
-
ARMOR_STAND_RIGHT- 类型:
int - 修饰符:
private static final - 源码定位:
L53 - 说明:
TODO
- 类型:
-
ARMOR_STAND_BOTTOM- 类型:
int - 修饰符:
private static final - 源码定位:
L54 - 说明:
TODO
- 类型:
-
templateIcon- 类型:
CyclingSlotBackground - 修饰符:
private final - 源码定位:
L55 - 说明:
TODO
- 类型:
-
baseIcon- 类型:
CyclingSlotBackground - 修饰符:
private final - 源码定位:
L56 - 说明:
TODO
- 类型:
-
additionalIcon- 类型:
CyclingSlotBackground - 修饰符:
private final - 源码定位:
L57 - 说明:
TODO
- 类型:
-
armorStandPreview- 类型:
ArmorStandRenderState - 修饰符:
private final - 源码定位:
L58 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public SmithingScreen(SmithingMenu menu, Inventory inventory, Component title) @ L60
- 构造器名:SmithingScreen
- 源码定位:L60
- 修饰符:public
参数:
- menu: SmithingMenu
- inventory: Inventory
- title: Component
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected void subInit() @ L71
- 方法名:subInit
- 源码定位:L71
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
public void containerTick() @ L76
- 方法名:containerTick
- 源码定位:L76
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
private Optional<SmithingTemplateItem> getTemplateItem() @ L85
- 方法名:getTemplateItem
- 源码定位:L85
- 返回类型:Optional
- 修饰符:private
参数:
- 无
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L92
- 方法名:extractRenderState
- 源码定位:L92
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L98
- 方法名:extractBackground
- 源码定位:L98
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
public void slotChanged(AbstractContainerMenu container, int slotIndex, ItemStack itemStack) @ L111
- 方法名:slotChanged
- 源码定位:L111
- 返回类型:void
- 修饰符:public
参数:
- container: AbstractContainerMenu
- slotIndex: int
- itemStack: ItemStack
说明:
TODO
private void updateArmorStandPreview(ItemStack itemStack) @ L118
- 方法名:updateArmorStandPreview
- 源码定位:L118
- 返回类型:void
- 修饰符:private
参数:
- itemStack: ItemStack
说明:
TODO
protected void extractErrorIcon(GuiGraphicsExtractor graphics, int xo, int yo) @ L157
- 方法名:extractErrorIcon
- 源码定位:L157
- 返回类型:void
- 修饰符:protected
参数:
- graphics: GuiGraphicsExtractor
- xo: int
- yo: int
说明:
TODO
private void extractOnboardingTooltips(GuiGraphicsExtractor graphics, int mouseX, int mouseY) @ L164
- 方法名:extractOnboardingTooltips
- 源码定位:L164
- 返回类型:void
- 修饰符:private
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
说明:
TODO
private boolean hasRecipeError() @ L189
- 方法名:hasRecipeError
- 源码定位:L189
- 返回类型:boolean
- 修饰符:private
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class SmithingScreen extends ItemCombinerScreen<SmithingMenu> {
private static final Identifier ERROR_SPRITE = Identifier.withDefaultNamespace("container/smithing/error");
private static final Identifier EMPTY_SLOT_SMITHING_TEMPLATE_ARMOR_TRIM = Identifier.withDefaultNamespace("container/slot/smithing_template_armor_trim");
private static final Identifier EMPTY_SLOT_SMITHING_TEMPLATE_NETHERITE_UPGRADE = Identifier.withDefaultNamespace(
"container/slot/smithing_template_netherite_upgrade"
);
private static final Component MISSING_TEMPLATE_TOOLTIP = Component.translatable("container.upgrade.missing_template_tooltip");
private static final Component ERROR_TOOLTIP = Component.translatable("container.upgrade.error_tooltip");
private static final List<Identifier> EMPTY_SLOT_SMITHING_TEMPLATES = List.of(
EMPTY_SLOT_SMITHING_TEMPLATE_ARMOR_TRIM, EMPTY_SLOT_SMITHING_TEMPLATE_NETHERITE_UPGRADE
);
private static final int TITLE_LABEL_X = 44;
private static final int TITLE_LABEL_Y = 15;
private static final int ERROR_ICON_WIDTH = 28;
private static final int ERROR_ICON_HEIGHT = 21;
private static final int ERROR_ICON_X = 65;
private static final int ERROR_ICON_Y = 46;
private static final int TOOLTIP_WIDTH = 115;
private static final int ARMOR_STAND_Y_ROT = 210;
private static final int ARMOR_STAND_X_ROT = 25;
private static final Vector3f ARMOR_STAND_TRANSLATION = new Vector3f(0.0F, 1.0F, 0.0F);
private static final Quaternionf ARMOR_STAND_ANGLE = new Quaternionf().rotationXYZ(0.43633232F, 0.0F, (float) Math.PI);
private static final int ARMOR_STAND_SCALE = 25;
private static final int ARMOR_STAND_LEFT = 121;
private static final int ARMOR_STAND_TOP = 20;
private static final int ARMOR_STAND_RIGHT = 161;
private static final int ARMOR_STAND_BOTTOM = 80;
private final CyclingSlotBackground templateIcon = new CyclingSlotBackground(0);
private final CyclingSlotBackground baseIcon = new CyclingSlotBackground(1);
private final CyclingSlotBackground additionalIcon = new CyclingSlotBackground(2);
private final ArmorStandRenderState armorStandPreview = new ArmorStandRenderState();
public SmithingScreen(SmithingMenu menu, Inventory inventory, Component title) {
super(menu, inventory, title, Identifier.withDefaultNamespace("textures/gui/container/smithing.png"));
this.titleLabelX = 44;
this.titleLabelY = 15;
this.armorStandPreview.entityType = EntityType.ARMOR_STAND;
this.armorStandPreview.showBasePlate = false;
this.armorStandPreview.showArms = true;
this.armorStandPreview.xRot = 25.0F;
this.armorStandPreview.bodyRot = 210.0F;
}
@Override
protected void subInit() {
this.updateArmorStandPreview(this.menu.getSlot(3).getItem());
}
@Override
public void containerTick() {
super.containerTick();
Optional<SmithingTemplateItem> template = this.getTemplateItem();
this.templateIcon.tick(EMPTY_SLOT_SMITHING_TEMPLATES);
this.baseIcon.tick(template.map(SmithingTemplateItem::getBaseSlotEmptyIcons).orElse(List.of()));
this.additionalIcon.tick(template.map(SmithingTemplateItem::getAdditionalSlotEmptyIcons).orElse(List.of()));
}
private Optional<SmithingTemplateItem> getTemplateItem() {
ItemStack templateSlotItem = this.menu.getSlot(0).getItem();
return !templateSlotItem.isEmpty() && templateSlotItem.getItem() instanceof SmithingTemplateItem templateItem
? Optional.of(templateItem)
: Optional.empty();
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
super.extractRenderState(graphics, mouseX, mouseY, a);
this.extractOnboardingTooltips(graphics, mouseX, mouseY);
}
@Override
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
super.extractBackground(graphics, mouseX, mouseY, a);
this.templateIcon.extractRenderState(this.menu, graphics, a, this.leftPos, this.topPos);
this.baseIcon.extractRenderState(this.menu, graphics, a, this.leftPos, this.topPos);
this.additionalIcon.extractRenderState(this.menu, graphics, a, this.leftPos, this.topPos);
int x0 = this.leftPos + 121;
int y0 = this.topPos + 20;
int x1 = this.leftPos + 161;
int y1 = this.topPos + 80;
graphics.entity(this.armorStandPreview, 25.0F, ARMOR_STAND_TRANSLATION, ARMOR_STAND_ANGLE, null, x0, y0, x1, y1);
}
@Override
public void slotChanged(AbstractContainerMenu container, int slotIndex, ItemStack itemStack) {
if (slotIndex == 3) {
this.updateArmorStandPreview(itemStack);
}
}
private void updateArmorStandPreview(ItemStack itemStack) {
this.armorStandPreview.leftHandItemStack = ItemStack.EMPTY;
this.armorStandPreview.leftHandItemState.clear();
this.armorStandPreview.headEquipment = ItemStack.EMPTY;
this.armorStandPreview.headItem.clear();
this.armorStandPreview.chestEquipment = ItemStack.EMPTY;
this.armorStandPreview.legsEquipment = ItemStack.EMPTY;
this.armorStandPreview.feetEquipment = ItemStack.EMPTY;
if (!itemStack.isEmpty()) {
Equippable equippable = itemStack.get(DataComponents.EQUIPPABLE);
EquipmentSlot slot = equippable != null ? equippable.slot() : null;
ItemModelResolver itemModelResolver = this.minecraft.getItemModelResolver();
switch (slot) {
case HEAD:
if (HumanoidArmorLayer.shouldRender(itemStack, EquipmentSlot.HEAD)) {
this.armorStandPreview.headEquipment = itemStack.copy();
} else {
itemModelResolver.updateForTopItem(this.armorStandPreview.headItem, itemStack, ItemDisplayContext.HEAD, null, null, 0);
}
break;
case CHEST:
this.armorStandPreview.chestEquipment = itemStack.copy();
break;
case LEGS:
this.armorStandPreview.legsEquipment = itemStack.copy();
break;
case FEET:
this.armorStandPreview.feetEquipment = itemStack.copy();
break;
case null:
default:
this.armorStandPreview.leftHandItemStack = itemStack.copy();
itemModelResolver.updateForTopItem(
this.armorStandPreview.leftHandItemState, itemStack, ItemDisplayContext.THIRD_PERSON_LEFT_HAND, null, null, 0
);
}
}
}
@Override
protected void extractErrorIcon(GuiGraphicsExtractor graphics, int xo, int yo) {
if (this.hasRecipeError()) {
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, ERROR_SPRITE, xo + 65, yo + 46, 28, 21);
}
}
private void extractOnboardingTooltips(GuiGraphicsExtractor graphics, int mouseX, int mouseY) {
Optional<Component> tooltip = Optional.empty();
if (this.hasRecipeError() && this.isHovering(65, 46, 28, 21, mouseX, mouseY)) {
tooltip = Optional.of(ERROR_TOOLTIP);
}
if (this.hoveredSlot != null) {
ItemStack template = this.menu.getSlot(0).getItem();
ItemStack hoveredStack = this.hoveredSlot.getItem();
if (template.isEmpty()) {
if (this.hoveredSlot.index == 0) {
tooltip = Optional.of(MISSING_TEMPLATE_TOOLTIP);
}
} else if (template.getItem() instanceof SmithingTemplateItem templateItem && hoveredStack.isEmpty()) {
if (this.hoveredSlot.index == 1) {
tooltip = Optional.of(templateItem.getBaseSlotDescription());
} else if (this.hoveredSlot.index == 2) {
tooltip = Optional.of(templateItem.getAdditionSlotDescription());
}
}
}
tooltip.ifPresent(component -> graphics.setTooltipForNextFrame(this.font, this.font.split(component, 115), mouseX, mouseY));
}
private boolean hasRecipeError() {
return this.menu.hasRecipeError();
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
CyclingSlotBackground()
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
HumanoidArmorLayer.shouldRender()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
ArmorStandRenderState()
- 引用位置:
-
- 引用位置:
参数/字段/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
返回值
- 引用位置: