Slight tweak to early loading, to accommodate FMP

This commit is contained in:
cpw 2016-06-13 09:33:26 -04:00
parent 1164ace8df
commit dd09da27b5
4 changed files with 13 additions and 14 deletions

View file

@ -204,10 +204,10 @@ public class FMLClientHandler implements IFMLSidedHandler
return; return;
} }
FMLCommonHandler.instance().beginLoading(this); List<String> injectedModContainers = FMLCommonHandler.instance().beginLoading(this);
try try
{ {
Loader.instance().loadMods(); Loader.instance().loadMods(injectedModContainers);
} }
catch (WrongMinecraftVersionException wrong) catch (WrongMinecraftVersionException wrong)
{ {

View file

@ -140,11 +140,12 @@ public class FMLCommonHandler
return eventBus; return eventBus;
} }
public void beginLoading(IFMLSidedHandler handler) public List<String> beginLoading(IFMLSidedHandler handler)
{ {
sidedDelegate = handler; sidedDelegate = handler;
MinecraftForge.initialize(); MinecraftForge.initialize();
// MinecraftForge.registerCrashCallable(); // MinecraftForge.registerCrashCallable();
return ImmutableList.<String>of();
} }
/** /**

View file

@ -26,14 +26,11 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.ICrashReportDetail;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.fml.common.LoaderState.ModState; import net.minecraftforge.fml.common.LoaderState.ModState;
import net.minecraftforge.fml.common.ModContainer.Disableable; import net.minecraftforge.fml.common.ModContainer.Disableable;
import net.minecraftforge.fml.common.ProgressManager.ProgressBar; import net.minecraftforge.fml.common.ProgressManager.ProgressBar;
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData;
import net.minecraftforge.fml.common.discovery.ModDiscoverer; import net.minecraftforge.fml.common.discovery.ModDiscoverer;
import net.minecraftforge.fml.common.event.FMLInterModComms; import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLLoadEvent; import net.minecraftforge.fml.common.event.FMLLoadEvent;
@ -338,8 +335,9 @@ public class Loader
* Finally, if they are successfully loaded as classes, they are then added * Finally, if they are successfully loaded as classes, they are then added
* to the available mod list. * to the available mod list.
*/ */
private ModDiscoverer identifyMods() private ModDiscoverer identifyMods(List<String> additionalContainers)
{ {
injectedContainers.addAll(additionalContainers);
FMLLog.fine("Building injected Mod Containers %s", injectedContainers); FMLLog.fine("Building injected Mod Containers %s", injectedContainers);
// Add in the MCP mod container // Add in the MCP mod container
mods.add(new InjectedModContainer(mcp,new File("minecraft.jar"))); mods.add(new InjectedModContainer(mcp,new File("minecraft.jar")));
@ -487,8 +485,9 @@ public class Loader
* Called from the hook to start mod loading. We trigger the * Called from the hook to start mod loading. We trigger the
* {@link #identifyMods()} and Constructing, Preinitalization, and Initalization phases here. Finally, * {@link #identifyMods()} and Constructing, Preinitalization, and Initalization phases here. Finally,
* the mod list is frozen completely and is consider immutable from then on. * the mod list is frozen completely and is consider immutable from then on.
* @param injectedModContainers
*/ */
public void loadMods() public void loadMods(List<String> injectedModContainers)
{ {
progressBar = ProgressManager.push("Loading", 7); progressBar = ProgressManager.push("Loading", 7);
progressBar.step("Constructing Mods"); progressBar.step("Constructing Mods");
@ -497,7 +496,7 @@ public class Loader
namedMods = Maps.newHashMap(); namedMods = Maps.newHashMap();
modController = new LoadController(this); modController = new LoadController(this);
modController.transition(LoaderState.LOADING, false); modController.transition(LoaderState.LOADING, false);
discoverer = identifyMods(); discoverer = identifyMods(injectedModContainers);
ModAPIManager.INSTANCE.manageAPI(modClassLoader, discoverer); ModAPIManager.INSTANCE.manageAPI(modClassLoader, discoverer);
disableRequestedMods(); disableRequestedMods();
modController.distributeStateMessage(FMLLoadEvent.class); modController.distributeStateMessage(FMLLoadEvent.class);

View file

@ -13,7 +13,6 @@
package net.minecraftforge.fml.server; package net.minecraftforge.fml.server;
import java.io.*; import java.io.*;
import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -74,22 +73,22 @@ public class FMLServerHandler implements IFMLSidedHandler
* A reference to the server itself * A reference to the server itself
*/ */
private MinecraftServer server; private MinecraftServer server;
private List<String> injectedModContainers;
private FMLServerHandler() private FMLServerHandler()
{ {
FMLCommonHandler.instance().beginLoading(this); injectedModContainers = FMLCommonHandler.instance().beginLoading(this);
} }
/** /**
* Called to start the whole game off from * Called to start the whole game off from
* {@link MinecraftServer#startServer} * {@link MinecraftServer#startServer}
* *
* @param minecraftServer * @param minecraftServer server
*/ */
@Override @Override
public void beginServerLoading(MinecraftServer minecraftServer) public void beginServerLoading(MinecraftServer minecraftServer)
{ {
server = minecraftServer; server = minecraftServer;
Loader.instance().loadMods(); Loader.instance().loadMods(injectedModContainers);
Loader.instance().preinitializeMods(); Loader.instance().preinitializeMods();
} }