mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-15 09:34:50 +00:00
Modify how ModLoadingStage handles dispatch to Registry Events. Stops the objectholder spam and generally improves performance on larger packs.
Signed-off-by: cpw <[email protected]>
This commit is contained in:
4 files changed
+52
-45
No files matched your search
@@ -19,6 +19,7 @@
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
|
||||
@@ -102,14 +103,13 @@ public abstract class ModContainer
|
||||
public static <T extends Event & IModBusEvent> CompletableFuture<Void> buildTransitionHandler(
|
||||
final ModContainer target,
|
||||
final ModLoadingStage.EventGenerator<T> eventGenerator,
|
||||
final ModLoadingStage.EventDispatcher<T> eventDispatcher,
|
||||
final BiFunction<ModLoadingStage, Throwable, ModLoadingStage> stateChangeHandler,
|
||||
final Executor executor) {
|
||||
return CompletableFuture
|
||||
.runAsync(() -> {
|
||||
ModLoadingContext.get().setActiveContainer(target, target.contextExtension.get());
|
||||
target.activityMap.getOrDefault(target.modLoadingStage, ()->{}).run();
|
||||
eventDispatcher.apply(target::acceptEvent).accept(eventGenerator.apply(target));
|
||||
target.acceptEvent(eventGenerator.apply(target));
|
||||
}, executor)
|
||||
.whenComplete((mc, exception) -> {
|
||||
target.modLoadingStage = stateChangeHandler.apply(target.modLoadingStage, exception);
|
||||
|
||||
Reference in new issue
Block a user