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:
AbstractFurnaceScreen
,BeaconScreen
,BrewingStandScreen
,CartographyTableScreen
,ContainerScreen
,ContainerTypeTest.TestGui
,CrafterScreen
,CraftingScreen
,DispenserScreen
,EffectRenderingInventoryScreen
,EnchantmentScreen
,GrindstoneScreen
,HopperScreen
,HorseInventoryScreen
,ItemCombinerScreen
,LoomScreen
,MerchantScreen
,RecipeBookTestScreen
,ShulkerBoxScreen
,StonecutterScreen
public abstract class AbstractContainerScreen<T extends AbstractContainerMenu>
extends Screen
implements MenuAccess<T>
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.client.gui.screens.Screen
Screen.NarratableSearchResult
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Slot
Used when touchscreen is enabledprivate boolean
private ItemStack
Used when touchscreen is enabledprivate static final int
protected 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 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
static final int
protected int
private static final float
private Slot
private ItemStack
Used when touchscreen is enabledprivate int
private int
private long
protected int
protected int
protected int
Starting Y position for the Gui.Fields inherited from class net.minecraft.client.gui.screens.Screen
CUBE_MAP, font, FOOTER_SEPARATOR, HEADER_SEPARATOR, height, INWORLD_FOOTER_SEPARATOR, INWORLD_HEADER_SEPARATOR, MENU_BACKGROUND, minecraft, narratorButton, PANORAMA, 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 boolean
checkHotbarKeyPressed
(int pKeyCode, int pScanCode) private void
checkHotbarMouseClicked
(int pKeyCode) void
protected void
private Slot
findSlot
(double pMouseX, double pMouseY) int
int
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.void
onClose()
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) 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) static void
renderSlotHighlight
(GuiGraphics pGuiGraphics, int pX, int pY, int pBlitOffset) static void
renderSlotHighlight
(GuiGraphics pGuiGraphics, int pX, int pY, int pBlitOffset, int color) protected void
renderSlotHighlight
(GuiGraphics guiGraphics, Slot slot, int mouseX, int mouseY, float partialTick) Renders a highlight for the given slot to indicate the mouse is currently hovering over it.protected void
renderTooltip
(GuiGraphics pGuiGraphics, int pX, int pY) 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, clearTooltipForNextRenderPass, clearWidgets, findNarratableWidget, getBackgroundMusic, getMinecraft, getNarrationMessage, getRectangle, getTitle, getTooltipFromItem, getUsageNarration, 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, setTooltipForNextRenderPass, setTooltipForNextRenderPass, setTooltipForNextRenderPass, setTooltipForNextRenderPass, shouldCloseOnEsc, shouldNarrateNavigation, triggerImmediateNarration, updateNarratedWidget, updateNarrationState, updateNarratorStatus, wrapScreenError
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, mouseScrolled, nextFocusPath, setFocused
Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
mouseMoved
Methods inherited from interface net.minecraft.client.gui.components.TabOrderedElement
getTabOrderGroup
-
Field Details
-
INVENTORY_LOCATION
The location of the inventory background texture -
SNAPBACK_SPEED
private static final float SNAPBACK_SPEED- See Also:
-
QUICKDROP_DELAY
private static final int QUICKDROP_DELAY- See Also:
-
SLOT_ITEM_BLIT_OFFSET
public static final int SLOT_ITEM_BLIT_OFFSET- See Also:
-
HOVER_ITEM_BLIT_OFFSET
private static final int HOVER_ITEM_BLIT_OFFSET- 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 -
playerInventoryTitle
-
hoveredSlot
Holds the slot currently hovered -
clickedSlot
Used when touchscreen is enabled -
snapbackEnd
-
quickdropSlot
-
lastClickSlot
-
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 -
snapbackStartX
private int snapbackStartX -
snapbackStartY
private int snapbackStartY -
snapbackTime
private long snapbackTime -
snapbackItem
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() -
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.
-
renderBackground
public void renderBackground(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) - Overrides:
renderBackground
in classScreen
-
renderSlotHighlight
-
renderSlotHighlight
public static void renderSlotHighlight(GuiGraphics pGuiGraphics, int pX, int pY, int pBlitOffset, int color) -
renderSlotHighlight
protected void renderSlotHighlight(GuiGraphics guiGraphics, Slot slot, int mouseX, int mouseY, float partialTick) Renders a highlight for the given slot to indicate the mouse is currently hovering over it. -
renderTooltip
-
getTooltipFromContainerItem
-
renderFloatingItem
private void renderFloatingItem(GuiGraphics pGuiGraphics, ItemStack pStack, int pX, int pY, 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() -
findSlot
-
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) -
slotClicked
Called when the mouse is clicked over a slot or outside the gui. -
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()
-