Class Tabs.TabSpec

java.lang.Object
com.trevlar.menukit.api.element.Tabs.TabSpec
Enclosing class:
Tabs

public static final class Tabs.TabSpec extends Object
A tab under construction.
  • Method Details

    • id

      public String id()
    • label

      public Tabs.TabSpec label(net.minecraft.network.chat.Component label)
    • icon

      public Tabs.TabSpec icon(Supplier<@Nullable net.minecraft.resources.Identifier> texture, int textureSize, int drawSize)
      An icon drawSize px square left of the label, Tabs.ICON_LABEL_GAP from it: a standalone square texture textureSize texels on a side (a mod's icon read from its jar into a DynamicTexture, say), drawn whole and scaled, as Icon.Builder.texture(Supplier, int) draws it. Read every frame; null draws nothing and keeps the room, so the tab does not change width while its texture loads. The tab widens by the icon and gap, and in every mode the icon and label are placed as one group. Default: none.
    • icon

      public Tabs.TabSpec icon(net.minecraft.resources.Identifier sprite, int drawSize)
      icon(Supplier, int, int) with a GUI-atlas sprite (textures/gui/sprites) for the picture.
    • visibleWhen

      public Tabs.TabSpec visibleWhen(BooleanSupplier visibleWhen)
      Read every frame; a change relays out the strip. Default: always shown.
    • body

      public Tabs.TabSpec body(List<PanelElement> body)
      The body: elements positioned from the body's top-left. For the owner's own tabs.
    • body

      public Tabs.TabSpec body(Supplier<List<PanelElement>> factory)
      The body as a factory, run each time the menu is built, so the body's elements are fresh and read the current config. Required for a tab added with Tabs.addTo(Identifier, Tabs.TabSpec); fine for the owner's tabs too.
    • standIn

      public Tabs.TabSpec standIn()
      Owner only: this tab stands in for one another mod may add. A tab added to the menu with the same id takes this one's place, label and body; with nothing to replace it, the tab shows with a dimmed label and this body, typically a line saying which mod to install.

      Only the place carries over. The replacement keeps its own visibleWhen, or always shows if it has none: a stand-in's visibility is about advertising the missing mod (an owner's "hide the companion's tabs" switch), not about the real feature once it is there.

    • after

      public Tabs.TabSpec after(String id)
      For a tab added with Tabs.addTo(Identifier, Tabs.TabSpec): place it right after the tab with this id.
    • before

      public Tabs.TabSpec before(String id)
      For a tab added with Tabs.addTo(Identifier, Tabs.TabSpec): place it right before the tab with this id.