From a27be9cf41c39eff119be86c035b7611111610b0 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 11 Jun 2022 01:06:08 +0800 Subject: Fix #874 --- .../impl/common/entry/type/EntryRegistryImpl.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'runtime/src') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryRegistryImpl.java index 1aa49902b..28baa75c1 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryRegistryImpl.java @@ -36,6 +36,11 @@ import me.shedaniel.rei.api.client.overlay.ScreenOverlay; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.entry.comparison.ComparisonContext; +import me.shedaniel.rei.api.common.entry.type.EntryDefinition; +import me.shedaniel.rei.api.common.entry.type.EntryType; +import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry; +import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.registry.ReloadStage; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.api.common.util.EntryStacks; @@ -172,8 +177,19 @@ public class EntryRegistryImpl implements EntryRegistry { @Override public List appendStacksForItem(Item item) { NonNullList list = NonNullList.create(); - CreativeModeTab category = item.getItemCategory(); - item.fillItemCategory(MoreObjects.firstNonNull(category, CreativeModeTab.TAB_SEARCH), list); + LongSet set = new LongOpenHashSet(); + EntryDefinition itemDefinition = VanillaEntryTypes.ITEM.getDefinition(); + for (CreativeModeTab tab : CreativeModeTab.TABS) { + if (tab != CreativeModeTab.TAB_HOTBAR && tab != CreativeModeTab.TAB_INVENTORY) { + NonNullList tabList = NonNullList.create(); + item.fillItemCategory(tab, tabList); + for (ItemStack stack : tabList) { + if (set.add(itemDefinition.hash(null, stack, ComparisonContext.EXACT))) { + list.add(stack); + } + } + } + } if (list.isEmpty()) { return Collections.singletonList(item.getDefaultInstance()); } -- cgit