Class ScrollableListWidget<T extends net.minecraft.client.gui.layouts.LayoutElement & net.minecraft.client.gui.components.Renderable>

java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
net.minecraft.client.gui.components.AbstractScrollWidget
com.pixelmonmod.pixelmon.client.gui.npc.widget.ScrollableListWidget<T>
All Implemented Interfaces:
net.minecraft.client.gui.components.events.GuiEventListener, net.minecraft.client.gui.components.Renderable, net.minecraft.client.gui.components.TabOrderedElement, net.minecraft.client.gui.layouts.LayoutElement, net.minecraft.client.gui.narration.NarratableEntry, net.minecraft.client.gui.narration.NarrationSupplier

public class ScrollableListWidget<T extends net.minecraft.client.gui.layouts.LayoutElement & net.minecraft.client.gui.components.Renderable> extends net.minecraft.client.gui.components.AbstractScrollWidget
  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntry

    net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected T
     
    protected int
     
    protected List<T>
     

    Fields inherited from class net.minecraft.client.gui.components.AbstractScrollWidget

    scrollAmount, scrolling

    Fields inherited from class net.minecraft.client.gui.components.AbstractWidget

    active, alpha, focused, height, hoverOrFocusedStartTime, isHovered, message, MIN_SCROLL_PERIOD, packedFGColor, PERIOD_PER_SCROLLED_PIXEL, tabOrderGroup, tooltip, tooltipMsDelay, UNSET_FG_COLOR, visible, wasHoveredOrFocused, width, x, y

    Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener

    DOUBLE_CLICK_THRESHOLD_MS
  • Constructor Summary

    Constructors
    Constructor
    Description
    ScrollableListWidget(int width, int height)
     
    ScrollableListWidget(int x, int y, int width, int height)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addWidgets(T... widgets)
     
    boolean
    charTyped(char character, int modifiers)
     
    protected T
    findElementFor(double mouseX, double mouseY)
     
    protected double
    findYFor(T widget, double mouseY)
     
    double
    getElementY(T element)
    Gets the y position of a widget relative to the scrollable list widget.
    protected int
     
    int
    getInnerHeightOfLayoutElementWidget(net.minecraft.client.gui.layouts.LayoutElement widgetToGetHeightFor)
     
    double
    Gets the y position of the cursor relative to the scrollable list widget.
     
    boolean
    keyPressed(int keyCode, int scanCode, int modifiers)
     
    boolean
    mouseClicked(double mouseX, double mouseY, int button)
     
    boolean
    mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)
     
    boolean
    mouseScrolled(double mouseX, double mouseY, double deltaX, double deltaY)
     
    protected void
    renderBackground(net.minecraft.client.gui.GuiGraphics p_282207_)
     
    protected void
    renderContents(net.minecraft.client.gui.GuiGraphics gui, int mouseX, int mouseY, float partialTicks)
     
    protected double
     
    void
    Scrolls the scrollbar upon a widget being clicked.
    protected void
    setFocussed(T focussed)
     
    void
    setPaddingY(int paddingY)
     
    protected void
    updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput p_259858_)
     

    Methods inherited from class net.minecraft.client.gui.components.AbstractScrollWidget

    getMaxScrollAmount, innerPadding, mouseReleased, renderBorder, renderDecorations, renderWidget, scrollAmount, scrollbarVisible, scrollbarWidth, setScrollAmount, totalInnerPadding, withinContentAreaPoint, withinContentAreaTopBottom

    Methods inherited from class net.minecraft.client.gui.components.AbstractWidget

    clearFGColor, clicked, createNarrationMessage, createTooltipPositioner, defaultButtonNarrationText, getFGColor, getHeight, getMessage, getRectangle, getTabOrderGroup, getTooltip, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isMouseOver, isValidClickButton, narrationPriority, nextFocusPath, onClick, onDrag, onRelease, playDownSound, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setFocused, setHeight, setMessage, setTabOrderGroup, setTooltip, setTooltipDelay, setWidth, setX, setY, updateNarration, visitWidgets, wrapDefaultNarrationMessage

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener

    getCurrentFocusPath, getRectangle, isFocused, isMouseOver, keyReleased, mouseMoved, nextFocusPath, setFocused

    Methods inherited from interface net.minecraft.client.gui.layouts.LayoutElement

    setPosition

    Methods inherited from interface net.minecraft.client.gui.components.Renderable

    render

    Methods inherited from interface net.minecraft.client.gui.components.TabOrderedElement

    getTabOrderGroup
  • Field Details

    • widgets

      protected List<T extends net.minecraft.client.gui.layouts.LayoutElement & net.minecraft.client.gui.components.Renderable> widgets
    • paddingY

      protected int paddingY
    • focussed

      protected T extends net.minecraft.client.gui.layouts.LayoutElement & net.minecraft.client.gui.components.Renderable focussed
  • Constructor Details

    • ScrollableListWidget

      public ScrollableListWidget(int x, int y, int width, int height)
    • ScrollableListWidget

      public ScrollableListWidget(int width, int height)
  • Method Details

    • addWidgets

      public void addWidgets(T... widgets)
    • setPaddingY

      public void setPaddingY(int paddingY)
    • getInnerHeight

      protected int getInnerHeight()
      Specified by:
      getInnerHeight in class net.minecraft.client.gui.components.AbstractScrollWidget
    • getInnerHeightOfLayoutElementWidget

      public int getInnerHeightOfLayoutElementWidget(net.minecraft.client.gui.layouts.LayoutElement widgetToGetHeightFor)
    • scrollRate

      protected double scrollRate()
      Specified by:
      scrollRate in class net.minecraft.client.gui.components.AbstractScrollWidget
    • renderContents

      protected void renderContents(net.minecraft.client.gui.GuiGraphics gui, int mouseX, int mouseY, float partialTicks)
      Specified by:
      renderContents in class net.minecraft.client.gui.components.AbstractScrollWidget
    • renderBackground

      protected void renderBackground(net.minecraft.client.gui.GuiGraphics p_282207_)
      Overrides:
      renderBackground in class net.minecraft.client.gui.components.AbstractScrollWidget
    • mouseClicked

      public boolean mouseClicked(double mouseX, double mouseY, int button)
      Specified by:
      mouseClicked in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      mouseClicked in class net.minecraft.client.gui.components.AbstractScrollWidget
    • scrollWidgetUponMouseClicked

      public void scrollWidgetUponMouseClicked(T element)
      Scrolls the scrollbar upon a widget being clicked.

      Find the position and height of the widget clicked and checks to see if its bottom y coordinate is past the bottom y coordinate of the scrollable list widget. If it is, it scrolls the scrollbar downward, and sets the scroll amount the difference in length between the two y coordinates. Otherwise, it scrolls the scrollbar upward to position the clicked widget towards the bottom of the scrollable list widget.

      Parameters:
      element - The widget clicked.
    • mouseScrolled

      public boolean mouseScrolled(double mouseX, double mouseY, double deltaX, double deltaY)
      Specified by:
      mouseScrolled in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      mouseScrolled in class net.minecraft.client.gui.components.AbstractScrollWidget
    • mouseDragged

      public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)
      Specified by:
      mouseDragged in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      mouseDragged in class net.minecraft.client.gui.components.AbstractScrollWidget
    • keyPressed

      public boolean keyPressed(int keyCode, int scanCode, int modifiers)
      Specified by:
      keyPressed in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      keyPressed in class net.minecraft.client.gui.components.AbstractScrollWidget
    • charTyped

      public boolean charTyped(char character, int modifiers)
    • findElementFor

      protected T findElementFor(double mouseX, double mouseY)
    • findYFor

      protected double findYFor(T widget, double mouseY)
    • setFocussed

      protected void setFocussed(T focussed)
    • updateWidgetNarration

      protected void updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput p_259858_)
      Specified by:
      updateWidgetNarration in class net.minecraft.client.gui.components.AbstractWidget
    • getWidgets

      public List<T> getWidgets()
    • getMouseYTranslatedToWidgetY

      public double getMouseYTranslatedToWidgetY(double mouseY)
      Gets the y position of the cursor relative to the scrollable list widget.
      Parameters:
      mouseY - The y position of the cursor.
      Returns:
      The cursor's y coordinate, where 0 is at the top of the scrollable list widget.
    • getElementY

      public double getElementY(T element)
      Gets the y position of a widget relative to the scrollable list widget.
      Parameters:
      element - The widget inside this scrollable list widget.
      Returns:
      The y position of the widget, where 0 is at the top of the scrollable list widget.