Class EntryListWidget<E extends EntryListWidget.Entry<E>>

All Implemented Interfaces:
Drawable, Element, ParentElement
Direct Known Subclasses:
AlwaysSelectedEntryListWidget, ElementListWidget

@Environment(CLIENT)
public abstract class EntryListWidget<E extends EntryListWidget.Entry<E>>
extends AbstractParentElement
implements Drawable
  • Field Details

    • client

      protected final MinecraftClient client
    • itemHeight

      protected final int itemHeight
    • children

      private final List<E extends EntryListWidget.Entry<E>> children
    • width

      protected int width
    • height

      protected int height
    • top

      protected int top
    • bottom

      protected int bottom
    • left

      protected int left
    • centerListVertically

      protected boolean centerListVertically
    • scrollAmount

      private double scrollAmount
    • renderSelection

      private boolean renderSelection
    • renderHeader

      private boolean renderHeader
    • headerHeight

      protected int headerHeight
    • scrolling

      private boolean scrolling
    • selected

      private E extends EntryListWidget.Entry<E> selected
    • field_26846

      private boolean field_26846
    • field_26847

      private boolean field_26847
  • Constructor Details

    • EntryListWidget

      public EntryListWidget​(MinecraftClient client, int width, int height, int top, int bottom, int itemHeight)
  • Method Details

    • setRenderSelection

      public void setRenderSelection​(boolean renderSelection)
    • setRenderHeader

      protected void setRenderHeader​(boolean renderHeader, int headerHeight)
    • getRowWidth

      public int getRowWidth()
    • getSelected

      @Nullable public E getSelected()
    • setSelected

      public void setSelected​(@Nullable E entry)
    • method_31322

      public void method_31322​(boolean bool)
    • method_31323

      public void method_31323​(boolean bool)
    • getFocused

      @Nullable public E getFocused()
      Specified by:
      getFocused in interface ParentElement
      Overrides:
      getFocused in class AbstractParentElement
    • children

      public final List<E> children()
      Gets a list of all child GUI elements.
      Specified by:
      children in interface ParentElement
    • clearEntries

      protected final void clearEntries()
    • replaceEntries

      protected void replaceEntries​(Collection<E> newEntries)
    • getEntry

      protected E getEntry​(int index)
    • addEntry

      protected int addEntry​(E entry)
    • getItemCount

      protected int getItemCount()
    • isSelectedItem

      protected boolean isSelectedItem​(int index)
    • getEntryAtPosition

      @Nullable protected final E getEntryAtPosition​(double x, double y)
    • updateSize

      public void updateSize​(int width, int height, int top, int bottom)
    • setLeftPos

      public void setLeftPos​(int left)
    • getMaxPosition

      protected int getMaxPosition()
    • clickedHeader

      protected void clickedHeader​(int x, int y)
    • renderHeader

      protected void renderHeader​(MatrixStack matrices, int x, int y, Tessellator tessellator)
    • renderBackground

      protected void renderBackground​(MatrixStack matrices)
    • renderDecorations

      protected void renderDecorations​(MatrixStack matrixStack, int int2, int int3)
    • render

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

      protected void centerScrollOn​(E entry)
    • ensureVisible

      protected void ensureVisible​(E entry)
    • scroll

      private void scroll​(int amount)
    • getScrollAmount

      public double getScrollAmount()
    • setScrollAmount

      public void setScrollAmount​(double amount)
    • getMaxScroll

      public int getMaxScroll()
    • updateScrollingState

      protected void updateScrollingState​(double mouseX, double mouseY, int button)
    • getScrollbarPositionX

      protected int getScrollbarPositionX()
    • 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
    • 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
    • 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
    • mouseScrolled

      public boolean mouseScrolled​(double mouseX, double mouseY, double amount)
      Callback for when a mouse button scroll event has been captured.
      Specified by:
      mouseScrolled in interface Element
      Specified by:
      mouseScrolled in interface ParentElement
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      amount - value is > 1 if scrolled down, < 1 if scrolled up
      Returns:
      true to indicate that the event handling is successful/valid
      See Also:
      Mouse.onMouseScroll(long, double, double)
    • 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
      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 {@linkplain https://www.glfw.org/docs/3.3/group__mods.html 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)
    • moveSelection

      protected void moveSelection​(EntryListWidget.MoveDirection direction)
    • method_30015

      protected void method_30015()
    • moveSelectionIf

      protected void moveSelectionIf​(EntryListWidget.MoveDirection direction, Predicate<E> predicate)
      Moves the selection in the specified direction until the predicate returns true.
      Parameters:
      direction - the direction to move the selection
    • isMouseOver

      public boolean isMouseOver​(double mouseX, double mouseY)
      Checks if the mouse position is within the bound of the element.
      Specified by:
      isMouseOver in interface Element
      Parameters:
      mouseX - the X coordinate of the mouse
      mouseY - the Y coordinate of the mouse
      Returns:
      true if the mouse is within the bound of the element, otherwise false
    • renderList

      protected void renderList​(MatrixStack matrices, int x, int y, int mouseX, int mouseY, float delta)
    • getRowLeft

      public int getRowLeft()
    • method_31383

      public int method_31383()
    • getRowTop

      protected int getRowTop​(int index)
    • getRowBottom

      private int getRowBottom​(int index)
    • isFocused

      protected boolean isFocused()
    • remove

      protected E remove​(int index)
    • removeEntry

      protected boolean removeEntry​(E entry)
    • method_29621

      private void method_29621​(EntryListWidget.Entry<E> entry)