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 Summary
FieldsModifier and TypeFieldDescriptionprivate final CreativeModeTab.ItemDisplayParametersprivate final InsertableLinkedOpenCustomHashSet<ItemStack> private final InsertableLinkedOpenCustomHashSet<ItemStack> private final CreativeModeTabprivate final ResourceKey<CreativeModeTab> -
Constructor Summary
ConstructorsConstructorDescriptionBuildCreativeModeTabContentsEvent(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.ItemDisplayParameters parameters, InsertableLinkedOpenCustomHashSet<ItemStack> parentEntries, InsertableLinkedOpenCustomHashSet<ItemStack> searchEntries) -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(ItemStack newEntry, CreativeModeTab.TabVisibility visibility) Inserts a new stack at the end of the given tab at this point in time.private voidassertNewEntryDoesNotAlreadyExists(InsertableLinkedOpenCustomHashSet<ItemStack> setToCheck, ItemStack newEntry) private static voidassertStackCount(ItemStack newEntry) private voidassertTargetExists(InsertableLinkedOpenCustomHashSet<ItemStack> setToCheck, ItemStack existingEntry) getFlags()Returns the enabled feature flags.Returns the item display parameters.it.unimi.dsi.fastutil.objects.ObjectSortedSet<ItemStack> Returns an unmodifiable view of the ordered set of the parent tab entries, in the order to be added to the creative menu..it.unimi.dsi.fastutil.objects.ObjectSortedSet<ItemStack> Returns an unmodifiable view of the ordered set of the search tab entries, in the order to be added to the creative menu..getTab()Returns the creative mode tab currently populating its contents.Returns the key of the creative mode tab currently populating its contents.booleanReturns whether the operator-only items should be shown.voidinsertAfter(ItemStack existingEntry, ItemStack newEntry, CreativeModeTab.TabVisibility visibility) Inserts a new stack after the specified existing entry.voidinsertBefore(ItemStack existingEntry, ItemStack newEntry, CreativeModeTab.TabVisibility visibility) Inserts the new entry before the specified existing entry.voidinsertFirst(ItemStack newEntry, CreativeModeTab.TabVisibility visibility) Inserts a new stack at the front of the tab's content.(package private) static booleanisParentTab(CreativeModeTab.TabVisibility visibility) (package private) static booleanisSearchTab(CreativeModeTab.TabVisibility visibility) voidremove(ItemStack existingEntry, CreativeModeTab.TabVisibility visibility) Removes an entry from the tab's content.voidremoveIf(Predicate<? super ItemStack> predicate, CreativeModeTab.TabVisibility visibility) Remove all entries that match the given predicate from the tab's content.
-
Field Details
-
tab
-
parameters
-
parentEntries
-
searchEntries
-
tabKey
-
-
Constructor Details
-
BuildCreativeModeTabContentsEvent
@Internal public BuildCreativeModeTabContentsEvent(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.ItemDisplayParameters parameters, InsertableLinkedOpenCustomHashSet<ItemStack> parentEntries, InsertableLinkedOpenCustomHashSet<ItemStack> searchEntries)
-
-
Method Details
-
getTab
Returns the creative mode tab currently populating its contents.- Returns:
- the creative mode tab currently populating its contents
-
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
Returns the enabled feature flags.- Returns:
- the enabled feature flags
-
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
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
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
Inserts a new stack at the end of the given tab at this point in time.- Specified by:
acceptin interfaceCreativeModeTab.Output- Parameters:
newEntry- the entry to be addedvisibility- 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 entrynewEntry- 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 entrynewEntry- 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
Inserts a new stack at the front of the tab's content.- Parameters:
newEntry- the stack to be addedvisibility- 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
Removes an entry from the tab's content.- Parameters:
existingEntry- the stack to be removedvisibility- 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 predicatevisibility- the target tab visibility
-
isParentTab
-
isSearchTab
-
assertTargetExists
private void assertTargetExists(InsertableLinkedOpenCustomHashSet<ItemStack> setToCheck, ItemStack existingEntry) -
assertNewEntryDoesNotAlreadyExists
private void assertNewEntryDoesNotAlreadyExists(InsertableLinkedOpenCustomHashSet<ItemStack> setToCheck, ItemStack newEntry) -
assertStackCount
-