diff --git a/src/main/java/net/neoforged/neoforge/event/AddReloadListenerEvent.java b/src/main/java/net/neoforged/neoforge/event/AddReloadListenerEvent.java index c83170fe1f..0b56f212ca 100644 --- a/src/main/java/net/neoforged/neoforge/event/AddReloadListenerEvent.java +++ b/src/main/java/net/neoforged/neoforge/event/AddReloadListenerEvent.java @@ -19,6 +19,7 @@ import net.neoforged.fml.ModLoader; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.common.conditions.ICondition; +import net.neoforged.neoforge.resource.ContextAwareReloadListener; /** * The main ResourceManager is recreated on each reload, just after {@link ReloadableServerResources}'s creation. @@ -73,13 +74,20 @@ public RegistryAccess getRegistryAccess() { return registryAccess; } - private static class WrappedStateAwareListener implements PreparableReloadListener { + private static class WrappedStateAwareListener extends ContextAwareReloadListener implements PreparableReloadListener { private final PreparableReloadListener wrapped; private WrappedStateAwareListener(final PreparableReloadListener wrapped) { this.wrapped = wrapped; } + @Override + public void injectContext(ICondition.IContext context, RegistryAccess regAccess) { + if (this.wrapped instanceof ContextAwareReloadListener contextAwareListener) { + contextAwareListener.injectContext(context, regAccess); + } + } + @Override public CompletableFuture reload(final PreparationBarrier stage, final ResourceManager resourceManager, final ProfilerFiller preparationsProfiler, final ProfilerFiller reloadProfiler, final Executor backgroundExecutor, final Executor gameExecutor) { if (ModLoader.isLoadingStateValid())