Skip to content

Commit

Permalink
Look in the SERVICE layer for ImmediateWindowProvider implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
FiniteReality committed Feb 23, 2024
1 parent 9b239e3 commit 8d26fa6
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package net.neoforged.fml.loading;

import cpw.mods.modlauncher.Launcher;
import cpw.mods.modlauncher.api.IModuleLayerManager.Layer;
import net.neoforged.fml.loading.progress.ProgressMeter;
import net.neoforged.fml.loading.progress.StartupNotificationManager;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -32,7 +34,10 @@ public static void load(final String launchTarget, final String[] arguments) {
} else {
final var providername = FMLConfig.getConfigValue(FMLConfig.ConfigValue.EARLY_WINDOW_PROVIDER);
LOGGER.info("Loading ImmediateWindowProvider {}", providername);
final var maybeProvider = ServiceLoader.load(ImmediateWindowProvider.class)
final var layer = Launcher.INSTANCE.findLayerManager()
.flatMap(manager -> manager.getLayer(Layer.SERVICE))
.orElse(ImmediateWindowHandler.class.getModule().getLayer()); // This will likely be the BOOT layer, but is a sensible fallback.
final var maybeProvider = ServiceLoader.load(layer, ImmediateWindowProvider.class)
.stream()
.map(ServiceLoader.Provider::get)
.filter(p -> Objects.equals(p.name(), providername))
Expand Down

0 comments on commit 8d26fa6

Please sign in to comment.