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 Renderable, NarratableEntry
  • Field Details

    • NO_TAB

      private static final int NO_TAB
      See Also:
    • MAX_WIDTH

      private static final int MAX_WIDTH
      See Also:
    • HEIGHT

      private static final int HEIGHT
      See Also:
    • MARGIN

      private static final int MARGIN
      See Also:
    • USAGE_NARRATION

      private static final Component USAGE_NARRATION
    • layout

      private final LinearLayout layout
    • width

      private int width
    • tabManager

      private final TabManager tabManager
    • tabs

      private final com.google.common.collect.ImmutableList<Tab> tabs
    • tabButtons

      private final com.google.common.collect.ImmutableList<TabButton> tabButtons
  • Constructor Details

  • Method Details

    • builder

      public static TabNavigationBar.Builder builder(TabManager pTabManager, int pWidth)
    • setWidth

      public void setWidth(int pWidth)
    • setFocused

      public void setFocused(boolean pFocused)
      Sets the focus state of the GUI element.
      Specified by:
      setFocused in interface ContainerEventHandler
      Specified by:
      setFocused in interface GuiEventListener
      Parameters:
      pFocused - true to apply focus, false to remove focus
    • setFocused

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

      @Nullable public ComponentPath nextFocusPath(FocusNavigationEvent pEvent)
      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:
      pEvent - 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
    • narrationPriority

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

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

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

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

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

      public void arrangeElements()
    • selectTab

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

      public boolean keyPressed(int pKeycode)
      Handles key pressed events.

      Parameters:
      pKeycode - the keycode of the pressed key.
      Returns:
      true if the key press was handled, false otherwise.
    • getNextTabIndex

      private int getNextTabIndex(int pKeycode)
      Returns the index of the next tab based on the given key code.

      Parameters:
      pKeycode - the keycode of the pressed key.
      Returns:
      the index of the next tab, or -1 if no valid tab index is found.
    • currentTabIndex

      private int currentTabIndex()
    • currentTabButton

      @Nullable private TabButton currentTabButton()