Class AutoComplete<T>

java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
com.blamejared.searchables.api.autcomplete.AutoComplete<T>
Type Parameters:
T - The type of element that is being searched for.
All Implemented Interfaces:
Consumer<String>, 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 AutoComplete<T> extends net.minecraft.client.gui.components.AbstractWidget implements Consumer<String>
A small widget that displays current suggestions for an AutoCompletingEditBox<T>.
  • 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 inherited from class net.minecraft.client.gui.components.AbstractWidget

    active, alpha, height, isHovered, visible, width
  • Constructor Summary

    Constructors
    Constructor
    Description
    AutoComplete(SearchableType<T> type, AutoCompletingEditBox<T> editBox, Supplier<List<T>> entries, int x, int y, int width, int suggestionHeight)
    Create a new AutoComplete with the given values and a maxSuggestion size of 7
    AutoComplete(SearchableType<T> type, AutoCompletingEditBox<T> editBox, Supplier<List<T>> entries, int x, int y, int width, int suggestionHeight, int maxSuggestions)
    Create a new AutoComplete with the given values.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accept(String value)
    Compiles suggestions for the given value.
     
    void
    Inserts the currently selected suggestion into attached AutoCompletingEditBox<T>.
    boolean
    isMouseOver(double xpos, double ypos)
     
    int
     
    boolean
    mouseClicked(net.minecraft.client.input.MouseButtonEvent event, boolean doubleClick)
     
    boolean
    mouseScrolled(double xpos, double ypos, double xDelta, double yDelta)
     
    void
    renderWidget(net.minecraft.client.gui.GuiGraphics guiGraphics, int mx, int my, float partial)
     
    void
    Scrolls the current suggestions down by 1.
    void
    scrollDown(int amount)
    Scrolls the current suggestions down by the given amount.
    void
    Scrolls the current suggestions up by 1.
    void
    scrollUp(int amount)
    Scrolls the current suggestions up by the given amount.
    protected void
    updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput output)
     

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

    createNarrationMessage, defaultButtonNarrationText, getBottom, getHeight, getMessage, getRectangle, getRight, getTabOrderGroup, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isValidClickButton, mouseDragged, mouseReleased, narrationPriority, nextFocusPath, onClick, onDrag, onRelease, playButtonClickSound, playDownSound, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFocused, setHeight, setMessage, setRectangle, setSize, 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 java.util.function.Consumer

    andThen

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

    charTyped, getBorderForArrowNavigation, getCurrentFocusPath, keyPressed, keyReleased, mouseMoved, shouldTakeFocusAfterInteraction

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

    setPosition

    Methods inherited from interface net.minecraft.client.gui.narration.NarratableEntry

    getNarratables
  • Constructor Details

    • AutoComplete

      public AutoComplete(SearchableType<T> type, AutoCompletingEditBox<T> editBox, Supplier<List<T>> entries, int x, int y, int width, int suggestionHeight)
      Create a new AutoComplete with the given values and a maxSuggestion size of 7
      Parameters:
      type - The SearchableType<T> that this AutoComplete<T> completes for.
      editBox - The attached AutoCompletingEditBox<T> that this AutoComplete<T> is attached to.
      entries - The entries that should be used for completion.
      x - The x position of this widget on the screen.
      y - The y position of this widget on the screen.
      width - The width of this widget on the screen.
      suggestionHeight - The height of each individual suggestion. Recommended to be Font#lineHeight + 2
    • AutoComplete

      public AutoComplete(SearchableType<T> type, AutoCompletingEditBox<T> editBox, Supplier<List<T>> entries, int x, int y, int width, int suggestionHeight, int maxSuggestions)
      Create a new AutoComplete with the given values.
      Parameters:
      type - The SearchableType<T> that this AutoComplete<T> completes for.
      editBox - The attached AutoCompletingEditBox<T> that this AutoComplete<T> is attached to.
      entries - The entries that should be used for completion.
      x - The x position of this widget on the screen.
      y - The y position of this widget on the screen.
      width - The width of this widget on the screen.
      suggestionHeight - The height of each individual suggestion.
      maxSuggestions - How many suggestions to show.
  • Method Details

    • accept

      public void accept(String value)
      Compiles suggestions for the given value.
      Specified by:
      accept in interface Consumer<T>
      Parameters:
      value - the input argument
    • isMouseOver

      public boolean isMouseOver(double xpos, double ypos)
      Specified by:
      isMouseOver in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      isMouseOver in class net.minecraft.client.gui.components.AbstractWidget
    • mouseScrolled

      public boolean mouseScrolled(double xpos, double ypos, double xDelta, double yDelta)
      Specified by:
      mouseScrolled in interface net.minecraft.client.gui.components.events.GuiEventListener
    • mouseClicked

      public boolean mouseClicked(net.minecraft.client.input.MouseButtonEvent event, boolean doubleClick)
      Specified by:
      mouseClicked in interface net.minecraft.client.gui.components.events.GuiEventListener
      Overrides:
      mouseClicked in class net.minecraft.client.gui.components.AbstractWidget
    • insertSuggestion

      public void insertSuggestion()
      Inserts the currently selected suggestion into attached AutoCompletingEditBox<T>.
    • renderWidget

      public void renderWidget(net.minecraft.client.gui.GuiGraphics guiGraphics, int mx, int my, float partial)
      Specified by:
      renderWidget in class net.minecraft.client.gui.components.AbstractWidget
    • scrollUp

      public void scrollUp()
      Scrolls the current suggestions up by 1.
    • scrollUp

      public void scrollUp(int amount)
      Scrolls the current suggestions up by the given amount.
      Parameters:
      amount - The amount to scroll by.
    • scrollDown

      public void scrollDown()
      Scrolls the current suggestions down by 1.
    • scrollDown

      public void scrollDown(int amount)
      Scrolls the current suggestions down by the given amount.
      Parameters:
      amount - The amount to scroll by.
    • maxSuggestions

      public int maxSuggestions()
    • editBox

      public AutoCompletingEditBox<T> editBox()
    • updateWidgetNarration

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