mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 05:02:18 +00:00
Fix up all the things. Removed SidedProvider because it served no real purpose anymore.
Signed-off-by: cpw <[email protected]>
This commit is contained in:
20 files changed
+282
-204
No files matched your search
@@ -1,13 +1,18 @@
|
||||
package net.minecraftforge.event;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.resources.DataPackRegistries;
|
||||
import net.minecraft.resources.IFutureReloadListener;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* The main ResourceManager is recreated on each reload, through {@link DataPackRegistries}'s creation.
|
||||
@@ -30,7 +35,7 @@ public class AddReloadListenerEvent extends Event
|
||||
*/
|
||||
public void addListener(IFutureReloadListener listener)
|
||||
{
|
||||
listeners.add(listener);
|
||||
listeners.add(new WrappedStateAwareListener(listener));
|
||||
}
|
||||
|
||||
public List<IFutureReloadListener> getListeners()
|
||||
@@ -42,4 +47,19 @@ public class AddReloadListenerEvent extends Event
|
||||
{
|
||||
return dataPackRegistries;
|
||||
}
|
||||
private static class WrappedStateAwareListener implements IFutureReloadListener {
|
||||
private final IFutureReloadListener wrapped;
|
||||
|
||||
private WrappedStateAwareListener(final IFutureReloadListener wrapped) {
|
||||
this.wrapped = wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> reload(final IStage stage, final IResourceManager resourceManager, final IProfiler preparationsProfiler, final IProfiler reloadProfiler, final Executor backgroundExecutor, final Executor gameExecutor) {
|
||||
if (ModLoader.isLoadingStateValid())
|
||||
return wrapped.reload(stage, resourceManager, preparationsProfiler, reloadProfiler, backgroundExecutor, gameExecutor);
|
||||
else
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user