Class AbstractContainerScreen<T extends AbstractContainerMenu>

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>
  • Field Details

    • INVENTORY_LOCATION

      public static final ResourceLocation 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 imageWidth
      The X size of the inventory window in pixels.
    • imageHeight

      protected int imageHeight
      The 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

      protected final Component playerInventoryTitle
    • hoveredSlot

      @Nullable protected Slot hoveredSlot
      Holds the slot currently hovered
    • clickedSlot

      @Nullable private Slot clickedSlot
      Used when touchscreen is enabled
    • snapbackEnd

      @Nullable private Slot snapbackEnd
    • quickdropSlot

      @Nullable private Slot quickdropSlot
    • lastClickSlot

      @Nullable private Slot lastClickSlot
    • leftPos

      protected int leftPos
      Starting X position for the Gui. Inconsistent use for Gui backgrounds.
    • topPos

      protected int topPos
      Starting Y position for the Gui. Inconsistent use for Gui backgrounds.
    • isSplittingStack

      private boolean isSplittingStack
      Used when touchscreen is enabled.
    • draggingItem

      private ItemStack draggingItem
      Used when touchscreen is enabled
    • snapbackStartX

      private int snapbackStartX
    • snapbackStartY

      private int snapbackStartY
    • snapbackTime

      private long snapbackTime
    • snapbackItem

      private ItemStack snapbackItem
      Used when touchscreen is enabled
    • quickdropTime

      private long quickdropTime
    • quickCraftSlots

      protected final Set<Slot> 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

      private ItemStack lastQuickMoved
    • slotColor

      protected int slotColor
  • Constructor Details

    • AbstractContainerScreen

      public AbstractContainerScreen(T pMenu, Inventory pPlayerInventory, Component pTitle)
  • Method Details

    • init

      protected void init()
      Overrides:
      init in class Screen
    • render

      public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick)
      Renders the graphical user interface (GUI) element.
      Specified by:
      render in interface Renderable
      Overrides:
      render in class Screen
      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 class Screen
    • renderSlotHighlight

      public static void renderSlotHighlight(GuiGraphics pGuiGraphics, int pX, int pY, int pBlitOffset)
    • 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

      protected void renderTooltip(GuiGraphics pGuiGraphics, int pX, int pY)
    • getTooltipFromContainerItem

      protected List<Component> getTooltipFromContainerItem(ItemStack pStack)
    • renderFloatingItem

      private void renderFloatingItem(GuiGraphics pGuiGraphics, ItemStack pStack, int pX, int pY, String pText)
    • renderLabels

      protected void renderLabels(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY)
    • renderBg

      protected abstract void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY)
    • renderSlot

      protected void renderSlot(GuiGraphics pGuiGraphics, Slot pSlot)
    • renderSlotContents

      protected void renderSlotContents(GuiGraphics guiGraphics, ItemStack itemstack, Slot slot, @Nullable String countString)
    • recalculateQuickCraftRemaining

      private void recalculateQuickCraftRemaining()
    • findSlot

      @Nullable private Slot findSlot(double pMouseX, double pMouseY)
    • 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 interface ContainerEventHandler
      Specified by:
      mouseClicked in interface GuiEventListener
      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 interface ContainerEventHandler
      Specified by:
      mouseDragged in interface GuiEventListener
      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 interface ContainerEventHandler
      Specified by:
      mouseReleased in interface GuiEventListener
      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

      private boolean isHovering(Slot pSlot, double pMouseX, double pMouseY)
    • isHovering

      protected boolean isHovering(int pX, int pY, int pWidth, int pHeight, double pMouseX, double pMouseY)
    • slotClicked

      protected void slotClicked(Slot pSlot, int pSlotId, int pMouseButton, ClickType pType)
      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 interface ContainerEventHandler
      Specified by:
      keyPressed in interface GuiEventListener
      Overrides:
      keyPressed in class Screen
      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()
      Overrides:
      removed in class Screen
    • isPauseScreen

      public boolean isPauseScreen()
      Overrides:
      isPauseScreen in class Screen
    • tick

      public final void tick()
      Overrides:
      tick in class Screen
    • containerTick

      protected void containerTick()
    • getMenu

      public T getMenu()
      Specified by:
      getMenu in interface MenuAccess<T extends AbstractContainerMenu>
    • getSlotUnderMouse

      @Nullable public @Nullable Slot 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()
      Overrides:
      onClose in class Screen