Skip to content

Commit

Permalink
close #4300, #4343
Browse files Browse the repository at this point in the history
  • Loading branch information
yrsegal committed Sep 29, 2023
1 parent 58c4ed6 commit c6444bd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/vazkii/quark/base/handler/RecipeCrawlHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.world.item.crafting.*;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.AddReloadListenerEvent;
import net.minecraftforge.event.TagsUpdatedEvent;
import net.minecraftforge.event.TickEvent.ServerTickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
Expand All @@ -31,8 +32,9 @@ public class RecipeCrawlHandler {
private static Multimap<Item, ItemStack> recipeDigestion = HashMultimap.create();
private static Multimap<Item, ItemStack> backwardsDigestion = HashMultimap.create();

private static Object mutex = new Object();
private static final Object mutex = new Object();
private static boolean needsCrawl = false;
private static boolean mayCrawl = false;

@SubscribeEvent
public static void addListener(AddReloadListenerEvent event) {
Expand All @@ -50,7 +52,13 @@ public static void addListener(AddReloadListenerEvent event) {
});
}

@SubscribeEvent
public static void tagsHaveUpdated(TagsUpdatedEvent event) {
mayCrawl = true;
}

private static void clear() {
mayCrawl = false;
MinecraftForge.EVENT_BUS.post(new RecipeCrawlEvent.Reset());
}

Expand Down Expand Up @@ -94,7 +102,7 @@ else if (recipe instanceof AbstractCookingRecipe acr)
@SubscribeEvent
public static void onTick(ServerTickEvent tick) {
synchronized(mutex) {
if(needsCrawl) {
if(mayCrawl && needsCrawl) {
RecipeManager manager = tick.getServer().getRecipeManager();
load(manager);
needsCrawl = false;
Expand Down

0 comments on commit c6444bd

Please sign in to comment.