Class AbstractContainerScreen<T extends AbstractContainerMenu>

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

    • INVENTORY_LOCATION

      public static final ResourceLocation INVENTORY_LOCATION
      The location of the inventory background texture
    • SLOT_HIGHLIGHT_BACK_SPRITE

      private static final ResourceLocation SLOT_HIGHLIGHT_BACK_SPRITE
    • SLOT_HIGHLIGHT_FRONT_SPRITE

      private static final ResourceLocation 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:
    • 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
    • itemSlotMouseActions

      private final List<ItemSlotMouseAction> itemSlotMouseActions
    • 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 menu, Inventory playerInventory, Component title)
  • Method Details

    • init

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

      protected void addItemSlotMouseAction(ItemSlotMouseAction itemSlotMouseAction)
    • render

      public void render(GuiGraphics p_283479_, int p_283661_, int p_281248_, float p_281886_)
      Description copied from class: Screen
      Neo: mixins targeting this method won't fire for container screens as render(net.minecraft.client.gui.GuiGraphics, int, int, float) replicates this method in place of a super call to insert an event
      Specified by:
      render in interface Renderable
      Overrides:
      render in class Screen
      Parameters:
      p_283479_ - the GuiGraphics object used for rendering.
      p_283661_ - the x-coordinate of the mouse cursor.
      p_281248_ - the y-coordinate of the mouse cursor.
      p_281886_ - the partial tick time.
    • renderSlots

      protected void renderSlots(GuiGraphics guiGraphics)
    • renderBackground

      public void renderBackground(GuiGraphics p_295206_, int p_295457_, int p_294596_, float p_296351_)
      Overrides:
      renderBackground in class Screen
    • mouseScrolled

      public boolean mouseScrolled(double p_364830_, double p_360707_, double p_364436_, double p_364417_)
      Specified by:
      mouseScrolled in interface ContainerEventHandler
      Specified by:
      mouseScrolled in interface GuiEventListener
    • renderSlotHighlightBack

      private void renderSlotHighlightBack(GuiGraphics guiGraphics)
    • renderSlotHighlightFront

      private void renderSlotHighlightFront(GuiGraphics guiGraphics)
    • renderTooltip

      protected void renderTooltip(GuiGraphics guiGraphics, int x, int y)
    • showTooltipWithItemInHand

      private boolean showTooltipWithItemInHand(ItemStack stack)
    • getTooltipFromContainerItem

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

      private void renderFloatingItem(GuiGraphics guiGraphics, ItemStack stack, int x, int y, @Nullable String text)
    • renderLabels

      protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY)
    • renderBg

      protected abstract void renderBg(GuiGraphics guiGraphics, float partialTick, int mouseX, int mouseY)
    • renderSlot

      protected void renderSlot(GuiGraphics guiGraphics, Slot slot)
    • renderSlotContents

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

      private void recalculateQuickCraftRemaining()
    • getHoveredSlot

      @Nullable private Slot getHoveredSlot(double mouseX, double mouseY)
    • mouseClicked

      public boolean mouseClicked(double mouseX, double mouseY, int button)
      Description copied from interface: ContainerEventHandler
      Called when a mouse button is clicked within the GUI element.

      Specified by:
      mouseClicked in interface ContainerEventHandler
      Specified by:
      mouseClicked in interface GuiEventListener
      Parameters:
      mouseX - the X coordinate of the mouse.
      mouseY - the Y coordinate of the mouse.
      button - the button that was clicked.
      Returns:
      true if the event is consumed, false otherwise.
    • 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)
      Description copied from interface: ContainerEventHandler
      Called when the mouse is dragged within the GUI element.

      Specified by:
      mouseDragged in interface ContainerEventHandler
      Specified by:
      mouseDragged in interface GuiEventListener
      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:
      true if the event is consumed, false otherwise.
    • mouseReleased

      public boolean mouseReleased(double mouseX, double mouseY, int button)
      Description copied from interface: ContainerEventHandler
      Called when a mouse button is released within the GUI element.

      Specified by:
      mouseReleased in interface ContainerEventHandler
      Specified by:
      mouseReleased in interface GuiEventListener
      Parameters:
      mouseX - the X coordinate of the mouse.
      mouseY - the Y coordinate of the mouse.
      button - the button that was released.
      Returns:
      true if the event is consumed, false otherwise.
    • clearDraggingState

      public void clearDraggingState()
    • isHovering

      private boolean isHovering(Slot slot, double mouseX, double mouseY)
    • isHovering

      protected boolean isHovering(int x, int y, int width, int height, double mouseX, double mouseY)
    • onStopHovering

      private void onStopHovering(Slot slot)
    • slotClicked

      protected void slotClicked(Slot slot, int slotId, int mouseButton, ClickType type)
      Called when the mouse is clicked over a slot or outside the gui.
    • onMouseClickAction

      void onMouseClickAction(@Nullable Slot slot, ClickType type)
    • handleSlotStateChanged

      protected void handleSlotStateChanged(int slotId, int containerId, boolean newState)
    • keyPressed

      public boolean keyPressed(int keyCode, int scanCode, int modifiers)
      Description copied from interface: ContainerEventHandler
      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:
      keyCode - the key code of the pressed key.
      scanCode - the scan code of the pressed key.
      modifiers - the keyboard modifiers.
      Returns:
      true if the event is consumed, false otherwise.
    • checkHotbarKeyPressed

      protected boolean checkHotbarKeyPressed(int keyCode, int scanCode)
    • 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