From a21f32a4b3fa0a624f1a739744b636f550854d28 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 26 Apr 2020 19:37:15 +0200 Subject: [PATCH] possibly finally fixed that recipe tag issue --- .../de/ellpeck/naturesaura/NaturesAura.java | 1 - .../naturesaura/events/CommonEvents.java | 14 +++++++++++++- .../naturesaura/recipes/ModRecipes.java | 18 ++++++++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index 6b2c3b74..1cbd325f 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -82,7 +82,6 @@ public final class NaturesAura { ModRegistry.init(); DrainSpotEffects.init(); - DeferredWorkQueue.runLater(ModRecipes::init); proxy.init(event); } diff --git a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java index e7b1db27..f81fdd5a 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -12,9 +12,13 @@ import de.ellpeck.naturesaura.chunk.AuraChunkProvider; import de.ellpeck.naturesaura.commands.CommandAura; import de.ellpeck.naturesaura.misc.WorldData; import de.ellpeck.naturesaura.packet.PacketHandler; +import de.ellpeck.naturesaura.recipes.ModRecipes; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.profiler.IProfiler; +import net.minecraft.resources.IFutureReloadListener; +import net.minecraft.resources.IResourceManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; @@ -28,12 +32,15 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.ChunkWatchEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; +import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; public class CommonEvents { @@ -126,7 +133,12 @@ public class CommonEvents { } @SubscribeEvent - public void onServerAboutToStartEvent(FMLServerStartingEvent event) { + public void onServerStarting(FMLServerStartingEvent event) { CommandAura.register(event.getCommandDispatcher()); } + + @SubscribeEvent + public void onServerAboutToStart(FMLServerAboutToStartEvent event) { + event.getServer().getResourceManager().addReloadListener(new ModRecipes()); + } } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index 9095e2f3..4ccb8695 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -14,6 +14,7 @@ import de.ellpeck.naturesaura.misc.ColoredBlockHelper; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.block.FlowerBlock; +import net.minecraft.client.resources.ReloadListener; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.SheepEntity; @@ -24,6 +25,8 @@ import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.potion.PotionUtils; import net.minecraft.potion.Potions; +import net.minecraft.profiler.IProfiler; +import net.minecraft.resources.IResourceManager; import net.minecraft.tags.ItemTags; import net.minecraft.tags.Tag; import net.minecraft.util.ResourceLocation; @@ -33,9 +36,9 @@ import net.minecraftforge.registries.ForgeRegistries; import java.util.Arrays; -public final class ModRecipes { +public class ModRecipes extends ReloadListener { - public static void init() { + private void init() { new TreeRitualRecipe(res("eye"), ing(new ItemStack(Blocks.OAK_SAPLING)), new ItemStack(ModItems.EYE), 250, ing(Items.SPIDER_EYE), @@ -391,4 +394,15 @@ public final class ModRecipes { private static ResourceLocation res(String name) { return new ResourceLocation(NaturesAura.MOD_ID, name); } + + @Override + protected Object prepare(IResourceManager resourceManagerIn, IProfiler profilerIn) { + return null; + } + + @Override + protected void apply(Object splashList, IResourceManager resourceManagerIn, IProfiler profilerIn) { + NaturesAura.LOGGER.info("Loading recipes"); + this.init(); + } }