mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-24 22:14:32 +00:00
Moved ForgeHooksClient.onCreativeModeTabBuildContents to ForgeHooks to fix #9662
This commit is contained in:
1 parent
2745531f08
commit
881725c7d5
3 files changed
+32
-20
No files matched your search
@@ -134,7 +134,9 @@ import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.common.util.BrainBuilder;
|
||||
import net.minecraftforge.common.util.Lazy;
|
||||
import net.minecraftforge.common.util.MavenVersionStringHelper;
|
||||
import net.minecraftforge.common.util.MutableHashedLinkedMap;
|
||||
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.event.DifficultyChangeEvent;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.event.GrindstoneEvent;
|
||||
@@ -1604,4 +1606,27 @@ public class ForgeHooks
|
||||
entity.stopRiding();
|
||||
}
|
||||
}
|
||||
|
||||
public static void onCreativeModeTabBuildContents(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output)
|
||||
{
|
||||
final var entries = new MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility>(ItemStackLinkedSet.TYPE_AND_TAG,
|
||||
(key, left, right) -> {
|
||||
//throw new IllegalStateException("Accidentally adding the same item stack twice " + key.getDisplayName().getString() + " to a Creative Mode Tab: " + tab.getDisplayName().getString());
|
||||
// Vanilla adds enchanting books twice in both visibilities.
|
||||
// This is just code cleanliness for them. For us lets just increase the visibility and merge the entries.
|
||||
return CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS;
|
||||
}
|
||||
);
|
||||
|
||||
originalGenerator.accept(params, (stack, vis) -> {
|
||||
if (stack.getCount() != 1)
|
||||
throw new IllegalArgumentException("The stack count must be 1");
|
||||
entries.put(stack, vis);
|
||||
});
|
||||
|
||||
ModLoader.get().postEvent(new BuildCreativeModeTabContentsEvent(tab, tabKey, params, entries));
|
||||
|
||||
for (var entry : entries)
|
||||
output.accept(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user