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 pMinecraft, int pWidth, int pHeight, int pY, int pItemHeight)
  • Method Details

    • setRenderHeader

      protected void setRenderHeader(boolean pRenderHeader, int pHeaderHeight)
    • getRowWidth

      public int getRowWidth()
    • getSelected

      @Nullable public E getSelected()
    • setSelected

      public void setSelected(@Nullable E pSelected)
    • 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> pEntries)
    • getEntry

      protected E getEntry(int pIndex)
    • addEntry

      protected int addEntry(E pEntry)
    • addEntryToTop

      protected void addEntryToTop(E pEntry)
    • removeEntryFromTop

      protected boolean removeEntryFromTop(E pEntry)
    • getItemCount

      protected int getItemCount()
    • isSelectedItem

      protected boolean isSelectedItem(int pIndex)
    • getEntryAtPosition

      @Nullable protected final E getEntryAtPosition(double pMouseX, double pMouseY)
    • updateSize

      public void updateSize(int pWidth, HeaderAndFooterLayout pLayout)
    • updateSizeAndPosition

      public void updateSizeAndPosition(int pWidth, int pHeight, int pY)
    • getMaxPosition

      protected int getMaxPosition()
    • clickedHeader

      protected boolean clickedHeader(int pX, int pY)
    • renderHeader

      protected void renderHeader(GuiGraphics pGuiGraphics, int pX, int pY)
    • renderDecorations

      protected void renderDecorations(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY)
    • renderWidget

      public void renderWidget(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick)
      Specified by:
      renderWidget in class AbstractWidget
    • scrollbarVisible

      protected boolean scrollbarVisible()
    • renderListSeparators

      protected void renderListSeparators(GuiGraphics pGuiGraphics)
    • renderListBackground

      protected void renderListBackground(GuiGraphics pGuiGraphics)
    • enableScissor

      protected void enableScissor(GuiGraphics pGuiGraphics)
    • centerScrollOn

      protected void centerScrollOn(E pEntry)
    • ensureVisible

      protected void ensureVisible(E pEntry)
    • scroll

      private void scroll(int pScroll)
    • getScrollAmount

      public double getScrollAmount()
    • setClampedScrollAmount

      public void setClampedScrollAmount(double pScroll)
    • setScrollAmount

      public void setScrollAmount(double pScroll)
    • clampScrollAmount

      public void clampScrollAmount()
    • getMaxScroll

      public int getMaxScroll()
    • updateScrollingState

      protected void updateScrollingState(double pMouseX, double pMouseY, int pButton)
    • getScrollbarPosition

      protected int getScrollbarPosition()
    • getDefaultScrollbarPosition

      protected int getDefaultScrollbarPosition()
    • getListOutlinePadding

      private int getListOutlinePadding()
    • isValidMouseClick

      protected boolean isValidMouseClick(int pButton)
    • mouseClicked

      public boolean mouseClicked(double pMouseX, double pMouseY, int pButton)
      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:
      pMouseX - the X coordinate of the mouse.
      pMouseY - the Y coordinate of the mouse.
      pButton - the button that was clicked.
      Returns:
      true if the event is consumed, false otherwise.
    • mouseReleased

      public boolean mouseReleased(double pMouseX, double pMouseY, int pButton)
      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:
      pMouseX - the X coordinate of the mouse.
      pMouseY - the Y coordinate of the mouse.
      pButton - the button that was released.
      Returns:
      true if the event is consumed, false otherwise.
    • mouseDragged

      public boolean mouseDragged(double pMouseX, double pMouseY, int pButton, double pDragX, double pDragY)
      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:
      pMouseX - the X coordinate of the mouse.
      pMouseY - the Y coordinate of the mouse.
      pButton - the button that is being dragged.
      pDragX - the X distance of the drag.
      pDragY - the Y distance of the drag.
      Returns:
      true if the event is consumed, false otherwise.
    • mouseScrolled

      public boolean mouseScrolled(double pMouseX, double pMouseY, double pScrollX, double pScrollY)
    • setFocused

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

      @Nullable protected E nextEntry(ScreenDirection pDirection)
    • nextEntry

      @Nullable protected E nextEntry(ScreenDirection pDirection, Predicate<E> pPredicate)
    • nextEntry

      @Nullable protected E nextEntry(ScreenDirection pDirection, Predicate<E> pPredicate, @Nullable E pSelected)
    • isMouseOver

      public boolean isMouseOver(double pMouseX, double pMouseY)
      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:
      pMouseX - the X coordinate of the mouse.
      pMouseY - the Y coordinate of the mouse.
      Returns:
      true if the mouse is over the GUI element, false otherwise.
    • renderListItems

      protected void renderListItems(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick)
    • renderItem

      protected void renderItem(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick, int pIndex, int pLeft, int pTop, int pWidth, int pHeight)
    • renderSelection

      protected void renderSelection(GuiGraphics pGuiGraphics, int pTop, int pWidth, int pHeight, int pOuterColor, int pInnerColor)
    • getRowLeft

      public int getRowLeft()
    • getRealRowLeft

      private int getRealRowLeft()
    • getRowRight

      public int getRowRight()
    • getRealRowRight

      private int getRealRowRight()
    • getRowTop

      protected int getRowTop(int pIndex)
    • getRowBottom

      protected int getRowBottom(int pIndex)
    • narrationPriority

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

      @Nullable protected E remove(int pIndex)
    • removeEntry

      protected boolean removeEntry(E pEntry)
    • getHovered

      @Nullable protected E getHovered()
    • bindEntryToSelf

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

      protected void narrateListElementPosition(NarrationElementOutput pNarrationElementOutput, E pEntry)