Class AbstractSelectionList<E extends AbstractSelectionList.Entry<E>>

All Implemented Interfaces:
ContainerEventHandler, GuiEventListener, Renderable, TabOrderedElement, LayoutElement, NarratableEntry, NarrationSupplier, IAbstractWidgetExtension
Direct Known Subclasses:
ContainerObjectSelectionList, ObjectSelectionList

public abstract class AbstractSelectionList<E extends AbstractSelectionList.Entry<E>> extends AbstractContainerWidget
  • Field Details

    • SCROLLBAR_WIDTH

      protected static final int SCROLLBAR_WIDTH
      See Also:
    • SCROLLER_SPRITE

      private static final ResourceLocation SCROLLER_SPRITE
    • SCROLLER_BACKGROUND_SPRITE

      private static final ResourceLocation SCROLLER_BACKGROUND_SPRITE
    • INWORLD_MENU_LIST_BACKGROUND

      private static final ResourceLocation INWORLD_MENU_LIST_BACKGROUND
    • minecraft

      protected final Minecraft minecraft
    • itemHeight

      protected final int itemHeight
    • children

      private final List<E extends AbstractSelectionList.Entry<E>> children
    • centerListVertically

      protected boolean centerListVertically
    • scrollAmount

      private double scrollAmount
    • renderHeader

      private boolean renderHeader
    • headerHeight

      protected int headerHeight
    • scrolling

      private boolean scrolling
    • selected

      @Nullable private E extends AbstractSelectionList.Entry<E> selected
    • hovered

      @Nullable private E extends AbstractSelectionList.Entry<E> hovered
  • Constructor Details

    • AbstractSelectionList

      public AbstractSelectionList(Minecraft minecraft, int width, int height, int y, int itemHeight)
  • Method Details

    • setRenderHeader

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

      public int getRowWidth()
    • getSelected

      @Nullable public E getSelected()
    • setSelected

      public void setSelected(@Nullable E selected)
    • getFirstElement

      public E getFirstElement()
    • getFocused

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

      public final List<E> children()
    • clearEntries

      protected void clearEntries()
    • replaceEntries

      protected void replaceEntries(Collection<E> entries)
    • getEntry

      protected E getEntry(int index)
    • addEntry

      protected int addEntry(E entry)
    • addEntryToTop

      protected void addEntryToTop(E entry)
    • removeEntryFromTop

      protected boolean removeEntryFromTop(E entry)
    • getItemCount

      protected int getItemCount()
    • isSelectedItem

      protected boolean isSelectedItem(int index)
    • getEntryAtPosition

      @Nullable protected final E getEntryAtPosition(double mouseX, double mouseY)
    • updateSize

      public void updateSize(int width, HeaderAndFooterLayout layout)
    • updateSizeAndPosition

      public void updateSizeAndPosition(int width, int height, int y)
    • getMaxPosition

      protected int getMaxPosition()
    • clickedHeader

      protected boolean clickedHeader(int x, int y)
    • renderHeader

      protected void renderHeader(GuiGraphics guiGraphics, int x, int y)
    • renderDecorations

      protected void renderDecorations(GuiGraphics guiGraphics, int mouseX, int mouseY)
    • renderWidget

      public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
      Specified by:
      renderWidget in class AbstractWidget
    • scrollbarVisible

      protected boolean scrollbarVisible()
    • renderListSeparators

      protected void renderListSeparators(GuiGraphics guiGraphics)
    • renderListBackground

      protected void renderListBackground(GuiGraphics guiGraphics)
    • enableScissor

      protected void enableScissor(GuiGraphics guiGraphics)
    • centerScrollOn

      protected void centerScrollOn(E entry)
    • ensureVisible

      protected void ensureVisible(E entry)
    • scroll

      private void scroll(int scroll)
    • getScrollAmount

      public double getScrollAmount()
    • setClampedScrollAmount

      public void setClampedScrollAmount(double scroll)
    • setScrollAmount

      public void setScrollAmount(double scroll)
    • clampScrollAmount

      public void clampScrollAmount()
    • getMaxScroll

      public int getMaxScroll()
    • updateScrollingState

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

      protected int getScrollbarPosition()
    • getDefaultScrollbarPosition

      protected int getDefaultScrollbarPosition()
    • getListOutlinePadding

      private int getListOutlinePadding()
    • isValidMouseClick

      protected boolean isValidMouseClick(int button)
    • mouseClicked

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

      Specified by:
      mouseClicked in interface ContainerEventHandler
      Specified by:
      mouseClicked in interface GuiEventListener
      Overrides:
      mouseClicked in class AbstractContainerWidget
      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.
    • mouseReleased

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

      Specified by:
      mouseReleased in interface ContainerEventHandler
      Specified by:
      mouseReleased in interface GuiEventListener
      Overrides:
      mouseReleased in class AbstractContainerWidget
      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.
    • mouseDragged

      public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY)
      Description copied from class: AbstractWidget
      Called when the mouse is dragged within the GUI element.

      Specified by:
      mouseDragged in interface ContainerEventHandler
      Specified by:
      mouseDragged in interface GuiEventListener
      Overrides:
      mouseDragged in class AbstractContainerWidget
      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.
    • mouseScrolled

      public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY)
    • setFocused

      public void setFocused(@Nullable GuiEventListener focused)
      Sets the focus state of the GUI element.
      Specified by:
      setFocused in interface ContainerEventHandler
      Overrides:
      setFocused in class AbstractContainerWidget
      Parameters:
      focused - the focused GUI element.
    • nextEntry

      @Nullable protected E nextEntry(ScreenDirection direction)
    • nextEntry

      @Nullable protected E nextEntry(ScreenDirection direction, Predicate<E> predicate)
    • nextEntry

      @Nullable protected E nextEntry(ScreenDirection direction, Predicate<E> predicate, @Nullable E selected)
    • isMouseOver

      public boolean isMouseOver(double mouseX, double mouseY)
      Description copied from class: AbstractWidget
      Checks if the given mouse coordinates are over the GUI element.

      Specified by:
      isMouseOver in interface GuiEventListener
      Overrides:
      isMouseOver in class AbstractWidget
      Parameters:
      mouseX - the X coordinate of the mouse.
      mouseY - the Y coordinate of the mouse.
      Returns:
      true if the mouse is over the GUI element, false otherwise.
    • renderListItems

      protected void renderListItems(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
    • renderItem

      protected void renderItem(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick, int index, int left, int top, int width, int height)
    • renderSelection

      protected void renderSelection(GuiGraphics guiGraphics, int top, int width, int height, int outerColor, int innerColor)
    • getRowLeft

      public int getRowLeft()
    • getRealRowLeft

      private int getRealRowLeft()
    • getRowRight

      public int getRowRight()
    • getRealRowRight

      private int getRealRowRight()
    • getRowTop

      protected int getRowTop(int index)
    • getRowBottom

      protected int getRowBottom(int index)
    • narrationPriority

      public NarratableEntry.NarrationPriority narrationPriority()
      Specified by:
      narrationPriority in interface NarratableEntry
      Overrides:
      narrationPriority in class AbstractWidget
    • remove

      @Nullable protected E remove(int index)
    • removeEntry

      protected boolean removeEntry(E entry)
    • getHovered

      @Nullable protected E getHovered()
    • bindEntryToSelf

      void bindEntryToSelf(AbstractSelectionList.Entry<E> entry)
    • narrateListElementPosition

      protected void narrateListElementPosition(NarrationElementOutput narrationElementOutput, E entry)