diff --git a/src/main/java/vazkii/quark/base/handler/RecipeCrawlHandler.java b/src/main/java/vazkii/quark/base/handler/RecipeCrawlHandler.java index b233a8e700..728bb3859b 100644 --- a/src/main/java/vazkii/quark/base/handler/RecipeCrawlHandler.java +++ b/src/main/java/vazkii/quark/base/handler/RecipeCrawlHandler.java @@ -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; @@ -31,8 +32,9 @@ public class RecipeCrawlHandler { private static Multimap recipeDigestion = HashMultimap.create(); private static Multimap 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) { @@ -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()); } @@ -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;