diff options
| author | shedaniel <daniel@shedaniel.me> | 2023-11-02 16:03:44 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2023-11-02 16:05:35 +0800 |
| commit | 11b87fdd96f5542d646aa8f5136095917f207564 (patch) | |
| tree | b11c8db175d900d742feb86125928d6dbff890be /default-plugin | |
| parent | b81619d917d472615cd027eca3b408113c7f6750 (diff) | |
| parent | 48db9a4d892888bc80bcfd53ef50b8f304937e2f (diff) | |
| download | RoughlyEnoughItems-11b87fdd96f5542d646aa8f5136095917f207564.tar.gz RoughlyEnoughItems-11b87fdd96f5542d646aa8f5136095917f207564.tar.bz2 RoughlyEnoughItems-11b87fdd96f5542d646aa8f5136095917f207564.zip | |
Merge remote-tracking branch 'origin/12.x-1.20' into 13.x-1.20.2
# Conflicts:
# fabric/src/main/resources/roughlyenoughitems.accessWidener
Diffstat (limited to 'default-plugin')
| -rw-r--r-- | default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java index d18033475..ea61c622f 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java @@ -41,7 +41,6 @@ import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry; import me.shedaniel.rei.api.client.registry.transfer.simple.SimpleTransferHandler; -import me.shedaniel.rei.api.common.display.basic.BasicDisplay; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.EntryIngredients; @@ -105,6 +104,7 @@ import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; import org.jetbrains.annotations.ApiStatus; +import java.lang.reflect.InvocationTargetException; import java.util.*; import java.util.function.Supplier; import java.util.function.UnaryOperator; @@ -129,28 +129,19 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin @Override public void registerEntries(EntryRegistry registry) { - if (Minecraft.getInstance().player == null || Minecraft.getInstance().player.connection == null) - return; - Minecraft.getInstance().executeBlocking(() -> { - CreativeModeTabs.tryRebuildTabContents(Minecraft.getInstance().player.connection.enabledFeatures(), - Minecraft.getInstance().options.operatorItemsTab().get() && Minecraft.getInstance().player.canUseGameMasterBlocks(), - BasicDisplay.registryAccess()); - }); Multimap<Item, EntryStack<ItemStack>> items = Multimaps.newListMultimap(new Reference2ObjectOpenHashMap<>() , ArrayList::new); - for (CreativeModeTab tab : CreativeModeTabs.allTabs()) { - if (tab.getType() != CreativeModeTab.Type.HOTBAR && tab.getType() != CreativeModeTab.Type.INVENTORY) { - try { - for (ItemStack stack : tab.getDisplayItems()) { - try { - items.put(stack.getItem(), EntryStacks.of(stack)); - } catch (Exception ignore) { - } + for (Map.Entry<CreativeModeTab, Collection<ItemStack>> entry : collectTabs().entrySet()) { + try { + for (ItemStack stack : entry.getValue()) { + try { + items.put(stack.getItem(), EntryStacks.of(stack)); + } catch (Exception ignore) { } - } catch (Exception exception) { - exception.printStackTrace(); } + } catch (Exception exception) { + exception.printStackTrace(); } } @@ -175,6 +166,17 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin } } + private static Map<CreativeModeTab, Collection<ItemStack>> collectTabs() { + try { + return (Map<CreativeModeTab, Collection<ItemStack>>) Class.forName(Platform.isForge() ? "me.shedaniel.rei.impl.client.forge.CreativeModeTabCollectorImpl" + : "me.shedaniel.rei.impl.client.fabric.CreativeModeTabCollectorImpl") + .getDeclaredMethod("collectTabs") + .invoke(null); + } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + @Override public void registerCategories(CategoryRegistry registry) { registry.add( |
