diff --git a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch index a6fb1261b2..504b073434 100644 --- a/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch +++ b/patches/minecraft/net/minecraft/server/ReloadableServerResources.java.patch @@ -6,7 +6,7 @@ ReloadableServerResources reloadableserverresources = new ReloadableServerResources(p_206863_, p_206864_, p_206865_); - return SimpleReloadInstance.m_203834_(p_206862_, reloadableserverresources.m_206890_(), p_206866_, p_206867_, f_206846_, f_206845_.isDebugEnabled()).m_7237_().thenApply((p_206880_) -> { + List listeners = new java.util.ArrayList<>(reloadableserverresources.m_206890_()); -+ listeners.addAll(net.minecraftforge.event.ForgeEventFactory.onResourceReload()); ++ listeners.addAll(net.minecraftforge.event.ForgeEventFactory.onResourceReload(reloadableserverresources)); + return SimpleReloadInstance.m_203834_(p_206862_, listeners, p_206866_, p_206867_, f_206846_, f_206845_.isDebugEnabled()).m_7237_().thenApply((p_206880_) -> { return reloadableserverresources; }); diff --git a/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java b/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java index b089a48195..f2121cb503 100644 --- a/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java +++ b/src/main/java/net/minecraftforge/event/AddReloadListenerEvent.java @@ -6,7 +6,7 @@ package net.minecraftforge.event; import com.google.common.collect.ImmutableList; -import net.minecraft.server.MinecraftServer; +import net.minecraft.server.ReloadableServerResources; import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.server.packs.resources.PreparableReloadListener; import net.minecraft.server.packs.resources.ResourceManager; @@ -19,10 +19,8 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; -import net.minecraft.server.packs.resources.PreparableReloadListener.PreparationBarrier; - /** - * The main ResourceManager is recreated on each reload, through {@link MinecraftServer.ReloadableResources}'s creation. + * The main ResourceManager is recreated on each reload, just after {@link ReloadableServerResources}'s creation. * * The event is fired on each reload and lets modders add their own ReloadListeners, for server-side resources. * The event is fired on the {@link MinecraftForge#EVENT_BUS} @@ -30,14 +28,12 @@ import net.minecraft.server.packs.resources.PreparableReloadListener.Preparation public class AddReloadListenerEvent extends Event { private final List listeners = new ArrayList<>(); - /* - private final MinecraftServer.ReloadableResources dataPackRegistries; + private final ReloadableServerResources serverResources; - public AddReloadListenerEvent(MinecraftServer.ReloadableResources dataPackRegistries) + public AddReloadListenerEvent(ReloadableServerResources serverResources) { - this.dataPackRegistries = dataPackRegistries; + this.serverResources = serverResources; } - */ /** * @param listener the listener to add to the ResourceManager on reload @@ -52,12 +48,11 @@ public class AddReloadListenerEvent extends Event return ImmutableList.copyOf(listeners); } - /* - public MinecraftServer.ReloadableResources getDataPackRegistries() + public ReloadableServerResources getServerResources() { - return dataPackRegistries; + return serverResources; } - */ + private static class WrappedStateAwareListener implements PreparableReloadListener { private final PreparableReloadListener wrapped; diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index 869b9ab4a9..d1a8672838 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -17,7 +17,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.server.MinecraftServer; +import net.minecraft.server.ReloadableServerResources; import net.minecraft.server.players.PlayerList; import net.minecraft.world.Container; import net.minecraft.world.entity.projectile.FireworkRocketEntity; @@ -710,9 +710,9 @@ public class ForgeEventFactory return event.getNewTime(); } - public static List onResourceReload(/*MinecraftServer.ReloadableResources dataPackRegistries*/) + public static List onResourceReload(ReloadableServerResources serverResources) { - AddReloadListenerEvent event = new AddReloadListenerEvent(/*dataPackRegistries*/); + AddReloadListenerEvent event = new AddReloadListenerEvent(serverResources); MinecraftForge.EVENT_BUS.post(event); return event.getListeners(); }