Skip to content

Commit

Permalink
Fix ContextAwareReloadListener for listeners added through the event (n…
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n authored Apr 1, 2024
1 parent aea5698 commit 1754aac
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<Void> reload(final PreparationBarrier stage, final ResourceManager resourceManager, final ProfilerFiller preparationsProfiler, final ProfilerFiller reloadProfiler, final Executor backgroundExecutor, final Executor gameExecutor) {
if (ModLoader.isLoadingStateValid())
Expand Down

0 comments on commit 1754aac

Please sign in to comment.