Package net.neoforged.neoforge.event
Class BuildCreativeModeTabContentsEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent
- All Implemented Interfaces:
net.minecraft.world.item.CreativeModeTab.Output
,net.neoforged.fml.event.IModBusEvent
public final class BuildCreativeModeTabContentsEvent
extends net.neoforged.bus.api.Event
implements net.neoforged.fml.event.IModBusEvent, net.minecraft.world.item.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 net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters
private final InsertableLinkedOpenCustomHashSet
<net.minecraft.world.item.ItemStack> private final InsertableLinkedOpenCustomHashSet
<net.minecraft.world.item.ItemStack> private final net.minecraft.world.item.CreativeModeTab
private final net.minecraft.resources.ResourceKey
<net.minecraft.world.item.CreativeModeTab> -
Constructor Summary
ConstructorsConstructorDescriptionBuildCreativeModeTabContentsEvent
(net.minecraft.world.item.CreativeModeTab tab, net.minecraft.resources.ResourceKey<net.minecraft.world.item.CreativeModeTab> tabKey, net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters parameters, InsertableLinkedOpenCustomHashSet<net.minecraft.world.item.ItemStack> parentEntries, InsertableLinkedOpenCustomHashSet<net.minecraft.world.item.ItemStack> searchEntries) -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(net.minecraft.world.item.ItemStack newEntry, net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) Inserts the new stack at the end of the given tab at this point in time.private void
assertNewEntryDoesNotAlreadyExists
(InsertableLinkedOpenCustomHashSet<net.minecraft.world.item.ItemStack> setToCheck, net.minecraft.world.item.ItemStack newEntry) private static void
assertStackCount
(net.minecraft.world.item.ItemStack newEntry) private void
assertTargetExists
(InsertableLinkedOpenCustomHashSet<net.minecraft.world.item.ItemStack> setToCheck, net.minecraft.world.item.ItemStack existingEntry) net.minecraft.world.flag.FeatureFlagSet
getFlags()
net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters
it.unimi.dsi.fastutil.objects.ObjectSortedSet
<net.minecraft.world.item.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
<net.minecraft.world.item.ItemStack> The current immutable ordered set of the search tab entries in the order to be added to the Creative Menu.net.minecraft.world.item.CreativeModeTab
getTab()
Returns the creative mode tab currently populating its contents.net.minecraft.resources.ResourceKey
<net.minecraft.world.item.CreativeModeTab> Returns the key of the creative mode tab currently populating its contents.boolean
void
insertAfter
(net.minecraft.world.item.ItemStack existingEntry, net.minecraft.world.item.ItemStack newEntry, net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) Inserts the new entry after the specified existing entry.void
insertBefore
(net.minecraft.world.item.ItemStack existingEntry, net.minecraft.world.item.ItemStack newEntry, net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) Inserts the new entry before the specified existing entry.void
insertFirst
(net.minecraft.world.item.ItemStack newEntry, net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) Inserts the new entry in the front of the tab's content.(package private) static boolean
isParentTab
(net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) (package private) static boolean
isSearchTab
(net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) void
remove
(net.minecraft.world.item.ItemStack existingEntry, net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) Removes an entry from the tab's content.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.world.item.CreativeModeTab.Output
accept, accept, accept, acceptAll, acceptAll
-
Field Details
-
tab
private final net.minecraft.world.item.CreativeModeTab tab -
parameters
private final net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters parameters -
parentEntries
-
searchEntries
-
tabKey
private final net.minecraft.resources.ResourceKey<net.minecraft.world.item.CreativeModeTab> tabKey
-
-
Constructor Details
-
BuildCreativeModeTabContentsEvent
@Internal public BuildCreativeModeTabContentsEvent(net.minecraft.world.item.CreativeModeTab tab, net.minecraft.resources.ResourceKey<net.minecraft.world.item.CreativeModeTab> tabKey, net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters parameters, InsertableLinkedOpenCustomHashSet<net.minecraft.world.item.ItemStack> parentEntries, InsertableLinkedOpenCustomHashSet<net.minecraft.world.item.ItemStack> searchEntries)
-
-
Method Details
-
getTab
public net.minecraft.world.item.CreativeModeTab getTab()Returns the creative mode tab currently populating its contents.- Returns:
- the creative mode tab currently populating its contents
-
getTabKey
public net.minecraft.resources.ResourceKey<net.minecraft.world.item.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 net.minecraft.world.flag.FeatureFlagSet getFlags() -
getParameters
public net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters getParameters() -
hasPermissions
public boolean hasPermissions() -
getParentEntries
public it.unimi.dsi.fastutil.objects.ObjectSortedSet<net.minecraft.world.item.ItemStack> 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
public it.unimi.dsi.fastutil.objects.ObjectSortedSet<net.minecraft.world.item.ItemStack> 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
public void accept(net.minecraft.world.item.ItemStack newEntry, net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) Inserts the new stack at the end of the given tab at this point in time.- Specified by:
accept
in interfacenet.minecraft.world.item.CreativeModeTab.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(net.minecraft.world.item.ItemStack existingEntry, net.minecraft.world.item.ItemStack newEntry, net.minecraft.world.item.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(net.minecraft.world.item.ItemStack existingEntry, net.minecraft.world.item.ItemStack newEntry, net.minecraft.world.item.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
public void insertFirst(net.minecraft.world.item.ItemStack newEntry, net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) 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
public void remove(net.minecraft.world.item.ItemStack existingEntry, net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) Removes an entry from the tab's content. -
isParentTab
static boolean isParentTab(net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) -
isSearchTab
static boolean isSearchTab(net.minecraft.world.item.CreativeModeTab.TabVisibility visibility) -
assertTargetExists
private void assertTargetExists(InsertableLinkedOpenCustomHashSet<net.minecraft.world.item.ItemStack> setToCheck, net.minecraft.world.item.ItemStack existingEntry) -
assertNewEntryDoesNotAlreadyExists
private void assertNewEntryDoesNotAlreadyExists(InsertableLinkedOpenCustomHashSet<net.minecraft.world.item.ItemStack> setToCheck, net.minecraft.world.item.ItemStack newEntry) -
assertStackCount
private static void assertStackCount(net.minecraft.world.item.ItemStack newEntry)
-