Skip to content

Commit

Permalink
Merge pull request #20 from imreallybadatnames/1.20.1
Browse files Browse the repository at this point in the history
JEI fixes
  • Loading branch information
DaFuqs authored Jun 21, 2024
2 parents 521101c + 6c8509d commit 3f70868
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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<CloakSetChanged> 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<Item> addedCloaks, Set<Item> removedCloaks, Set<Item> newCloaks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
});
}
Expand All @@ -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()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3f70868

Please sign in to comment.