Class BuildCreativeModeTabContentsEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent
All Implemented Interfaces:
CreativeModeTab.Output, IModBusEvent

public final class BuildCreativeModeTabContentsEvent extends net.neoforged.bus.api.Event implements IModBusEvent, CreativeModeTab.Output

Fired when the contents of a specific creative mode tab are being populated in CreativeModeTab.buildContents(CreativeModeTab.ItemDisplayParameters).

This event may be fired multiple times if the operator status of the local player or enabled feature flags changes.

In vanilla, this is only fired on the logical client, but mods may request creative mode tab contents on the server.

  • Field Details

  • Constructor Details

  • Method Details

    • getTab

      public CreativeModeTab getTab()
      Returns the creative mode tab currently populating its contents.
      Returns:
      the creative mode tab currently populating its contents
    • getTabKey

      public ResourceKey<CreativeModeTab> getTabKey()
      Returns the key of the creative mode tab currently populating its contents.
      Returns:
      the key of the creative mode tab currently populating its contents
    • getFlags

      public FeatureFlagSet getFlags()
      Returns the enabled feature flags.
      Returns:
      the enabled feature flags
    • getParameters

      public CreativeModeTab.ItemDisplayParameters getParameters()
      Returns the item display parameters.
      Returns:
      the item display parameters
    • hasPermissions

      public boolean hasPermissions()
      Returns whether the operator-only items should be shown.
      Returns:
      whether the operator-only items should be shown
      See Also:
    • getParentEntries

      public it.unimi.dsi.fastutil.objects.ObjectSortedSet<ItemStack> getParentEntries()
      Returns an unmodifiable view of the ordered set of the parent tab entries, in the order to be added to the creative menu..
      Returns:
      an unmodifiable view of the ordered set of the parent tab entries, in the order to be added to the creative menu.
    • getSearchEntries

      public it.unimi.dsi.fastutil.objects.ObjectSortedSet<ItemStack> getSearchEntries()
      Returns an unmodifiable view of the ordered set of the search tab entries, in the order to be added to the creative menu..
      Returns:
      an unmodifiable view of the ordered set of the search tab entries, in the order to be added to the creative menu.
    • accept

      public void accept(ItemStack newEntry, CreativeModeTab.TabVisibility visibility)
      Inserts a new stack at the end of the given tab at this point in time.
      Specified by:
      accept in interface CreativeModeTab.Output
      Parameters:
      newEntry - the entry to be added
      visibility - the target tab visibility
      Throws:
      IllegalArgumentException - if the new stack's count is not 1, or the new stack already exists in the tab
    • insertAfter

      public void insertAfter(ItemStack existingEntry, ItemStack newEntry, CreativeModeTab.TabVisibility visibility)
      Inserts a new stack after the specified existing entry.
      Parameters:
      existingEntry - the existing entry
      newEntry - the stack to be added (after the existing entry)
      visibility - the target tab visibility
      Throws:
      IllegalArgumentException - if the new stack's count is not 1, or if the new stack already exists in the tab, or if the existing entry is not found in the tab
    • insertBefore

      public void insertBefore(ItemStack existingEntry, ItemStack newEntry, CreativeModeTab.TabVisibility visibility)
      Inserts the new entry before the specified existing entry.
      Parameters:
      existingEntry - the existing entry
      newEntry - the stack to be added (before the existing entry)
      visibility - the target tab visibility
      Throws:
      IllegalArgumentException - if the new stack's count is not 1, or if the new stack already exists in the tab, or if the existing entry is not found in the tab
    • insertFirst

      public void insertFirst(ItemStack newEntry, CreativeModeTab.TabVisibility visibility)
      Inserts a new stack at the front of the tab's content.
      Parameters:
      newEntry - the stack to be added
      visibility - the target tab visibility
      Throws:
      IllegalArgumentException - if the new stack's count is not 1, or if the new stack already exists in the tab
    • remove

      public void remove(ItemStack existingEntry, CreativeModeTab.TabVisibility visibility)
      Removes an entry from the tab's content.
      Parameters:
      existingEntry - the stack to be removed
      visibility - the target tab visibility
    • removeIf

      public void removeIf(Predicate<? super ItemStack> predicate, CreativeModeTab.TabVisibility visibility)
      Remove all entries that match the given predicate from the tab's content.
      Parameters:
      predicate - the item stack predicate
      visibility - the target tab visibility
    • isParentTab

      static boolean isParentTab(CreativeModeTab.TabVisibility visibility)
    • isSearchTab

      static boolean isSearchTab(CreativeModeTab.TabVisibility visibility)
    • assertTargetExists

      private void assertTargetExists(InsertableLinkedOpenCustomHashSet<ItemStack> setToCheck, ItemStack existingEntry)
    • assertNewEntryDoesNotAlreadyExists

      private void assertNewEntryDoesNotAlreadyExists(InsertableLinkedOpenCustomHashSet<ItemStack> setToCheck, ItemStack newEntry)
    • assertStackCount

      private static void assertStackCount(ItemStack newEntry)