Class AbstractContainerScreen<T extends AbstractContainerMenu>
java.lang.Object
net.minecraft.client.gui.components.events.AbstractContainerEventHandler
net.minecraft.client.gui.screens.Screen
net.minecraft.client.gui.screens.inventory.AbstractContainerScreen<T>
- All Implemented Interfaces:
ContainerEventHandler
,GuiEventListener
,Renderable
,TabOrderedElement
,MenuAccess<T>
- Direct Known Subclasses:
AbstractRecipeBookScreen
,BeaconScreen
,BrewingStandScreen
,CartographyTableScreen
,ContainerScreen
,CrafterScreen
,CreativeModeInventoryScreen
,DispenserScreen
,EnchantmentScreen
,GrindstoneScreen
,HopperScreen
,HorseInventoryScreen
,ItemCombinerScreen
,LoomScreen
,MerchantScreen
,ShulkerBoxScreen
,StonecutterScreen
public abstract class AbstractContainerScreen<T extends AbstractContainerMenu>
extends Screen
implements MenuAccess<T>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final record
Nested classes/interfaces inherited from class net.minecraft.client.gui.screens.Screen
Screen.NarratableSearchResult
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
protected static final int
private Slot
Used when touchscreen is enabledprivate boolean
private ItemStack
Used when touchscreen is enabledprotected Slot
Holds the slot currently hoveredprotected int
The Y size of the inventory window in pixels.protected int
The X size of the inventory window in pixels.static final ResourceLocation
The location of the inventory background textureprotected int
protected int
protected boolean
private boolean
Used when touchscreen is enabled.private final List
<ItemSlotMouseAction> private int
private Slot
private long
private ItemStack
protected int
Starting X position for the Gui.protected final T
A list of the players inventory slotsprotected final Component
private int
private int
private int
private static final int
private Slot
private long
private boolean
private static final ResourceLocation
private static final ResourceLocation
protected int
private static final float
protected int
protected int
protected int
Starting Y position for the Gui.Fields inherited from class net.minecraft.client.gui.screens.Screen
FADE_IN_TIME, font, FOOTER_SEPARATOR, HEADER_SEPARATOR, height, INWORLD_FOOTER_SEPARATOR, INWORLD_HEADER_SEPARATOR, MENU_BACKGROUND, minecraft, narratorButton, renderables, screenExecutor, title, width
Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractContainerScreen
(T pMenu, Inventory pPlayerInventory, Component pTitle) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addItemSlotMouseAction
(ItemSlotMouseAction pItemSlotMouseAction) protected boolean
checkHotbarKeyPressed
(int pKeyCode, int pScanCode) private void
checkHotbarMouseClicked
(int pKeyCode) void
protected void
int
int
private Slot
getHoveredSlot
(double pMouseX, double pMouseY) getMenu()
int
getSlotColor
(int index) @Nullable Slot
getTooltipFromContainerItem
(ItemStack pStack) int
getXSize()
int
getYSize()
protected void
handleSlotStateChanged
(int pSlotId, int pContainerId, boolean pNewState) protected boolean
hasClickedOutside
(double pMouseX, double pMouseY, int pGuiLeft, int pGuiTop, int pMouseButton) protected void
init()
protected boolean
isHovering
(int pX, int pY, int pWidth, int pHeight, double pMouseX, double pMouseY) private boolean
isHovering
(Slot pSlot, double pMouseX, double pMouseY) boolean
boolean
keyPressed
(int pKeyCode, int pScanCode, int pModifiers) Called when a keyboard key is pressed within the GUI element.boolean
mouseClicked
(double pMouseX, double pMouseY, int pButton) Called when a mouse button is clicked within the GUI element.boolean
mouseDragged
(double pMouseX, double pMouseY, int pButton, double pDragX, double pDragY) Called when the mouse is dragged within the GUI element.boolean
mouseReleased
(double pMouseX, double pMouseY, int pButton) Called when a mouse button is released within the GUI element.boolean
mouseScrolled
(double pMouseX, double pMouseY, double pScrollX, double pScrollY) void
onClose()
(package private) void
onMouseClickAction
(Slot pSlot, ClickType pType) private void
onStopHovering
(Slot pSlot) private void
void
removed()
void
render
(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) Renders the graphical user interface (GUI) element.void
renderBackground
(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) protected abstract void
renderBg
(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY) void
renderCarriedItem
(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY) void
renderContents
(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) private void
renderFloatingItem
(GuiGraphics pGuiGraphics, ItemStack pStack, int pX, int pY, String pText) protected void
renderLabels
(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY) protected void
renderSlot
(GuiGraphics pGuiGraphics, Slot pSlot) protected void
renderSlotContents
(GuiGraphics guiGraphics, ItemStack itemstack, Slot slot, String countString) private void
renderSlotHighlightBack
(GuiGraphics pGuiGraphics) private void
renderSlotHighlightFront
(GuiGraphics pGuiGraphics) protected void
renderSlots
(GuiGraphics pGuiGraphics) void
renderSnapbackItem
(GuiGraphics pGuiGraphics) protected void
renderTooltip
(GuiGraphics pGuiGraphics, int pX, int pY) private boolean
showTooltipWithItemInHand
(ItemStack pStack) protected void
slotClicked
(Slot pSlot, int pSlotId, int pMouseButton, ClickType pType) Called when the mouse is clicked over a slot or outside the gui.final void
tick()
Methods inherited from class net.minecraft.client.gui.screens.Screen
added, addRenderableOnly, addRenderableWidget, addWidget, afterKeyboardAction, afterMouseAction, afterMouseMove, changeFocus, children, clearFocus, clearWidgets, clickCommandAction, clickUrlAction, defaultHandleClickEvent, defaultHandleGameClickEvent, fadeWidgets, fillCrashDetails, findNarratableWidget, getBackgroundMusic, getFont, getMinecraft, getNarrationMessage, getRectangle, getTitle, getTooltipFromItem, getUsageNarration, handleClickEvent, handleComponentClicked, handleDelayedNarration, hasAltDown, hasControlDown, hasShiftDown, init, insertText, isCopy, isCut, isMouseOver, isPaste, isSelectAll, isValidCharacterForName, onFilesDrop, rebuildWidgets, removeWidget, renderBlurredBackground, renderMenuBackground, renderMenuBackground, renderMenuBackgroundTexture, renderPanorama, renderTransparentBackground, renderWithTooltip, repositionElements, resize, setInitialFocus, setInitialFocus, shouldCloseOnEsc, shouldNarrateNavigation, showsActiveEffects, triggerImmediateNarration, updateNarratedWidget, updateNarrationState, updateNarratorStatus
Methods inherited from class net.minecraft.client.gui.components.events.AbstractContainerEventHandler
getFocused, isDragging, setDragging, setFocused
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.client.gui.components.events.ContainerEventHandler
charTyped, getChildAt, getCurrentFocusPath, isFocused, keyReleased, nextFocusPath, setFocused
Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
getBorderForArrowNavigation, mouseMoved
Methods inherited from interface net.minecraft.client.gui.components.TabOrderedElement
getTabOrderGroup
-
Field Details
-
INVENTORY_LOCATION
The location of the inventory background texture -
SLOT_HIGHLIGHT_BACK_SPRITE
-
SLOT_HIGHLIGHT_FRONT_SPRITE
-
BACKGROUND_TEXTURE_WIDTH
protected static final int BACKGROUND_TEXTURE_WIDTH- See Also:
-
BACKGROUND_TEXTURE_HEIGHT
protected static final int BACKGROUND_TEXTURE_HEIGHT- See Also:
-
SNAPBACK_SPEED
private static final float SNAPBACK_SPEED- See Also:
-
QUICKDROP_DELAY
private static final int QUICKDROP_DELAY- See Also:
-
imageWidth
protected int imageWidthThe X size of the inventory window in pixels. -
imageHeight
protected int imageHeightThe Y size of the inventory window in pixels. -
titleLabelX
protected int titleLabelX -
titleLabelY
protected int titleLabelY -
inventoryLabelX
protected int inventoryLabelX -
inventoryLabelY
protected int inventoryLabelY -
itemSlotMouseActions
-
playerInventoryTitle
-
hoveredSlot
Holds the slot currently hovered -
clickedSlot
Used when touchscreen is enabled -
quickdropSlot
-
lastClickSlot
-
snapbackData
-
leftPos
protected int leftPosStarting X position for the Gui. Inconsistent use for Gui backgrounds. -
topPos
protected int topPosStarting Y position for the Gui. Inconsistent use for Gui backgrounds. -
isSplittingStack
private boolean isSplittingStackUsed when touchscreen is enabled. -
draggingItem
Used when touchscreen is enabled -
quickdropTime
private long quickdropTime -
quickCraftSlots
-
isQuickCrafting
protected boolean isQuickCrafting -
quickCraftingType
private int quickCraftingType -
quickCraftingButton
private int quickCraftingButton -
skipNextRelease
private boolean skipNextRelease -
quickCraftingRemainder
private int quickCraftingRemainder -
lastClickTime
private long lastClickTime -
lastClickButton
private int lastClickButton -
doubleclick
private boolean doubleclick -
lastQuickMoved
-
slotColor
protected int slotColor
-
-
Constructor Details
-
AbstractContainerScreen
-
-
Method Details
-
init
protected void init() -
addItemSlotMouseAction
-
render
Renders the graphical user interface (GUI) element.- Specified by:
render
in interfaceRenderable
- Overrides:
render
in classScreen
- Parameters:
pGuiGraphics
- the GuiGraphics object used for rendering.pMouseX
- the x-coordinate of the mouse cursor.pMouseY
- the y-coordinate of the mouse cursor.pPartialTick
- the partial tick time.
-
renderContents
-
renderCarriedItem
-
renderSnapbackItem
-
renderSlots
-
renderBackground
public void renderBackground(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) - Overrides:
renderBackground
in classScreen
-
mouseScrolled
public boolean mouseScrolled(double pMouseX, double pMouseY, double pScrollX, double pScrollY) - Specified by:
mouseScrolled
in interfaceContainerEventHandler
- Specified by:
mouseScrolled
in interfaceGuiEventListener
-
renderSlotHighlightBack
-
renderSlotHighlightFront
-
renderTooltip
-
showTooltipWithItemInHand
-
getTooltipFromContainerItem
-
renderFloatingItem
private void renderFloatingItem(GuiGraphics pGuiGraphics, ItemStack pStack, int pX, int pY, @Nullable String pText) -
renderLabels
-
renderBg
protected abstract void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY) -
renderSlot
-
renderSlotContents
protected void renderSlotContents(GuiGraphics guiGraphics, ItemStack itemstack, Slot slot, @Nullable String countString) -
recalculateQuickCraftRemaining
private void recalculateQuickCraftRemaining() -
getHoveredSlot
-
mouseClicked
public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) Called when a mouse button is clicked within the GUI element.- Specified by:
mouseClicked
in interfaceContainerEventHandler
- Specified by:
mouseClicked
in interfaceGuiEventListener
- Parameters:
pMouseX
- the X coordinate of the mouse.pMouseY
- the Y coordinate of the mouse.pButton
- the button that was clicked.- Returns:
true
if the event is consumed,false
otherwise.
-
checkHotbarMouseClicked
private void checkHotbarMouseClicked(int pKeyCode) -
hasClickedOutside
protected boolean hasClickedOutside(double pMouseX, double pMouseY, int pGuiLeft, int pGuiTop, int pMouseButton) -
mouseDragged
public boolean mouseDragged(double pMouseX, double pMouseY, int pButton, double pDragX, double pDragY) Called when the mouse is dragged within the GUI element.- Specified by:
mouseDragged
in interfaceContainerEventHandler
- Specified by:
mouseDragged
in interfaceGuiEventListener
- Parameters:
pMouseX
- the X coordinate of the mouse.pMouseY
- the Y coordinate of the mouse.pButton
- the button that is being dragged.pDragX
- the X distance of the drag.pDragY
- the Y distance of the drag.- Returns:
true
if the event is consumed,false
otherwise.
-
mouseReleased
public boolean mouseReleased(double pMouseX, double pMouseY, int pButton) Called when a mouse button is released within the GUI element.- Specified by:
mouseReleased
in interfaceContainerEventHandler
- Specified by:
mouseReleased
in interfaceGuiEventListener
- Parameters:
pMouseX
- the X coordinate of the mouse.pMouseY
- the Y coordinate of the mouse.pButton
- the button that was released.- Returns:
true
if the event is consumed,false
otherwise.
-
clearDraggingState
public void clearDraggingState() -
isHovering
-
isHovering
protected boolean isHovering(int pX, int pY, int pWidth, int pHeight, double pMouseX, double pMouseY) -
onStopHovering
-
slotClicked
Called when the mouse is clicked over a slot or outside the gui. -
onMouseClickAction
-
handleSlotStateChanged
protected void handleSlotStateChanged(int pSlotId, int pContainerId, boolean pNewState) -
keyPressed
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) Called when a keyboard key is pressed within the GUI element.- Specified by:
keyPressed
in interfaceContainerEventHandler
- Specified by:
keyPressed
in interfaceGuiEventListener
- Overrides:
keyPressed
in classScreen
- Parameters:
pKeyCode
- the key code of the pressed key.pScanCode
- the scan code of the pressed key.pModifiers
- the keyboard modifiers.- Returns:
true
if the event is consumed,false
otherwise.
-
checkHotbarKeyPressed
protected boolean checkHotbarKeyPressed(int pKeyCode, int pScanCode) -
removed
public void removed() -
isPauseScreen
public boolean isPauseScreen()- Overrides:
isPauseScreen
in classScreen
-
tick
public final void tick() -
containerTick
protected void containerTick() -
getMenu
- Specified by:
getMenu
in interfaceMenuAccess<T extends AbstractContainerMenu>
-
getSlotUnderMouse
-
getGuiLeft
public int getGuiLeft() -
getGuiTop
public int getGuiTop() -
getXSize
public int getXSize() -
getYSize
public int getYSize() -
getSlotColor
public int getSlotColor(int index) -
onClose
public void onClose()
-