diff --git a/src/main/java/de/dafuqs/revelationary/api/revelations/CloakSetChanged.java b/src/main/java/de/dafuqs/revelationary/api/revelations/CloakSetChanged.java index d855eff..e4a21e5 100644 --- a/src/main/java/de/dafuqs/revelationary/api/revelations/CloakSetChanged.java +++ b/src/main/java/de/dafuqs/revelationary/api/revelations/CloakSetChanged.java @@ -1,16 +1,22 @@ package de.dafuqs.revelationary.api.revelations; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; +import net.minecraft.client.MinecraftClient; import net.minecraft.item.Item; import java.util.Set; +@Environment(EnvType.CLIENT) @FunctionalInterface public interface CloakSetChanged { Event EVENT = EventFactory.createArrayBacked(CloakSetChanged.class, (listeners) -> (addedCloaks, removedCloaks, newCloaks) -> { - for (CloakSetChanged listener : listeners) listener.onChange(addedCloaks, removedCloaks, newCloaks); + MinecraftClient.getInstance().execute(() -> { + for (CloakSetChanged listener : listeners) listener.onChange(addedCloaks, removedCloaks, newCloaks); + }); }); // the diffs matter for JEI, the new cloaks set matters for REI void onChange(Set addedCloaks, Set removedCloaks, Set newCloaks); diff --git a/src/main/java/de/dafuqs/revelationary/compat/jei/RevelationaryJEIPlugin.java b/src/main/java/de/dafuqs/revelationary/compat/jei/RevelationaryJEIPlugin.java index 437570b..9f28521 100644 --- a/src/main/java/de/dafuqs/revelationary/compat/jei/RevelationaryJEIPlugin.java +++ b/src/main/java/de/dafuqs/revelationary/compat/jei/RevelationaryJEIPlugin.java @@ -24,10 +24,12 @@ public RevelationaryJEIPlugin() { stacksCache = newStacks; if (runtime != null) { var manager = runtime.getIngredientManager(); - manager.removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, - added.stream().map(ItemStack::new).collect(Collectors.toList())); - manager.addIngredientsAtRuntime(VanillaTypes.ITEM_STACK, - removed.stream().map(ItemStack::new).collect(Collectors.toList())); + if(added != null && !added.isEmpty()) + manager.removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, + added.stream().map(ItemStack::new).collect(Collectors.toList())); + if(removed != null && !removed.isEmpty()) + manager.addIngredientsAtRuntime(VanillaTypes.ITEM_STACK, + removed.stream().map(ItemStack::new).collect(Collectors.toList())); } }); } @@ -41,7 +43,7 @@ public RevelationaryJEIPlugin() { public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { runtime = jeiRuntime; if (!RevelationaryConfig.get().HideCloakedEntriesFromRecipeViewers) return; - if (stacksCache != null) runtime.getIngredientManager() + if (stacksCache != null && !stacksCache.isEmpty()) runtime.getIngredientManager() .removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, stacksCache.stream().map(ItemStack::new).collect(Collectors.toList())); } diff --git a/src/main/java/de/dafuqs/revelationary/compat/rei/RevelationaryREIPlugin.java b/src/main/java/de/dafuqs/revelationary/compat/rei/RevelationaryREIPlugin.java index 1db4445..93be5f2 100644 --- a/src/main/java/de/dafuqs/revelationary/compat/rei/RevelationaryREIPlugin.java +++ b/src/main/java/de/dafuqs/revelationary/compat/rei/RevelationaryREIPlugin.java @@ -28,8 +28,8 @@ public RevelationaryREIPlugin() { @Override public void registerBasicEntryFiltering(@SuppressWarnings("UnstableApiUsage") BasicFilteringRule rule) { // not using .show to not interfere with other filtering rules - //noinspection UnstableApiUsage if (!RevelationaryConfig.get().HideCloakedEntriesFromRecipeViewers) return; + //noinspection UnstableApiUsage filteringRule = rule.hide(() -> hiddenStacks.stream() .map(EntryStacks::of)