Class TabNavigationBar

java.lang.Object
net.minecraft.client.gui.components.events.AbstractContainerEventHandler
net.minecraft.client.gui.components.tabs.TabNavigationBar
All Implemented Interfaces:
ContainerEventHandler, GuiEventListener, Renderable, TabOrderedElement, NarratableEntry, NarrationSupplier

public class TabNavigationBar extends AbstractContainerEventHandler implements NarratableEntry, Renderable
  • Field Details

  • Constructor Details

  • Method Details

    • builder

      public static TabNavigationBar.Builder builder(TabManager tabManager, int width)
    • updateWidth

      public void updateWidth(int width)
    • isMouseOver

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

      Specified by:
      isMouseOver in interface GuiEventListener
      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.
    • setFocused

      public void setFocused(boolean focused)
      Sets the focus state of the GUI element.
      Specified by:
      setFocused in interface ContainerEventHandler
      Specified by:
      setFocused in interface GuiEventListener
      Parameters:
      focused - true to apply focus, false to remove focus
    • 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 AbstractContainerEventHandler
      Parameters:
      focused - the focused GUI element.
    • nextFocusPath

      public @Nullable ComponentPath nextFocusPath(FocusNavigationEvent navigationEvent)
      Retrieves the next focus path based on the given focus navigation event.

      Specified by:
      nextFocusPath in interface ContainerEventHandler
      Specified by:
      nextFocusPath in interface GuiEventListener
      Parameters:
      navigationEvent - the focus navigation event.
      Returns:
      the next focus path as a ComponentPath, or null if there is no next focus path.
    • children

      public List<? extends GuiEventListener> children()
      Specified by:
      children in interface ContainerEventHandler
    • getTabs

      public List<Tab> getTabs()
    • narrationPriority

      public NarratableEntry.NarrationPriority narrationPriority()
      Specified by:
      narrationPriority in interface NarratableEntry
    • updateNarration

      public void updateNarration(NarrationElementOutput output)
      Updates the narration output with the current narration information.
      Specified by:
      updateNarration in interface NarrationSupplier
      Parameters:
      output - the output to update with narration information.
    • narrateListElementPosition

      protected void narrateListElementPosition(NarrationElementOutput output, TabButton widget)
      Narrates the position of a list element (tab button).
      Parameters:
      output - the narration output to update.
      widget - the tab button whose position is being narrated.
    • render

      public void render(GuiGraphics graphics, int mouseX, int mouseY, float a)
      Renders the graphical user interface (GUI) element.
      Specified by:
      render in interface Renderable
      Parameters:
      graphics - the GuiGraphics object used for rendering.
      mouseX - the x-coordinate of the mouse cursor.
      mouseY - the y-coordinate of the mouse cursor.
      a - the partial tick time.
    • getRectangle

      public ScreenRectangle getRectangle()
      Specified by:
      getRectangle in interface GuiEventListener
    • arrangeElements

      public void arrangeElements()
    • selectTab

      public void selectTab(int index, boolean playSound)
      Selects the tab at the specified index.
      Parameters:
      index - the index of the tab to select.
      playSound - whether to play a click sound when selecting the tab.
    • setTabActiveState

      public void setTabActiveState(int index, boolean active)
    • setTabTooltip

      public void setTabTooltip(int index, @Nullable Tooltip hint)
    • keyPressed

      public boolean keyPressed(KeyEvent event)
      Specified by:
      keyPressed in interface ContainerEventHandler
      Specified by:
      keyPressed in interface GuiEventListener
    • getNextTabIndex

      private int getNextTabIndex(KeyEvent event)
    • getNextTabIndex

      private int getNextTabIndex(int currentTab, KeyEvent event)
    • currentTabIndex

      private int currentTabIndex()
    • currentTabButton

      private @Nullable TabButton currentTabButton()