Class AbstractContainerScreen<T extends AbstractContainerMenu>

All Implemented Interfaces:
ContainerEventHandler, GuiEventListener, Renderable, TabOrderedElement, MenuAccess<T>
Direct Known Subclasses:
AbstractMountInventoryScreen, AbstractRecipeBookScreen, BeaconScreen, BrewingStandScreen, CartographyTableScreen, ContainerScreen, CrafterScreen, CreativeModeInventoryScreen, DispenserScreen, EnchantmentScreen, GrindstoneScreen, HopperScreen, ItemCombinerScreen, LoomScreen, MerchantScreen, ShulkerBoxScreen, StonecutterScreen

public abstract class AbstractContainerScreen<T extends AbstractContainerMenu> extends Screen implements MenuAccess<T>
  • Field Details

    • INVENTORY_LOCATION

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

      private static final Identifier SLOT_HIGHLIGHT_BACK_SPRITE
    • SLOT_HIGHLIGHT_FRONT_SPRITE

      private static final Identifier 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:
    • DEFAULT_IMAGE_WIDTH

      protected static final int DEFAULT_IMAGE_WIDTH
      See Also:
    • DEFAULT_IMAGE_HEIGHT

      protected static final int DEFAULT_IMAGE_HEIGHT
      See Also:
    • imageWidth

      protected final int imageWidth
      The X size of the inventory window in pixels.
    • imageHeight

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

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

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

      private @Nullable Slot quickdropSlot
    • lastClickSlot

      private @Nullable Slot lastClickSlot
    • snapbackData

      private @Nullable AbstractContainerScreen.SnapbackData snapbackData
    • 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
    • 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
    • doubleclick

      private boolean doubleclick
    • lastQuickMoved

      private ItemStack lastQuickMoved
    • slotColor

      protected int slotColor
  • Constructor Details

    • AbstractContainerScreen

      public AbstractContainerScreen(T menu, Inventory inventory, Component title)
    • AbstractContainerScreen

      public AbstractContainerScreen(T menu, Inventory inventory, Component title, int imageWidth, int imageHeight)
  • Method Details

    • init

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

      protected void addItemSlotMouseAction(ItemSlotMouseAction itemSlotMouseAction)
    • render

      public void render(GuiGraphics graphics, int mouseX, int mouseY, float a)
      Description copied from interface: Renderable
      Renders the graphical user interface (GUI) element.
      Specified by:
      render in interface Renderable
      Overrides:
      render in class Screen
      Parameters:
      graphics - the GuiGraphics object used for rendering.
      mouseX - the x-coordinate of the mouse cursor.
      mouseY - the y-coordinate of the mouse cursor.
      a - the partial tick time.
    • renderContents

      public void renderContents(GuiGraphics graphics, int mouseX, int mouseY, float a)
    • renderCarriedItem

      public void renderCarriedItem(GuiGraphics graphics, int mouseX, int mouseY)
    • renderSnapbackItem

      public void renderSnapbackItem(GuiGraphics graphics)
    • renderSlots

      protected void renderSlots(GuiGraphics graphics, int mouseX, int mouseY)
    • renderBackground

      public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float a)
      Overrides:
      renderBackground in class Screen
    • mouseScrolled

      public boolean mouseScrolled(double x, double y, double scrollX, double scrollY)
      Specified by:
      mouseScrolled in interface ContainerEventHandler
      Specified by:
      mouseScrolled in interface GuiEventListener
    • renderSlotHighlightBack

      private void renderSlotHighlightBack(GuiGraphics graphics)
    • renderSlotHighlightFront

      private void renderSlotHighlightFront(GuiGraphics graphics)
    • renderTooltip

      protected void renderTooltip(GuiGraphics graphics, int mouseX, int mouseY)
    • showTooltipWithItemInHand

      private boolean showTooltipWithItemInHand(ItemStack item)
    • getTooltipFromContainerItem

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

      private void renderFloatingItem(GuiGraphics graphics, ItemStack carried, int x, int y, @Nullable String itemCount)
    • renderLabels

      protected void renderLabels(GuiGraphics graphics, int xm, int ym)
    • renderBg

      protected abstract void renderBg(GuiGraphics graphics, float a, int xm, int ym)
    • renderSlot

      protected void renderSlot(GuiGraphics graphics, Slot slot, int mouseX, int mouseY)
    • renderSlotContents

      protected void renderSlotContents(GuiGraphics graphics, ItemStack itemStack, Slot slot, @Nullable String itemCount)
    • recalculateQuickCraftRemaining

      private void recalculateQuickCraftRemaining()
    • getHoveredSlot

      private @Nullable Slot getHoveredSlot(double x, double y)
    • mouseClicked

      public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick)
      Specified by:
      mouseClicked in interface ContainerEventHandler
      Specified by:
      mouseClicked in interface GuiEventListener
    • checkHotbarMouseClicked

      private void checkHotbarMouseClicked(MouseButtonEvent event)
    • hasClickedOutside

      protected boolean hasClickedOutside(double mx, double my, int xo, int yo)
    • mouseDragged

      public boolean mouseDragged(MouseButtonEvent event, double dx, double dy)
      Specified by:
      mouseDragged in interface ContainerEventHandler
      Specified by:
      mouseDragged in interface GuiEventListener
    • mouseReleased

      public boolean mouseReleased(MouseButtonEvent event)
      Specified by:
      mouseReleased in interface ContainerEventHandler
      Specified by:
      mouseReleased in interface GuiEventListener
    • clearDraggingState

      public void clearDraggingState()
    • isHovering

      private boolean isHovering(Slot slot, double xm, double ym)
    • isHovering

      protected boolean isHovering(int left, int top, int w, int h, double xm, double ym)
    • onStopHovering

      private void onStopHovering(Slot slot)
    • slotClicked

      protected void slotClicked(Slot slot, int slotId, int buttonNum, ContainerInput containerInput)
    • onMouseClickAction

      void onMouseClickAction(@Nullable Slot slot, ContainerInput containerInput)
    • handleSlotStateChanged

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

      public boolean keyPressed(KeyEvent event)
      Specified by:
      keyPressed in interface ContainerEventHandler
      Specified by:
      keyPressed in interface GuiEventListener
      Overrides:
      keyPressed in class Screen
    • checkHotbarKeyPressed

      protected boolean checkHotbarKeyPressed(KeyEvent event)
    • removed

      public void removed()
      Overrides:
      removed in class Screen
    • isPauseScreen

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

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

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

      protected void containerTick()
    • shouldAddSlotToQuickCraft

      private boolean shouldAddSlotToQuickCraft(Slot slot, ItemStack carried)
    • quickCraftToSlots

      private void quickCraftToSlots()
    • getMenu

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

      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