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,CrafterScreen,CraftingScreen,DispenserScreen,EffectRenderingInventoryScreen,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 classes/interfaces inherited from class net.minecraft.client.gui.screens.Screen
Screen.NarratableSearchResult -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SlotUsed when touchscreen is enabledprivate booleanprivate ItemStackUsed when touchscreen is enabledprivate static final intprotected SlotHolds the slot currently hoveredprotected intThe Y size of the inventory window in pixels.protected intThe X size of the inventory window in pixels.static final ResourceLocationThe location of the inventory background textureprotected intprotected intprotected booleanprivate booleanUsed when touchscreen is enabled.private intprivate Slotprivate longprivate ItemStackprotected intStarting X position for the Gui.protected final TA list of the players inventory slotsprotected final Componentprivate intprivate intprivate intprivate static final intprivate Slotprivate longprivate booleanstatic final intprotected intprivate static final floatprivate Slotprivate ItemStackUsed when touchscreen is enabledprivate intprivate intprivate longprotected intprotected intprotected intStarting 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, widthFields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckHotbarKeyPressed(int keyCode, int scanCode) private voidcheckHotbarMouseClicked(int keyCode) voidprotected voidprivate SlotfindSlot(double mouseX, double mouseY) intintgetMenu()intgetSlotColor(int index) @Nullable SlotintgetXSize()intgetYSize()protected voidhandleSlotStateChanged(int slotId, int containerId, boolean newState) protected booleanhasClickedOutside(double mouseX, double mouseY, int guiLeft, int guiTop, int mouseButton) protected voidinit()protected booleanisHovering(int x, int y, int width, int height, double mouseX, double mouseY) private booleanisHovering(Slot slot, double mouseX, double mouseY) booleanbooleankeyPressed(int keyCode, int scanCode, int modifiers) Called when a keyboard key is pressed within the GUI element.booleanmouseClicked(double mouseX, double mouseY, int button) Called when a mouse button is clicked within the GUI element.booleanmouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) Called when the mouse is dragged within the GUI element.booleanmouseReleased(double mouseX, double mouseY, int button) Called when a mouse button is released within the GUI element.voidonClose()private voidvoidremoved()voidrender(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) Renders the graphical user interface (GUI) element.voidrenderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) protected abstract voidrenderBg(GuiGraphics guiGraphics, float partialTick, int mouseX, int mouseY) private voidrenderFloatingItem(GuiGraphics guiGraphics, ItemStack stack, int x, int y, String text) protected voidrenderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) protected voidrenderSlot(GuiGraphics guiGraphics, Slot slot) protected voidrenderSlotContents(GuiGraphics guiGraphics, ItemStack itemstack, Slot slot, String countString) static voidrenderSlotHighlight(GuiGraphics guiGraphics, int x, int y, int blitOffset) static voidrenderSlotHighlight(GuiGraphics guiGraphics, int x, int y, int blitOffset, int color) protected voidrenderSlotHighlight(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 voidrenderTooltip(GuiGraphics guiGraphics, int x, int y) protected voidslotClicked(Slot slot, int slotId, int mouseButton, ClickType type) Called when the mouse is clicked over a slot or outside the gui.final voidtick()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, wrapScreenErrorMethods inherited from class net.minecraft.client.gui.components.events.AbstractContainerEventHandler
getFocused, isDragging, setDragging, setFocusedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.components.events.ContainerEventHandler
charTyped, getChildAt, getCurrentFocusPath, isFocused, keyReleased, mouseScrolled, nextFocusPath, setFocusedMethods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
mouseMovedMethods 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:
renderin interfaceRenderable- Overrides:
renderin classScreen- Parameters:
guiGraphics- the GuiGraphics object used for rendering.mouseX- the x-coordinate of the mouse cursor.mouseY- the y-coordinate of the mouse cursor.partialTick- the partial tick time.
-
renderBackground
- Overrides:
renderBackgroundin classScreen
-
renderSlotHighlight
-
renderSlotHighlight
public static void renderSlotHighlight(GuiGraphics guiGraphics, int x, int y, int blitOffset, 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 guiGraphics, ItemStack stack, int x, int y, String text) -
renderLabels
-
renderBg
protected abstract void renderBg(GuiGraphics guiGraphics, float partialTick, int mouseX, int mouseY) -
renderSlot
-
renderSlotContents
protected void renderSlotContents(GuiGraphics guiGraphics, ItemStack itemstack, Slot slot, @Nullable String countString) -
recalculateQuickCraftRemaining
private void recalculateQuickCraftRemaining() -
findSlot
-
mouseClicked
public boolean mouseClicked(double mouseX, double mouseY, int button) Called when a mouse button is clicked within the GUI element.- Specified by:
mouseClickedin interfaceContainerEventHandler- Specified by:
mouseClickedin interfaceGuiEventListener- Parameters:
mouseX- the X coordinate of the mouse.mouseY- the Y coordinate of the mouse.button- the button that was clicked.- Returns:
trueif the event is consumed,falseotherwise.
-
checkHotbarMouseClicked
private void checkHotbarMouseClicked(int keyCode) -
hasClickedOutside
protected boolean hasClickedOutside(double mouseX, double mouseY, int guiLeft, int guiTop, int mouseButton) -
mouseDragged
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) Called when the mouse is dragged within the GUI element.- Specified by:
mouseDraggedin interfaceContainerEventHandler- Specified by:
mouseDraggedin interfaceGuiEventListener- Parameters:
mouseX- the X coordinate of the mouse.mouseY- the Y coordinate of the mouse.button- the button that is being dragged.dragX- the X distance of the drag.dragY- the Y distance of the drag.- Returns:
trueif the event is consumed,falseotherwise.
-
mouseReleased
public boolean mouseReleased(double mouseX, double mouseY, int button) Called when a mouse button is released within the GUI element.- Specified by:
mouseReleasedin interfaceContainerEventHandler- Specified by:
mouseReleasedin interfaceGuiEventListener- Parameters:
mouseX- the X coordinate of the mouse.mouseY- the Y coordinate of the mouse.button- the button that was released.- Returns:
trueif the event is consumed,falseotherwise.
-
clearDraggingState
public void clearDraggingState() -
isHovering
-
isHovering
protected boolean isHovering(int x, int y, int width, int height, double mouseX, double mouseY) -
slotClicked
Called when the mouse is clicked over a slot or outside the gui. -
handleSlotStateChanged
protected void handleSlotStateChanged(int slotId, int containerId, boolean newState) -
keyPressed
public boolean keyPressed(int keyCode, int scanCode, int modifiers) Called when a keyboard key is pressed within the GUI element.- Specified by:
keyPressedin interfaceContainerEventHandler- Specified by:
keyPressedin interfaceGuiEventListener- Overrides:
keyPressedin classScreen- Parameters:
keyCode- the key code of the pressed key.scanCode- the scan code of the pressed key.modifiers- the keyboard modifiers.- Returns:
trueif the event is consumed,falseotherwise.
-
checkHotbarKeyPressed
protected boolean checkHotbarKeyPressed(int keyCode, int scanCode) -
removed
public void removed() -
isPauseScreen
public boolean isPauseScreen()- Overrides:
isPauseScreenin classScreen
-
tick
public final void tick() -
containerTick
protected void containerTick() -
getMenu
- Specified by:
getMenuin 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()
-