Class HandledScreen<T extends ScreenHandler>

All Implemented Interfaces:
Drawable, Element, ParentElement, ScreenHandlerProvider<T>, TickableElement
Direct Known Subclasses:
AbstractFurnaceScreen, AbstractInventoryScreen, BeaconScreen, BrewingStandScreen, CartographyTableScreen, CraftingScreen, EnchantmentScreen, ForgingScreen, Generic3x3ContainerScreen, GenericContainerScreen, GrindstoneScreen, HopperScreen, HorseScreen, LoomScreen, MerchantScreen, ShulkerBoxScreen, StonecutterScreen

@Environment(CLIENT)
public abstract class HandledScreen<T extends ScreenHandler>
extends Screen
implements ScreenHandlerProvider<T>
  • Field Details

    • BACKGROUND_TEXTURE

      public static final Identifier BACKGROUND_TEXTURE
    • backgroundWidth

      protected int backgroundWidth
    • backgroundHeight

      protected int backgroundHeight
    • titleX

      protected int titleX
    • titleY

      protected int titleY
    • playerInventoryTitleX

      protected int playerInventoryTitleX
    • playerInventoryTitleY

      protected int playerInventoryTitleY
    • handler

      protected final T extends ScreenHandler handler
    • playerInventory

      protected final PlayerInventory playerInventory
    • focusedSlot

      @Nullable protected Slot focusedSlot
    • touchDragSlotStart

      @Nullable private Slot touchDragSlotStart
    • touchDropOriginSlot

      @Nullable private Slot touchDropOriginSlot
    • touchHoveredSlot

      @Nullable private Slot touchHoveredSlot
    • lastClickedSlot

      @Nullable private Slot lastClickedSlot
    • x

      protected int x
    • y

      protected int y
    • touchIsRightClickDrag

      private boolean touchIsRightClickDrag
    • touchDragStack

      private ItemStack touchDragStack
    • touchDropX

      private int touchDropX
    • touchDropY

      private int touchDropY
    • touchDropTime

      private long touchDropTime
    • touchDropReturningStack

      private ItemStack touchDropReturningStack
    • touchDropTimer

      private long touchDropTimer
    • cursorDragSlots

      protected final Set<Slot> cursorDragSlots
    • cursorDragging

      protected boolean cursorDragging
    • heldButtonType

      private int heldButtonType
    • heldButtonCode

      private int heldButtonCode
    • cancelNextRelease

      private boolean cancelNextRelease
    • draggedStackRemainder

      private int draggedStackRemainder
    • lastButtonClickTime

      private long lastButtonClickTime
    • lastClickedButton

      private int lastClickedButton
    • doubleClicking

      private boolean doubleClicking
    • quickMovingStack

      private ItemStack quickMovingStack
  • Constructor Details

  • Method Details

    • init

      protected void init()
      Called when a screen should be initialized.

      This method is called when this screen is opened or resized.

      Overrides:
      init in class Screen
    • render

      public void render​(MatrixStack matrices, int mouseX, int mouseY, float delta)
      Specified by:
      render in interface Drawable
      Overrides:
      render in class Screen
    • method_33285

      public static void method_33285​(MatrixStack matrixStack, int int2, int int3, int int4)
    • drawMouseoverTooltip

      protected void drawMouseoverTooltip​(MatrixStack matrices, int x, int y)
    • drawItem

      private void drawItem​(ItemStack stack, int xPosition, int yPosition, String amountText)
    • drawForeground

      protected void drawForeground​(MatrixStack matrices, int mouseX, int mouseY)
    • drawBackground

      protected abstract void drawBackground​(MatrixStack matrices, float delta, int mouseX, int mouseY)
    • drawSlot

      private void drawSlot​(MatrixStack matrices, Slot slot)
    • calculateOffset

      private void calculateOffset()
    • getSlotAt

      @Nullable private Slot getSlotAt​(double xPosition, double yPosition)
    • mouseClicked

      public boolean mouseClicked​(double mouseX, double mouseY, int button)
      Callback for when a mouse button down event has been captured. The button number is identified by the constants in GLFW class.
      Specified by:
      mouseClicked in interface Element
      Specified by:
      mouseClicked in interface ParentElement
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      button - the mouse button number
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mouse.onMouseButton(long, int, int, int), GLFW.GLFW_MOUSE_BUTTON_1
    • method_30107

      private void method_30107​(int int2)
    • isClickOutsideBounds

      protected boolean isClickOutsideBounds​(double mouseX, double mouseY, int left, int top, int button)
    • mouseDragged

      public boolean mouseDragged​(double mouseX, double mouseY, int button, double deltaX, double deltaY)
      Callback for when a mouse button drag event has been captured. The button number is identified by the constants in GLFW class.
      Specified by:
      mouseDragged in interface Element
      Specified by:
      mouseDragged in interface ParentElement
      Parameters:
      mouseX - the current X coordinate of the mouse
      mouseY - the current Y coordinate of the mouse
      button - the mouse button number
      deltaX - the difference of the current X with the previous X coordinate
      deltaY - the difference of the current Y with the previous Y coordinate
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mouse.onCursorPos(long, double, double), GLFW.GLFW_MOUSE_BUTTON_1
    • mouseReleased

      public boolean mouseReleased​(double mouseX, double mouseY, int button)
      Callback for when a mouse button release event has been captured. The button number is identified by the constants in GLFW class.
      Specified by:
      mouseReleased in interface Element
      Specified by:
      mouseReleased in interface ParentElement
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      button - the mouse button number
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mouse.onMouseButton(long, int, int, int), GLFW.GLFW_MOUSE_BUTTON_1
    • isPointOverSlot

      private boolean isPointOverSlot​(Slot slot, double pointX, double pointY)
    • isPointWithinBounds

      protected boolean isPointWithinBounds​(int xPosition, int yPosition, int width, int height, double pointX, double pointY)
    • onMouseClick

      protected void onMouseClick​(Slot slot, int invSlot, int clickData, SlotActionType actionType)
      See Also:
      ScreenHandler.onSlotClick(int, int, net.minecraft.screen.slot.SlotActionType, net.minecraft.entity.player.PlayerEntity)
    • keyPressed

      public boolean keyPressed​(int keyCode, int scanCode, int modifiers)
      Callback for when a key down event has been captured. The key code is identified by the constants in GLFW class.
      Specified by:
      keyPressed in interface Element
      Specified by:
      keyPressed in interface ParentElement
      Overrides:
      keyPressed in class Screen
      Parameters:
      keyCode - the named key code of the event as described in the GLFW class
      scanCode - the unique/platform-specific scan code of the keyboard input
      modifiers - a GLFW bitfield describing the modifier keys that are held down (see GLFW Modifier key flags)
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Keyboard.onKey(long, int, int, int, int), GLFW.GLFW_KEY_Q, GLFWKeyCallbackI.invoke(long, int, int, int, int)
    • handleHotbarKeyPressed

      protected boolean handleHotbarKeyPressed​(int keyCode, int scanCode)
    • removed

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

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

      public void tick()
      Specified by:
      tick in interface TickableElement
      Overrides:
      tick in class Screen
    • getScreenHandler

      public T getScreenHandler()
      Specified by:
      getScreenHandler in interface ScreenHandlerProvider<T extends ScreenHandler>
    • onClose

      public void onClose()
      Overrides:
      onClose in class Screen