Skip to content

Instantly share code, notes, and snippets.

@RainWarrior
Last active August 29, 2015 14:18
Show Gist options
  • Save RainWarrior/b42b24f0cf5e328078e5 to your computer and use it in GitHub Desktop.
Save RainWarrior/b42b24f0cf5e328078e5 to your computer and use it in GitHub Desktop.
Splash testing code
--- a/src/main/java/cpw/mods/fml/common/LoadController.java
+++ b/src/main/java/cpw/mods/fml/common/LoadController.java
@@ -37,6 +37,7 @@ import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import cpw.mods.fml.common.LoaderState.ModState;
+import cpw.mods.fml.common.ProgressManager.ProgressBar;
import cpw.mods.fml.common.event.FMLEvent;
import cpw.mods.fml.common.event.FMLLoadEvent;
import cpw.mods.fml.common.event.FMLModDisabledEvent;
@@ -182,10 +183,16 @@ public class LoadController
{
modObjectList = buildModObjectList();
}
+ String event = stateEvent.toString();
+ event = event.substring(event.lastIndexOf('.') + 1);
+ event = event.substring(0, event.indexOf('@'));
+ ProgressBar bar = ProgressManager.push(event + " propagation", activeModList.size());
for (ModContainer mc : activeModList)
{
+ bar.step("mod: " + mc.getName());
sendEventToModContainer(stateEvent, mc);
}
+ ProgressManager.pop(bar);
}
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
--- a/src/main/java/net/minecraftforge/fml/common/Loader.java
+++ b/src/main/java/net/minecraftforge/fml/common/Loader.java
@@ -28,6 +28,7 @@ import java.util.Set;
import net.minecraftforge.fml.common.LoaderState.ModState;
import net.minecraftforge.fml.common.ModContainer.Disableable;
+import net.minecraftforge.fml.common.ProgressManager.ProgressBar;
import net.minecraftforge.fml.common.discovery.ModDiscoverer;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLLoadEvent;
@@ -154,6 +155,8 @@ public class Loader
private File forcedModFile;
private ModDiscoverer discoverer;
+ private static ProgressBar progressBar;
+
public static Loader instance()
{
if (instance == null)
@@ -461,6 +464,8 @@ public class Loader
*/
public void loadMods()
{
+ progressBar = ProgressManager.push("FML", 5);
+ progressBar.step("Constructing");
initializeLoader();
mods = Lists.newArrayList();
namedMods = Maps.newHashMap();
@@ -500,6 +505,7 @@ public class Loader
{
FMLLog.fine("No user mod signature data found");
}
+ progressBar.step("Preinitialization");
modController.transition(LoaderState.PREINITIALIZATION, false);
}
@@ -513,6 +519,7 @@ public class Loader
ObjectHolderRegistry.INSTANCE.findObjectHolders(discoverer.getASMTable());
modController.distributeStateMessage(LoaderState.PREINITIALIZATION, discoverer.getASMTable(), canonicalConfigDir);
ObjectHolderRegistry.INSTANCE.applyObjectHolders();
+ progressBar.step("Initialization");
modController.transition(LoaderState.INITIALIZATION, false);
}
@@ -690,13 +697,17 @@ public class Loader
{
// Mod controller should be in the initialization state here
modController.distributeStateMessage(LoaderState.INITIALIZATION);
+ progressBar.step("Postinitialization");
modController.transition(LoaderState.POSTINITIALIZATION, false);
modController.distributeStateMessage(FMLInterModComms.IMCEvent.class);
modController.distributeStateMessage(LoaderState.POSTINITIALIZATION);
+ progressBar.step("Available");
modController.transition(LoaderState.AVAILABLE, false);
modController.distributeStateMessage(LoaderState.AVAILABLE);
GameData.freezeData();
FMLLog.info("Forge Mod Loader has successfully loaded %d mod%s", mods.size(), mods.size() == 1 ? "" : "s");
+ ProgressManager.pop(progressBar);
+ progressBar = null;
}
public ICrashCallable getCallableCrashInformation()
package net.minecraftforge.fml.debug;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.ProgressManager;
import net.minecraftforge.fml.common.ProgressManager.ProgressBar;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@Mod(modid = "slowly-loading")
public class SlowlyLoadingMod {
@EventHandler
public void preInit(FMLPreInitializationEvent event) throws InterruptedException
{
Thread.sleep(3000);
}
@EventHandler
public void init(FMLInitializationEvent event) throws InterruptedException
{
ProgressBar bar = ProgressManager.push("slowBar", 30);
for(int i = 0; i < 30; i++)
{
bar.step("step " + i);
Thread.sleep(100);
if(i == 23)
{
ProgressBar bar2 = ProgressManager.push("slowBar2", 5);
for(int j = 0; j < 5; j++)
{
bar2.step("step " + j);
Thread.sleep(500);
}
ProgressManager.pop(bar2);
}
}
ProgressManager.pop(bar);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) throws InterruptedException
{
Thread.sleep(3000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment