Package net.neoforged.neoforge.event
Class BuildCreativeModeTabContentsEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent
- All Implemented Interfaces:
CreativeModeTab.Output
,net.neoforged.fml.event.IModBusEvent
public final class BuildCreativeModeTabContentsEvent
extends net.neoforged.bus.api.Event
implements net.neoforged.fml.event.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.ItemDisplayParameters
private final InsertableLinkedOpenCustomHashSet
<ItemStack> private final InsertableLinkedOpenCustomHashSet
<ItemStack> private final CreativeModeTab
private final ResourceKey
<CreativeModeTab> -
Constructor Summary
ConstructorsConstructorDescriptionBuildCreativeModeTabContentsEvent
(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.ItemDisplayParameters parameters, InsertableLinkedOpenCustomHashSet<ItemStack> parentEntries, InsertableLinkedOpenCustomHashSet<ItemStack> searchEntries) -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(ItemStack newEntry, CreativeModeTab.TabVisibility visibility) Inserts the new stack at the end of the given tab at this point in time.private void
assertNewEntryDoesNotAlreadyExists
(InsertableLinkedOpenCustomHashSet<ItemStack> setToCheck, ItemStack newEntry) private static void
assertStackCount
(ItemStack newEntry) private void
assertTargetExists
(InsertableLinkedOpenCustomHashSet<ItemStack> setToCheck, ItemStack existingEntry) getFlags()
it.unimi.dsi.fastutil.objects.ObjectSortedSet
<ItemStack> The current immutable ordered set of the parent tab entries in the order to be added to the Creative Menu.it.unimi.dsi.fastutil.objects.ObjectSortedSet
<ItemStack> The current immutable 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.boolean
void
insertAfter
(ItemStack existingEntry, ItemStack newEntry, CreativeModeTab.TabVisibility visibility) Inserts the new entry after the specified existing entry.void
insertBefore
(ItemStack existingEntry, ItemStack newEntry, CreativeModeTab.TabVisibility visibility) Inserts the new entry before the specified existing entry.void
insertFirst
(ItemStack newEntry, CreativeModeTab.TabVisibility visibility) Inserts the new entry in the front of the tab's content.(package private) static boolean
isParentTab
(CreativeModeTab.TabVisibility visibility) (package private) static boolean
isSearchTab
(CreativeModeTab.TabVisibility visibility) void
remove
(ItemStack existingEntry, CreativeModeTab.TabVisibility visibility) Removes an entry 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
-
getParameters
-
hasPermissions
public boolean hasPermissions() -
getParentEntries
The current immutable ordered set of the parent tab entries in the order to be added to the Creative Menu. Purely for querying to see what in it. Please use the other event methods for modifications. -
getSearchEntries
The current immutable ordered set of the search tab entries in the order to be added to the Creative Menu. Purely for querying to see what in it. Please use the other event methods for modifications. -
accept
Inserts the new stack at the end of the given tab at this point in time.- Specified by:
accept
in interfaceCreativeModeTab.Output
- Throws:
IllegalArgumentException
- if the new itemstack's count is not 1 or entry already was added to the tab previously.
-
insertAfter
public void insertAfter(ItemStack existingEntry, ItemStack newEntry, CreativeModeTab.TabVisibility visibility) Inserts the new entry after the specified existing entry.- Throws:
IllegalArgumentException
- if the new itemstack's count is not 1 or target does not exist in set OR if the existing entry is not found in the tab's lists.
-
insertBefore
public void insertBefore(ItemStack existingEntry, ItemStack newEntry, CreativeModeTab.TabVisibility visibility) Inserts the new entry before the specified existing entry.- Throws:
IllegalArgumentException
- if the new itemstack's count is not 1 or target does not exist in set OR if the existing entry is not found in the tab's lists.
-
insertFirst
Inserts the new entry in the front of the tab's content.- Throws:
IllegalArgumentException
- if the new itemstack's count is not 1 or entry already was added to the tab previously.
-
remove
Removes an entry from the tab's content. -
isParentTab
-
isSearchTab
-
assertTargetExists
private void assertTargetExists(InsertableLinkedOpenCustomHashSet<ItemStack> setToCheck, ItemStack existingEntry) -
assertNewEntryDoesNotAlreadyExists
private void assertNewEntryDoesNotAlreadyExists(InsertableLinkedOpenCustomHashSet<ItemStack> setToCheck, ItemStack newEntry) -
assertStackCount
-