diff --git a/fml/.gitattributes b/fml/.gitattributes
new file mode 100644
index 0000000000..176a458f94
--- /dev/null
+++ b/fml/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/fml/.gitignore b/fml/.gitignore
index f5d15818b6..6c6c3b08e4 100644
--- a/fml/.gitignore
+++ b/fml/.gitignore
@@ -8,3 +8,5 @@
/eclipse/.metadata/
/target
fmlbranding.properties
+/fernflower.zip
+/commands.py.bck
diff --git a/fml/LICENSE-fml.txt b/fml/LICENSE-fml.txt
index f454481a2f..b1345ced9d 100644
--- a/fml/LICENSE-fml.txt
+++ b/fml/LICENSE-fml.txt
@@ -3,6 +3,12 @@ under the GNU LGPL v2.1 or later.
Homepage: https://github.com/cpw/FML
+This software includes portions from the Apache Maven project at
+http://maven.apache.org/ specifically the ComparableVersion.java code. It is
+included based on guidelines at
+http://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html
+with notices intact. The only change is a non-functional change of package name.
+
========
GNU LESSER GENERAL PUBLIC LICENSE
diff --git a/fml/applypatches.py b/fml/applypatches.py
index bbc80c5614..cec544de14 100644
--- a/fml/applypatches.py
+++ b/fml/applypatches.py
@@ -1,66 +1,14 @@
-import sys
-import os, os.path, shutil
-import commands
-import fnmatch
-import re
-import subprocess, shlex
-
-def cmdsplit(args):
- if os.sep == '\\':
- args = args.replace('\\', '\\\\')
- return shlex.split(args)
+import os, sys
def main():
- print("Applying patches")
- sys.stdout.flush()
- patches = os.path.abspath(sys.argv[1])
- work = os.path.normpath(sys.argv[2])
- mcp = os.path.normpath(sys.argv[3])
- temp = os.path.abspath('temp.patch')
+ fml_dir = os.path.abspath(sys.argv[1])
+ work_dir = os.path.normpath(sys.argv[2])
+ mcp_dir = os.path.normpath(sys.argv[3])
- cmd = cmdsplit('patch -p2 -i "%s" ' % temp)
- display = True
+ sys.path.append(os.path.join(fml_dir, 'install'))
+ from fml import apply_fml_patches
- if os.name == 'nt':
- mcp = os.path.abspath(os.path.join(mcp, 'runtime', 'bin', 'applydiff.exe'))
- cmd = cmdsplit('"%s" -uf -p2 -i "%s"' % (mcp, temp))
- display = False
-
- for path, _, filelist in os.walk(patches, followlinks=True):
- for cur_file in fnmatch.filter(filelist, '*.patch'):
- patch_file = os.path.normpath(os.path.join(patches, path[len(patches)+1:], cur_file))
- if display:
- print 'patching file %s' % os.path.join(path[len(patches)+1:], cur_file)
- normaliselines(patch_file, temp)
- process = subprocess.Popen(cmd, cwd=work, bufsize=-1)
- process.communicate()
-
- if os.path.isfile(temp):
- os.remove(temp)
-
-#Taken from MCP
-def normaliselines(in_filename, out_filename=None):
- in_filename = os.path.normpath(in_filename)
- if out_filename is None:
- tmp_filename = in_filename + '.tmp'
- else:
- out_filename = os.path.normpath(out_filename)
- tmp_filename = out_filename
- dir_name = os.path.dirname(out_filename)
- if dir_name:
- if not os.path.exists(dir_name):
- os.makedirs(dir_name)
- regex_ending = re.compile(r'\r?\n')
- with open(in_filename, 'rb') as in_file:
- with open(tmp_filename, 'wb') as out_file:
- buf = in_file.read()
- if os.linesep == '\r\n':
- buf = regex_ending.sub(r'\r\n', buf)
- else:
- buf = buf.replace('\r\n', '\n')
- out_file.write(buf)
- if out_filename is None:
- shutil.move(tmp_filename, in_filename)
+ apply_fml_patches(fml_dir, mcp_dir, work_dir, False)
if __name__ == '__main__':
main()
diff --git a/fml/build.xml b/fml/build.xml
index 900e910d56..c6222bb000 100644
--- a/fml/build.xml
+++ b/fml/build.xml
@@ -29,7 +29,7 @@
-
+
@@ -55,6 +55,10 @@
+
+
+
+
@@ -90,23 +94,23 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
@@ -150,9 +154,9 @@
-
+
-
+
@@ -204,11 +208,11 @@
-
+
-
+
@@ -222,63 +226,104 @@
You have decided not to continue. This script will stop now.Preparing the MCP environment at ${mcp.home}
-
+
-
-
-
-
-
+
+
+
+
-
+
+
+ Moving old patched sources at ${patch.mcp.srcdir} out of the way
-
+
- Deleting old patch references at ${mcp.home}/src-base
-
- Creating new patch references at ${mcp.home}/src-base
-
-
+ Deleting old patch references at ${clean.mcp.srcdir}
+
+ Creating new patch references at ${clean.mcp.srcdir}
+
+
+
- Creating clean patched references at ${mcp.home}/src-work
-
-
+ Creating clean patched references at ${patch.mcp.srcdir}
+
+ Setup complete! You should now be able to open ${basedir}/eclipse as a workspace in eclipse and import/refresh the FML-Server and FML-Client projects
-
+ Moving old patched sources at ${mcp.home}/src-work out of the way
-
+
-
-
-
+
+
+
+
+
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A patch is out of date. Update your patches!
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fml/client/cpw/mods/fml/client/BlockRenderManager.java b/fml/client/cpw/mods/fml/client/BlockRenderManager.java
new file mode 100644
index 0000000000..43a78ba358
--- /dev/null
+++ b/fml/client/cpw/mods/fml/client/BlockRenderManager.java
@@ -0,0 +1,81 @@
+package cpw.mods.fml.client;
+
+import java.util.HashMap;
+
+import cpw.mods.fml.common.modloader.ModLoaderHelper;
+import cpw.mods.fml.common.modloader.ModLoaderModContainer;
+
+import net.minecraft.src.BaseMod;
+import net.minecraft.src.Block;
+import net.minecraft.src.IBlockAccess;
+import net.minecraft.src.RenderBlocks;
+
+public class BlockRenderManager
+{
+ private static final BlockRenderManager INSTANCE = new BlockRenderManager();
+
+ private HashMap blockModelIds = new HashMap();
+
+ private int nextRenderId = 30;
+
+ public static BlockRenderManager instance()
+ {
+ return INSTANCE;
+ }
+
+ /**
+ * @param renderer
+ * @param world
+ * @param x
+ * @param y
+ * @param z
+ * @param block
+ * @param modelId
+ * @return
+ */
+ public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
+ {
+ if (!blockModelIds.containsKey(modelId)) { return false; }
+ BlockRenderInfo bri = blockModelIds.get(modelId);
+ return bri.renderWorldBlock(world, x, y, z, block, modelId, renderer);
+ }
+
+ /**
+ * @param renderer
+ * @param block
+ * @param metadata
+ * @param modelID
+ */
+ public void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
+ {
+ if (!blockModelIds.containsKey(modelID)) { return; }
+ BlockRenderInfo bri = blockModelIds.get(modelID);
+ bri.renderInventoryBlock(block, metadata, modelID, renderer);
+ }
+
+ /**
+ * @param p_1219_0_
+ * @return
+ */
+ public boolean renderItemAsFull3DBlock(int modelId)
+ {
+ BlockRenderInfo bri = blockModelIds.get(modelId);
+ if (bri != null) { return bri.shouldRender3DInInventory(); }
+ return false;
+ }
+
+
+ /**
+ * @param mod
+ * @param inventoryRenderer
+ * @return
+ */
+ public int obtainBlockModelIdFor(BaseMod mod, boolean inventoryRenderer)
+ {
+ ModLoaderModContainer mlmc=ModLoaderHelper.registerRenderHelper(mod);
+ int renderId=nextRenderId++;
+ BlockRenderInfo bri=new BlockRenderInfo(renderId, inventoryRenderer, mlmc);
+ blockModelIds.put(renderId, bri);
+ return renderId;
+ }
+}
diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
index 4b1ef000b9..b801f4a190 100644
--- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java
+++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
@@ -43,11 +43,14 @@ import javax.imageio.ImageIO;
import org.lwjgl.opengl.GL11;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableMap;
+
import net.minecraft.client.Minecraft;
import net.minecraft.src.BaseMod;
import net.minecraft.src.BiomeGenBase;
import net.minecraft.src.Block;
-import net.minecraft.src.ClientRegistry;
+import net.minecraft.src.CrashReport;
import net.minecraft.src.EntityItem;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.GameSettings;
@@ -59,7 +62,6 @@ import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.KeyBinding;
import net.minecraft.src.MLProp;
-import net.minecraft.src.MinecraftImpl;
import net.minecraft.src.ModTextureStatic;
import net.minecraft.src.NetClientHandler;
import net.minecraft.src.NetworkManager;
@@ -77,21 +79,25 @@ import net.minecraft.src.SidedProxy;
import net.minecraft.src.StringTranslate;
import net.minecraft.src.TextureFX;
import net.minecraft.src.TexturePackBase;
-import net.minecraft.src.UnexpectedThrowable;
import net.minecraft.src.World;
import net.minecraft.src.WorldType;
import argo.jdom.JdomParser;
import argo.jdom.JsonNode;
+import cpw.mods.fml.client.registry.ClientRegistry;
+import cpw.mods.fml.client.registry.KeyBindingRegistry;
+import cpw.mods.fml.common.DummyModContainer;
import cpw.mods.fml.common.FMLCommonHandler;
-import cpw.mods.fml.common.FMLModLoaderContainer;
+import cpw.mods.fml.common.FMLDummyContainer;
+import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.IFMLSidedHandler;
-import cpw.mods.fml.common.IKeyHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.LoaderException;
+import cpw.mods.fml.common.LoaderState;
+import cpw.mods.fml.common.MetadataCollection;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.ProxyInjector;
-import cpw.mods.fml.common.ReflectionHelper;
+import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.modloader.ModLoaderHelper;
@@ -103,7 +109,7 @@ import cpw.mods.fml.common.registry.FMLRegistry;
/**
* Handles primary communication from hooked code into the system
*
- * The FML entry point is {@link #onPreLoad(MinecraftServer)} called from
+ * The FML entry point is {@link #beginMinecraftLoading(MinecraftServer)} called from
* {@link MinecraftServer}
*
* Obfuscated code should focus on this class and other members of the "server"
@@ -131,28 +137,11 @@ public class FMLClientHandler implements IFMLSidedHandler
*/
private Minecraft client;
- /**
- * A handy list of the default overworld biomes
- */
- private BiomeGenBase[] defaultOverworldBiomes;
-
- private int nextRenderId = 30;
private TexturePackBase fallbackTexturePack;
private NetClientHandler networkClient;
- private ModContainer animationCallbackMod;
-
- // Cached lookups
- private HashMap> overrideInfo = new HashMap>();
- private HashMap blockModelIds = new HashMap();
- private HashMap keyBindings = new HashMap();
- private List keyHandlers = new ArrayList();
- private HashSet animationSet = new HashSet();
-
- private List addedTextureFX = new ArrayList();
-
private boolean firstTick;
/**
* Called to start the whole game off from
@@ -161,40 +150,37 @@ public class FMLClientHandler implements IFMLSidedHandler
* @param minecraftServer
*/
- private OptifineModContainer optifineContainer;
+ private DummyModContainer optifineContainer;
private boolean guiLoaded;
- public void onPreLoad(Minecraft minecraft)
+ private boolean serverIsRunning;
+
+ public void beginMinecraftLoading(Minecraft minecraft)
{
+ if (minecraft.func_71355_q())
+ {
+ FMLLog.severe("DEMO MODE DETECTED, FML will not work. Finishing now.");
+ haltGame("FML will not run in demo mode", new RuntimeException());
+ return;
+ }
+
client = minecraft;
- ReflectionHelper.detectObfuscation(World.class);
+ ObfuscationReflectionHelper.detectObfuscation(World.class);
FMLCommonHandler.instance().beginLoading(this);
- FMLRegistry.registerRegistry(new ClientRegistry());
try
{
Class> optifineConfig = Class.forName("Config", false, Loader.instance().getModClassLoader());
- optifineContainer = new OptifineModContainer(optifineConfig);
+ String optifineVersion = (String) optifineConfig.getField("VERSION").get(null);
+ Map dummyOptifineMeta = ImmutableMap.builder().put("name", "Optifine").put("version", optifineVersion).build();
+ ModMetadata optifineMetadata = MetadataCollection.from(getClass().getResourceAsStream("optifinemod.info")).getMetadataForId("optifine", dummyOptifineMeta);
+ optifineContainer = new DummyModContainer(optifineMetadata);
+ FMLLog.info("Forge Mod Loader has detected optifine %s, enabling compatibility features",optifineContainer.getVersion());
}
catch (Exception e)
{
- // OPTIFINE not found
optifineContainer = null;
}
- if (optifineContainer != null)
- {
- ModMetadata optifineMetadata;
- try
- {
- optifineMetadata = readMetadataFrom(Loader.instance().getModClassLoader().getResourceAsStream("optifinemod.info"), optifineContainer);
- optifineContainer.setMetadata(optifineMetadata);
- }
- catch (Exception e)
- {
- //not available
- }
- FMLCommonHandler.instance().getFMLLogger().info(String.format("Forge Mod Loader has detected optifine %s, enabling compatibility features",optifineContainer.getVersion()));
- }
try
{
Loader.instance().loadMods();
@@ -209,14 +195,15 @@ public class FMLClientHandler implements IFMLSidedHandler
@Override
public void haltGame(String message, Throwable t)
{
- client.func_28003_b(new UnexpectedThrowable(message, t));
+ client.func_71377_b(new CrashReport(message, t));
+ throw Throwables.propagate(t);
}
/**
* Called a bit later on during initialization to finish loading mods
* Also initializes key bindings
*
*/
- public void onLoadComplete()
+ public void finishMinecraftLoading()
{
try
{
@@ -227,81 +214,28 @@ public class FMLClientHandler implements IFMLSidedHandler
haltGame("There was a severe problem during mod loading that has caused the game to fail", le);
return;
}
- for (ModContainer mod : Loader.getModList()) {
- mod.gatherRenderers(RenderManager.field_1233_a.getRendererList());
- for (Render r : RenderManager.field_1233_a.getRendererList().values()) {
- r.func_4009_a(RenderManager.field_1233_a);
- }
- }
- // Load the key bindings into the settings table
-
- GameSettings gs = client.field_6304_y;
- KeyBinding[] modKeyBindings = harvestKeyBindings();
- KeyBinding[] allKeys = new KeyBinding[gs.field_1564_t.length + modKeyBindings.length];
- System.arraycopy(gs.field_1564_t, 0, allKeys, 0, gs.field_1564_t.length);
- System.arraycopy(modKeyBindings, 0, allKeys, gs.field_1564_t.length, modKeyBindings.length);
- gs.field_1564_t = allKeys;
- gs.func_6519_a();
+ // TODO
+// for (ModContainer mod : Loader.getModList()) {
+// mod.gatherRenderers(RenderManager.field_1233_a.getRendererList());
+// for (Render r : RenderManager.field_1233_a.getRendererList().values()) {
+// r.func_4009_a(RenderManager.field_1233_a);
+// }
+// }
+ KeyBindingRegistry.uploadKeyBindingsToGame(client.field_71474_y);
// Mark this as a "first tick"
-
firstTick = true;
}
- public KeyBinding[] harvestKeyBindings() {
- List allKeys=FMLCommonHandler.instance().gatherKeyBindings();
- KeyBinding[] keys=new KeyBinding[allKeys.size()];
- int i=0;
- for (IKeyHandler key : allKeys) {
- keys[i++]=(KeyBinding)key.getKeyBinding();
- keyBindings.put((KeyBinding) key.getKeyBinding(), key.getOwningContainer());
- }
- keyHandlers = allKeys;
- return keys;
- }
- /**
- * Every tick just before world and other ticks occur
- */
- public void onPreWorldTick()
- {
- if (client.field_6324_e != null) {
- // For the client world ticks and game ticks are the same
- FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLD), client.field_6324_e, client.field_6313_p, client.field_6324_e);
- FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GAME,TickType.WORLDGUI), 0.0f, client.field_6313_p, client.field_6324_e);
- }
- }
-
- /**
- * Every tick just after world and other ticks occur
- */
- public void onPostWorldTick()
- {
- if (client.field_6324_e != null) {
- // For the client world ticks and game ticks are the same
- FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.WORLD), client.field_6324_e, client.field_6313_p, client.field_6324_e);
- FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.GAME,TickType.WORLDGUI), 0.0f, client.field_6313_p, client.field_6324_e);
- }
- for (IKeyHandler entry : keyHandlers)
- {
- entry.onEndTick();
- }
- }
-
- public void onWorldLoadTick()
- {
- if (client.field_6324_e != null) {
- if (firstTick)
- {
- loadTextures(fallbackTexturePack);
- firstTick = false;
- }
- FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLDLOAD));
- }
- }
-
public void onRenderTickStart(float partialTickTime)
{
- FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_6313_p);
+ if (firstTick)
+ {
+ // TODO
+// loadTextures(fallbackTexturePack);
+ firstTick = false;
+ }
+ FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_71462_r);
}
public void onRenderTickEnd(float partialTickTime)
@@ -309,10 +243,10 @@ public class FMLClientHandler implements IFMLSidedHandler
if (!guiLoaded)
{
FMLCommonHandler.instance().rescheduleTicks();
- FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GUILOAD), partialTickTime, client.field_6313_p);
+ FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GUILOAD), partialTickTime, client.field_71462_r);
guiLoaded = true;
}
- FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_6313_p);
+ FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_71462_r);
}
/**
* Get the server instance
@@ -333,85 +267,6 @@ public class FMLClientHandler implements IFMLSidedHandler
return null;
}
- /**
- * Called from ChunkProvider when a chunk needs to be populated
- *
- * To avoid polluting the worldgen seed, we generate a new random from the
- * world seed and generate a seed from that
- *
- * @param chunkProvider
- * @param chunkX
- * @param chunkZ
- * @param world
- * @param generator
- */
- public void onChunkPopulate(IChunkProvider chunkProvider, int chunkX, int chunkZ, World world, IChunkProvider generator)
- {
- FMLCommonHandler.instance().handleWorldGeneration(chunkX, chunkZ, world.func_22138_q(), world, generator, chunkProvider);
- }
-
- /**
- * Is the offered class and instance of BaseMod and therefore a ModLoader
- * mod?
- */
- public boolean isModLoaderMod(Class> clazz)
- {
- return BaseMod.class.isAssignableFrom(clazz);
- }
-
- /**
- * Load the supplied mod class into a mod container
- */
- public ModContainer loadBaseModMod(Class> clazz, File canonicalFile)
- {
- @SuppressWarnings("unchecked")
- Class extends BaseMod> bmClazz = (Class extends BaseMod>) clazz;
- return new ModLoaderModContainer(bmClazz, canonicalFile);
- }
-
- /**
- * Called to notify that an item was picked up from the world
- *
- * @param entityItem
- * @param entityPlayer
- */
- public void notifyItemPickup(EntityItem entityItem, EntityPlayer entityPlayer)
- {
- for (ModContainer mod : Loader.getModList())
- {
- if (mod.wantsPickupNotification())
- {
- mod.getPickupNotifier().notifyPickup(entityItem, entityPlayer);
- }
- }
- }
-
- /**
- * Attempt to dispense the item as an entity other than just as a the item
- * itself
- *
- * @param world
- * @param x
- * @param y
- * @param z
- * @param xVelocity
- * @param zVelocity
- * @param item
- * @return
- */
- public boolean tryDispensingEntity(World world, double x, double y, double z, byte xVelocity, byte zVelocity, ItemStack item)
- {
- for (ModContainer mod : Loader.getModList())
- {
- if (mod.wantsToDispense() && mod.getDispenseHandler().dispense(x, y, z, xVelocity, zVelocity, world, item))
- {
- return true;
- }
- }
-
- return false;
- }
-
/**
* @return the instance
*/
@@ -420,207 +275,6 @@ public class FMLClientHandler implements IFMLSidedHandler
return INSTANCE;
}
- /**
- * Build a list of default overworld biomes
- *
- * @return
- */
- public BiomeGenBase[] getDefaultOverworldBiomes()
- {
- if (defaultOverworldBiomes == null)
- {
- ArrayList biomes = new ArrayList(20);
-
- for (int i = 0; i < 23; i++)
- {
- if ("Sky".equals(BiomeGenBase.field_35486_a[i].field_6504_m) || "Hell".equals(BiomeGenBase.field_35486_a[i].field_6504_m))
- {
- continue;
- }
-
- biomes.add(BiomeGenBase.field_35486_a[i]);
- }
-
- defaultOverworldBiomes = new BiomeGenBase[biomes.size()];
- biomes.toArray(defaultOverworldBiomes);
- }
-
- return defaultOverworldBiomes;
- }
-
- /**
- * Called when an item is crafted
- *
- * @param player
- * @param craftedItem
- * @param craftingGrid
- */
- public void onItemCrafted(EntityPlayer player, ItemStack craftedItem, IInventory craftingGrid)
- {
- for (ModContainer mod : Loader.getModList())
- {
- if (mod.wantsCraftingNotification())
- {
- mod.getCraftingHandler().onCrafting(player, craftedItem, craftingGrid);
- }
- }
- }
-
- /**
- * Called when an item is smelted
- *
- * @param player
- * @param smeltedItem
- */
- public void onItemSmelted(EntityPlayer player, ItemStack smeltedItem)
- {
- for (ModContainer mod : Loader.getModList())
- {
- if (mod.wantsCraftingNotification())
- {
- mod.getCraftingHandler().onSmelting(player, smeltedItem);
- }
- }
- }
-
- /**
- * Called when a chat packet is received
- *
- * @param chat
- * @param player
- * @return true if you want the packet to stop processing and not echo to
- * the rest of the world
- */
- public boolean handleChatPacket(Packet3Chat chat)
- {
- for (ModContainer mod : Loader.getModList())
- {
- if (mod.wantsNetworkPackets() && mod.getNetworkHandler().onChat(chat))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public void handleServerLogin(Packet1Login loginPacket, NetClientHandler handler, NetworkManager networkManager)
- {
- this.networkClient=handler;
- Packet250CustomPayload packet = new Packet250CustomPayload();
- packet.field_44012_a = "REGISTER";
- packet.field_44011_c = FMLCommonHandler.instance().getPacketRegistry();
- packet.field_44010_b = packet.field_44011_c.length;
- if (packet.field_44010_b > 0)
- {
- networkManager.func_972_a(packet);
- }
- for (ModContainer mod : Loader.getModList()) {
- mod.getNetworkHandler().onServerLogin(handler);
- }
- }
-
- /**
- * Called when a packet 250 packet is received from the player
- *
- * @param packet
- * @param player
- */
- public void handlePacket250(Packet250CustomPayload packet)
- {
- if ("REGISTER".equals(packet.field_44012_a) || "UNREGISTER".equals(packet.field_44012_a))
- {
- handleServerRegistration(packet);
- return;
- }
-
- ModContainer mod = FMLCommonHandler.instance().getModForChannel(packet.field_44012_a);
-
- if (mod != null)
- {
- mod.getNetworkHandler().onPacket250Packet(packet);
- }
- }
-
- /**
- * Handle register requests for packet 250 channels
- *
- * @param packet
- */
- private void handleServerRegistration(Packet250CustomPayload packet)
- {
- if (packet.field_44011_c == null)
- {
- return;
- }
- try
- {
- for (String channel : new String(packet.field_44011_c, "UTF8").split("\0"))
- {
- // Skip it if we don't know it
- if (FMLCommonHandler.instance().getModForChannel(channel) == null)
- {
- continue;
- }
-
- if ("REGISTER".equals(packet.field_44012_a))
- {
- FMLCommonHandler.instance().activateChannel(client.field_6322_g,channel);
- }
- else
- {
- FMLCommonHandler.instance().deactivateChannel(client.field_6322_g,channel);
- }
- }
- }
- catch (UnsupportedEncodingException e)
- {
- getMinecraftLogger().warning("Received invalid registration packet");
- }
- }
-
- @Override
- public File getMinecraftRootDirectory()
- {
- return client.field_6297_D;
- }
-
- /**
- * @param player
- */
- public void announceLogout(EntityPlayer player)
- {
- for (ModContainer mod : Loader.getModList())
- {
- if (mod.wantsPlayerTracking())
- {
- mod.getPlayerTracker().onPlayerLogout(player);
- }
- }
- }
-
- /**
- * @param p_28168_1_
- */
- public void announceDimensionChange(EntityPlayer player)
- {
- for (ModContainer mod : Loader.getModList())
- {
- if (mod.wantsPlayerTracking())
- {
- mod.getPlayerTracker().onPlayerChangedDimension(player);
- }
- }
- }
-
- /**
- * @param biome
- */
- public void addBiomeToDefaultWorldGenerator(BiomeGenBase biome)
- {
- WorldType.field_48635_b.addNewBiome(biome);
- }
-
/**
* Return the minecraft instance
*/
@@ -629,82 +283,26 @@ public class FMLClientHandler implements IFMLSidedHandler
{
return client;
}
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.IFMLSidedHandler#getCurrentLanguage()
- */
- @Override
- public String getCurrentLanguage()
- {
- return StringTranslate.func_20162_a().func_44024_c();
- }
-
- public Properties getCurrentLanguageTable() {
- return StringTranslate.func_20162_a().getTranslationTable();
- }
/**
* @param armor
* @return
*/
public int addNewArmourRendererPrefix(String armor)
{
- return RenderPlayer.addNewArmourPrefix(armor);
+ String[] prefixes = ObfuscationReflectionHelper.getPrivateValue(RenderPlayer.class, null, "field_77110_j", "j", "armorFilenamePrefix");
+ String[] newPrefixes = Arrays.copyOf(prefixes, prefixes.length+1);
+ newPrefixes[prefixes.length] = armor;
+ ObfuscationReflectionHelper.setPrivateValue(RenderPlayer.class, null, newPrefixes, "field_77110_j", "j", "armorFilenamePrefix" );
+ return prefixes.length;
}
-
- public void addNewTextureOverride(String textureToOverride, String overridingTexturePath, int location) {
- if (!overrideInfo.containsKey(textureToOverride))
- {
- overrideInfo.put(textureToOverride, new ArrayList());
- }
- ArrayList list = overrideInfo.get(textureToOverride);
- OverrideInfo info = new OverrideInfo();
- info.index = location;
- info.override = overridingTexturePath;
- info.texture = textureToOverride;
- list.add(info);
- FMLCommonHandler.instance().getFMLLogger().log(Level.FINE, String.format("Overriding %s @ %d with %s. %d slots remaining",textureToOverride, location, overridingTexturePath, SpriteHelper.freeSlotCount(textureToOverride)));
- }
- /**
- * @param mod
- * @param inventoryRenderer
- * @return
- */
- public int obtainBlockModelIdFor(BaseMod mod, boolean inventoryRenderer)
- {
- ModLoaderModContainer mlmc=ModLoaderHelper.registerRenderHelper(mod);
- int renderId=nextRenderId++;
- BlockRenderInfo bri=new BlockRenderInfo(renderId, inventoryRenderer, mlmc);
- blockModelIds.put(renderId, bri);
- return renderId;
- }
-
- /**
- * @param renderEngine
- * @param path
- * @return
- */
- public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine, String path) throws IOException
- {
- InputStream image=client.field_6298_C.field_6534_a.func_6481_a(path);
- if (image==null) {
- throw new RuntimeException(String.format("The requested image path %s is not found",path));
- }
- BufferedImage result=ImageIO.read(image);
- if (result==null)
- {
- throw new RuntimeException(String.format("The requested image path %s appears to be corrupted",path));
- }
- return result;
- }
-
/**
* @param player
* @param gui
*/
public void displayGuiScreen(EntityPlayer player, GuiScreen gui)
{
- if (client.field_22009_h==player && gui != null) {
- client.func_6272_a(gui);
+ if (client.field_71439_g==player && gui != null) {
+ client.func_71373_a(gui);
}
}
@@ -713,406 +311,19 @@ public class FMLClientHandler implements IFMLSidedHandler
* @param keyHandler
* @param allowRepeat
*/
- public void registerKeyHandler(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat)
+ public void registerModLoaderKeyHandler(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat)
{
ModLoaderModContainer mlmc=ModLoaderHelper.registerKeyHelper(mod);
- mlmc.addKeyHandler(new KeyBindingHandler(keyHandler, allowRepeat, mlmc));
+ KeyBindingRegistry.registerKeyBinding(new ModLoaderKeyBindingHandler(keyHandler, allowRepeat, mlmc));
}
-
- /**
- * @param renderer
- * @param world
- * @param x
- * @param y
- * @param z
- * @param block
- * @param modelId
- * @return
- */
- public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
- {
- if (!blockModelIds.containsKey(modelId)) {
- return false;
- }
- BlockRenderInfo bri = blockModelIds.get(modelId);
- return bri.renderWorldBlock(world, x, y, z, block, modelId, renderer);
- }
-
- /**
- * @param renderer
- * @param block
- * @param metadata
- * @param modelID
- */
- public void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
- {
- if (!blockModelIds.containsKey(modelID)) {
- return;
- }
- BlockRenderInfo bri=blockModelIds.get(modelID);
- bri.renderInventoryBlock(block, metadata, modelID, renderer);
- }
-
- /**
- * @param p_1219_0_
- * @return
- */
- public boolean renderItemAsFull3DBlock(int modelId)
- {
- BlockRenderInfo bri = blockModelIds.get(modelId);
- if (bri!=null) {
- return bri.shouldRender3DInInventory();
- }
- return false;
- }
-
- public void registerTextureOverrides(RenderEngine renderer) {
- for (ModContainer mod : Loader.getModList()) {
- registerAnimatedTexturesFor(mod);
- }
-
- for (OverrideInfo animationOverride : animationSet) {
- renderer.func_1066_a(animationOverride.textureFX);
- addedTextureFX.add(animationOverride.textureFX);
- FMLCommonHandler.instance().getFMLLogger().finer(String.format("Registered texture override %d (%d) on %s (%d)", animationOverride.index, animationOverride.textureFX.field_1126_b, animationOverride.textureFX.getClass().getSimpleName(), animationOverride.textureFX.field_1128_f));
- }
-
- for (String fileToOverride : overrideInfo.keySet()) {
- for (OverrideInfo override : overrideInfo.get(fileToOverride)) {
- try
- {
- BufferedImage image=loadImageFromTexturePack(renderer, override.override);
- ModTextureStatic mts=new ModTextureStatic(override.index, 1, override.texture, image);
- renderer.func_1066_a(mts);
- addedTextureFX.add(mts);
- FMLCommonHandler.instance().getFMLLogger().finer(String.format("Registered texture override %d (%d) on %s (%d)", override.index, mts.field_1126_b, override.texture, mts.field_1128_f));
- }
- catch (IOException e)
- {
- FMLCommonHandler.instance().getFMLLogger().throwing("FMLClientHandler", "registerTextureOverrides", e);
- }
- }
- }
- }
-
- /**
- * @param mod
- */
- private void registerAnimatedTexturesFor(ModContainer mod)
- {
- this.animationCallbackMod=mod;
- mod.requestAnimations();
- this.animationCallbackMod=null;
- }
-
- public String getObjectName(Object instance) {
- String objectName;
- if (instance instanceof Item) {
- objectName=((Item)instance).func_20009_a();
- } else if (instance instanceof Block) {
- objectName=((Block)instance).func_20013_i();
- } else if (instance instanceof ItemStack) {
- objectName=Item.field_233_c[((ItemStack)instance).field_1617_c].func_21011_b((ItemStack)instance);
- } else {
- throw new IllegalArgumentException(String.format("Illegal object for naming %s",instance));
- }
- objectName+=".name";
- return objectName;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.IFMLSidedHandler#readMetadataFrom(java.io.InputStream, cpw.mods.fml.common.ModContainer)
- */
- @Override
- public ModMetadata readMetadataFrom(InputStream input, ModContainer mod) throws Exception
- {
- JsonNode root=new JdomParser().func_27366_a(new InputStreamReader(input));
- List lst=root.func_27217_b();
- JsonNode modinfo = null;
- for (JsonNode tmodinfo : lst) {
- if (mod.getName().equals(tmodinfo.func_27213_a("modid"))) {
- modinfo = tmodinfo;
- break;
- }
- }
- if (modinfo == null) {
- FMLCommonHandler.instance().getFMLLogger().fine(String.format("Unable to process JSON modinfo file for %s", mod.getName()));
- return null;
- }
- ModMetadata meta=new ModMetadata(mod);
- try {
- meta.name=modinfo.func_27213_a("name");
- meta.description=modinfo.func_27213_a("description").replace("\r", "");
- meta.version=modinfo.func_27213_a("version");
- meta.credits=modinfo.func_27213_a("credits");
- List authors=modinfo.func_27217_b("authors");
- StringBuilder sb=new StringBuilder();
- for (int i=0; i effects)
- {
- ListIterator li = addedTextureFX.listIterator();
- while (li.hasNext())
- {
- TextureFX tex = li.next();
- if (tex instanceof FMLTextureFX)
- {
- if (((FMLTextureFX)tex).unregister(client.field_6315_n, effects))
- {
- li.remove();
- }
- }
- else
- {
- effects.remove(tex);
- li.remove();
- }
- }
- }
-
- /**
- * @param p_6531_1_
- */
- public void loadTextures(TexturePackBase texturePack)
- {
- registerTextureOverrides(client.field_6315_n);
- }
-
- /**
- * @param field_6539_c
- */
- public void onEarlyTexturePackLoad(TexturePackBase fallback)
- {
- if (client==null) {
- // We're far too early- let's wait
- this.fallbackTexturePack=fallback;
- } else {
- loadTextures(fallback);
- }
- }
-
- /**
- * @param packet
- */
- public void sendPacket(Packet packet)
- {
- if (this.networkClient!=null) {
- this.networkClient.func_847_a(packet);
- }
- }
-
- /**
- * @param anim
- */
- public void addAnimation(TextureFX anim)
- {
- if (animationCallbackMod==null) {
- return;
- }
- OverrideInfo info=new OverrideInfo();
- info.index=anim.field_1126_b;
- info.imageIndex=anim.field_1128_f;
- info.textureFX=anim;
- if (animationSet.contains(info)) {
- animationSet.remove(info);
- }
- animationSet.add(info);
- }
-
@Override
public void profileStart(String profileLabel) {
- Profiler.func_40663_a(profileLabel);
+ client.field_71424_I.func_76320_a(profileLabel);
}
@Override
public void profileEnd() {
- Profiler.func_40662_b();
- }
-
- /**
- *
- */
- public void preGameLoad(String user, String sessionToken)
- {
- // Currently this does nothing, but it's possible I could relaunch Minecraft in a new classloader if I wished
- Minecraft.fmlReentry(user, sessionToken);
- }
-
- public void onTexturePackChange(RenderEngine engine, TexturePackBase texturepack, List effects)
- {
- FMLClientHandler.instance().pruneOldTextureFX(texturepack, effects);
-
- for (TextureFX tex : effects)
- {
- if (tex instanceof ITextureFX)
- {
- ((ITextureFX)tex).onTexturePackChanged(engine, texturepack, getTextureDimensions(tex));
- }
- }
-
- FMLClientHandler.instance().loadTextures(texturepack);
- }
-
- private HashMap textureDims = new HashMap();
- private IdentityHashMap effectTextures = new IdentityHashMap();
- public void setTextureDimensions(int id, int width, int height, List effects)
- {
- Dimension dim = new Dimension(width, height);
- textureDims.put(id, dim);
-
- for (TextureFX tex : effects)
- {
- if (getEffectTexture(tex) == id && tex instanceof ITextureFX)
- {
- ((ITextureFX)tex).onTextureDimensionsUpdate(width, height);
- }
- }
- }
-
- public Dimension getTextureDimensions(TextureFX effect)
- {
- return getTextureDimensions(getEffectTexture(effect));
- }
-
- public Dimension getTextureDimensions(int id)
- {
- return textureDims.get(id);
- }
-
- public int getEffectTexture(TextureFX effect)
- {
- Integer id = effectTextures.get(effect);
- if (id != null)
- {
- return id;
- }
-
- int old = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);
-
- effect.func_782_a(client.field_6315_n);
-
- id = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);
-
- GL11.glBindTexture(GL_TEXTURE_2D, old);
-
- effectTextures.put(effect, id);
-
- return id;
- }
-
- public boolean onUpdateTextureEffect(TextureFX effect)
- {
- Logger log = FMLCommonHandler.instance().getFMLLogger();
- ITextureFX ifx = (effect instanceof ITextureFX ? ((ITextureFX)effect) : null);
-
- if (ifx != null && ifx.getErrored())
- {
- return false;
- }
-
- String name = effect.getClass().getSimpleName();
- Profiler.func_40663_a(name);
-
- try
- {
- if (optifineContainer == null)
- {
- effect.func_783_a();
- }
- }
- catch (Exception e)
- {
- log.warning(String.format("Texture FX %s has failed to animate. Likely caused by a texture pack change that they did not respond correctly to", name));
- if (ifx != null)
- {
- ifx.setErrored(true);
- }
- Profiler.func_40662_b();
- return false;
- }
- Profiler.func_40662_b();
-
- if (ifx != null)
- {
- Dimension dim = getTextureDimensions(effect);
- int target = ((dim.width >> 4) * (dim.height >> 4)) << 2;
- if (effect.field_1127_a.length != target)
- {
- log.warning(String.format("Detected a texture FX sizing discrepancy in %s (%d, %d)", name, effect.field_1127_a.length, target));
- ifx.setErrored(true);
- return false;
- }
- }
- return true;
- }
-
- //Quick and dirty image scaling, no smoothing or fanciness, meant for speed as it will be called every tick.
- public void scaleTextureFXData(byte[] data, ByteBuffer buf, int target, int length)
- {
- int sWidth = (int)Math.sqrt(data.length / 4);
- int factor = target / sWidth;
- byte[] tmp = new byte[4];
-
- buf.clear();
-
- if (factor > 1)
- {
- for (int y = 0; y < sWidth; y++)
- {
- int sRowOff = sWidth * y;
- int tRowOff = target * y * factor;
- for (int x = 0; x < sWidth; x++)
- {
- int sPos = (x + sRowOff) * 4;
- tmp[0] = data[sPos + 0];
- tmp[1] = data[sPos + 1];
- tmp[2] = data[sPos + 2];
- tmp[3] = data[sPos + 3];
-
- int tPosTop = (x * factor) + tRowOff;
- for (int y2 = 0; y2 < factor; y2++)
- {
- buf.position((tPosTop + (y2 * target)) * 4);
- for (int x2 = 0; x2 < factor; x2++)
- {
- buf.put(tmp);
- }
- }
- }
- }
- }
-
- buf.position(0).limit(length);
- }
-
- public void onPreRegisterEffect(TextureFX effect)
- {
- Dimension dim = getTextureDimensions(effect);
- if (effect instanceof ITextureFX)
- {
- ((ITextureFX)effect).onTextureDimensionsUpdate(dim.width, dim.height);
- }
+ client.field_71424_I.func_76319_b();
}
/* (non-Javadoc)
@@ -1134,7 +345,7 @@ public class FMLClientHandler implements IFMLSidedHandler
*/
public void addSpecialModEntries(ArrayList mods)
{
- mods.add(new FMLModLoaderContainer());
+ mods.add(new FMLDummyContainer());
if (optifineContainer!=null) {
mods.add(optifineContainer);
}
@@ -1171,11 +382,26 @@ public class FMLClientHandler implements IFMLSidedHandler
return null;
}
- /**
- * @param biome
- */
- public void removeBiomeFromDefaultWorldGenerator(BiomeGenBase biome)
+ @Override
+ public String getCurrentLanguage()
{
- WorldType.field_48635_b.removeBiome(biome);
+ return null;
+ }
+
+ @Override
+ public Properties getCurrentLanguageTable()
+ {
+ return null;
+ }
+
+ @Override
+ public String getObjectName(Object minecraftObject)
+ {
+ return null;
+ }
+
+ public boolean hasOptifine()
+ {
+ return optifineContainer!=null;
}
}
diff --git a/fml/client/cpw/mods/fml/client/FMLTextureFX.java b/fml/client/cpw/mods/fml/client/FMLTextureFX.java
index be2c71f6ab..2dbf232237 100644
--- a/fml/client/cpw/mods/fml/client/FMLTextureFX.java
+++ b/fml/client/cpw/mods/fml/client/FMLTextureFX.java
@@ -32,20 +32,20 @@ public class FMLTextureFX extends TextureFX implements ITextureFX
public int tileSizeSquareMask = 255;
public boolean errored = false;
protected Logger log = FMLCommonHandler.instance().getFMLLogger();
-
+
public FMLTextureFX(int icon)
{
super(icon);
}
-
+
@Override public void setErrored(boolean err){ errored = err; }
@Override public boolean getErrored(){ return errored; }
- @Override
+ @Override
public void onTexturePackChanged(RenderEngine engine, TexturePackBase texturepack, Dimension dimensions)
{
onTextureDimensionsUpdate(dimensions.width, dimensions.height);
}
- @Override
+ @Override
public void onTextureDimensionsUpdate(int width, int height)
{
tileSizeBase = width >> 4;
@@ -58,9 +58,9 @@ public class FMLTextureFX extends TextureFX implements ITextureFX
protected void setup()
{
- field_1127_a = new byte[tileSizeSquare << 2];
+ field_76852_a = new byte[tileSizeSquare << 2];
}
-
+
public boolean unregister(RenderEngine engine, List effects)
{
effects.remove(this);
diff --git a/fml/client/cpw/mods/fml/client/GuiModList.java b/fml/client/cpw/mods/fml/client/GuiModList.java
index 3ce6203c16..1e9d548bdc 100644
--- a/fml/client/cpw/mods/fml/client/GuiModList.java
+++ b/fml/client/cpw/mods/fml/client/GuiModList.java
@@ -22,7 +22,7 @@ import java.util.Map;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.FMLModContainer;
-import cpw.mods.fml.common.FMLModLoaderContainer;
+import cpw.mods.fml.common.FMLDummyContainer;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import net.minecraft.client.Minecraft;
@@ -39,7 +39,6 @@ import net.minecraft.src.Tessellator;
*/
public class GuiModList extends GuiScreen
{
-
private GuiScreen mainMenu;
private GuiSlotModList modList;
private int selected = -1;
@@ -55,98 +54,104 @@ public class GuiModList extends GuiScreen
this.mainMenu=mainMenu;
this.mods=new ArrayList();
FMLClientHandler.instance().addSpecialModEntries(mods);
- for (ModContainer mod : Loader.getModList()) {
+ for (ModContainer mod : Loader.instance().getModList()) {
if (mod.getMetadata()!=null && mod.getMetadata().parentMod != null) {
continue;
}
mods.add(mod);
}
}
-
- public void func_6448_a()
+
+ @Override
+ public void func_73866_w_()
{
for (ModContainer mod : mods) {
- listWidth=Math.max(listWidth,getFontRenderer().func_871_a(mod.getName()) + 10);
- listWidth=Math.max(listWidth,getFontRenderer().func_871_a(mod.getVersion()) + 10);
+ listWidth=Math.max(listWidth,getFontRenderer().func_78256_a(mod.getName()) + 10);
+ listWidth=Math.max(listWidth,getFontRenderer().func_78256_a(mod.getVersion()) + 10);
}
listWidth=Math.min(listWidth, 150);
- StringTranslate translations = StringTranslate.func_20162_a();
- this.field_949_e.add(new GuiSmallButton(6, this.field_951_c / 2 - 75, this.field_950_d - 38, translations.func_20163_a("gui.done")));
+ StringTranslate translations = StringTranslate.func_74808_a();
+ this.field_73887_h.add(new GuiSmallButton(6, this.field_73880_f / 2 - 75, this.field_73881_g - 38, translations.func_74805_b("gui.done")));
this.modList=new GuiSlotModList(this, mods, listWidth);
- this.modList.registerScrollButtons(this.field_949_e, 7, 8);
+ this.modList.registerScrollButtons(this.field_73887_h, 7, 8);
}
- protected void func_572_a(GuiButton button) {
- if (button.field_937_g)
+ @Override
+ protected void func_73875_a(GuiButton button) {
+ if (button.field_73742_g)
{
- switch (button.field_938_f)
+ switch (button.field_73741_f)
{
case 6:
- this.field_945_b.func_6272_a(this.mainMenu);
+ this.field_73882_e.func_71373_a(this.mainMenu);
return;
}
}
- super.func_572_a(button);
+ super.func_73875_a(button);
}
public int drawLine(String line, int offset, int shifty)
{
- this.field_6451_g.func_873_b(line, offset, shifty, 0xd7edea);
+ this.field_73886_k.func_78276_b(line, offset, shifty, 0xd7edea);
return shifty + 10;
}
- public void func_571_a(int p_571_1_, int p_571_2_, float p_571_3_)
+
+ @Override
+ public void func_73863_a(int p_571_1_, int p_571_2_, float p_571_3_)
{
this.modList.drawScreen(p_571_1_, p_571_2_, p_571_3_);
- this.func_548_a(this.field_6451_g, "Mod List", this.field_951_c / 2, 16, 0xFFFFFF);
+ this.func_73732_a(this.field_73886_k, "Mod List", this.field_73880_f / 2, 16, 0xFFFFFF);
int offset = this.listWidth + 20;
if (selectedMod != null) {
- if (selectedMod.getMetadata() != null) {
+ if (!selectedMod.getMetadata().autogenerated) {
int shifty = 35;
if (!selectedMod.getMetadata().logoFile.isEmpty())
{
- int texture = this.field_945_b.field_6315_n.func_1070_a(selectedMod.getMetadata().logoFile);
+ int texture = this.field_73882_e.field_71446_o.func_78341_b(selectedMod.getMetadata().logoFile);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- this.field_945_b.field_6315_n.func_1076_b(texture);
- Dimension dim = FMLClientHandler.instance().getTextureDimensions(texture);
+ this.field_73882_e.field_71446_o.func_78342_b(texture);
+ Dimension dim = TextureFXManager.instance().getTextureDimensions(texture);
int top = 32;
- Tessellator tess = Tessellator.field_1512_a;
- tess.func_977_b();
- tess.func_983_a(offset, top + dim.height, field_923_k, 0, 1);
- tess.func_983_a(offset + dim.width, top + dim.height, field_923_k, 1, 1);
- tess.func_983_a(offset + dim.width, top, field_923_k, 1, 0);
- tess.func_983_a(offset, top, field_923_k, 0, 0);
- tess.func_982_a();
-
+ Tessellator tess = Tessellator.field_78398_a;
+ tess.func_78382_b();
+ tess.func_78374_a(offset, top + dim.height, field_73735_i, 0, 1);
+ tess.func_78374_a(offset + dim.width, top + dim.height, field_73735_i, 1, 1);
+ tess.func_78374_a(offset + dim.width, top, field_73735_i, 1, 0);
+ tess.func_78374_a(offset, top, field_73735_i, 0, 0);
+ tess.func_78381_a();
+
shifty += 65;
}
- this.field_6451_g.func_50103_a(selectedMod.getMetadata().name, offset, shifty, 0xFFFFFF);
+ this.field_73886_k.func_78261_a(selectedMod.getMetadata().name, offset, shifty, 0xFFFFFF);
shifty += 12;
-
+
shifty = drawLine(String.format("Version: %s (%s)", selectedMod.getMetadata().version, selectedMod.getVersion()), offset, shifty);
+ shifty = drawLine(String.format("Mod State: %s", Loader.instance().getModState(selectedMod)), offset, shifty);
if (!selectedMod.getMetadata().credits.isEmpty()) {
shifty = drawLine(String.format("Credits: %s", selectedMod.getMetadata().credits), offset, shifty);
}
shifty = drawLine(String.format("Authors: %s", selectedMod.getMetadata().getAuthorList()), offset, shifty);
shifty = drawLine(String.format("URL: %s", selectedMod.getMetadata().url), offset, shifty);
shifty = drawLine(selectedMod.getMetadata().childMods.isEmpty() ? "No child mods for this mod" : String.format("Child mods: %s", selectedMod.getMetadata().getChildModList()), offset, shifty);
- this.getFontRenderer().func_27278_a(selectedMod.getMetadata().description, offset, shifty + 10, this.field_951_c - offset - 20, 0xDDDDDD);
+ this.getFontRenderer().func_78279_b(selectedMod.getMetadata().description, offset, shifty + 10, this.field_73880_f - offset - 20, 0xDDDDDD);
} else {
- offset = ( this.listWidth + this.field_951_c ) / 2;
- this.func_548_a(this.field_6451_g, selectedMod.getName(), offset, 35, 0xFFFFFF);
- this.func_548_a(this.field_6451_g, String.format("Version: %s",selectedMod.getVersion()), offset, 45, 0xFFFFFF);
- this.func_548_a(this.field_6451_g, "No mod information found", offset, 55, 0xDDDDDD);
- this.func_548_a(this.field_6451_g, "Ask your mod author to provide a mod .info file", offset, 65, 0xDDDDDD);
+ offset = ( this.listWidth + this.field_73880_f ) / 2;
+ this.func_73732_a(this.field_73886_k, selectedMod.getName(), offset, 35, 0xFFFFFF);
+ this.func_73732_a(this.field_73886_k, String.format("Version: %s",selectedMod.getVersion()), offset, 45, 0xFFFFFF);
+ this.func_73732_a(this.field_73886_k, String.format("Mod State: %s",Loader.instance().getModState(selectedMod)), offset, 55, 0xFFFFFF);
+ this.func_73732_a(this.field_73886_k, "No mod information found", offset, 65, 0xDDDDDD);
+ this.func_73732_a(this.field_73886_k, "Ask your mod author to provide a mod mcmod.info file", offset, 75, 0xDDDDDD);
}
}
- super.func_571_a(p_571_1_, p_571_2_, p_571_3_);
+ super.func_73863_a(p_571_1_, p_571_2_, p_571_3_);
}
Minecraft getMinecraftInstance() {
- return field_945_b;
+ return field_73882_e;
}
-
+
FontRenderer getFontRenderer() {
- return field_6451_g;
+ return field_73886_k;
}
/**
diff --git a/fml/client/cpw/mods/fml/client/GuiScrollingList.java b/fml/client/cpw/mods/fml/client/GuiScrollingList.java
index a48c8354dc..033d3655a0 100644
--- a/fml/client/cpw/mods/fml/client/GuiScrollingList.java
+++ b/fml/client/cpw/mods/fml/client/GuiScrollingList.java
@@ -117,15 +117,15 @@ public abstract class GuiScrollingList
public void actionPerformed(GuiButton button)
{
- if (button.field_937_g)
+ if (button.field_73742_g)
{
- if (button.field_938_f == this.scrollUpActionId)
+ if (button.field_73741_f == this.scrollUpActionId)
{
this.scrollDistance -= (float)(this.slotHeight * 2 / 3);
this.initialMouseClickY = -2.0F;
this.applyScrollLimits();
}
- else if (button.field_938_f == this.scrollDownActionId)
+ else if (button.field_73741_f == this.scrollDownActionId)
{
this.scrollDistance += (float)(this.slotHeight * 2 / 3);
this.initialMouseClickY = -2.0F;
@@ -249,17 +249,17 @@ public abstract class GuiScrollingList
this.applyScrollLimits();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_FOG);
- Tessellator var18 = Tessellator.field_1512_a;
- GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.client.field_6315_n.func_1070_a("/gui/background.png"));
+ Tessellator var18 = Tessellator.field_78398_a;
+ GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.client.field_71446_o.func_78341_b("/gui/background.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
float var17 = 32.0F;
- var18.func_977_b();
- var18.func_990_b(2105376);
- var18.func_983_a((double)this.left, (double)this.bottom, 0.0D, (double)((float)this.left / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
- var18.func_983_a((double)this.right, (double)this.bottom, 0.0D, (double)((float)this.right / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
- var18.func_983_a((double)this.right, (double)this.top, 0.0D, (double)((float)this.right / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
- var18.func_983_a((double)this.left, (double)this.top, 0.0D, (double)((float)this.left / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
- var18.func_982_a();
+ var18.func_78382_b();
+ var18.func_78378_d(2105376);
+ var18.func_78374_a((double)this.left, (double)this.bottom, 0.0D, (double)((float)this.left / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
+ var18.func_78374_a((double)this.right, (double)this.bottom, 0.0D, (double)((float)this.right / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
+ var18.func_78374_a((double)this.right, (double)this.top, 0.0D, (double)((float)this.right / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
+ var18.func_78374_a((double)this.left, (double)this.top, 0.0D, (double)((float)this.left / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
+ var18.func_78381_a();
// boxRight = this.listWidth / 2 - 92 - 16;
var10 = this.top + 4 - (int)this.scrollDistance;
@@ -283,18 +283,18 @@ public abstract class GuiScrollingList
int var15 = boxRight;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
- var18.func_977_b();
- var18.func_990_b(8421504);
- var18.func_983_a((double)var14, (double)(var19 + var13 + 2), 0.0D, 0.0D, 1.0D);
- var18.func_983_a((double)var15, (double)(var19 + var13 + 2), 0.0D, 1.0D, 1.0D);
- var18.func_983_a((double)var15, (double)(var19 - 2), 0.0D, 1.0D, 0.0D);
- var18.func_983_a((double)var14, (double)(var19 - 2), 0.0D, 0.0D, 0.0D);
- var18.func_990_b(0);
- var18.func_983_a((double)(var14 + 1), (double)(var19 + var13 + 1), 0.0D, 0.0D, 1.0D);
- var18.func_983_a((double)(var15 - 1), (double)(var19 + var13 + 1), 0.0D, 1.0D, 1.0D);
- var18.func_983_a((double)(var15 - 1), (double)(var19 - 1), 0.0D, 1.0D, 0.0D);
- var18.func_983_a((double)(var14 + 1), (double)(var19 - 1), 0.0D, 0.0D, 0.0D);
- var18.func_982_a();
+ var18.func_78382_b();
+ var18.func_78378_d(8421504);
+ var18.func_78374_a((double)var14, (double)(var19 + var13 + 2), 0.0D, 0.0D, 1.0D);
+ var18.func_78374_a((double)var15, (double)(var19 + var13 + 2), 0.0D, 1.0D, 1.0D);
+ var18.func_78374_a((double)var15, (double)(var19 - 2), 0.0D, 1.0D, 0.0D);
+ var18.func_78374_a((double)var14, (double)(var19 - 2), 0.0D, 0.0D, 0.0D);
+ var18.func_78378_d(0);
+ var18.func_78374_a((double)(var14 + 1), (double)(var19 + var13 + 1), 0.0D, 0.0D, 1.0D);
+ var18.func_78374_a((double)(var15 - 1), (double)(var19 + var13 + 1), 0.0D, 1.0D, 1.0D);
+ var18.func_78374_a((double)(var15 - 1), (double)(var19 - 1), 0.0D, 1.0D, 0.0D);
+ var18.func_78374_a((double)(var14 + 1), (double)(var19 - 1), 0.0D, 0.0D, 0.0D);
+ var18.func_78381_a();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
@@ -311,22 +311,22 @@ public abstract class GuiScrollingList
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glDisable(GL11.GL_TEXTURE_2D);
- var18.func_977_b();
- var18.func_6513_a(0, 0);
- var18.func_983_a((double)this.left, (double)(this.top + var20), 0.0D, 0.0D, 1.0D);
- var18.func_983_a((double)this.right, (double)(this.top + var20), 0.0D, 1.0D, 1.0D);
- var18.func_6513_a(0, 255);
- var18.func_983_a((double)this.right, (double)this.top, 0.0D, 1.0D, 0.0D);
- var18.func_983_a((double)this.left, (double)this.top, 0.0D, 0.0D, 0.0D);
- var18.func_982_a();
- var18.func_977_b();
- var18.func_6513_a(0, 255);
- var18.func_983_a((double)this.left, (double)this.bottom, 0.0D, 0.0D, 1.0D);
- var18.func_983_a((double)this.right, (double)this.bottom, 0.0D, 1.0D, 1.0D);
- var18.func_6513_a(0, 0);
- var18.func_983_a((double)this.right, (double)(this.bottom - var20), 0.0D, 1.0D, 0.0D);
- var18.func_983_a((double)this.left, (double)(this.bottom - var20), 0.0D, 0.0D, 0.0D);
- var18.func_982_a();
+ var18.func_78382_b();
+ var18.func_78384_a(0, 0);
+ var18.func_78374_a((double)this.left, (double)(this.top + var20), 0.0D, 0.0D, 1.0D);
+ var18.func_78374_a((double)this.right, (double)(this.top + var20), 0.0D, 1.0D, 1.0D);
+ var18.func_78384_a(0, 255);
+ var18.func_78374_a((double)this.right, (double)this.top, 0.0D, 1.0D, 0.0D);
+ var18.func_78374_a((double)this.left, (double)this.top, 0.0D, 0.0D, 0.0D);
+ var18.func_78381_a();
+ var18.func_78382_b();
+ var18.func_78384_a(0, 255);
+ var18.func_78374_a((double)this.left, (double)this.bottom, 0.0D, 0.0D, 1.0D);
+ var18.func_78374_a((double)this.right, (double)this.bottom, 0.0D, 1.0D, 1.0D);
+ var18.func_78384_a(0, 0);
+ var18.func_78374_a((double)this.right, (double)(this.bottom - var20), 0.0D, 1.0D, 0.0D);
+ var18.func_78374_a((double)this.left, (double)(this.bottom - var20), 0.0D, 0.0D, 0.0D);
+ var18.func_78381_a();
var19 = this.getContentHeight() - (this.bottom - this.top - 4);
if (var19 > 0)
@@ -350,27 +350,27 @@ public abstract class GuiScrollingList
var14 = this.top;
}
- var18.func_977_b();
- var18.func_6513_a(0, 255);
- var18.func_983_a((double)scrollBarXStart, (double)this.bottom, 0.0D, 0.0D, 1.0D);
- var18.func_983_a((double)scrollBarXEnd, (double)this.bottom, 0.0D, 1.0D, 1.0D);
- var18.func_983_a((double)scrollBarXEnd, (double)this.top, 0.0D, 1.0D, 0.0D);
- var18.func_983_a((double)scrollBarXStart, (double)this.top, 0.0D, 0.0D, 0.0D);
- var18.func_982_a();
- var18.func_977_b();
- var18.func_6513_a(8421504, 255);
- var18.func_983_a((double)scrollBarXStart, (double)(var14 + var13), 0.0D, 0.0D, 1.0D);
- var18.func_983_a((double)scrollBarXEnd, (double)(var14 + var13), 0.0D, 1.0D, 1.0D);
- var18.func_983_a((double)scrollBarXEnd, (double)var14, 0.0D, 1.0D, 0.0D);
- var18.func_983_a((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
- var18.func_982_a();
- var18.func_977_b();
- var18.func_6513_a(12632256, 255);
- var18.func_983_a((double)scrollBarXStart, (double)(var14 + var13 - 1), 0.0D, 0.0D, 1.0D);
- var18.func_983_a((double)(scrollBarXEnd - 1), (double)(var14 + var13 - 1), 0.0D, 1.0D, 1.0D);
- var18.func_983_a((double)(scrollBarXEnd - 1), (double)var14, 0.0D, 1.0D, 0.0D);
- var18.func_983_a((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
- var18.func_982_a();
+ var18.func_78382_b();
+ var18.func_78384_a(0, 255);
+ var18.func_78374_a((double)scrollBarXStart, (double)this.bottom, 0.0D, 0.0D, 1.0D);
+ var18.func_78374_a((double)scrollBarXEnd, (double)this.bottom, 0.0D, 1.0D, 1.0D);
+ var18.func_78374_a((double)scrollBarXEnd, (double)this.top, 0.0D, 1.0D, 0.0D);
+ var18.func_78374_a((double)scrollBarXStart, (double)this.top, 0.0D, 0.0D, 0.0D);
+ var18.func_78381_a();
+ var18.func_78382_b();
+ var18.func_78384_a(8421504, 255);
+ var18.func_78374_a((double)scrollBarXStart, (double)(var14 + var13), 0.0D, 0.0D, 1.0D);
+ var18.func_78374_a((double)scrollBarXEnd, (double)(var14 + var13), 0.0D, 1.0D, 1.0D);
+ var18.func_78374_a((double)scrollBarXEnd, (double)var14, 0.0D, 1.0D, 0.0D);
+ var18.func_78374_a((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
+ var18.func_78381_a();
+ var18.func_78382_b();
+ var18.func_78384_a(12632256, 255);
+ var18.func_78374_a((double)scrollBarXStart, (double)(var14 + var13 - 1), 0.0D, 0.0D, 1.0D);
+ var18.func_78374_a((double)(scrollBarXEnd - 1), (double)(var14 + var13 - 1), 0.0D, 1.0D, 1.0D);
+ var18.func_78374_a((double)(scrollBarXEnd - 1), (double)var14, 0.0D, 1.0D, 0.0D);
+ var18.func_78374_a((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
+ var18.func_78381_a();
}
this.func_27257_b(mouseX, mouseY);
@@ -382,17 +382,17 @@ public abstract class GuiScrollingList
private void overlayBackground(int p_22239_1_, int p_22239_2_, int p_22239_3_, int p_22239_4_)
{
- Tessellator var5 = Tessellator.field_1512_a;
- GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.client.field_6315_n.func_1070_a("/gui/background.png"));
+ Tessellator var5 = Tessellator.field_78398_a;
+ GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.client.field_71446_o.func_78341_b("/gui/background.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
float var6 = 32.0F;
- var5.func_977_b();
- var5.func_6513_a(4210752, p_22239_4_);
- var5.func_983_a(0.0D, (double)p_22239_2_, 0.0D, 0.0D, (double)((float)p_22239_2_ / var6));
- var5.func_983_a((double)this.listWidth + 30, (double)p_22239_2_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_2_ / var6));
- var5.func_6513_a(4210752, p_22239_3_);
- var5.func_983_a((double)this.listWidth + 30, (double)p_22239_1_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_1_ / var6));
- var5.func_983_a(0.0D, (double)p_22239_1_, 0.0D, 0.0D, (double)((float)p_22239_1_ / var6));
- var5.func_982_a();
+ var5.func_78382_b();
+ var5.func_78384_a(4210752, p_22239_4_);
+ var5.func_78374_a(0.0D, (double)p_22239_2_, 0.0D, 0.0D, (double)((float)p_22239_2_ / var6));
+ var5.func_78374_a((double)this.listWidth + 30, (double)p_22239_2_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_2_ / var6));
+ var5.func_78384_a(4210752, p_22239_3_);
+ var5.func_78374_a((double)this.listWidth + 30, (double)p_22239_1_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_1_ / var6));
+ var5.func_78374_a(0.0D, (double)p_22239_1_, 0.0D, 0.0D, (double)((float)p_22239_1_ / var6));
+ var5.func_78381_a();
}
}
diff --git a/fml/client/cpw/mods/fml/client/GuiSlotModList.java b/fml/client/cpw/mods/fml/client/GuiSlotModList.java
index 8398d743cd..d40ea1b466 100644
--- a/fml/client/cpw/mods/fml/client/GuiSlotModList.java
+++ b/fml/client/cpw/mods/fml/client/GuiSlotModList.java
@@ -17,6 +17,7 @@ package cpw.mods.fml.client;
import java.util.ArrayList;
import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.common.LoaderState.ModState;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.ModMetadata;
import net.minecraft.client.Minecraft;
@@ -36,7 +37,7 @@ public class GuiSlotModList extends GuiScrollingList
public GuiSlotModList(GuiModList parent, ArrayList mods, int listWidth)
{
- super(parent.getMinecraftInstance(), listWidth, parent.field_950_d, 32, parent.field_950_d - 65 + 4, 10, 35);
+ super(parent.getMinecraftInstance(), listWidth, parent.field_73881_g, 32, parent.field_73881_g - 65 + 4, 10, 35);
this.parent=parent;
this.mods=mods;
}
@@ -62,7 +63,7 @@ public class GuiSlotModList extends GuiScrollingList
@Override
protected void drawBackground()
{
- this.parent.func_578_i();
+ this.parent.func_73873_v_();
}
@Override
@@ -70,14 +71,23 @@ public class GuiSlotModList extends GuiScrollingList
{
return (this.getSize()) * 35 + 1;
}
-
+
@Override
protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5)
{
ModContainer mc=mods.get(listIndex);
- this.parent.getFontRenderer().func_873_b(this.parent.getFontRenderer().func_50107_a(mc.getName(), listWidth - 11), this.left + 3 , var3 + 2, 0xFFFFFF);
- this.parent.getFontRenderer().func_873_b(this.parent.getFontRenderer().func_50107_a(mc.getVersion(), listWidth - 11), this.left + 3 , var3 + 12, 0xCCCCCC);
- this.parent.getFontRenderer().func_873_b(this.parent.getFontRenderer().func_50107_a(mc.getMetadata() !=null ? mc.getMetadata().getChildModCountString() : "Metadata not found", listWidth - 9), this.left + 3 , var3 + 22, 0xCCCCCC);
+ if (Loader.instance().getModState(mc)==ModState.DISABLED)
+ {
+ this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a(mc.getName(), listWidth - 11), this.left + 3 , var3 + 2, 0xFF2222);
+ this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a(mc.getVersion(), listWidth - 11), this.left + 3 , var3 + 12, 0xFF2222);
+ this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a("DISABLED", listWidth - 11), this.left + 3 , var3 + 22, 0xFF2222);
+ }
+ else
+ {
+ this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a(mc.getName(), listWidth - 11), this.left + 3 , var3 + 2, 0xFFFFFF);
+ this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a(mc.getVersion(), listWidth - 11), this.left + 3 , var3 + 12, 0xCCCCCC);
+ this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a(mc.getMetadata() !=null ? mc.getMetadata().getChildModCountString() : "Metadata not found", listWidth - 9), this.left + 3 , var3 + 22, 0xCCCCCC);
+ }
}
}
diff --git a/fml/client/cpw/mods/fml/client/KeyBindingHandler.java b/fml/client/cpw/mods/fml/client/KeyBindingHandler.java
deleted file mode 100644
index 72744c8600..0000000000
--- a/fml/client/cpw/mods/fml/client/KeyBindingHandler.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * The FML Forge Mod Loader suite.
- * Copyright (C) 2012 cpw
- *
- * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package cpw.mods.fml.client;
-
-import org.lwjgl.input.Keyboard;
-import org.lwjgl.input.Mouse;
-
-import net.minecraft.src.KeyBinding;
-import cpw.mods.fml.common.IKeyHandler;
-import cpw.mods.fml.common.ModContainer;
-import cpw.mods.fml.common.modloader.ModLoaderModContainer;
-
-/**
- * @author cpw
- *
- */
-public class KeyBindingHandler implements IKeyHandler
-{
-
- private boolean shouldRepeat;
- private KeyBinding keyBinding;
- private ModContainer modContainer;
- private boolean lastState = false;
-
- /**
- * @param keyHandler
- * @param allowRepeat
- * @param modContainer
- */
- public KeyBindingHandler(KeyBinding keyHandler, boolean allowRepeat, ModContainer modContainer)
- {
- this.keyBinding=keyHandler;
- this.shouldRepeat=allowRepeat;
- this.modContainer=modContainer;
- }
-
- @Override
- public Object getKeyBinding()
- {
- return this.keyBinding;
- }
-
- /**
- * @return the modContainer
- */
- public ModContainer getOwningContainer()
- {
- return modContainer;
- }
-
- @Override
- public void onEndTick()
- {
- int keyCode = keyBinding.field_1370_b;
- boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode));
- if (state && (!lastState || (lastState && shouldRepeat)))
- {
- modContainer.keyBindEvent(keyBinding);
- }
- lastState = state;
- }
-}
diff --git a/fml/client/cpw/mods/fml/client/ModLoaderKeyBindingHandler.java b/fml/client/cpw/mods/fml/client/ModLoaderKeyBindingHandler.java
new file mode 100644
index 0000000000..e28dbfb723
--- /dev/null
+++ b/fml/client/cpw/mods/fml/client/ModLoaderKeyBindingHandler.java
@@ -0,0 +1,104 @@
+/*
+ * The FML Forge Mod Loader suite.
+ * Copyright (C) 2012 cpw
+ *
+ * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package cpw.mods.fml.client;
+
+import java.util.EnumSet;
+
+import net.minecraft.src.KeyBinding;
+
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+
+import cpw.mods.fml.client.registry.KeyBindingRegistry;
+import cpw.mods.fml.common.TickType;
+import cpw.mods.fml.common.modloader.ModLoaderModContainer;
+import cpw.mods.fml.common.registry.TickRegistry;
+
+/**
+ * @author cpw
+ *
+ */
+public class ModLoaderKeyBindingHandler extends KeyBindingRegistry.KeyHandler
+{
+ private ModLoaderModContainer modContainer;
+ private boolean downArmed;
+ private boolean upArmed;
+
+ /**
+ * @param keyHandler
+ * @param allowRepeat
+ * @param modContainer
+ */
+ public ModLoaderKeyBindingHandler(KeyBinding keyBinding, boolean allowRepeat, ModLoaderModContainer modContainer)
+ {
+ super(keyBinding, allowRepeat);
+ this.modContainer=modContainer;
+ }
+
+ public void onRenderEndTick()
+ {
+ ((net.minecraft.src.BaseMod)modContainer.getMod()).keyboardEvent(keyBinding);
+ }
+
+ @Override
+ public void keyDown(EnumSet type, boolean end, boolean repeats)
+ {
+ if (!end)
+ {
+ return;
+ }
+ upArmed = false;
+ if (type.contains(TickType.GUILOAD)|| type.contains(TickType.GAME))
+ {
+ downArmed = true;
+ }
+ if (type.contains(TickType.RENDER) && downArmed)
+ {
+ onRenderEndTick();
+ downArmed = false;
+ }
+ }
+
+ @Override
+ public void keyUp(EnumSet type, boolean end)
+ {
+ if (!end)
+ {
+ return;
+ }
+ downArmed = false;
+ if (type.contains(TickType.GUILOAD)|| type.contains(TickType.GAME))
+ {
+ upArmed = true;
+ }
+ if (type.contains(TickType.RENDER) && upArmed)
+ {
+ onRenderEndTick();
+ upArmed = false;
+ }
+ }
+
+ @Override
+ public EnumSet ticks()
+ {
+ return EnumSet.of(TickType.GAME, TickType.RENDER, TickType.GUILOAD);
+ }
+
+ @Override
+ public String getLabel()
+ {
+ return modContainer.getModId() +" KB "+keyBinding.field_74512_d;
+ }
+}
diff --git a/fml/client/cpw/mods/fml/client/OptifineModContainer.java b/fml/client/cpw/mods/fml/client/OptifineModContainer.java
deleted file mode 100644
index 944dca941d..0000000000
--- a/fml/client/cpw/mods/fml/client/OptifineModContainer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * The FML Forge Mod Loader suite.
- * Copyright (C) 2012 cpw
- *
- * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package cpw.mods.fml.client;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import cpw.mods.fml.common.FMLModContainer;
-import cpw.mods.fml.common.IConsoleHandler;
-import cpw.mods.fml.common.ICraftingHandler;
-import cpw.mods.fml.common.IDispenseHandler;
-import cpw.mods.fml.common.IKeyHandler;
-import cpw.mods.fml.common.INetworkHandler;
-import cpw.mods.fml.common.IPickupNotifier;
-import cpw.mods.fml.common.IPlayerTracker;
-import cpw.mods.fml.common.IWorldGenerator;
-import cpw.mods.fml.common.ModContainer;
-import cpw.mods.fml.common.ModMetadata;
-
-/**
- * @author cpw
- *
- */
-public class OptifineModContainer extends FMLModContainer
-{
- private String optifineVersion;
- private ModMetadata metadata;
- /**
- * @param optifineConfig
- */
- public OptifineModContainer(Class> optifineConfig)
- {
- super("Optifine");
- try
- {
- optifineVersion = (String) optifineConfig.getField("VERSION").get(null);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public String getName()
- {
- return "Optifine";
- }
- @Override
- public String getVersion()
- {
- return optifineVersion;
- }
-
-}
diff --git a/fml/client/cpw/mods/fml/client/SpriteHelper.java b/fml/client/cpw/mods/fml/client/SpriteHelper.java
index ed95441fe5..92d65f0ee9 100644
--- a/fml/client/cpw/mods/fml/client/SpriteHelper.java
+++ b/fml/client/cpw/mods/fml/client/SpriteHelper.java
@@ -16,10 +16,11 @@ package cpw.mods.fml.client;
import java.util.BitSet;
import java.util.HashMap;
+import java.util.logging.Level;
import net.minecraft.src.ModLoader;
import cpw.mods.fml.common.FMLCommonHandler;
-import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.LoaderException;
/**
@@ -31,7 +32,7 @@ public class SpriteHelper
private static HashMap spriteInfo = new HashMap();
private static void initMCSpriteMaps() {
- BitSet slots =
+ BitSet slots =
SpriteHelper.toBitSet(
"0000000000000000" +
"0000000000000000" +
@@ -50,7 +51,7 @@ public class SpriteHelper
"0000000111111000" +
"0000000000000000");
spriteInfo.put("/terrain.png", slots);
-
+
slots = SpriteHelper.toBitSet(
"0000000000000000" +
"0000000000000000" +
@@ -73,8 +74,8 @@ public class SpriteHelper
/**
* Register a sprite map for ModTextureStatic, to allow for other mods to override
* your sprite page.
- *
- *
+ *
+ *
*/
public static void registerSpriteMapForFile(String file, String spriteMap) {
if (spriteInfo.size() == 0) {
@@ -86,20 +87,20 @@ public class SpriteHelper
}
spriteInfo.put(file, toBitSet(spriteMap));
}
-
+
public static int getUniqueSpriteIndex(String path)
{
if (!spriteInfo.containsKey("/terrain.png"))
{
initMCSpriteMaps();
}
-
+
BitSet slots = spriteInfo.get(path);
-
+
if (slots == null)
{
Exception ex = new Exception(String.format("Invalid getUniqueSpriteIndex call for texture: %s", path));
- Loader.log.throwing("ModLoader", "getUniqueSpriteIndex", ex);
+ FMLLog.log(Level.SEVERE, ex, "A critical error has been detected with sprite overrides");
FMLCommonHandler.instance().raiseException(ex,"Invalid request to getUniqueSpriteIndex",true);
}
@@ -108,7 +109,7 @@ public class SpriteHelper
if (ret == -1)
{
Exception ex = new Exception(String.format("No more sprite indicies left for: %s", path));
- Loader.log.throwing("ModLoader", "getUniqueSpriteIndex", ex);
+ FMLLog.log(Level.SEVERE, ex, "There are no sprite indicies left for %s", path);
FMLCommonHandler.instance().raiseException(ex,"No more sprite indicies left", true);
}
return ret;
diff --git a/fml/client/cpw/mods/fml/client/TextureFXManager.java b/fml/client/cpw/mods/fml/client/TextureFXManager.java
new file mode 100644
index 0000000000..dbb27cdf67
--- /dev/null
+++ b/fml/client/cpw/mods/fml/client/TextureFXManager.java
@@ -0,0 +1,342 @@
+package cpw.mods.fml.client;
+
+import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
+import static org.lwjgl.opengl.GL11.GL_TEXTURE_BINDING_2D;
+
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import javax.imageio.ImageIO;
+
+import org.lwjgl.opengl.GL11;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.src.KeyBinding;
+import net.minecraft.src.ModTextureStatic;
+import net.minecraft.src.Profiler;
+import net.minecraft.src.RenderEngine;
+import net.minecraft.src.TextureFX;
+import net.minecraft.src.TexturePackBase;
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.FMLLog;
+import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.common.ModContainer;
+
+public class TextureFXManager
+{
+ private static final TextureFXManager INSTANCE = new TextureFXManager();
+
+ private class TextureProperties
+ {
+ private int textureId;
+ private Dimension dim;
+ }
+
+ private Map textureProperties = Maps.newHashMap();
+ private Multimap overrideInfo = ArrayListMultimap.create();
+ private HashSet animationSet = new HashSet();
+
+ private List addedTextureFX = new ArrayList();
+
+ private Minecraft client;
+
+ public boolean onUpdateTextureEffect(TextureFX effect)
+ {
+ ITextureFX ifx = (effect instanceof ITextureFX ? ((ITextureFX)effect) : null);
+
+ if (ifx != null && ifx.getErrored())
+ {
+ return false;
+ }
+
+ String name = effect.getClass().getSimpleName();
+ FMLClientHandler.instance().profileStart(name);
+
+ try
+ {
+ if (!FMLClientHandler.instance().hasOptifine())
+ {
+ effect.func_76846_a();
+ }
+ }
+ catch (Exception e)
+ {
+ FMLLog.warning("Texture FX %s has failed to animate. Likely caused by a texture pack change that they did not respond correctly to", name);
+ if (ifx != null)
+ {
+ ifx.setErrored(true);
+ }
+ FMLClientHandler.instance().profileEnd();
+ return false;
+ }
+ FMLClientHandler.instance().profileEnd();
+
+ if (ifx != null)
+ {
+ Dimension dim = getTextureDimensions(effect);
+ int target = ((dim.width >> 4) * (dim.height >> 4)) << 2;
+ if (effect.field_76852_a.length != target)
+ {
+ FMLLog.warning("Detected a texture FX sizing discrepancy in %s (%d, %d)", name, effect.field_76852_a.length, target);
+ ifx.setErrored(true);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ //Quick and dirty image scaling, no smoothing or fanciness, meant for speed as it will be called every tick.
+ public void scaleTextureFXData(byte[] data, ByteBuffer buf, int target, int length)
+ {
+ int sWidth = (int)Math.sqrt(data.length / 4);
+ int factor = target / sWidth;
+ byte[] tmp = new byte[4];
+
+ buf.clear();
+
+ if (factor > 1)
+ {
+ for (int y = 0; y < sWidth; y++)
+ {
+ int sRowOff = sWidth * y;
+ int tRowOff = target * y * factor;
+ for (int x = 0; x < sWidth; x++)
+ {
+ int sPos = (x + sRowOff) * 4;
+ tmp[0] = data[sPos + 0];
+ tmp[1] = data[sPos + 1];
+ tmp[2] = data[sPos + 2];
+ tmp[3] = data[sPos + 3];
+
+ int tPosTop = (x * factor) + tRowOff;
+ for (int y2 = 0; y2 < factor; y2++)
+ {
+ buf.position((tPosTop + (y2 * target)) * 4);
+ for (int x2 = 0; x2 < factor; x2++)
+ {
+ buf.put(tmp);
+ }
+ }
+ }
+ }
+ }
+
+ buf.position(0).limit(length);
+ }
+
+ public void onPreRegisterEffect(TextureFX effect)
+ {
+ Dimension dim = getTextureDimensions(effect);
+ if (effect instanceof ITextureFX)
+ {
+ ((ITextureFX)effect).onTextureDimensionsUpdate(dim.width, dim.height);
+ }
+ }
+
+
+ public int getEffectTexture(TextureFX effect)
+ {
+ Integer id = effectTextures.get(effect);
+ if (id != null)
+ {
+ return id;
+ }
+
+ int old = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);
+
+ effect.func_76845_a(client.field_71446_o);
+
+ id = GL11.glGetInteger(GL_TEXTURE_BINDING_2D);
+
+ GL11.glBindTexture(GL_TEXTURE_2D, old);
+
+ effectTextures.put(effect, id);
+
+ return id;
+ }
+
+ public void onTexturePackChange(RenderEngine engine, TexturePackBase texturepack, List effects)
+ {
+ pruneOldTextureFX(texturepack, effects);
+
+ for (TextureFX tex : effects)
+ {
+ if (tex instanceof ITextureFX)
+ {
+ ((ITextureFX)tex).onTexturePackChanged(engine, texturepack, getTextureDimensions(tex));
+ }
+ }
+
+ loadTextures(texturepack);
+ }
+
+ private HashMap textureDims = new HashMap();
+ private IdentityHashMap effectTextures = new IdentityHashMap();
+ private TexturePackBase earlyTexturePack;
+ public void setTextureDimensions(int id, int width, int height, List effects)
+ {
+ Dimension dim = new Dimension(width, height);
+ textureDims.put(id, dim);
+
+ for (TextureFX tex : effects)
+ {
+ if (getEffectTexture(tex) == id && tex instanceof ITextureFX)
+ {
+ ((ITextureFX)tex).onTextureDimensionsUpdate(width, height);
+ }
+ }
+ }
+
+ public Dimension getTextureDimensions(TextureFX effect)
+ {
+ return getTextureDimensions(getEffectTexture(effect));
+ }
+
+ public Dimension getTextureDimensions(int id)
+ {
+ return textureDims.get(id);
+ }
+
+ /**
+ * @param anim
+ */
+ public void addAnimation(TextureFX anim)
+ {
+ OverrideInfo info=new OverrideInfo();
+ info.index=anim.field_76850_b;
+ info.imageIndex=anim.field_76847_f;
+ info.textureFX=anim;
+ if (animationSet.contains(info)) {
+ animationSet.remove(info);
+ }
+ animationSet.add(info);
+ }
+
+
+ /**
+ * @param p_6531_1_
+ */
+ public void loadTextures(TexturePackBase texturePack)
+ {
+ registerTextureOverrides(client.field_71446_o);
+ }
+
+
+ public void registerTextureOverrides(RenderEngine renderer) {
+ for (ModContainer mod : Loader.instance().getActiveModList()) {
+ registerAnimatedTexturesFor(mod);
+ }
+
+ for (OverrideInfo animationOverride : animationSet) {
+ renderer.func_78355_a(animationOverride.textureFX);
+ addedTextureFX.add(animationOverride.textureFX);
+ FMLCommonHandler.instance().getFMLLogger().finer(String.format("Registered texture override %d (%d) on %s (%d)", animationOverride.index, animationOverride.textureFX.field_76850_b, animationOverride.textureFX.getClass().getSimpleName(), animationOverride.textureFX.field_76847_f));
+ }
+
+ for (String fileToOverride : overrideInfo.keySet()) {
+ for (OverrideInfo override : overrideInfo.get(fileToOverride)) {
+ try
+ {
+ BufferedImage image=loadImageFromTexturePack(renderer, override.override);
+ ModTextureStatic mts=new ModTextureStatic(override.index, 1, override.texture, image);
+ renderer.func_78355_a(mts);
+ addedTextureFX.add(mts);
+ FMLCommonHandler.instance().getFMLLogger().finer(String.format("Registered texture override %d (%d) on %s (%d)", override.index, mts.field_76850_b, override.texture, mts.field_76847_f));
+ }
+ catch (IOException e)
+ {
+ FMLCommonHandler.instance().getFMLLogger().throwing("FMLClientHandler", "registerTextureOverrides", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * @param mod
+ */
+ private void registerAnimatedTexturesFor(ModContainer mod)
+ {
+ }
+
+ /**
+ * @param field_6539_c
+ */
+ public void onEarlyTexturePackLoad(TexturePackBase fallback)
+ {
+ if (client==null) {
+ // We're far too early- let's wait
+ this.earlyTexturePack = fallback;
+ } else {
+ loadTextures(fallback);
+ }
+ }
+
+
+ public void pruneOldTextureFX(TexturePackBase var1, List effects)
+ {
+ ListIterator li = addedTextureFX.listIterator();
+ while (li.hasNext())
+ {
+ TextureFX tex = li.next();
+ if (tex instanceof FMLTextureFX)
+ {
+ if (((FMLTextureFX)tex).unregister(client.field_71446_o, effects))
+ {
+ li.remove();
+ }
+ }
+ else
+ {
+ effects.remove(tex);
+ li.remove();
+ }
+ }
+ }
+ public void addNewTextureOverride(String textureToOverride, String overridingTexturePath, int location) {
+ OverrideInfo info = new OverrideInfo();
+ info.index = location;
+ info.override = overridingTexturePath;
+ info.texture = textureToOverride;
+ overrideInfo.put(textureToOverride, info);
+ FMLLog.fine("Overriding %s @ %d with %s. %d slots remaining",textureToOverride, location, overridingTexturePath, SpriteHelper.freeSlotCount(textureToOverride));
+ }
+
+ /**
+ * @param renderEngine
+ * @param path
+ * @return
+ */
+ public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine, String path) throws IOException
+ {
+ InputStream image=client.field_71418_C.func_77292_e().func_77532_a(path);
+ if (image==null) {
+ throw new RuntimeException(String.format("The requested image path %s is not found",path));
+ }
+ BufferedImage result=ImageIO.read(image);
+ if (result==null)
+ {
+ throw new RuntimeException(String.format("The requested image path %s appears to be corrupted",path));
+ }
+ return result;
+ }
+
+ public static TextureFXManager instance()
+ {
+ return INSTANCE;
+ }
+
+}
diff --git a/fml/client/cpw/mods/fml/client/registry/ClientRegistry.java b/fml/client/cpw/mods/fml/client/registry/ClientRegistry.java
new file mode 100644
index 0000000000..ecef00f9a8
--- /dev/null
+++ b/fml/client/cpw/mods/fml/client/registry/ClientRegistry.java
@@ -0,0 +1,37 @@
+package cpw.mods.fml.client.registry;
+
+import java.util.Collections;
+
+import net.minecraft.src.BiomeGenBase;
+import net.minecraft.src.TileEntity;
+import net.minecraft.src.TileEntityRenderer;
+import net.minecraft.src.TileEntitySpecialRenderer;
+
+import cpw.mods.fml.client.FMLClientHandler;
+import cpw.mods.fml.common.ObfuscationReflectionHelper;
+import cpw.mods.fml.common.registry.FMLRegistry;
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.registry.IMinecraftRegistry;
+
+public class ClientRegistry
+{
+ /**
+ *
+ * Utility method for registering a tile entity and it's renderer at once - generally you should register them separately
+ *
+ * @param tileEntityClass
+ * @param id
+ * @param specialRenderer
+ */
+ public static void registerTileEntity(Class extends TileEntity > tileEntityClass, String id, TileEntitySpecialRenderer specialRenderer)
+ {
+ GameRegistry.registerTileEntity(tileEntityClass, id);
+ bindTileEntitySpecialRenderer(tileEntityClass, specialRenderer);
+ }
+
+ public static void bindTileEntitySpecialRenderer(Class extends TileEntity> tileEntityClass, TileEntitySpecialRenderer specialRenderer)
+ {
+ TileEntityRenderer.field_76963_a.field_76966_m.put(tileEntityClass, specialRenderer);
+ specialRenderer.func_76893_a(TileEntityRenderer.field_76963_a);
+ }
+}
diff --git a/fml/client/cpw/mods/fml/client/registry/KeyBindingRegistry.java b/fml/client/cpw/mods/fml/client/registry/KeyBindingRegistry.java
new file mode 100644
index 0000000000..2744dd6c9f
--- /dev/null
+++ b/fml/client/cpw/mods/fml/client/registry/KeyBindingRegistry.java
@@ -0,0 +1,92 @@
+package cpw.mods.fml.client.registry;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+
+import com.google.common.collect.Lists;
+
+import net.minecraft.src.GameSettings;
+import net.minecraft.src.KeyBinding;
+
+import cpw.mods.fml.common.ITickHandler;
+import cpw.mods.fml.common.TickType;
+import cpw.mods.fml.common.registry.TickRegistry;
+
+public class KeyBindingRegistry
+{
+ public static abstract class KeyHandler implements ITickHandler
+ {
+ protected KeyBinding keyBinding;
+ protected boolean keyDown;
+ protected boolean repeating;
+
+ public KeyHandler(KeyBinding keyBinding, boolean repeating)
+ {
+ this.keyBinding = keyBinding;
+ this.repeating = repeating;
+ }
+
+ public KeyBinding getKeyBinding()
+ {
+ return this.keyBinding;
+ }
+
+ @Override
+ public final void tickStart(EnumSet type, Object... tickData)
+ {
+ keyTick(type, false);
+ }
+
+ @Override
+ public final void tickEnd(EnumSet type, Object... tickData)
+ {
+ keyTick(type, true);
+ }
+
+ private void keyTick(EnumSet type, boolean tickEnd)
+ {
+ int keyCode = keyBinding.field_74512_d;
+ boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode));
+ if (state != keyDown || (state && repeating))
+ {
+ if (state)
+ {
+ keyDown(type, tickEnd, state!=keyDown);
+ }
+ else
+ {
+ keyUp(type, tickEnd);
+ }
+ keyDown = state;
+ }
+ }
+
+ public abstract void keyDown(EnumSet types, boolean tickEnd, boolean isRepeat);
+ public abstract void keyUp(EnumSet types, boolean tickEnd);
+ }
+
+ private static List keyHandlers = Lists.newArrayList();
+
+ public static void registerKeyBinding(KeyHandler handler) {
+ keyHandlers.add(handler);
+ }
+
+ public static void uploadKeyBindingsToGame(GameSettings settings)
+ {
+ ArrayList harvestedBindings = Lists.newArrayList();
+ for (KeyHandler key : keyHandlers)
+ {
+ harvestedBindings.add(key.keyBinding);
+ }
+ KeyBinding[] modKeyBindings = harvestedBindings.toArray(new KeyBinding[harvestedBindings.size()]);
+ KeyBinding[] allKeys = new KeyBinding[settings.field_74324_K.length + modKeyBindings.length];
+ System.arraycopy(settings.field_74324_K, 0, allKeys, 0, settings.field_74324_K.length);
+ System.arraycopy(modKeyBindings, 0, allKeys, settings.field_74324_K.length, modKeyBindings.length);
+ settings.field_74324_K = allKeys;
+ settings.func_74300_a();
+ }
+}
diff --git a/fml/client/cpw/mods/fml/client/registry/RenderingRegistry.java b/fml/client/cpw/mods/fml/client/registry/RenderingRegistry.java
new file mode 100644
index 0000000000..c959918793
--- /dev/null
+++ b/fml/client/cpw/mods/fml/client/registry/RenderingRegistry.java
@@ -0,0 +1,6 @@
+package cpw.mods.fml.client.registry;
+
+public class RenderingRegistry
+{
+
+}
diff --git a/fml/client/net/minecraft/src/BaseMod.java b/fml/client/net/minecraft/src/BaseMod.java
index 45646af2dc..6044758531 100644
--- a/fml/client/net/minecraft/src/BaseMod.java
+++ b/fml/client/net/minecraft/src/BaseMod.java
@@ -42,7 +42,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
public final boolean doTickInGame(TickType tick, boolean tickEnd, Object minecraftInstance, Object... data)
{
Minecraft mc = (Minecraft) minecraftInstance;
- boolean hasWorld = mc.field_6324_e != null;
+ boolean hasWorld = true;
// World and render ticks
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.GAME ) && hasWorld) {
return onTickInGame((Float) data[0], mc);
@@ -54,7 +54,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
{
Minecraft mc = (Minecraft) minecraftInstance;
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.GAME ) || tick == TickType.GUILOAD) {
- return onTickInGUI((Float) data[0], mc, mc.field_6313_p);
+ return onTickInGUI((Float) data[0], mc, mc.field_71462_r);
}
return true;
}
@@ -89,7 +89,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
}
@Override
- public final boolean dispense(double x, double y, double z, byte xVelocity, byte zVelocity, Object... data)
+ public final boolean dispense(double x, double y, double z, int xVelocity, int zVelocity, Object... data)
{
return dispenseEntity((World)data[0], x, y, z, xVelocity, zVelocity, (ItemStack)data[1]);
}
@@ -97,7 +97,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
@Override
public final boolean onChat(Object... data)
{
- receiveChatPacket(((Packet3Chat)data[0]).field_517_a);
+ receiveChatPacket(((Packet3Chat)data[0]).field_73476_b);
return true;
}
@@ -140,7 +140,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
{
EntityItem item = (EntityItem) pickupData[0];
EntityPlayer player = (EntityPlayer) pickupData[1];
- onItemPickup(player, item.field_801_a);
+ onItemPickup(player, item.field_70294_a);
}
@Override
diff --git a/fml/client/net/minecraft/src/ClientRegistry.java b/fml/client/net/minecraft/src/ClientRegistry.java
deleted file mode 100644
index 20da5ffa7a..0000000000
--- a/fml/client/net/minecraft/src/ClientRegistry.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package net.minecraft.src;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import cpw.mods.fml.client.FMLClientHandler;
-import cpw.mods.fml.common.registry.FMLRegistry;
-import cpw.mods.fml.common.registry.IMinecraftRegistry;
-
-public class ClientRegistry implements IMinecraftRegistry
-{
-
- public static ClientRegistry instance() {
- return (ClientRegistry) FMLRegistry.instance();
- }
- @Override
- public void addRecipe(ItemStack output, Object... params)
- {
- CraftingManager.func_1120_a().func_1121_a(output, params);
- }
-
- @Override
- public void addShapelessRecipe(ItemStack output, Object... params)
- {
- CraftingManager.func_1120_a().func_21187_b(output, params);
- }
-
- @Override
- public void addRecipe(IRecipe recipe)
- {
- CraftingManager.func_1120_a().func_25193_b().add(recipe);
- }
-
- @Override
- public void addSmelting(int input, ItemStack output)
- {
- FurnaceRecipes.func_21200_a().func_21199_a(input, output);
- }
-
- @Override
- public void registerBlock(Block block)
- {
- registerBlock(block, ItemBlock.class);
- }
-
- @Override
- public void registerBlock(Block block, Class extends ItemBlock > itemclass)
- {
- try
- {
- assert block != null : "registerBlock: block cannot be null";
- assert itemclass != null : "registerBlock: itemclass cannot be null";
- int blockItemId = block.field_376_bc - 256;
- itemclass.getConstructor(int.class).newInstance(blockItemId);
- }
- catch (Exception e)
- {
- //HMMM
- }
- }
-
- @Override
- public void registerEntityID(Class extends Entity > entityClass, String entityName, int id)
- {
- EntityList.addNewEntityListMapping(entityClass, entityName, id);
- }
-
- @Override
- public void registerEntityID(Class extends Entity > entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)
- {
- EntityList.addNewEntityListMapping(entityClass, entityName, id, backgroundEggColour, foregroundEggColour);
- }
-
- @Override
- public void registerTileEntity(Class extends TileEntity > tileEntityClass, String id)
- {
- TileEntity.addNewTileEntityMapping(tileEntityClass, id);
- }
-
- public void registerTileEntity(Class extends TileEntity > tileEntityClass, String id, TileEntitySpecialRenderer specialRenderer)
- {
- registerTileEntity(tileEntityClass, id);
- TileEntityRenderer.setTileEntityRenderer(tileEntityClass, specialRenderer);
- }
-
- @Override
- public void addBiome(BiomeGenBase biome)
- {
- FMLClientHandler.instance().addBiomeToDefaultWorldGenerator(biome);
- }
-
- @Override
- public void addSpawn(Class extends EntityLiving > entityClass, int weightedProb, int min, int max, EnumCreatureType typeOfCreature, BiomeGenBase... biomes)
- {
- for (BiomeGenBase biome : biomes)
- {
- @SuppressWarnings("unchecked")
- List spawns = biome.func_25063_a(typeOfCreature);
-
- for (SpawnListEntry entry : spawns)
- {
- //Adjusting an existing spawn entry
- if (entry.field_25212_a == entityClass)
- {
- entry.field_35590_d = weightedProb;
- entry.field_35591_b = min;
- entry.field_35592_c = max;
- break;
- }
- }
-
- spawns.add(new SpawnListEntry(entityClass, weightedProb, min, max));
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
- {
- Class extends Entity > entityClazz = EntityList.getEntityToClassMapping().get(entityName);
-
- if (EntityLiving.class.isAssignableFrom(entityClazz))
- {
- addSpawn((Class extends EntityLiving >) entityClazz, weightedProb, min, max, spawnList, biomes);
- }
- }
-
- @Override
- public void removeBiome(BiomeGenBase biome)
- {
- FMLClientHandler.instance().removeBiomeFromDefaultWorldGenerator(biome);
- }
-
- @Override
- public void removeSpawn(Class extends EntityLiving > entityClass, EnumCreatureType typeOfCreature, BiomeGenBase... biomes)
- {
- for (BiomeGenBase biome : biomes)
- {
- @SuppressWarnings("unchecked")
- Iterator spawns = biome.func_25063_a(typeOfCreature).iterator();
-
- while (spawns.hasNext())
- {
- SpawnListEntry entry = spawns.next();
- if (entry.field_25212_a == entityClass)
- {
- spawns.remove();
- }
- }
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes)
- {
- Class extends Entity > entityClazz = EntityList.getEntityToClassMapping().get(entityName);
-
- if (EntityLiving.class.isAssignableFrom(entityClazz))
- {
- removeSpawn((Class extends EntityLiving >) entityClazz, spawnList, biomes);
- }
- }
-
-}
diff --git a/fml/client/net/minecraft/src/EntityRendererProxy.java b/fml/client/net/minecraft/src/EntityRendererProxy.java
index 14dadb7d3e..a875e2654d 100644
--- a/fml/client/net/minecraft/src/EntityRendererProxy.java
+++ b/fml/client/net/minecraft/src/EntityRendererProxy.java
@@ -20,17 +20,17 @@ public class EntityRendererProxy extends EntityRenderer
{
private Minecraft game;
-
+
public EntityRendererProxy(Minecraft minecraft)
{
super(minecraft);
game = minecraft;
}
-
+
@Override
- public void func_4136_b(float tick)
+ public void func_78480_b(float tick)
{
- super.func_4136_b(tick);
+ super.func_78480_b(tick);
//This is where ModLoader does all of it's ticking
}
}
diff --git a/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java b/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java
index c627e0adc2..5bc7c01480 100644
--- a/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java
+++ b/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java
@@ -19,13 +19,15 @@ import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
+import cpw.mods.fml.client.BlockRenderManager;
import cpw.mods.fml.client.FMLClientHandler;
+import cpw.mods.fml.client.TextureFXManager;
import cpw.mods.fml.common.FMLCommonHandler;
/**
- *
+ *
* A static hook library for optifine and other basemod editing code to access FML functions
- *
+ *
* @author cpw
*
*/
@@ -35,54 +37,54 @@ public class FMLRenderAccessLibrary
{
return FMLCommonHandler.instance().getFMLLogger();
}
-
+
public static void log(Level level, String message)
{
getLogger().log(level, message);
}
-
+
public static void log(Level level, String message, Throwable throwable)
{
getLogger().log(level, message, throwable);
}
-
+
public static void setTextureDimensions(int textureId, int width, int height, List textureFXList)
{
- FMLClientHandler.instance().setTextureDimensions(textureId, width, height, textureFXList);
+ TextureFXManager.instance().setTextureDimensions(textureId, width, height, textureFXList);
}
-
+
public static void preRegisterEffect(TextureFX textureFX)
{
- FMLClientHandler.instance().onPreRegisterEffect(textureFX);
+ TextureFXManager.instance().onPreRegisterEffect(textureFX);
}
-
+
public static boolean onUpdateTextureEffect(TextureFX textureFX)
{
- return FMLClientHandler.instance().onUpdateTextureEffect(textureFX);
+ return TextureFXManager.instance().onUpdateTextureEffect(textureFX);
}
-
+
public static Dimension getTextureDimensions(TextureFX textureFX)
{
- return FMLClientHandler.instance().getTextureDimensions(textureFX);
+ return TextureFXManager.instance().getTextureDimensions(textureFX);
}
-
+
public static void onTexturePackChange(RenderEngine engine, TexturePackBase texturePack, List textureFXList)
{
- FMLClientHandler.instance().onTexturePackChange(engine, texturePack, textureFXList);
+ TextureFXManager.instance().onTexturePackChange(engine, texturePack, textureFXList);
}
-
+
public static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
{
- return FMLClientHandler.instance().renderWorldBlock(renderer, world, x, y, z, block, modelId);
+ return BlockRenderManager.instance().renderWorldBlock(renderer, world, x, y, z, block, modelId);
}
-
+
public static void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
{
- FMLClientHandler.instance().renderInventoryBlock(renderer, block, metadata, modelID);
+ BlockRenderManager.instance().renderInventoryBlock(renderer, block, metadata, modelID);
}
-
+
public static boolean renderItemAsFull3DBlock(int modelId)
{
- return FMLClientHandler.instance().renderItemAsFull3DBlock(modelId);
+ return BlockRenderManager.instance().renderItemAsFull3DBlock(modelId);
}
}
diff --git a/fml/client/net/minecraft/src/ModLoader.java b/fml/client/net/minecraft/src/ModLoader.java
index 91be235c7d..dbcf14bd33 100644
--- a/fml/client/net/minecraft/src/ModLoader.java
+++ b/fml/client/net/minecraft/src/ModLoader.java
@@ -22,14 +22,18 @@ import java.util.logging.Logger;
import net.minecraft.client.Minecraft;
+import cpw.mods.fml.client.BlockRenderManager;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.SpriteHelper;
+import cpw.mods.fml.client.TextureFXManager;
+import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
-import cpw.mods.fml.common.ReflectionHelper;
import cpw.mods.fml.common.modloader.ModLoaderHelper;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
import cpw.mods.fml.common.registry.FMLRegistry;
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.ObfuscationReflectionHelper;
public class ModLoader
{
@@ -72,7 +76,7 @@ public class ModLoader
public static void addAnimation(TextureFX anim)
{
- FMLClientHandler.instance().addAnimation(anim);
+ TextureFXManager.instance().addAnimation(anim);
}
/**
@@ -165,7 +169,7 @@ public class ModLoader
*/
public static void addOverride(String path, String overlayPath, int index)
{
- FMLClientHandler.instance().addNewTextureOverride(path, overlayPath, index);
+ TextureFXManager.instance().addNewTextureOverride(path, overlayPath, index);
}
/**
@@ -176,7 +180,7 @@ public class ModLoader
*/
public static void addRecipe(ItemStack output, Object... params)
{
- FMLRegistry.addRecipe(output, params);
+ GameRegistry.addRecipe(output, params);
}
/**
@@ -187,7 +191,7 @@ public class ModLoader
*/
public static void addShapelessRecipe(ItemStack output, Object... params)
{
- FMLRegistry.addShapelessRecipe(output, params);
+ GameRegistry.addShapelessRecipe(output, params);
}
/**
@@ -288,7 +292,7 @@ public class ModLoader
*/
public static void genericContainerRemoval(World world, int x, int y, int z)
{
- TileEntity te = world.func_603_b(x, y, z);
+/* TileEntity te = world.func_603_b(x, y, z);
if (!(te instanceof IInventory))
{
@@ -334,7 +338,7 @@ public class ModLoader
world.func_674_a(entityitem);
}
}
- }
+*/ }
/**
* Get a list of all BaseMod loaded into the system
@@ -375,7 +379,7 @@ public class ModLoader
/**
* Get a value from a field using reflection
- * {@link ReflectionHelper#getPrivateValue(Class, Object, int)}
+ * {@link ObfuscationReflectionHelper#getPrivateValue(Class, Object, int)}
*
* @param instanceclass
* @param instance
@@ -384,12 +388,12 @@ public class ModLoader
*/
public static T getPrivateValue(Class super E> instanceclass, E instance, int fieldindex)
{
- return ReflectionHelper.getPrivateValue(instanceclass, instance, fieldindex);
+ return ObfuscationReflectionHelper.getPrivateValue(instanceclass, instance, fieldindex);
}
/**
* Get a value from a field using reflection
- * {@link ReflectionHelper#getPrivateValue(Class, Object, String)}
+ * {@link ObfuscationReflectionHelper#getPrivateValue(Class, Object, String)}
*
* @param instanceclass
* @param instance
@@ -398,7 +402,7 @@ public class ModLoader
*/
public static T getPrivateValue(Class super E> instanceclass, E instance, String field)
{
- return ReflectionHelper.getPrivateValue(instanceclass, instance, field);
+ return ObfuscationReflectionHelper.getPrivateValue(instanceclass, instance, field);
}
/**
@@ -407,7 +411,7 @@ public class ModLoader
*/
public static int getUniqueBlockModelID(BaseMod mod, boolean inventoryRenderer)
{
- return FMLClientHandler.instance().obtainBlockModelIdFor(mod, inventoryRenderer);
+ return BlockRenderManager.instance().obtainBlockModelIdFor(mod, inventoryRenderer);
}
/**
@@ -441,7 +445,7 @@ public class ModLoader
public static boolean isGUIOpen(Class extends GuiScreen> gui)
{
- return FMLClientHandler.instance().getClient().field_6313_p!=null && FMLClientHandler.instance().getClient().field_6313_p.equals(gui);
+ return FMLClientHandler.instance().getClient().field_71462_r != null && FMLClientHandler.instance().getClient().field_71462_r.equals(gui);
}
/**
@@ -466,7 +470,7 @@ public class ModLoader
public static BufferedImage loadImage(RenderEngine renderEngine, String path) throws Exception
{
- return FMLClientHandler.instance().loadImageFromTexturePack(renderEngine, path);
+ return TextureFXManager.instance().loadImageFromTexturePack(renderEngine, path);
}
/**
@@ -567,7 +571,7 @@ public class ModLoader
public static void registerKey(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat)
{
- FMLClientHandler.instance().registerKeyHandler(mod, keyHandler, allowRepeat);
+ FMLClientHandler.instance().registerModLoaderKeyHandler(mod, keyHandler, allowRepeat);
}
/**
@@ -659,19 +663,19 @@ public class ModLoader
@Deprecated
public static boolean renderBlockIsItemFull3D(int modelID)
{
- return FMLClientHandler.instance().renderItemAsFull3DBlock(modelID);
+ return BlockRenderManager.instance().renderItemAsFull3DBlock(modelID);
}
@Deprecated
public static void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
{
- FMLClientHandler.instance().renderInventoryBlock(renderer, block, metadata, modelID);
+ BlockRenderManager.instance().renderInventoryBlock(renderer, block, metadata, modelID);
}
@Deprecated
public static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID)
{
- return FMLClientHandler.instance().renderWorldBlock(renderer, world, x, y, z, block, modelID);
+ return BlockRenderManager.instance().renderWorldBlock(renderer, world, x, y, z, block, modelID);
}
/**
@@ -724,7 +728,7 @@ public class ModLoader
/**
* Set a private field to a value using reflection
- * {@link ReflectionHelper#setPrivateValue(Class, Object, int, Object)}
+ * {@link ObfuscationReflectionHelper#setPrivateValue(Class, Object, int, Object)}
*
* @param instanceclass
* @param instance
@@ -733,12 +737,12 @@ public class ModLoader
*/
public static void setPrivateValue(Class super T> instanceclass, T instance, int fieldindex, E value)
{
- ReflectionHelper.setPrivateValue(instanceclass, instance, fieldindex, value);
+ ObfuscationReflectionHelper.setPrivateValue(instanceclass, instance, value, fieldindex);
}
/**
* Set a private field to a value using reflection
- * {@link ReflectionHelper#setPrivateValue(Class, Object, String, Object)}
+ * {@link ObfuscationReflectionHelper#setPrivateValue(Class, Object, String, Object)}
*
* @param instanceclass
* @param instance
@@ -747,7 +751,7 @@ public class ModLoader
*/
public static void setPrivateValue(Class super T> instanceclass, T instance, String field, E value)
{
- ReflectionHelper.setPrivateValue(instanceclass, instance, field, value);
+ ObfuscationReflectionHelper.setPrivateValue(instanceclass, instance, value, field);
}
/**
diff --git a/fml/commands.patch b/fml/commands.patch
new file mode 100644
index 0000000000..8197d8ac23
--- /dev/null
+++ b/fml/commands.patch
@@ -0,0 +1,93 @@
+--- commands.py
++++ commands.py
+@@ -22,6 +22,7 @@
+ import errno
+ import shlex
+ import platform
++import pprint
+ from hashlib import md5 # pylint: disable-msg=E0611
+ from contextlib import closing
+ from textwrap import TextWrapper
+@@ -502,6 +503,7 @@
+ self.binclienttmp = os.path.normpath(config.get('OUTPUT', 'BinClientTemp'))
+ self.binservertmp = os.path.normpath(config.get('OUTPUT', 'BinServerTemp'))
+ self.srcclient = os.path.normpath(config.get('OUTPUT', 'SrcClient'))
++ self.srcshared = os.path.normpath(os.path.join(self.dirsrc, 'common'))
+ self.srcserver = os.path.normpath(config.get('OUTPUT', 'SrcServer'))
+ self.testclient = config.get('OUTPUT', 'TestClient')
+ self.testserver = config.get('OUTPUT', 'TestServer')
+@@ -1039,6 +1041,7 @@
+ all_files = True
+ append_pattern = False
+ pkglist = filterdirs(pathsrclk[side], '*.java', append_pattern=append_pattern, all_files=all_files)
++ pkglist = pkglist + filterdirs(self.srcshared, '*.java', append_pattern=True) #FML, Add Common folder
+ dirs = ' '.join(pkglist)
+ classpath = os.pathsep.join(cplk[side])
+ forkcmd = self.cmdrecomp.format(classpath=classpath, sourcepath=pathsrclk[side], outpath=pathbinlk[side],
+@@ -1238,6 +1241,11 @@
+
+ # HINT: We pathwalk the sources
+ for path, _, filelist in os.walk(pathsrclk[side], followlinks=True):
++ for cur_file in fnmatch.filter(filelist, '*.java'):
++ updatefile(os.path.normpath(os.path.join(path, cur_file)))
++
++ # FML, copy of the above, for the common folder
++ for path, _, filelist in os.walk(self.srcshared, followlinks=True):
+ for cur_file in fnmatch.filter(filelist, '*.java'):
+ updatefile(os.path.normpath(os.path.join(path, cur_file)))
+ return True
+@@ -1320,12 +1328,14 @@
+ pathsrclk = {CLIENT: self.srcclient, SERVER: self.srcserver}
+
+ strip_comments(pathsrclk[side])
++ strip_comments(self.srcshared)
+
+ def process_cleanup(self, side):
+ """Do lots of random cleanups including stripping comments, trailing whitespace and extra blank lines"""
+ pathsrclk = {CLIENT: self.srcclient, SERVER: self.srcserver}
+
+ src_cleanup(pathsrclk[side], fix_imports=True, fix_unicode=True, fix_charval=True, fix_pi=True, fix_round=False)
++ src_cleanup(self.srcshared, fix_imports=True, fix_unicode=True, fix_charval=True, fix_pi=True, fix_round=False)
+
+ def process_javadoc(self, side):
+ """Add CSV descriptions to methods and fields as javadoc"""
+@@ -1334,6 +1344,21 @@
+ if not self.has_doc_csv:
+ self.logger.warning('!! javadoc disabled due to no csvs !!')
+ return False
++
++ #FML Recall this function on the common folder
++ #Potential bug: If this is called without a subsiquent rename call, will cause double comments
++ if pathsrclk[side] != self.srcshared:
++ if side == CLIENT:
++ tmp = self.srcclient
++ self.srcclient = self.srcshared
++ process_javadoc(self, side)
++ self.srcclient = tmp
++ else:
++ tmp = self.srcserver
++ self.srcserver = self.srcshared
++ process_javadoc(self, side)
++ self.srcserver = tmp
++
+
+ #HINT: We read the relevant CSVs
+ methodsreader = csv.DictReader(open(self.csvmethods, 'r'))
+@@ -1420,6 +1445,7 @@
+
+ # HINT: We create the list of source directories based on the list of packages
+ pkglist = filterdirs(pathsrclk[side], '*.java', append_pattern=True)
++ pkglist = pkglist + filterdirs(self.srcshared, '*.java', append_pattern=True) #FML, Add Common folder
+ dirs = ' '.join(pkglist)
+ forkcmd = self.cmdastyle.format(classes=dirs, conffile=self.astyleconf)
+ self.runcmd(forkcmd)
+@@ -1592,6 +1618,9 @@
+ sys.exit(1)
+
+ for entry in newfiles:
++ if 'commands.py' in entry[0]: #FML, Disable updating of Commands.py
++ print 'Update to runtime/commands.py found, but disbled due to using fml'
++ continue
+ if entry[3] == 'U':
+ self.logger.info('Retrieving file from server : %s', entry[0])
+ cur_file = os.path.normpath(entry[0])
diff --git a/fml/common/cpw/mods/fml/common/DummyModContainer.java b/fml/common/cpw/mods/fml/common/DummyModContainer.java
new file mode 100644
index 0000000000..e76d1693bc
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/DummyModContainer.java
@@ -0,0 +1,120 @@
+package cpw.mods.fml.common;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.eventbus.EventBus;
+
+import cpw.mods.fml.common.LoaderState.ModState;
+import cpw.mods.fml.common.discovery.ContainerType;
+import cpw.mods.fml.common.versioning.ArtifactVersion;
+
+public class DummyModContainer implements ModContainer
+{
+ private ModMetadata md;
+
+ public DummyModContainer(ModMetadata md)
+ {
+ this.md = md;
+ }
+
+ public DummyModContainer()
+ {
+ }
+
+ @Override
+ public void bindMetadata(MetadataCollection mc)
+ {
+ }
+
+ @Override
+ public ProxyInjector findSidedProxy()
+ {
+ return null;
+ }
+
+ @Override
+ public List getDependants()
+ {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public List getDependencies()
+ {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public List getRequirements()
+ {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public ModMetadata getMetadata()
+ {
+ return md;
+ }
+
+ @Override
+ public Object getMod()
+ {
+ return null;
+ }
+
+ @Override
+ public String getModId()
+ {
+ return md.modId;
+ }
+
+ @Override
+ public String getName()
+ {
+ return md.name;
+ }
+
+ @Override
+ public String getSortingRules()
+ {
+ return "";
+ }
+
+ @Override
+ public File getSource()
+ {
+ return null;
+ }
+
+ @Override
+ public String getVersion()
+ {
+ return md.version;
+ }
+
+ public boolean matches(Object mod)
+ {
+ return false;
+ }
+
+ @Override
+ public void setEnabledState(boolean enabled)
+ {
+ }
+
+ @Override
+ public boolean registerBus(EventBus bus, LoadController controller)
+ {
+ return false;
+ }
+
+ @Override
+ public ArtifactVersion getProcessedVersion()
+ {
+ return null;
+ }
+
+}
diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
index 8a4d72ea4f..7c086b2ba3 100644
--- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
+++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
@@ -26,10 +26,10 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.PriorityQueue;
import java.util.Properties;
import java.util.Random;
import java.util.Set;
+import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -38,7 +38,17 @@ import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
-import cpw.mods.fml.common.ModContainer.SourceType;
+import net.minecraft.server.MinecraftServer;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+import com.google.common.collect.Lists;
+
+import cpw.mods.fml.common.discovery.ContainerType;
+import cpw.mods.fml.common.registry.TickRegistry;
+import cpw.mods.fml.common.registry.GameRegistry;
+
/**
* The main class for non-obfuscated hook handling code
@@ -83,68 +93,20 @@ public class FMLCommonHandler
private Map modLanguageData=new HashMap();
- private PriorityQueue tickHandlers = new PriorityQueue();
-
private List scheduledTicks = new ArrayList();
- private Set worldGenerators = new HashSet();
- /**
- * We register our delegate here
- * @param handler
- */
-
- private static class TickQueueElement implements Comparable
- {
- static long tickCounter = 0;
- public TickQueueElement(IScheduledTickHandler ticker)
- {
- this.ticker = ticker;
- update();
- }
- @Override
- public int compareTo(TickQueueElement o)
- {
- return (int)(next - o.next);
- }
-
- public void update()
- {
- next = tickCounter + Math.max(ticker.nextTickSpacing(),1);
- }
-
- private long next;
- private IScheduledTickHandler ticker;
-
- public boolean scheduledNow()
- {
- return tickCounter >= next;
- }
- }
-
public void beginLoading(IFMLSidedHandler handler)
{
sidedDelegate = handler;
- getFMLLogger().info("Attempting early MinecraftForge initialization");
+ FMLLog.info("Attempting early MinecraftForge initialization");
callForgeMethod("initialize");
- getFMLLogger().info("Completed early MinecraftForge initialization");
+ FMLLog.info("Completed early MinecraftForge initialization");
}
public void rescheduleTicks()
{
sidedDelegate.profileStart("modTickScheduling");
- TickQueueElement.tickCounter++;
- scheduledTicks.clear();
- while (true)
- {
- if (tickHandlers.size()==0 || !tickHandlers.peek().scheduledNow())
- {
- break;
- }
- TickQueueElement tickQueueElement = tickHandlers.poll();
- tickQueueElement.update();
- tickHandlers.offer(tickQueueElement);
- scheduledTicks.add(tickQueueElement.ticker);
- }
+ TickRegistry.updateTickQueue(scheduledTicks);
sidedDelegate.profileEnd();
}
public void tickStart(EnumSet ticks, Object ... data)
@@ -189,18 +151,6 @@ public class FMLCommonHandler
sidedDelegate.profileEnd();
}
- public List gatherKeyBindings() {
- List allKeys=new ArrayList();
- for (ModContainer mod : Loader.getModList())
- {
- allKeys.addAll(mod.getKeys());
- }
- for (ModContainer mod : auxilliaryContainers)
- {
- allKeys.addAll(mod.getKeys());
- }
- return allKeys;
- }
/**
* @return the instance
*/
@@ -215,7 +165,7 @@ public class FMLCommonHandler
*/
public ModContainer findContainerFor(Object mod)
{
- for (ModContainer mc : Loader.getModList())
+ for (ModContainer mc : Loader.instance().getActiveModList())
{
if (mc.matches(mod))
{
@@ -321,8 +271,7 @@ public class FMLCommonHandler
}
catch (UnsupportedEncodingException e)
{
- Loader.log.warning("Error building registration list");
- Loader.log.throwing("FMLHooks", "getPacketRegistry", e);
+ FMLLog.log(Level.WARNING, e, "Error building registration list");
return new byte[0];
}
}
@@ -344,7 +293,7 @@ public class FMLCommonHandler
*/
public Logger getFMLLogger()
{
- return Loader.log;
+ return FMLLog.getLogger();
}
/**
@@ -361,31 +310,6 @@ public class FMLCommonHandler
return sidedDelegate.getMinecraftLogger();
}
- /**
- * Is this a modloader mod?
- * @param clazz
- * @return
- */
- public boolean isModLoaderMod(Class> clazz)
- {
- return sidedDelegate.isModLoaderMod(clazz);
- }
-
- /**
- * Load the modloader mod
- * @param clazz
- * @param canonicalPath
- * @return
- */
- public ModContainer loadBaseModMod(Class> clazz, File canonicalFile)
- {
- return sidedDelegate.loadBaseModMod(clazz, canonicalFile);
- }
-
- public File getMinecraftRootDirectory() {
- return sidedDelegate.getMinecraftRootDirectory();
- }
-
/**
* @return
*/
@@ -456,12 +380,6 @@ public class FMLCommonHandler
public int fuelLookup(int itemId, int itemDamage)
{
int fv = 0;
-
- for (ModContainer mod : Loader.getModList())
- {
- fv = Math.max(fv, mod.lookupFuelValue(itemId, itemDamage));
- }
-
return fv;
}
@@ -490,6 +408,7 @@ public class FMLCommonHandler
private Class> forge;
private boolean noForge;
+ private List brandings;
private Class> findMinecraftForge()
{
@@ -527,87 +446,34 @@ public class FMLCommonHandler
* @param string
* @return
*/
- public String[] getBrandingStrings(String mcVersion)
+ public void computeBranding()
{
- ArrayList brandings=new ArrayList();
- brandings.add(mcVersion);
- brandings.add(Loader.instance().getFMLVersionString());
- String forgeVersion = (String)callForgeMethod("getVersionString");
- if (forgeVersion != null)
+ if (brandings == null)
{
- brandings.add(forgeVersion);
+ Builder brd = ImmutableList.builder();
+ brd.add(Loader.instance().getMCVersionString());
+ brd.add(Loader.instance().getFMLVersionString());
+ brd.addAll(sidedDelegate.getAdditionalBrandingInformation());
+ try {
+ Properties props=new Properties();
+ props.load(getClass().getClassLoader().getResourceAsStream("fmlbranding.properties"));
+ brd.add(props.getProperty("fmlbranding"));
+ } catch (Exception ex) {
+ // Ignore - no branding file found
+ }
+ int tModCount = Loader.instance().getModList().size();
+ int aModCount = Loader.instance().getActiveModList().size();
+ brd.add(String.format("%d mod%s loaded, %d mod%s active", tModCount, tModCount!=1 ? "s" :"", aModCount, aModCount!=1 ? "s" :"" ));
+ brandings = brd.build();
}
- brandings.addAll(sidedDelegate.getAdditionalBrandingInformation());
- try {
- Properties props=new Properties();
- props.load(FMLCommonHandler.class.getClassLoader().getResourceAsStream("fmlbranding.properties"));
- brandings.add(props.getProperty("fmlbranding"));
- } catch (Exception ex) {
- // Ignore - no branding file found
- }
- brandings.add(String.format("%d mod%s loaded",Loader.getModList().size(), Loader.getModList().size()!=1?"s":""));
- Collections.reverse(brandings);
- return brandings.toArray(new String[brandings.size()]);
}
-
- /**
- * @param mod
- */
- public void loadMetadataFor(ModContainer mod)
+ public List getBrandings()
{
- if (mod.getSourceType()==SourceType.JAR) {
- ZipFile jar = null;
- try
- {
- jar = new ZipFile(mod.getSource());
- ZipEntry infoFile=jar.getEntry("mcmod.info");
- if (infoFile!=null) {
- InputStream input=jar.getInputStream(infoFile);
- ModMetadata data=sidedDelegate.readMetadataFrom(input, mod);
- mod.setMetadata(data);
- } else {
- getFMLLogger().fine(String.format("Failed to find mcmod.info file in %s for %s", mod.getSource().getName(), mod.getName()));
- }
- }
- catch (Exception e)
- {
- // Something wrong but we don't care
- getFMLLogger().fine(String.format("Failed to find mcmod.info file in %s for %s", mod.getSource().getName(), mod.getName()));
- getFMLLogger().throwing("FMLCommonHandler", "loadMetadataFor", e);
- }
- finally
- {
- if (jar!=null)
- {
- try
- {
- jar.close();
- }
- catch (IOException e)
- {
- // GO AWAY
- }
- }
- }
- } else {
- try
- {
- InputStream input=Loader.instance().getModClassLoader().getResourceAsStream(mod.getName()+".info");
- if (input==null) {
- input=Loader.instance().getModClassLoader().getResourceAsStream("net/minecraft/src/"+mod.getName()+".info");
- }
- if (input!=null) {
- ModMetadata data=sidedDelegate.readMetadataFrom(input, mod);
- mod.setMetadata(data);
- }
- }
- catch (Exception e)
- {
- // Something wrong but we don't care
- getFMLLogger().fine(String.format("Failed to find %s.info file in %s for %s", mod.getName(), mod.getSource().getName(), mod.getName()));
- getFMLLogger().throwing("FMLCommonHandler", "loadMetadataFor", e);
- }
+ if (brandings == null)
+ {
+ computeBranding();
}
+ return ImmutableList.copyOf(brandings);
}
/**
@@ -632,29 +498,52 @@ public class FMLCommonHandler
public void handleWorldGeneration(int chunkX, int chunkZ, long worldSeed, Object... data)
{
- Random fmlRandom = new Random(worldSeed);
- long xSeed = fmlRandom.nextLong() >> 2 + 1L;
- long zSeed = fmlRandom.nextLong() >> 2 + 1L;
- fmlRandom.setSeed((xSeed * chunkX + zSeed * chunkZ) ^ worldSeed);
-
- for (IWorldGenerator generator : worldGenerators)
- {
- generator.generate(fmlRandom, chunkX, chunkZ, data);
- }
+ GameRegistry.generateWorld(chunkX, chunkZ, worldSeed, data);
}
- public void registerTickHandler(ITickHandler handler)
+ public void onPostServerTick()
{
- registerScheduledTickHandler(new SingleIntervalHandler(handler));
+ tickEnd(EnumSet.of(TickType.GAME));
}
- public void registerScheduledTickHandler(IScheduledTickHandler handler)
+ /**
+ * Every tick just after world and other ticks occur
+ */
+ public void onPostWorldTick(Object world)
{
- tickHandlers.add(new TickQueueElement(handler));
+ tickEnd(EnumSet.of(TickType.WORLD), world);
}
- public void registerWorldGenerator(IWorldGenerator generator)
+ public void onPreServerTick()
{
- worldGenerators.add(generator);
+ tickStart(EnumSet.of(TickType.GAME));
+ }
+
+ /**
+ * Every tick just before world and other ticks occur
+ */
+ public void onPreWorldTick(Object world)
+ {
+ tickStart(EnumSet.of(TickType.WORLD), world);
+ }
+
+ public void onWorldLoadTick()
+ {
+ tickStart(EnumSet.of(TickType.WORLDLOAD));
+ }
+
+ public void handleServerStarting(MinecraftServer server)
+ {
+ Loader.instance().serverStarting(server);
+ }
+
+ public void handleServerStarted()
+ {
+ Loader.instance().serverStarted();
+ }
+
+ public void handleServerStopping()
+ {
+ Loader.instance().serverStopping();
}
}
diff --git a/fml/common/cpw/mods/fml/common/FMLDummyContainer.java b/fml/common/cpw/mods/fml/common/FMLDummyContainer.java
new file mode 100644
index 0000000000..4a3f781342
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/FMLDummyContainer.java
@@ -0,0 +1,44 @@
+/*
+ * The FML Forge Mod Loader suite.
+ * Copyright (C) 2012 cpw
+ *
+ * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package cpw.mods.fml.common;
+
+import java.util.Arrays;
+
+/**
+ * @author cpw
+ *
+ */
+public class FMLDummyContainer extends DummyModContainer
+{
+ public FMLDummyContainer()
+ {
+ super(new ModMetadata());
+ ModMetadata meta = getMetadata();
+ meta.modId="FML";
+ meta.name="Forge Mod Loader";
+ meta.version=Loader.instance().getFMLVersionString();
+ meta.credits="Made possible with help from many people";
+ meta.authorList=Arrays.asList("cpw, LexManos");
+ meta.description="The Forge Mod Loader provides the ability for systems to load mods " +
+ "from the file system. It also provides key capabilities for mods to be able " +
+ "to cooperate and provide a good modding environment. " +
+ "The mod loading system is compatible with ModLoader, all your ModLoader " +
+ "mods should work.";
+ meta.url="https://github.com/cpw/FML/wiki";
+ meta.updateUrl="https://github.com/cpw/FML/wiki";
+ meta.screenshots=new String[0];
+ meta.logoFile="";
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/FMLLog.java b/fml/common/cpw/mods/fml/common/FMLLog.java
new file mode 100644
index 0000000000..53326568d7
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/FMLLog.java
@@ -0,0 +1,53 @@
+package cpw.mods.fml.common;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class FMLLog
+{
+ private static cpw.mods.fml.relauncher.FMLLog coreLog = cpw.mods.fml.relauncher.FMLLog.log;
+
+ public static void log(Level level, String format, Object... data)
+ {
+ coreLog.log(level, String.format(format, data));
+ }
+
+ public static void log(Level level, Throwable ex, String format, Object... data)
+ {
+ coreLog.log(level, String.format(format, data), ex);
+ }
+
+ public static void severe(String format, Object... data)
+ {
+ log(Level.SEVERE, format, data);
+ }
+
+ public static void warning(String format, Object... data)
+ {
+ log(Level.WARNING, format, data);
+ }
+
+ public static void info(String format, Object... data)
+ {
+ log(Level.INFO, format, data);
+ }
+
+ public static void fine(String format, Object... data)
+ {
+ log(Level.FINE, format, data);
+ }
+
+ public static void finer(String format, Object... data)
+ {
+ log(Level.FINER, format, data);
+ }
+
+ public static void finest(String format, Object... data)
+ {
+ log(Level.FINEST, format, data);
+ }
+ public static Logger getLogger()
+ {
+ return coreLog.getLogger();
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/FMLModContainer.java b/fml/common/cpw/mods/fml/common/FMLModContainer.java
index 5d501f6d74..4de0d86394 100644
--- a/fml/common/cpw/mods/fml/common/FMLModContainer.java
+++ b/fml/common/cpw/mods/fml/common/FMLModContainer.java
@@ -13,111 +13,76 @@
package cpw.mods.fml.common;
import java.io.File;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+
+import cpw.mods.fml.common.LoaderState.ModState;
+import cpw.mods.fml.common.Mod.Block;
+import cpw.mods.fml.common.Mod.Instance;
+import cpw.mods.fml.common.Mod.Metadata;
+import cpw.mods.fml.common.discovery.ContainerType;
+import cpw.mods.fml.common.event.FMLConstructionEvent;
+import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLPostInitializationEvent;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.registry.FMLRegistry;
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.versioning.ArtifactVersion;
+import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
+
public class FMLModContainer implements ModContainer
{
private Mod modDescriptor;
private Object modInstance;
private File source;
private ModMetadata modMetadata;
+ private String className;
+ private Map descriptor;
+ private boolean enabled = true;
+ private List requirements;
+ private List dependencies;
+ private List dependants;
+ private boolean overridesMetadata;
+ private EventBus eventBus;
+ private LoadController controller;
+ private Multimap, Object> annotations;
+ private DefaultArtifactVersion processedVersion;
- public FMLModContainer(String dummy)
+ public FMLModContainer(String className, File modSource, Map modDescriptor)
{
- this(new File(dummy));
- }
- public FMLModContainer(File source)
- {
- this.source = source;
- }
-
- public FMLModContainer(Class> clazz)
- {
- if (clazz == null)
- {
- return;
- }
-
- modDescriptor = clazz.getAnnotation(Mod.class);
-
- try
- {
- modInstance = clazz.newInstance();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
+ this.className = className;
+ this.source = modSource;
+ this.descriptor = modDescriptor;
}
@Override
- public boolean wantsPreInit()
+ public String getModId()
{
- return modDescriptor.wantsPreInit();
- }
-
- @Override
- public boolean wantsPostInit()
- {
- return modDescriptor.wantsPostInit();
- }
-
- @Override
- public void preInit()
- {
- }
-
- @Override
- public void init()
- {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void postInit()
- {
- // TODO Auto-generated method stub
- }
-
- public static ModContainer buildFor(Class> clazz)
- {
- return new FMLModContainer(clazz);
+ return (String) descriptor.get("modid");
}
@Override
public String getName()
{
- // TODO Auto-generated method stub
- return null;
+ return modMetadata.name;
}
@Override
- public ModState getModState()
+ public String getVersion()
{
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void nextState()
- {
- // TODO Auto-generated method stub
-
- }
- @Override
- public String getSortingRules()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean matches(Object mod)
- {
- // TODO Auto-generated method stub
- return false;
+ return modMetadata.version;
}
@Override
@@ -126,267 +91,250 @@ public class FMLModContainer implements ModContainer
return source;
}
- @Override
- public Object getMod()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public int lookupFuelValue(int itemId, int itemDamage)
- {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public boolean wantsPickupNotification()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public IPickupNotifier getPickupNotifier()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#wantsToDispense()
- */
- @Override
- public boolean wantsToDispense()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getDispenseHandler()
- */
- @Override
- public IDispenseHandler getDispenseHandler()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#wantsCraftingNotification()
- */
- @Override
- public boolean wantsCraftingNotification()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getCraftingHandler()
- */
- @Override
- public ICraftingHandler getCraftingHandler()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getDependencies()
- */
- @Override
- public List getDependencies()
- {
- // TODO Auto-generated method stub
- return new ArrayList(0);
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getPreDepends()
- */
- @Override
- public List getPreDepends()
- {
- // TODO Auto-generated method stub
- return new ArrayList(0);
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getPostDepends()
- */
- @Override
- public List getPostDepends()
- {
- // TODO Auto-generated method stub
- return new ArrayList(0);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString()
- {
- return getSource().getName();
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#wantsNetworkPackets()
- */
- @Override
- public boolean wantsNetworkPackets()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getNetworkHandler()
- */
- @Override
- public INetworkHandler getNetworkHandler()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#ownsNetworkChannel(java.lang.String)
- */
- @Override
- public boolean ownsNetworkChannel(String channel)
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#wantsConsoleCommands()
- */
- @Override
- public boolean wantsConsoleCommands()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getConsoleHandler()
- */
- @Override
- public IConsoleHandler getConsoleHandler()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#wantsPlayerTracking()
- */
- @Override
- public boolean wantsPlayerTracking()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getPlayerTracker()
- */
- @Override
- public IPlayerTracker getPlayerTracker()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getKeys()
- */
- @Override
- public List getKeys()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getSourceType()
- */
- @Override
- public SourceType getSourceType()
- {
- // TODO Auto-generated method stub
- return null;
- }
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#setSourceType(cpw.mods.fml.common.ModContainer.SourceType)
- */
- @Override
- public void setSourceType(SourceType type)
- {
- // TODO Auto-generated method stub
-
- }
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getMetadata()
- */
@Override
public ModMetadata getMetadata()
{
return modMetadata;
}
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#setMetadata(cpw.mods.fml.common.ModMetadata)
- */
+
@Override
- public void setMetadata(ModMetadata meta)
+ public void bindMetadata(MetadataCollection mc)
{
- this.modMetadata=meta;
+ modMetadata = mc.getMetadataForId(getModId(), descriptor);
+
+ if (descriptor.containsKey("usesMetadata"))
+ {
+ overridesMetadata = !((Boolean)descriptor.get("usesMetadata")).booleanValue();
+ }
+
+ if (overridesMetadata || !modMetadata.useDependencyInformation)
+ {
+ List requirements = Lists.newArrayList();
+ List dependencies = Lists.newArrayList();
+ List dependants = Lists.newArrayList();
+ Loader.instance().computeDependencies((String) descriptor.get("dependencies"), requirements, dependencies, dependants);
+ modMetadata.requiredMods = requirements;
+ modMetadata.dependencies = dependencies;
+ modMetadata.dependants = dependants;
+ }
}
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#gatherRenderers(java.util.Map)
- */
+
@Override
- public void gatherRenderers(Map renderers)
+ public void setEnabledState(boolean enabled)
{
- // TODO Auto-generated method stub
-
+ this.enabled = enabled;
}
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#requestAnimations()
- */
+
@Override
- public void requestAnimations()
+ public List getRequirements()
{
- // TODO Auto-generated method stub
-
+ return modMetadata.requiredMods;
}
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#getVersion()
- */
+
@Override
- public String getVersion()
+ public List getDependencies()
{
- // TODO Auto-generated method stub
- return null;
+ return modMetadata.dependencies;
}
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#findSidedProxy()
- */
+
+ @Override
+ public List getDependants()
+ {
+ return modMetadata.dependants;
+ }
+
+ @Override
+ public String getSortingRules()
+ {
+ return modMetadata.printableSortingRules();
+ }
+
+ @Override
+ public boolean matches(Object mod)
+ {
+ return mod == modInstance;
+ }
+
+ @Override
+ public Object getMod()
+ {
+ return modInstance;
+ }
+
@Override
public ProxyInjector findSidedProxy()
{
// TODO Auto-generated method stub
return null;
}
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#keyBindEvernt(java.lang.Object)
- */
+
@Override
- public void keyBindEvent(Object keyBinding)
+ public boolean registerBus(EventBus bus, LoadController controller)
{
- // TODO Auto-generated method stub
+ if (this.enabled)
+ {
+ FMLLog.fine("Enabling mod %s", getModId());
+ this.eventBus = bus;
+ this.controller = controller;
+ eventBus.register(this);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ private Multimap, Object> gatherAnnotations(Class> clazz) throws Exception
+ {
+ Multimap,Object> anns = ArrayListMultimap.create();
+
+ for (Field f : clazz.getDeclaredFields())
+ {
+ for (Annotation a : f.getAnnotations())
+ {
+ f.setAccessible(true);
+ anns.put(a.annotationType(), f);
+ }
+ }
+
+ for (Method m : clazz.getDeclaredMethods())
+ {
+ for (Annotation a : m.getAnnotations())
+ {
+ Class>[] paramTypes;
+ if (a.annotationType() == Mod.PreInit.class)
+ {
+ paramTypes = Mod.PreInit.paramTypes;
+ }
+ else if (a.annotationType() == Mod.Init.class)
+ {
+ paramTypes = Mod.Init.paramTypes;
+ }
+ else if (a.annotationType() == Mod.PostInit.class)
+ {
+ paramTypes = Mod.PostInit.paramTypes;
+ }
+ else
+ {
+ continue;
+ }
+ if (Arrays.equals(m.getParameterTypes(), paramTypes))
+ {
+ m.setAccessible(true);
+ anns.put(a.annotationType(), m);
+ }
+ else
+ {
+ FMLLog.severe("The mod %s appears to have an invalid method annotation %s. This annotation can only apply to methods with argument types %s -it will not be called", getModId(), a.annotationType().getSimpleName(), Arrays.toString(paramTypes));
+ }
+ }
+ }
+ return anns;
+ }
+
+ private void processFieldAnnotations() throws Exception
+ {
+ // Instance annotation
+ for (Object o : annotations.get(Instance.class))
+ {
+ Field f = (Field) o;
+ f.set(modInstance, modInstance);
+ }
+
+ for (Object o : annotations.get(Metadata.class))
+ {
+ Field f = (Field) o;
+ f.set(modInstance, modMetadata);
+ }
+
+ for (Object o : annotations.get(Block.class))
+ {
+ Field f = (Field) o;
+ f.set(modInstance, GameRegistry.buildBlock(this, f.getType(), f.getAnnotation(Block.class)));
+ }
+ }
+
+ @Subscribe
+ public void constructMod(FMLConstructionEvent event)
+ {
+ try
+ {
+ ModClassLoader modClassLoader = event.getModClassLoader();
+ modClassLoader.addFile(source);
+ Class> clazz = Class.forName(className, true, modClassLoader);
+ annotations = gatherAnnotations(clazz);
+ modInstance = clazz.newInstance();
+ processFieldAnnotations();
+ }
+ catch (Throwable e)
+ {
+ controller.errorOccurred(this, e);
+ Throwables.propagateIfPossible(e);
+ }
+ }
+
+ @Subscribe
+ public void preInitMod(FMLPreInitializationEvent event)
+ {
+ try
+ {
+ for (Object o : annotations.get(Mod.PreInit.class))
+ {
+ Method m = (Method) o;
+ m.invoke(modInstance, event);
+ }
+ }
+ catch (Throwable t)
+ {
+ controller.errorOccurred(this, t);
+ Throwables.propagateIfPossible(t);
+ }
+ }
+
+ @Subscribe
+ public void initMod(FMLInitializationEvent event)
+ {
+ try
+ {
+ for (Object o : annotations.get(Mod.Init.class))
+ {
+ Method m = (Method) o;
+ m.invoke(modInstance, event);
+ }
+ }
+ catch (Throwable t)
+ {
+ controller.errorOccurred(this, t);
+ Throwables.propagateIfPossible(t);
+ }
+ }
+
+ @Subscribe
+ public void postInitMod(FMLPostInitializationEvent event)
+ {
+ try
+ {
+ for (Object o : annotations.get(Mod.PostInit.class))
+ {
+ Method m = (Method) o;
+ m.invoke(modInstance, event);
+ }
+ }
+ catch (Throwable t)
+ {
+ controller.errorOccurred(this, t);
+ Throwables.propagateIfPossible(t);
+ }
+ }
+
+ @Override
+ public ArtifactVersion getProcessedVersion()
+ {
+ if (processedVersion == null)
+ {
+ processedVersion = new DefaultArtifactVersion(getModId(), getVersion());
+ }
+ return processedVersion;
}
}
diff --git a/fml/common/cpw/mods/fml/common/FMLModLoaderContainer.java b/fml/common/cpw/mods/fml/common/FMLModLoaderContainer.java
deleted file mode 100644
index 7cc27513af..0000000000
--- a/fml/common/cpw/mods/fml/common/FMLModLoaderContainer.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * The FML Forge Mod Loader suite.
- * Copyright (C) 2012 cpw
- *
- * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package cpw.mods.fml.common;
-
-import java.util.Arrays;
-
-/**
- * @author cpw
- *
- */
-public class FMLModLoaderContainer extends FMLModContainer
-{
-
- /**
- * @param dummy
- */
- public FMLModLoaderContainer()
- {
- super("Forge Mod Loader");
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.FMLModContainer#getMetadata()
- */
- @Override
- public ModMetadata getMetadata()
- {
- if (super.getMetadata()==null) {
- ModMetadata md=new ModMetadata(this);
- setMetadata(md);
- md.name="Forge Mod Loader";
- md.version=Loader.instance().getFMLVersionString();
- md.credits="Made possible with help from many people";
- md.authorList=Arrays.asList("cpw, LexManos");
- md.description="The Forge Mod Loader provides the ability for systems to load mods " +
- "from the file system. It also provides key capabilities for mods to be able " +
- "to cooperate and provide a good modding environment. " +
- "The mod loading system is compatible with ModLoader, all your ModLoader " +
- "mods should work.";
- md.url="https://github.com/cpw/FML/wiki";
- md.updateUrl="https://github.com/cpw/FML/wiki";
- md.screenshots=new String[0];
- md.logoFile="";
- }
- return super.getMetadata();
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.FMLModContainer#getName()
- */
- @Override
- public String getName()
- {
- return "Forge Mod Loader";
- }
-
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.FMLModContainer#getVersion()
- */
- @Override
- public String getVersion()
- {
- return Loader.instance().getFMLVersionString();
- }
-}
diff --git a/fml/common/cpw/mods/fml/common/IDispenseHandler.java b/fml/common/cpw/mods/fml/common/IDispenseHandler.java
index d4ba476859..9a3d4bad14 100644
--- a/fml/common/cpw/mods/fml/common/IDispenseHandler.java
+++ b/fml/common/cpw/mods/fml/common/IDispenseHandler.java
@@ -15,6 +15,6 @@ package cpw.mods.fml.common;
public interface IDispenseHandler
{
- boolean dispense(double x, double y, double z, byte xVelocity, byte zVelocity, Object... data);
+ boolean dispense(double x, double y, double z, int xVelocity, int zVelocity, Object... data);
}
diff --git a/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java b/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java
index 3eda416c36..e8f8162c55 100644
--- a/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java
+++ b/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java
@@ -13,19 +13,26 @@ import cpw.mods.fml.common.modloader.ModProperty;
public interface IFMLSidedHandler
{
Logger getMinecraftLogger();
- File getMinecraftRootDirectory();
- boolean isModLoaderMod(Class> clazz);
- ModContainer loadBaseModMod(Class> clazz, File canonicalFile);
+
Object getMinecraftInstance();
+
String getCurrentLanguage();
+
Properties getCurrentLanguageTable();
+
String getObjectName(Object minecraftObject);
- ModMetadata readMetadataFrom(InputStream input, ModContainer mod) throws Exception;
+
void profileStart(String profileLabel);
+
void profileEnd();
+
ModProperty getModLoaderPropertyFor(Field f);
+
List getAdditionalBrandingInformation();
+
Side getSide();
+
ProxyInjector findSidedProxyOn(BaseMod mod);
+
void haltGame(String message, Throwable exception);
}
diff --git a/fml/common/cpw/mods/fml/common/IKeyHandler.java b/fml/common/cpw/mods/fml/common/IKeyHandler.java
deleted file mode 100644
index e93c9ff2f1..0000000000
--- a/fml/common/cpw/mods/fml/common/IKeyHandler.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * The FML Forge Mod Loader suite.
- * Copyright (C) 2012 cpw
- *
- * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package cpw.mods.fml.common;
-
-/**
- * @author cpw
- *
- */
-public interface IKeyHandler
-{
-
- Object getKeyBinding();
-
- /**
- * @return
- */
- ModContainer getOwningContainer();
-
- void onEndTick();
-
-}
diff --git a/fml/common/cpw/mods/fml/common/LoadController.java b/fml/common/cpw/mods/fml/common/LoadController.java
new file mode 100644
index 0000000000..f0a109ee99
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/LoadController.java
@@ -0,0 +1,144 @@
+package cpw.mods.fml.common;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.logging.Level;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Multimap;
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+
+import cpw.mods.fml.common.LoaderState.ModState;
+import cpw.mods.fml.common.event.FMLStateEvent;
+
+public class LoadController
+{
+ private Loader loader;
+ private EventBus masterChannel;
+ private ImmutableMap eventChannels;
+ private LoaderState state;
+ private Multimap modStates = ArrayListMultimap.create();
+ private Multimap errors = ArrayListMultimap.create();
+ private Map modList;
+ private List activeModList = Lists.newArrayList();
+ private String activeContainer;
+
+ public LoadController(Loader loader)
+ {
+ this.loader = loader;
+ this.modList = loader.getIndexedModList();
+ this.masterChannel = new EventBus("FMLMainChannel");
+ this.masterChannel.register(this);
+
+ Builder eventBus = ImmutableMap.builder();
+
+ for (ModContainer mod : loader.getModList())
+ {
+ EventBus bus = new EventBus(mod.getModId());
+ boolean isActive = mod.registerBus(bus, this);
+ if (isActive)
+ {
+ FMLLog.fine("Activating mod %s", mod.getModId());
+ activeModList.add(mod);
+ modStates.put(mod.getModId(), ModState.UNLOADED);
+ eventBus.put(mod.getModId(), bus);
+ }
+ else
+ {
+ FMLLog.warning("Mod %s has been disabled through configuration", mod.getModId());
+ modStates.put(mod.getModId(), ModState.UNLOADED);
+ modStates.put(mod.getModId(), ModState.DISABLED);
+ }
+ }
+
+ eventChannels = eventBus.build();
+
+ state = LoaderState.NOINIT;
+ }
+
+ public void distributeStateMessage(LoaderState state, Object... eventData)
+ {
+ if (state.hasEvent())
+ {
+ masterChannel.post(state.getEvent(eventData));
+ }
+ }
+
+ public void transition(LoaderState desiredState)
+ {
+ LoaderState oldState = state;
+ state = state.transition(!errors.isEmpty());
+ if (state != desiredState)
+ {
+ FMLLog.severe("Fatal errors were detected during the transition from %s to %s. Loading cannot continue", oldState, desiredState);
+ StringBuilder sb = new StringBuilder();
+ printModStates(sb);
+ FMLLog.severe(sb.toString());
+ FMLLog.severe("The following problems were captured during this phase");
+ for (Entry error : errors.entries())
+ {
+ FMLLog.log(Level.SEVERE, error.getValue(), "Caught exception from %s", error.getKey());
+ }
+
+ // Throw embedding the first error (usually the only one)
+ throw new LoaderException(errors.values().iterator().next());
+ }
+ }
+
+ public ModContainer activeContainer()
+ {
+ return activeContainer!=null ? modList.get(activeContainer) : null;
+ }
+ @Subscribe
+ public void propogateStateMessage(FMLStateEvent stateEvent)
+ {
+ for (Map.Entry entry : eventChannels.entrySet())
+ {
+ activeContainer = entry.getKey();
+ stateEvent.applyModContainer(activeContainer());
+ entry.getValue().post(stateEvent);
+ activeContainer = null;
+ if (!errors.containsKey(entry.getKey()))
+ {
+ modStates.put(entry.getKey(), stateEvent.getModState());
+ }
+ else
+ {
+ modStates.put(entry.getKey(), ModState.ERRORED);
+ }
+ }
+ }
+
+ public void errorOccurred(ModContainer modContainer, Throwable exception)
+ {
+ errors.put(modContainer.getModId(), exception);
+ }
+
+ public void printModStates(StringBuilder ret)
+ {
+ for (String modId : modStates.keySet())
+ {
+ ModContainer mod = modList.get(modId);
+ ret.append("\n\t").append(mod.getName()).append(" (").append(mod.getSource().getName()).append(") ");
+ Joiner.on("->"). appendTo(ret, modStates.get(modId));
+ }
+ }
+
+ public List getActiveModList()
+ {
+ return activeModList;
+ }
+
+ public ModState getModState(ModContainer selectedMod)
+ {
+ return Iterables.getLast(modStates.get(selectedMod.getModId()), ModState.AVAILABLE);
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java
index b82c2e8c50..56aaa3feac 100644
--- a/fml/common/cpw/mods/fml/common/Loader.java
+++ b/fml/common/cpw/mods/fml/common/Loader.java
@@ -14,7 +14,8 @@
package cpw.mods.fml.common;
import java.io.File;
-import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -22,69 +23,76 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.logging.ConsoleHandler;
-import java.util.logging.FileHandler;
+import java.util.concurrent.Callable;
import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import cpw.mods.fml.common.ModContainer.SourceType;
+import net.minecraft.server.MinecraftServer;
+
+import com.google.common.base.CharMatcher;
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.base.Splitter;
+import com.google.common.base.Splitter.MapSplitter;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import cpw.mods.fml.common.LoaderState.ModState;
+import cpw.mods.fml.common.discovery.ContainerType;
+import cpw.mods.fml.common.discovery.ModDiscoverer;
+import cpw.mods.fml.common.functions.ModIdFunction;
import cpw.mods.fml.common.toposort.ModSorter;
+import cpw.mods.fml.common.toposort.ModSortingException;
import cpw.mods.fml.common.toposort.TopologicalSort;
+import cpw.mods.fml.common.versioning.ArtifactVersion;
+import cpw.mods.fml.common.versioning.VersionParser;
/**
* The loader class performs the actual loading of the mod code from disk.
*
- *
There are several {@link State}s to mod loading, triggered in two different stages from the FML handler code's hooks into the
- * minecraft code.
+ *
+ * There are several {@link LoaderState}s to mod loading, triggered in two
+ * different stages from the FML handler code's hooks into the minecraft code.
+ *
*
*
- *
LOADING. Scanning the filesystem for mod containers to load (zips, jars, directories), adding them to the {@link #modClassLoader}
- * Scanning, the loaded containers for mod classes to load and registering them appropriately.
- *
PREINIT. The mod classes are configured, they are sorted into a load order, and instances of the mods are constructed.
- *
INIT. The mod instances are initialized. For BaseMod mods, this involves calling the load method.
- *
POSTINIT. The mod instances are post initialized. For BaseMod mods this involves calling the modsLoaded method.
+ *
LOADING. Scanning the filesystem for mod containers to load (zips, jars,
+ * directories), adding them to the {@link #modClassLoader} Scanning, the loaded
+ * containers for mod classes to load and registering them appropriately.
+ *
PREINIT. The mod classes are configured, they are sorted into a load
+ * order, and instances of the mods are constructed.
+ *
INIT. The mod instances are initialized. For BaseMod mods, this involves
+ * calling the load method.
+ *
POSTINIT. The mod instances are post initialized. For BaseMod mods this
+ * involves calling the modsLoaded method.
*
UP. The Loader is complete
- *
ERRORED. The loader encountered an error during the LOADING phase and dropped to this state instead. It will not complete
- * loading from this state, but it attempts to continue loading before abandoning and giving a fatal error.
+ *
ERRORED. The loader encountered an error during the LOADING phase and
+ * dropped to this state instead. It will not complete loading from this state,
+ * but it attempts to continue loading before abandoning and giving a fatal
+ * error.
*
*
- * Phase 1 code triggers the LOADING and PREINIT states. Phase 2 code triggers the INIT and POSTINIT states.
+ * Phase 1 code triggers the LOADING and PREINIT states. Phase 2 code triggers
+ * the INIT and POSTINIT states.
*
* @author cpw
*
*/
public class Loader
{
- private static Pattern zipJar = Pattern.compile("(.+).(zip|jar)$");
- private static Pattern modClass = Pattern.compile("(.+/|)(mod\\_[^\\s$]+).class$");
-
- /**
- * The state enum used to help track state progression for the loader
- * @author cpw
- *
- */
- private enum State
- {
- NOINIT, LOADING, PREINIT, INIT, POSTINIT, UP, ERRORED
- };
-
+ private static final Splitter DEPENDENCYPARTSPLITTER = Splitter.on(":").omitEmptyStrings().trimResults();
+ private static final Splitter DEPENDENCYSPLITTER = Splitter.on(";").omitEmptyStrings().trimResults();
/**
* The singleton instance
*/
private static Loader instance;
- /**
- * Our special logger for logging issues to. We copy various assets from the Minecraft logger to acheive a similar appearance.
- */
- public static Logger log = Logger.getLogger("ForgeModLoader");
-
-
/**
* Build information for tracking purposes.
*/
@@ -95,10 +103,6 @@ public class Loader
private static String mccversion;
private static String mcsversion;
- /**
- * The {@link State} of the loader
- */
- private State state;
/**
* The class loader we load the mods into.
*/
@@ -119,8 +123,14 @@ public class Loader
* The canonical minecraft directory
*/
private File canonicalMinecraftDir;
+ /**
+ * The captured error
+ */
private Exception capturedError;
+ private File canonicalModsDir;
+ private LoadController modController;
+ private static File minecraftDir;
public static Loader instance()
{
@@ -132,188 +142,129 @@ public class Loader
return instance;
}
+ public static void injectData(Object... data)
+ {
+ major = (String) data[0];
+ minor = (String) data[1];
+ rev = (String) data[2];
+ build = (String) data[3];
+ mccversion = (String) data[4];
+ mcsversion = (String) data[5];
+ minecraftDir = (File) data[6];
+ }
+
private Loader()
{
- FMLLogFormatter formatter=new FMLLogFormatter();
- if (FMLCommonHandler.instance().getMinecraftLogger()!=null) {
- Loader.log.setParent(FMLCommonHandler.instance().getMinecraftLogger());
- } else {
- ConsoleHandler ch=new ConsoleHandler();
- Loader.log.setUseParentHandlers(false);
- Loader.log.addHandler(ch);
- ch.setFormatter(formatter);
-
- }
- Loader.log.setLevel(Level.ALL);
- try
- {
- File logPath=new File(FMLCommonHandler.instance().getMinecraftRootDirectory().getCanonicalPath(),"ForgeModLoader-%g.log");
- FileHandler fileHandler = new FileHandler(logPath.getPath(), 0, 3);
- // We're stealing minecraft's log formatter
- fileHandler.setFormatter(new FMLLogFormatter());
- fileHandler.setLevel(Level.ALL);
- Loader.log.addHandler(fileHandler);
- }
- catch (Exception e)
- {
- // Whatever - give up
- }
- InputStream stream = Loader.class.getClassLoader().getResourceAsStream("fmlversion.properties");
- Properties properties = new Properties();
-
- if (stream != null) {
- try {
- properties.load(stream);
- major = properties.getProperty("fmlbuild.major.number","none");
- minor = properties.getProperty("fmlbuild.minor.number","none");
- rev = properties.getProperty("fmlbuild.revision.number","none");
- build = properties.getProperty("fmlbuild.build.number","none");
- mccversion = properties.getProperty("fmlbuild.mcclientversion","none");
- mcsversion = properties.getProperty("fmlbuild.mcserverversion","none");
- } catch (IOException ex) {
- Loader.log.log(Level.SEVERE,"Could not get FML version information - corrupted installation detected!", ex);
- throw new LoaderException(ex);
- }
- }
-
- log.info(String.format("Forge Mod Loader version %s.%s.%s.%s for Minecraft c:%s, s:%s loading", major, minor, rev, build, mccversion, mcsversion));
- modClassLoader = new ModClassLoader();
+ modClassLoader = new ModClassLoader(getClass().getClassLoader());
}
/**
- * Sort the mods into a sorted list, using dependency information from the containers. The sorting is performed
- * using a {@link TopologicalSort} based on the pre- and post- dependency information provided by the mods.
+ * Sort the mods into a sorted list, using dependency information from the
+ * containers. The sorting is performed using a {@link TopologicalSort}
+ * based on the pre- and post- dependency information provided by the mods.
*/
private void sortModList()
{
- log.fine("Verifying mod dependencies are satisfied");
-
- for (ModContainer mod : mods)
- {
- if (!namedMods.keySet().containsAll(mod.getDependencies()))
- {
- log.severe(String.format("The mod %s requires mods %s to be available, one or more are not", mod.getName(), mod.getDependencies()));
- LoaderException le = new LoaderException();
- log.throwing("Loader", "sortModList", le);
- throw new LoaderException();
- }
- }
-
- log.fine("All dependencies are satisfied");
- ModSorter sorter = new ModSorter(mods, namedMods);
-
+ FMLLog.fine("Verifying mod requirements are satisfied");
try
{
- log.fine("Sorting mods into an ordered list");
- mods = sorter.sort();
- log.fine("Sorted mod list:");
+ Map modVersions = Maps.newHashMap();
for (ModContainer mod : mods)
{
- log.fine(String.format("\t%s: %s (%s)", mod.getName(), mod.getSource().getName(), mod.getSortingRules()));
+ modVersions.put(mod.getModId(), mod.getProcessedVersion());
}
- }
- catch (IllegalArgumentException iae)
- {
- log.severe("A dependency cycle was detected in the input mod set so they cannot be loaded in order");
- log.throwing("Loader", "sortModList", iae);
- throw new LoaderException(iae);
- }
- }
- /**
- * The first mod initialization stage, performed immediately after the jar files and mod classes are loaded,
- * {@link State#PREINIT}. The mods are configured from their configuration data and instantiated (for BaseMod mods).
- */
- private void preModInit()
- {
- state = State.PREINIT;
- log.fine("Beginning mod pre-initialization");
-
- for (ModContainer mod : mods)
- {
- if (mod.wantsPreInit())
+ for (ModContainer mod : mods)
{
- log.finer(String.format("Pre-initializing %s", mod.getSource()));
- try
+ ImmutableList allDeps = ImmutableList.builder().addAll(mod.getDependants()).addAll(mod.getDependencies()).build();
+ for (ArtifactVersion v : allDeps)
{
- mod.preInit();
+ if (modVersions.containsKey(v.getLabel()))
+ {
+ if (!v.containsVersion(modVersions.get(v.getLabel())))
+ {
+ FMLLog.log(Level.SEVERE, "The mod %s (%s) requires mods %s to be available, one or more are not", mod.getModId(), mod.getName(), allDeps);
+ throw new LoaderException();
+ }
+ }
}
- catch (Throwable t)
- {
- log.log(Level.SEVERE, String.format("The mod from file %s has failed to load. This is likely a mod installation error.", mod.getSource().getName()), t);
- throw new LoaderException(t);
- }
- namedMods.put(mod.getName(), mod);
- }
- mod.nextState();
- }
- // Link up mod metadatas
-
- for (ModContainer mod : mods) {
- if (mod.getMetadata()!=null) {
- mod.getMetadata().associate(namedMods);
}
- FMLCommonHandler.instance().injectSidedProxyDelegate(mod);
- }
- log.fine("Mod pre-initialization complete");
- }
+ FMLLog.fine("All mod requirements are satisfied");
- /**
- * The main mod initialization stage, performed on the sorted mod list.
- */
- private void modInit()
- {
- state = State.INIT;
- log.fine("Beginning mod initialization");
+ ModSorter sorter = new ModSorter(mods, namedMods);
- for (ModContainer mod : mods)
- {
- log.finer(String.format("Initializing %s", mod.getName()));
- mod.init();
- mod.nextState();
- }
-
- log.fine("Mod initialization complete");
- }
-
- private void postModInit()
- {
- state = State.POSTINIT;
- log.fine("Beginning mod post-initialization");
-
- for (ModContainer mod : mods)
- {
- if (mod.wantsPostInit())
+ try
{
- log.finer(String.format("Post-initializing %s", mod.getName()));
- mod.postInit();
- mod.nextState();
+ FMLLog.fine("Sorting mods into an ordered list");
+ mods = sorter.sort();
+ FMLLog.fine("Mod sorting completed successfully");
+ }
+ catch (ModSortingException sortException)
+ {
+ FMLLog.severe("A dependency cycle was detected in the input mod set so an ordering cannot be determined");
+ FMLLog.severe("The visited mod list is %s", sortException.getExceptionData().getVisitedNodes());
+ FMLLog.severe("The first mod in the cycle is %s", sortException.getExceptionData().getFirstBadNode());
+ FMLLog.log(Level.SEVERE, sortException, "The full error");
+ throw new LoaderException(sortException);
+ }
+ }
+ finally
+ {
+ FMLLog.fine("Mod sorting data:");
+ for (ModContainer mod : mods)
+ {
+ FMLLog.fine("\t%s(%s): %s (%s)", mod.getModId(), mod.getName(), mod.getSource().getName(), mod.getSortingRules());
+ }
+ if (mods.size()==0)
+ {
+ FMLLog.fine("No mods found to sort");
}
}
- log.fine("Mod post-initialization complete");
}
/**
* The primary loading code
*
- * This is visited during first initialization by Minecraft to scan and load the mods
- * from all sources
- * 1. The minecraft jar itself (for loading of in jar mods- I would like to remove this if possible but forge depends on it at present)
- * 2. The mods directory with expanded subdirs, searching for mods named mod_*.class
- * 3. The mods directory for zip and jar files, searching for mod classes named mod_*.class again
+ * This is visited during first initialization by Minecraft to scan and load
+ * the mods from all sources 1. The minecraft jar itself (for loading of in
+ * jar mods- I would like to remove this if possible but forge depends on it
+ * at present) 2. The mods directory with expanded subdirs, searching for
+ * mods named mod_*.class 3. The mods directory for zip and jar files,
+ * searching for mod classes named mod_*.class again
*
- * The found resources are first loaded into the {@link #modClassLoader} (always) then scanned for class resources matching the specification above.
+ * The found resources are first loaded into the {@link #modClassLoader}
+ * (always) then scanned for class resources matching the specification
+ * above.
*
- * If they provide the {@link Mod} annotation, they will be loaded as "FML mods", which currently is effectively a NO-OP.
- * If they are determined to be {@link BaseMod} subclasses they are loaded as such.
+ * If they provide the {@link Mod} annotation, they will be loaded as
+ * "FML mods", which currently is effectively a NO-OP. If they are
+ * determined to be {@link BaseMod} subclasses they are loaded as such.
*
- * Finally, if they are successfully loaded as classes, they are then added to the available mod list.
+ * Finally, if they are successfully loaded as classes, they are then added
+ * to the available mod list.
*/
- private void load()
+ private void identifyMods()
+ {
+ ModDiscoverer discoverer = new ModDiscoverer();
+ FMLLog.fine("Attempting to load mods contained in the minecraft jar file and associated classes");
+ discoverer.findClasspathMods(modClassLoader);
+ FMLLog.fine("Minecraft jar mods loaded successfully");
+
+ FMLLog.info("Searching %s for mods", canonicalModsDir.getAbsolutePath());
+ discoverer.findModDirMods(canonicalModsDir);
+
+ mods = discoverer.identifyMods();
+ namedMods = Maps.uniqueIndex(mods, new ModIdFunction());
+ FMLLog.info("Forge Mod Loader has identified %d mod%s to load", mods.size(), mods.size() != 1 ? "s" : "");
+ }
+
+ /**
+ * @return
+ */
+ private void initializeLoader()
{
- File minecraftDir = FMLCommonHandler.instance().getMinecraftRootDirectory();
File modsDir = new File(minecraftDir, "mods");
File configDir = new File(minecraftDir, "config");
String canonicalModsPath;
@@ -325,313 +276,125 @@ public class Loader
canonicalModsPath = modsDir.getCanonicalPath();
canonicalConfigPath = configDir.getCanonicalPath();
canonicalConfigDir = configDir.getCanonicalFile();
+ canonicalModsDir = modsDir.getCanonicalFile();
}
catch (IOException ioe)
{
- log.severe(String.format("Failed to resolve mods directory mods %s", modsDir.getAbsolutePath()));
- log.throwing("fml.server.Loader", "initialize", ioe);
+ FMLLog.log(Level.SEVERE, ioe, "Failed to resolve loader directories: mods : %s ; config %s", canonicalModsDir.getAbsolutePath(),
+ configDir.getAbsolutePath());
throw new LoaderException(ioe);
}
- if (!modsDir.exists())
+ if (!canonicalModsDir.exists())
{
- log.fine(String.format("No mod directory found, creating one: %s", canonicalModsPath));
-
- try
+ FMLLog.info("No mod directory found, creating one: %s", canonicalModsPath);
+ boolean dirMade = canonicalModsDir.mkdir();
+ if (!dirMade)
{
- modsDir.mkdir();
- }
- catch (Exception e)
- {
- log.throwing("fml.server.Loader", "initialize", e);
- throw new LoaderException(e);
+ FMLLog.severe("Unable to create the mod directory %s", canonicalModsPath);
+ throw new LoaderException();
}
+ FMLLog.info("Mod directory created successfully");
}
- if (!configDir.exists())
+ if (!canonicalConfigDir.exists())
{
- log.fine(String.format("No config directory found, creating one: %s", canonicalConfigPath));
-
- try
+ FMLLog.fine("No config directory found, creating one: %s", canonicalConfigPath);
+ boolean dirMade = canonicalConfigDir.mkdir();
+ if (!dirMade)
{
- configDir.mkdir();
- }
- catch (Exception e)
- {
- log.throwing("fml.server.Loader", "initialize", e);
- throw new LoaderException(e);
+ FMLLog.severe("Unable to create the config directory %s", canonicalConfigPath);
+ throw new LoaderException();
}
+ FMLLog.info("Config directory created successfully");
}
- if (!modsDir.isDirectory())
+ if (!canonicalModsDir.isDirectory())
{
- log.severe(String.format("Attempting to load mods from %s, which is not a directory", canonicalModsPath));
- LoaderException loaderException = new LoaderException();
- log.throwing("fml.server.Loader", "initialize", loaderException);
- throw loaderException;
+ FMLLog.severe("Attempting to load mods from %s, which is not a directory", canonicalModsPath);
+ throw new LoaderException();
}
if (!configDir.isDirectory())
{
- log.severe(String.format("Attempting to load configuration from %s, which is not a directory", canonicalConfigPath));
- LoaderException loaderException = new LoaderException();
- log.throwing("fml.server.Loader", "initialize", loaderException);
- throw loaderException;
- }
-
- state = State.LOADING;
- log.fine("Attempting to load mods contained in the minecraft jar file and associated classes");
- File[] minecraftSources=modClassLoader.getParentSources();
- if (minecraftSources.length==1 && minecraftSources[0].isFile()) {
- log.fine(String.format("Minecraft is a file at %s, loading",minecraftSources[0].getAbsolutePath()));
- attemptFileLoad(minecraftSources[0], SourceType.CLASSPATH);
- } else {
- for (int i=0; i clazz = Class.forName(clazzName, false, modClassLoader);
-
- ModContainer mod=null;
- if (clazz.isAnnotationPresent(Mod.class))
- {
- // an FML mod
- log.severe("Currently, the FML mod type is disabled");
- throw new LoaderException();
-// log.fine(String.format("FML mod class %s found, loading", clazzName));
-// mod = FMLModContainer.buildFor(clazz);
-// log.fine(String.format("FML mod class %s loaded", clazzName));
- }
- else if (FMLCommonHandler.instance().isModLoaderMod(clazz))
- {
- log.fine(String.format("ModLoader BaseMod class %s found, loading", clazzName));
- mod = FMLCommonHandler.instance().loadBaseModMod(clazz, classSource.getCanonicalFile());
- log.fine(String.format("ModLoader BaseMod class %s loaded", clazzName));
- }
- else
- {
- // Unrecognized
- }
- if (mod!=null) {
- mod.setSourceType(sourceType);
- FMLCommonHandler.instance().loadMetadataFor(mod);
- mods.add(mod);
- mod.nextState();
- }
- }
- catch (Throwable e)
- {
- log.warning(String.format("Failed to load mod class %s in %s", classFileName, classSource.getAbsoluteFile()));
- log.throwing("fml.server.Loader", "attemptLoad", e);
- throw new LoaderException(e);
+ FMLLog.severe("Attempting to load configuration from %s, which is not a directory", canonicalConfigPath);
+ throw new LoaderException();
}
}
- private void extendClassLoader(File file)
+ public List getModList()
{
- try
- {
- modClassLoader.addFile(file);
- }
- catch (MalformedURLException e)
- {
- throw new LoaderException(e);
- }
- }
-
- private boolean attemptFileLoad(File modFile, SourceType sourceType)
- {
- extendClassLoader(modFile);
- boolean foundAModClass = false;
-
- ZipFile jar = null;
- try
- {
- jar = new ZipFile(modFile);
-
- for (ZipEntry ze : Collections.list(jar.entries()))
- {
- Matcher match = modClass.matcher(ze.getName());
-
- if (match.matches())
- {
- String pkg = match.group(1).replace('/', '.');
- String clazzName = pkg + match.group(2);
- log.fine(String.format("Found a mod class %s in file %s, attempting to load it", clazzName, modFile.getName()));
- loadModClass(modFile, ze.getName(), clazzName, sourceType);
- log.fine(String.format("Mod class %s loaded successfully", clazzName, modFile.getName()));
- foundAModClass = true;
- }
- }
- }
- catch (Exception e)
- {
- log.severe(String.format("Zip file %s failed to read properly", modFile.getName()));
- log.throwing("fml.server.Loader", "attemptFileLoad", e);
- state = State.ERRORED;
- capturedError = e;
- }
- finally
- {
- if (jar != null)
- {
- try
- {
- jar.close();
- }
- catch (Exception e)
- {
- }
- }
- }
-
- return foundAModClass;
- }
-
- public static List getModList()
- {
- return instance().mods;
+ return ImmutableList.copyOf(instance().mods);
}
/**
- * Called from the hook to start mod loading. We trigger the {@link #load()} and {@link #preModInit()} phases here.
- * Finally, the mod list is frozen completely and is consider immutable from then on.
+ * Called from the hook to start mod loading. We trigger the
+ * {@link #identifyMods()} and {@link #preModInit()} phases here. Finally,
+ * the mod list is frozen completely and is consider immutable from then on.
*/
public void loadMods()
{
- state = State.NOINIT;
- mods = new ArrayList();
- namedMods = new HashMap();
- load();
- preModInit();
+ initializeLoader();
+ mods = Lists.newArrayList();
+ namedMods = Maps.newHashMap();
+ modController = new LoadController(this);
+ modController.transition(LoaderState.LOADING);
+ identifyMods();
+ disableRequestedMods();
sortModList();
- // Make mod list immutable
- mods = Collections.unmodifiableList(mods);
+ mods = ImmutableList.copyOf(mods);
+ modController.transition(LoaderState.CONSTRUCTING);
+ modController.distributeStateMessage(LoaderState.CONSTRUCTING, modClassLoader);
+ modController.transition(LoaderState.PREINITIALIZATION);
+ modController.distributeStateMessage(LoaderState.PREINITIALIZATION);
+ modController.transition(LoaderState.INITIALIZATION);
}
- /**
- * Complete the initialization of the mods {@link #initializeMods()} and {@link #postModInit()} and mark ourselves up and ready to run.
- */
- public void initializeMods()
+ private void disableRequestedMods()
{
- modInit();
- postModInit();
- for (ModContainer mod : getModList()) {
- mod.nextState();
+ String disabledModList = System.getProperty("fml.disabledMods", "");
+ FMLLog.fine("Received a system property request \'%s\'",disabledModList);
+ Map sysPropertyStateList = Splitter.on(CharMatcher.anyOf(";:"))
+ .omitEmptyStrings().trimResults().withKeyValueSeparator("=")
+ .split(disabledModList);
+ FMLLog.fine("System property request managing the state of %d mods", sysPropertyStateList.size());
+ Map modStates = Maps.newHashMap();
+
+ File disabledModFile = new File(canonicalConfigDir, "fmlModState.properties");
+ Properties disabledModListProperties = new Properties();
+ if (disabledModFile.exists() && disabledModFile.isFile())
+ {
+ FMLLog.fine("Found a mod state file %s", disabledModFile.getName());
+ try
+ {
+ disabledModListProperties.load(new FileReader(disabledModFile));
+ FMLLog.fine("Loaded states for %d mods from file", disabledModListProperties.size());
+ }
+ catch (Exception e)
+ {
+ FMLLog.log(Level.INFO, e, "An error occurred reading the fmlModState.properties file");
+ }
+ }
+ modStates.putAll(Maps.fromProperties(disabledModListProperties));
+ modStates.putAll(sysPropertyStateList);
+ FMLLog.fine("After merging, found state information for %d mods", modStates.size());
+
+ Map isEnabled = Maps.transformValues(modStates, new Function()
+ {
+ public Boolean apply(String input)
+ {
+ return !Boolean.parseBoolean(input);
+ }
+ });
+
+ for (Map.Entry entry : isEnabled.entrySet())
+ {
+ if (namedMods.containsKey(entry.getKey()))
+ {
+ FMLLog.info("Setting mod %s to enabled state %b", entry.getKey(), entry.getValue());
+ namedMods.get(entry.getKey()).setEnabledState(entry.getValue());
+ }
}
- state = State.UP;
- log.info(String.format("Forge Mod Loader load complete, %d mods loaded", mods.size()));
}
/**
@@ -655,13 +418,13 @@ public class Loader
public String getCrashInformation()
{
- StringBuffer ret = new StringBuffer();
- for (String brand : FMLCommonHandler.instance().getBrandingStrings(String.format("Forge Mod Loader version %s.%s.%s.%s for Minecraft %s", major, minor, rev, build, mccversion))) {
- ret.append(brand).append("\n");
- }
- for (ModContainer mod : mods)
+ StringBuilder ret = new StringBuilder();
+ List branding = FMLCommonHandler.instance().getBrandings();
+
+ Joiner.on(' ').skipNulls().appendTo(ret, branding.subList(1, branding.size()));
+ if (modController!=null)
{
- ret.append(String.format("\t%s : %s (%s)\n",mod.getName(), mod.getModState(), mod.getSource().getName()));
+ modController.printModStates(ret);
}
return ret.toString();
}
@@ -681,4 +444,139 @@ public class Loader
{
return modClassLoader;
}
+
+ public void computeDependencies(String dependencyString, List requirements, List dependencies, List dependants)
+ {
+ if (dependencyString == null || dependencyString.length() == 0)
+ {
+ return;
+ }
+
+ boolean parseFailure=false;
+
+ for (String dep : DEPENDENCYSPLITTER.split(dependencyString))
+ {
+ List depparts = Lists.newArrayList(DEPENDENCYPARTSPLITTER.split(dep));
+ // Need two parts to the string
+ if (depparts.size() != 2)
+ {
+ parseFailure=true;
+ continue;
+ }
+ String instruction = depparts.get(0);
+ String target = depparts.get(1);
+ boolean targetIsAll = target.startsWith("*");
+
+ // Cannot have an "all" relationship with anything except pure *
+ if (targetIsAll && target.length()>1)
+ {
+ parseFailure = true;
+ continue;
+ }
+
+ // If this is a required element, add it to the required list
+ if ("required-before".equals(instruction) || "required-after".equals(instruction))
+ {
+ // You can't require everything
+ if (!targetIsAll)
+ {
+ requirements.add(VersionParser.parseVersionReference(target));
+ }
+ else
+ {
+ parseFailure=true;
+ continue;
+ }
+ }
+
+ // You cannot have a versioned dependency on everything
+ if (targetIsAll && target.indexOf('@')>-1)
+ {
+ parseFailure = true;
+ continue;
+ }
+ // before elements are things we are loaded before (so they are our dependants)
+ if ("required-before".equals(instruction) || "before".equals(instruction))
+ {
+ dependants.add(VersionParser.parseVersionReference(target));
+ }
+ // after elements are things that load before we do (so they are out dependencies)
+ else if ("required-after".equals(instruction) || "after".equals(instruction))
+ {
+ dependencies.add(VersionParser.parseVersionReference(target));
+ }
+ else
+ {
+ parseFailure=true;
+ }
+ }
+
+ if (parseFailure)
+ {
+ FMLLog.log(Level.WARNING, "Unable to parse dependency string %s", dependencyString);
+ throw new LoaderException();
+ }
+ }
+
+ public Map getIndexedModList()
+ {
+ return ImmutableMap.copyOf(namedMods);
+ }
+
+ public void initializeMods()
+ {
+ // Mod controller should be in the initialization state here
+ modController.distributeStateMessage(LoaderState.INITIALIZATION);
+ modController.transition(LoaderState.POSTINITIALIZATION);
+ modController.distributeStateMessage(LoaderState.POSTINITIALIZATION);
+ modController.transition(LoaderState.AVAILABLE);
+ modController.distributeStateMessage(LoaderState.AVAILABLE);
+ FMLLog.info("Forge Mod Loader has successfully loaded %d mod%s", mods.size(), mods.size()==1 ? "" : "s");
+ }
+
+ public Callable getCallableCrashInformation()
+ {
+ return new Callable() {
+ @Override
+ public String call() throws Exception
+ {
+ return getCrashInformation();
+ }
+ };
+ }
+
+ public List getActiveModList()
+ {
+ return modController.getActiveModList();
+ }
+
+ public ModState getModState(ModContainer selectedMod)
+ {
+ return modController.getModState(selectedMod);
+ }
+
+ public String getMCVersionString()
+ {
+ return "Minecraft " + mccversion;
+ }
+
+ public void serverStarting(Object server)
+ {
+ modController.distributeStateMessage(LoaderState.SERVER_STARTING, server);
+ modController.transition(LoaderState.SERVER_STARTING);
+ }
+
+ public void serverStarted()
+ {
+ modController.distributeStateMessage(LoaderState.SERVER_STARTED);
+ modController.transition(LoaderState.SERVER_STARTED);
+ }
+
+ public void serverStopping()
+ {
+ modController.distributeStateMessage(LoaderState.SERVER_STOPPING);
+ modController.transition(LoaderState.SERVER_STOPPING);
+ modController.transition(LoaderState.AVAILABLE);
+
+ }
}
diff --git a/fml/common/cpw/mods/fml/common/LoaderState.java b/fml/common/cpw/mods/fml/common/LoaderState.java
new file mode 100644
index 0000000000..f7de8786bf
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/LoaderState.java
@@ -0,0 +1,103 @@
+package cpw.mods.fml.common;
+
+import com.google.common.base.Throwables;
+
+import cpw.mods.fml.common.event.FMLConstructionEvent;
+import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
+import cpw.mods.fml.common.event.FMLPostInitializationEvent;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.event.FMLServerStarted;
+import cpw.mods.fml.common.event.FMLServerStarting;
+import cpw.mods.fml.common.event.FMLServerStopping;
+import cpw.mods.fml.common.event.FMLStateEvent;
+
+/**
+ * The state enum used to help track state progression for the loader
+ * @author cpw
+ *
+ */
+public enum LoaderState
+{
+ NOINIT("Uninitialized",null),
+ LOADING("Loading",null),
+ CONSTRUCTING("Constructing mods",FMLConstructionEvent.class),
+ PREINITIALIZATION("Pre-initializing mods", FMLPreInitializationEvent.class),
+ INITIALIZATION("Initializing mods", FMLInitializationEvent.class),
+ POSTINITIALIZATION("Post-initializing mods", FMLPostInitializationEvent.class),
+ AVAILABLE("Mod loading complete", FMLLoadCompleteEvent.class),
+ SERVER_STARTING("Server starting", FMLServerStarting.class),
+ SERVER_STARTED("Server started", FMLServerStarted.class),
+ SERVER_STOPPING("Server stopping", FMLServerStopping.class),
+ ERRORED("Mod Loading errored",null);
+
+
+ private Class extends FMLStateEvent> eventClass;
+ private String name;
+
+ private LoaderState(String name, Class extends FMLStateEvent> event)
+ {
+ this.name = name;
+ this.eventClass = event;
+ }
+
+ public LoaderState transition(boolean errored)
+ {
+ if (errored)
+ {
+ return ERRORED;
+ }
+ // stopping -> available
+ if (this == SERVER_STOPPING)
+ {
+ return AVAILABLE;
+ }
+ return values()[ordinal() < values().length ? ordinal()+1 : ordinal()];
+ }
+
+ public boolean hasEvent()
+ {
+ return eventClass != null;
+ }
+
+ public FMLStateEvent getEvent(Object... eventData)
+ {
+ try
+ {
+ return eventClass.getConstructor(Object[].class).newInstance((Object)eventData);
+ }
+ catch (Exception e)
+ {
+ throw Throwables.propagate(e);
+ }
+ }
+ public LoaderState requiredState()
+ {
+ if (this == NOINIT) return NOINIT;
+ return LoaderState.values()[this.ordinal()-1];
+ }
+ public enum ModState
+ {
+ UNLOADED("Unloaded"),
+ LOADED("Loaded"),
+ CONSTRUCTED("Constructed"),
+ PREINITIALIZED("Pre-initialized"),
+ INITIALIZED("Initialized"),
+ POSTINITIALIZED("Post-initialized"),
+ AVAILABLE("Available"),
+ DISABLED("Disabled"),
+ ERRORED("Errored");
+
+ private String label;
+
+ private ModState(String label)
+ {
+ this.label = label;
+ }
+
+ public String toString()
+ {
+ return this.label;
+ }
+ }
+}
\ No newline at end of file
diff --git a/fml/common/cpw/mods/fml/common/MetadataCollection.java b/fml/common/cpw/mods/fml/common/MetadataCollection.java
new file mode 100644
index 0000000000..34652c7319
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/MetadataCollection.java
@@ -0,0 +1,90 @@
+package cpw.mods.fml.common;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import argo.jdom.JdomParser;
+import argo.jdom.JsonNode;
+import argo.jdom.JsonRootNode;
+import argo.saj.InvalidSyntaxException;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class MetadataCollection
+{
+ private static JdomParser parser = new JdomParser();
+ private Map metadatas = Maps.newHashMap();
+ private int metadataVersion = 1;
+
+ public static MetadataCollection from(InputStream inputStream)
+ {
+ if (inputStream == null)
+ {
+ return new MetadataCollection();
+ }
+
+ InputStreamReader reader = new InputStreamReader(inputStream);
+ try
+ {
+ JsonRootNode root = parser.parse(reader);
+ if (root.hasElements())
+ {
+ return parse10ModInfo(root);
+ }
+ else
+ {
+ return parseModInfo(root);
+ }
+ }
+ catch (Exception e)
+ {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ private static MetadataCollection parseModInfo(JsonRootNode root)
+ {
+ MetadataCollection mc = new MetadataCollection();
+ mc.metadataVersion = Integer.parseInt(root.getNumberValue("modinfoversion"));
+ mc.parseModMetadataList(root.getNode("modlist"));
+ return mc;
+ }
+
+ private static MetadataCollection parse10ModInfo(JsonRootNode root)
+ {
+ MetadataCollection mc = new MetadataCollection();
+ mc.parseModMetadataList(root);
+ return mc;
+ }
+
+ private void parseModMetadataList(JsonNode metadataList)
+ {
+ for (JsonNode node : metadataList.getElements())
+ {
+ ModMetadata mmd = new ModMetadata(node);
+ metadatas.put(mmd.modId, mmd);
+ }
+ }
+
+ public ModMetadata getMetadataForId(String modId, Map extraData)
+ {
+ if (!metadatas.containsKey(modId))
+ {
+ ModMetadata dummy = new ModMetadata();
+ dummy.modId = modId;
+ dummy.name = (String) extraData.get("name");
+ dummy.version = (String) extraData.get("version");
+ dummy.autogenerated = true;
+ metadatas.put(modId, dummy);
+ }
+ return metadatas.get(modId);
+ }
+
+}
diff --git a/fml/common/cpw/mods/fml/common/Mod.java b/fml/common/cpw/mods/fml/common/Mod.java
index ea6182a97c..237934e60a 100644
--- a/fml/common/cpw/mods/fml/common/Mod.java
+++ b/fml/common/cpw/mods/fml/common/Mod.java
@@ -13,23 +13,136 @@
*/
package cpw.mods.fml.common;
+import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLPostInitializationEvent;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+
+import net.minecraft.src.ItemBlock;
/**
- * A possible future way to indicate mods to the system is to use an annotation style
- *
+ * The new mod style in FML 1.3
+ *
* @author cpw
*
*/
@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
public @interface Mod
{
-String name() default "";
-String version() default "";
-boolean wantsPreInit() default false;
-boolean wantsPostInit() default false;
- public @interface PreInit {}
- public @interface Init {}
- public @interface PostInit {}
+ /**
+ * The unique mod identifier for this mod
+ * @return
+ */
+ String modid();
+ /**
+ * A user friendly name for the mod
+ * @return
+ */
+ String name() default "";
+ /**
+ * A version string for this mod
+ * @return
+ */
+ String version() default "";
+ /**
+ * A simple dependency string for this mod (see modloader's "priorities" string specification)
+ * @return
+ */
+ String dependencies() default "";
+ /**
+ * Whether to use the mcmod.info metadata by default for this mod.
+ * If true, settings in the mcmod.info file will override settings in these annotations.
+ * @return
+ */
+ boolean useMetadata() default false;
+
+ /**
+ * Mark the designated method as being called at the "pre-initialization" phase
+ * @author cpw
+ *
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+ public @interface PreInit {
+ static Class>[] paramTypes = new Class[] { FMLPreInitializationEvent.class };
+ }
+ /**
+ * Mark the designated method as being called at the "initialization" phase
+ * @author cpw
+ *
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+ public @interface Init {
+ static Class>[] paramTypes = new Class[] { FMLInitializationEvent.class };
+ }
+ /**
+ * Mark the designated method as being called at the "post-initialization" phase
+ * @author cpw
+ *
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+ public @interface PostInit {
+ static Class>[] paramTypes = new Class[] { FMLPostInitializationEvent.class };
+ }
+ /**
+ * Populate the annotated field with the mod instance.
+ * @author cpw
+ *
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.FIELD)
+ public @interface Instance {}
+ /**
+ * Populate the annotated field with the mod's metadata.
+ * @author cpw
+ *
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.FIELD)
+ public @interface Metadata {}
+ /**
+ * Populate the annotated field with an instance of the Block as specified
+ * @author cpw
+ *
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.FIELD)
+ public @interface Block {
+ /**
+ * The block's name
+ * @return
+ */
+ String name();
+ /**
+ * The associated ItemBlock subtype for the item (can be null for an ItemBlock)
+ * @return
+ */
+ Class> itemTypeClass() default ItemBlock.class;
+ }
+ /**
+ * Populate the annotated field with an Item
+ * @author cpw
+ *
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.FIELD)
+ public @interface Item {
+ /**
+ * The name of the item
+ * @return
+ */
+ String name();
+ /**
+ * The type of the item
+ * @return
+ */
+ String typeClass();
+ }
}
diff --git a/fml/common/cpw/mods/fml/common/ModClassLoader.java b/fml/common/cpw/mods/fml/common/ModClassLoader.java
index 44b9196fe0..c93dba3a19 100644
--- a/fml/common/cpw/mods/fml/common/ModClassLoader.java
+++ b/fml/common/cpw/mods/fml/common/ModClassLoader.java
@@ -19,61 +19,64 @@ import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.List;
+import java.util.logging.Level;
+
+import com.google.common.collect.ImmutableList;
+
+import cpw.mods.fml.common.discovery.ModCandidate;
+import cpw.mods.fml.relauncher.FMLRelauncher;
+import cpw.mods.fml.relauncher.RelaunchClassLoader;
/**
* A simple delegating class loader used to load mods into the system
- *
- *
+ *
+ *
* @author cpw
*
*/
public class ModClassLoader extends URLClassLoader
{
-
- public ModClassLoader()
- {
- super(new URL[0], ModClassLoader.class.getClassLoader());
- }
+ private static final List STANDARD_LIBRARIES = ImmutableList.of("jinput.jar", "lwjgl.jar", "lwjgl_util.jar");
+ private RelaunchClassLoader mainClassLoader;
public ModClassLoader(ClassLoader parent) {
super(new URL[0], null);
+ this.mainClassLoader = (RelaunchClassLoader)parent;
}
+
public void addFile(File modFile) throws MalformedURLException
{
- ClassLoader cl=getParent();
- if (cl instanceof URLClassLoader) {
- URLClassLoader ucl=(URLClassLoader) cl;
URL url = modFile.toURI().toURL();
- try {
- Method addUrl=URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
- addUrl.setAccessible(true);
- addUrl.invoke(ucl, url);
- } catch (Exception e) {
- Loader.log.severe("A fatal error occured attempting to load a file into the classloader");
- throw new LoaderException(e);
+ mainClassLoader.addURL(url);
+ }
+
+ @Override
+ public Class> loadClass(String name) throws ClassNotFoundException
+ {
+ return mainClassLoader.loadClass(name);
+ }
+
+ public File[] getParentSources() {
+ List urls=mainClassLoader.getSources();
+ File[] sources=new File[urls.size()];
+ try
+ {
+ for (int i = 0; i getDefaultLibraries()
+ {
+ return STANDARD_LIBRARIES;
}
}
diff --git a/fml/common/cpw/mods/fml/common/ModContainer.java b/fml/common/cpw/mods/fml/common/ModContainer.java
index 2139c051cd..c7677c71ff 100644
--- a/fml/common/cpw/mods/fml/common/ModContainer.java
+++ b/fml/common/cpw/mods/fml/common/ModContainer.java
@@ -15,15 +15,20 @@ package cpw.mods.fml.common;
import java.io.File;
import java.util.List;
-import java.util.Map;
-import cpw.mods.fml.common.ModContainer.SourceType;
+import com.google.common.eventbus.EventBus;
+
+import cpw.mods.fml.common.LoaderState.ModState;
+import cpw.mods.fml.common.versioning.ArtifactVersion;
/**
* The container that wraps around mods in the system.
- *
The philosophy is that individual mod implementation technologies should not impact the actual loading and management
- * of mod code. This interface provides a mechanism by which we can wrap actual mod code so that the loader and other
- * facilities can treat mods at arms length.
+ *
+ * The philosophy is that individual mod implementation technologies should not
+ * impact the actual loading and management of mod code. This interface provides
+ * a mechanism by which we can wrap actual mod code so that the loader and other
+ * facilities can treat mods at arms length.
+ *
*
* @author cpw
*
@@ -31,183 +36,116 @@ import cpw.mods.fml.common.ModContainer.SourceType;
public interface ModContainer
{
- public enum ModState {
- UNLOADED("Unloaded"), LOADED("Loaded"), PREINITIALIZED("Pre-initialized"), INITIALIZED("Initialized"), POSTINITIALIZED("Post-initialized"), AVAILABLE("Available");
- private String label;
+ /**
+ * The globally unique modid for this mod
+ *
+ * @return
+ */
+ String getModId();
- private ModState(String label) {
- this.label=label;
- }
- public String toString() {
- return this.label;
- }
- }
-
- public enum SourceType {
- JAR, CLASSPATH, DIR;
- }
/**
- * The enclosed mod wants to be called during pre-initialization.
- * @return
- */
- boolean wantsPreInit();
- /**
- * The enclosed mod wants to be called during post-initialization.
- * @return
- */
- boolean wantsPostInit();
- /**
- * Called when pre-initialization occurs.
- */
- void preInit();
- /**
- * Called when main initialization occurs.
- */
- void init();
- /**
- * Called when post-initialization occurs.
- */
- void postInit();
- /**
- * The name of the mod
+ * A human readable name
+ *
* @return
*/
+
String getName();
+
/**
- * The state of the mod
+ * A human readable version identifier
+ *
* @return
*/
- ModState getModState();
+ String getVersion();
+
/**
- * Move to the next mod state
+ * The location on the file system which this mod came from
+ *
+ * @return
*/
- void nextState();
+ File getSource();
+
/**
- * Does this mod match the supplied mod?
+ * The metadata for this mod
+ *
+ * @return
+ */
+ ModMetadata getMetadata();
+
+ /**
+ * Attach this mod to it's metadata from the supplied metadata collection
+ *
+ * @param mc
+ */
+ void bindMetadata(MetadataCollection mc);
+
+ /**
+ * Set the enabled/disabled state of this mod
+ *
+ * @param enabled
+ */
+ void setEnabledState(boolean enabled);
+
+ /**
+ * A list of the modids that this mod requires loaded prior to loading
+ *
+ * @return
+ */
+ List getRequirements();
+
+ /**
+ * A list of modids that should be loaded prior to this one. The special
+ * value * indicates to load before any other mod.
+ *
+ * @return
+ */
+ List getDependencies();
+
+ /**
+ * A list of modids that should be loaded after this one. The
+ * special value * indicates to load after any
+ * other mod.
+ *
+ * @return
+ */
+ List getDependants();
+
+ /**
+ * A representative string encapsulating the sorting preferences for this
+ * mod
+ *
+ * @return
+ */
+ String getSortingRules();
+
+ /**
+ * Register the event bus for the mod and the controller for error handling
+ * Returns if this bus was successfully registered - disabled mods and other
+ * mods that don't need real events should return false and avoid further
+ * processing
+ *
+ * @param bus
+ * @param controller
+ * @return
+ */
+ boolean registerBus(EventBus bus, LoadController controller);
+
+ /**
+ * Does this mod match the supplied mod
+ *
* @param mod
* @return
*/
boolean matches(Object mod);
+
/**
- * The source of this mod: the file on the file system
- * @return
- */
- File getSource();
- /**
- * Returns the sorting rules as a string for printing
- * @return
- */
- String getSortingRules();
- /**
- * The actual mod object itself
+ * Get the actual mod object
+ *
* @return
*/
Object getMod();
- /**
- * Lookup the fuel value for the supplied item/damage with this mod.
- * @param itemId
- * @param itemDamage
- * @return
- */
- int lookupFuelValue(int itemId, int itemDamage);
- /**
- * This mod wants to be notified when an object is picked up.
- * @return
- */
- boolean wantsPickupNotification();
- /**
- * The pickup notifier for this mod.
- * @return
- */
- IPickupNotifier getPickupNotifier();
- /**
- * This mod wants to have special dispenser handling.
- * @return
- */
- boolean wantsToDispense();
- /**
- * The dispensing handler.
- * @return
- */
- IDispenseHandler getDispenseHandler();
- /**
- * This mod wants notification of crafting and/or smelting events.
- * @return
- */
- boolean wantsCraftingNotification();
- /**
- * The crafting and smelting handler for this mod.
- * @return
- */
- ICraftingHandler getCraftingHandler();
- /**
- * The strong dependencies of this mod. If the named mods in this list are not present, the game will abort.
- * @return
- */
- List getDependencies();
- /**
- * Get a list of mods to load before this one. The special value "*" indicates to load after all other mods (except other "*" mods).
- * @return
- */
- List getPreDepends();
- /**
- * Get a list of mods to load after this one. The special value "*" indicates to load before all other mods (except other "*" mods).
- * @return
- */
- List getPostDepends();
- /**
- * This mod wants packets from the client, and wants them handled by FML.
- * @return
- */
- boolean wantsNetworkPackets();
- /**
- * The network handler for this mod.
- * @return
- */
- INetworkHandler getNetworkHandler();
- /**
- * Does this mod own this channel?
- * @param channel
- * @return
- */
- boolean ownsNetworkChannel(String channel);
-
- /**
- * Does this mod want commands from the console?
- * @return
- */
- boolean wantsConsoleCommands();
-
- IConsoleHandler getConsoleHandler();
-
- boolean wantsPlayerTracking();
-
- IPlayerTracker getPlayerTracker();
-
- List getKeys();
-
- SourceType getSourceType();
- void setSourceType(SourceType type);
-
- ModMetadata getMetadata();
- void setMetadata(ModMetadata meta);
- /**
- *
- */
- void gatherRenderers(Map renderers);
- /**
- *
- */
- void requestAnimations();
- /**
- * @return
- */
- String getVersion();
- /**
- * @return
- */
+ ArtifactVersion getProcessedVersion();
+
ProxyInjector findSidedProxy();
-
- void keyBindEvent(Object keyBinding);
}
diff --git a/fml/common/cpw/mods/fml/common/ModContainerFactory.java b/fml/common/cpw/mods/fml/common/ModContainerFactory.java
new file mode 100644
index 0000000000..dcbb31b193
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/ModContainerFactory.java
@@ -0,0 +1,39 @@
+package cpw.mods.fml.common;
+
+import java.io.File;
+import java.util.regex.Pattern;
+
+import org.objectweb.asm.Type;
+
+import cpw.mods.fml.common.discovery.asm.ASMModParser;
+import cpw.mods.fml.common.discovery.asm.ModAnnotation;
+import cpw.mods.fml.common.modloader.ModLoaderModContainer;
+
+public class ModContainerFactory
+{
+ private static Pattern modClass = Pattern.compile(".*(\\.|)(mod\\_[^\\s$]+)$");
+ private static ModContainerFactory INSTANCE = new ModContainerFactory();
+ public static ModContainerFactory instance() {
+ return INSTANCE;
+ }
+ public ModContainer build(ASMModParser modParser, File modSource)
+ {
+ String className = modParser.getASMType().getClassName();
+ if (modParser.isBaseMod() && modClass.matcher(className).find())
+ {
+ FMLLog.fine("Identified a BaseMod type mod %s", className);
+ return new ModLoaderModContainer(className, modSource, modParser.getBaseModProperties());
+ }
+
+ for (ModAnnotation ann : modParser.getAnnotations())
+ {
+ if (ann.getASMType().equals(Type.getType(Mod.class)))
+ {
+ FMLLog.fine("Identified a FMLMod type mod %s", className);
+ return new FMLModContainer(className, modSource, ann.getValues());
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/ModMetadata.java b/fml/common/cpw/mods/fml/common/ModMetadata.java
index c0a99422be..2208314984 100644
--- a/fml/common/cpw/mods/fml/common/ModMetadata.java
+++ b/fml/common/cpw/mods/fml/common/ModMetadata.java
@@ -20,85 +20,142 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.StringTokenizer;
import java.util.zip.ZipInputStream;
+import argo.jdom.JsonNode;
+import argo.jdom.JsonStringNode;
+
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import cpw.mods.fml.common.functions.ModNameFunction;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
+import cpw.mods.fml.common.versioning.ArtifactVersion;
+import cpw.mods.fml.common.versioning.VersionParser;
+
+import static argo.jdom.JsonNodeBuilders.*;
+
/**
* @author cpw
*
*/
public class ModMetadata
{
- public enum ModType { MODLOADER, FML };
- public ModContainer mod;
- public ModType type;
-
+ private static final class JsonStringConverter implements Function
+ {
+ public Object apply(JsonNode arg0)
+ {
+ if (arg0.hasElements())
+ {
+ return Lists.transform(arg0.getElements(), new JsonArrayConverter());
+ }
+ else
+ {
+ return arg0.getText();
+ }
+ }
+ }
+
+ private static final class JsonArrayConverter implements Function
+ {
+ public String apply(JsonNode arg0)
+ {
+ return arg0.getText();
+ }
+ }
+
+ public String modId;
public String name;
public String description;
-
- public String url="";
- public String updateUrl="";
-
- public String logoFile="";
- public String version="";
- public List authorList=new ArrayList(1);
- public String credits="";
- public String parent="";
+
+ public String url = "";
+ public String updateUrl = "";
+
+ public String logoFile = "";
+ public String version = "";
+ public List authorList = Lists.newArrayList();
+ public String credits = "";
+ public String parent = "";
public String[] screenshots;
-
+
public ModContainer parentMod;
- public List childMods = new ArrayList(1);
+ public List childMods = Lists.newArrayList();
+
+ public boolean useDependencyInformation;
+ public List requiredMods;
+ public List dependencies;
+ public List dependants;
+ public boolean autogenerated;
/**
* @param mod2
* @param type2
*/
- public ModMetadata(ModContainer mod)
+ public ModMetadata(JsonNode node)
{
- this.mod=mod;
- this.type=(mod instanceof FMLModContainer ? ModType.FML : ModType.MODLOADER);
- }
-
- public void associate(Map mods) {
- if (parent!=null && parent.length() > 0) {
- ModContainer mc=mods.get(parent);
- if (mc!=null && mc.getMetadata()!=null) {
- mc.getMetadata().childMods.add(mod);
- parentMod = mc;
- }
- }
+ Map processedFields = Maps.transformValues(node.getFields(), new JsonStringConverter());
+ modId = (String)processedFields.get(aStringBuilder("modid"));
+ name = Strings.nullToEmpty((String)processedFields.get(aStringBuilder("name")));
+ description = Strings.nullToEmpty((String)processedFields.get(aStringBuilder("description")));
+ url = Strings.nullToEmpty((String)processedFields.get(aStringBuilder("url")));
+ updateUrl = Strings.nullToEmpty((String)processedFields.get(aStringBuilder("updateUrl")));
+ logoFile = Strings.nullToEmpty((String)processedFields.get(aStringBuilder("logoFile")));
+ version = Strings.nullToEmpty((String)processedFields.get(aStringBuilder("version")));
+ credits = Strings.nullToEmpty((String)processedFields.get(aStringBuilder("credits")));
+ parent = Strings.nullToEmpty((String)processedFields.get(aStringBuilder("parent")));
+ authorList = Optional.fromNullable((List)processedFields.get(aStringBuilder("authorList"))).or(authorList);
+ requiredMods = processReferences((List)processedFields.get(aStringBuilder("requiredMods")));
+ dependencies = processReferences((List)processedFields.get(aStringBuilder("dependencies")));
+ dependants = processReferences((List)processedFields.get(aStringBuilder("dependants")));
+ useDependencyInformation = Boolean.parseBoolean(Strings.nullToEmpty((String)processedFields.get(aStringBuilder("useDependencyInformation"))));
}
+ ModMetadata()
+ {
+ }
+
+ private List processReferences(List refs)
+ {
+ List res = Lists.newArrayList();
+ if (refs == null)
+ {
+ return res;
+ }
+ for (String ref : refs)
+ {
+ res.add(VersionParser.parseVersionReference(ref));
+ }
+ return res;
+ }
/**
* @return
*/
public String getChildModCountString()
{
- return String.format("%d child mod%s", childMods.size(), childMods.size()!=1 ? "s" : "");
+ return String.format("%d child mod%s", childMods.size(), childMods.size() != 1 ? "s" : "");
}
- public String getAuthorList() {
- StringBuilder sb=new StringBuilder();
- for (int i=0; i T getPrivateValue(Class super E> classToAccess, E instance, int fieldIndex)
+ {
+ try
+ {
+ return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
+ }
+ catch (UnableToAccessFieldException e)
+ {
+ FMLLog.log(Level.SEVERE, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName());
+ throw e;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static T getPrivateValue(Class super E> classToAccess, E instance, String... fieldNames)
+ {
+ try
+ {
+ return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldNames);
+ }
+ catch (UnableToFindFieldException e)
+ {
+ FMLLog.log(Level.SEVERE,e,"Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName());
+ throw e;
+ }
+ catch (UnableToAccessFieldException e)
+ {
+ FMLLog.log(Level.SEVERE, e, "Unable to access any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName());
+ throw e;
+ }
+ }
+
+ @Deprecated
+ public static void setPrivateValue(Class super T> classToAccess, T instance, int fieldIndex, E value)
+ {
+ setPrivateValue(classToAccess, instance, value, fieldIndex);
+ }
+
+ public static void setPrivateValue(Class super T> classToAccess, T instance, E value, int fieldIndex)
+ {
+ try
+ {
+ ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
+ }
+ catch (UnableToAccessFieldException e)
+ {
+ FMLLog.log(Level.SEVERE, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName());
+ throw e;
+ }
+ }
+
+ @Deprecated
+ public static void setPrivateValue(Class super T> classToAccess, T instance, String fieldName, E value)
+ {
+ setPrivateValue(classToAccess, instance, value, fieldName);
+ }
+
+ public static void setPrivateValue(Class super T> classToAccess, T instance, E value, String... fieldNames)
+ {
+ try
+ {
+ ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldNames);
+ }
+ catch (UnableToFindFieldException e)
+ {
+ FMLLog.log(Level.SEVERE, e, "Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName());
+ throw e;
+ }
+ catch (UnableToAccessFieldException e)
+ {
+ FMLLog.log(Level.SEVERE, e, "Unable to set any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName());
+ throw e;
+ }
+ }
+
+ /**
+ *
+ */
+ public static void detectObfuscation(Class> clazz)
+ {
+ obfuscation = !clazz.getSimpleName().equals("World");
+ }
+
+}
diff --git a/fml/common/cpw/mods/fml/common/ReflectionHelper.java b/fml/common/cpw/mods/fml/common/ReflectionHelper.java
deleted file mode 100644
index 30bc523448..0000000000
--- a/fml/common/cpw/mods/fml/common/ReflectionHelper.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
- *
- * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package cpw.mods.fml.common;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-/**
- * Some reflection helper code.
- *
- * @author cpw
- *
- */
-public class ReflectionHelper
-{
- public static boolean obfuscation;
-
- @SuppressWarnings("unchecked")
- public static T getPrivateValue(Class super E > classToAccess, E instance, int fieldIndex)
- {
- try
- {
- Field f = classToAccess.getDeclaredFields()[fieldIndex];
- f.setAccessible(true);
- return (T) f.get(instance);
- }
- catch (Exception e)
- {
- FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem getting field %d from %s", fieldIndex, classToAccess.getName()));
- FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
- throw new RuntimeException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- public static T getPrivateValue(Class super E > classToAccess, E instance, String fieldName)
- {
- try
- {
- Field f = classToAccess.getDeclaredField(fieldName);
- f.setAccessible(true);
- return (T) f.get(instance);
- }
- catch (Exception e)
- {
- if ((fieldName.length() > 3 && !obfuscation) || (fieldName.length() <= 3 && obfuscation)) {
- FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem getting field %s from %s", fieldName, classToAccess.getName()));
- FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
- }
- throw new RuntimeException(e);
- }
- }
-
- public static void setPrivateValue(Class super T > classToAccess, T instance, int fieldIndex, E value)
- {
- try
- {
- Field f = classToAccess.getDeclaredFields()[fieldIndex];
- f.setAccessible(true);
- f.set(instance, value);
- }
- catch (Exception e)
- {
- FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem setting field %d from %s", fieldIndex, classToAccess.getName()));
- FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
- throw new RuntimeException(e);
- }
- }
-
- public static void setPrivateValue(Class super T > classToAccess, T instance, String fieldName, E value)
- {
- try
- {
- Field f = classToAccess.getDeclaredField(fieldName);
- f.setAccessible(true);
- f.set(instance, value);
- }
- catch (Exception e)
- {
- if ((fieldName.length() > 3 && !obfuscation) || (fieldName.length() <= 3 && obfuscation)) {
- FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem setting field %s from %s", fieldName, classToAccess.getName()));
- FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
- }
- throw new RuntimeException(e);
- }
- }
-
- /**
- *
- */
- public static void detectObfuscation(Class> clazz)
- {
- obfuscation=!clazz.getSimpleName().equals("World");
- }
-
-}
diff --git a/fml/common/cpw/mods/fml/common/asm/ASMTransformer.java b/fml/common/cpw/mods/fml/common/asm/ASMTransformer.java
new file mode 100644
index 0000000000..a4b106e73b
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/asm/ASMTransformer.java
@@ -0,0 +1,31 @@
+package cpw.mods.fml.common.asm;
+
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.tree.ClassNode;
+
+import cpw.mods.fml.common.registry.BlockProxy;
+import cpw.mods.fml.relauncher.IClassTransformer;
+
+public class ASMTransformer implements IClassTransformer
+{
+ @Override
+ public byte[] transform(String name, byte[] bytes)
+ {
+ if ("net.minecraft.src.Block".equals(name))
+ {
+ ClassReader cr = new ClassReader(bytes);
+ ClassNode cn = new ClassNode(Opcodes.ASM4);
+ cr.accept(cn, ClassReader.EXPAND_FRAMES);
+ cn.interfaces.add(Type.getInternalName(BlockProxy.class));
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
+ cn.accept(cw);
+ return cw.toByteArray();
+ }
+
+ return bytes;
+ }
+
+}
diff --git a/fml/common/cpw/mods/fml/common/discovery/ContainerType.java b/fml/common/cpw/mods/fml/common/discovery/ContainerType.java
new file mode 100644
index 0000000000..dc2e5f9e75
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/ContainerType.java
@@ -0,0 +1,32 @@
+package cpw.mods.fml.common.discovery;
+
+import java.util.List;
+
+import com.google.common.base.Throwables;
+
+import cpw.mods.fml.common.ModContainer;
+
+public enum ContainerType
+{
+ JAR(JarDiscoverer.class),
+ DIR(DirectoryDiscoverer.class);
+
+ private ITypeDiscoverer discoverer;
+
+ private ContainerType(Class extends ITypeDiscoverer> discovererClass)
+ {
+ try
+ {
+ this.discoverer = discovererClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ public List findMods(ModCandidate candidate)
+ {
+ return discoverer.discover(candidate);
+ }
+}
\ No newline at end of file
diff --git a/fml/common/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java b/fml/common/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java
new file mode 100644
index 0000000000..7fd289a337
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java
@@ -0,0 +1,100 @@
+package cpw.mods.fml.common.discovery;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.Lists;
+
+import cpw.mods.fml.common.FMLLog;
+import cpw.mods.fml.common.MetadataCollection;
+import cpw.mods.fml.common.ModContainer;
+import cpw.mods.fml.common.ModContainerFactory;
+import cpw.mods.fml.common.discovery.asm.ASMModParser;
+
+public class DirectoryDiscoverer implements ITypeDiscoverer
+{
+ private class ClassFilter implements FileFilter
+ {
+ @Override
+ public boolean accept(File file)
+ {
+ return (file.isFile() && classFile.matcher(file.getName()).find()) || file.isDirectory();
+ }
+ }
+
+ @Override
+ public List discover(ModCandidate candidate)
+ {
+ List found = Lists.newArrayList();
+ FMLLog.fine("Examining directory %s for potential mods", candidate.getModContainer().getName());
+ exploreFileSystem("", candidate.getModContainer(), found, candidate, null);
+ return found;
+ }
+
+ public void exploreFileSystem(String path, File modDir, List harvestedMods, ModCandidate candidate, MetadataCollection mc)
+ {
+ if (path.length() == 0)
+ {
+ File metadata = new File(modDir, "mcmod.info");
+ try
+ {
+ FileInputStream fis = new FileInputStream(metadata);
+ mc = MetadataCollection.from(fis);
+ fis.close();
+ }
+ catch (Exception e)
+ {
+ mc = MetadataCollection.from(null);
+ }
+ }
+
+ File[] content = modDir.listFiles(new ClassFilter());
+
+ // Always sort our content
+ Arrays.sort(content);
+ for (File file : content)
+ {
+ if (file.isDirectory())
+ {
+ FMLLog.finest("Recursing into package %s", path + file.getName());
+ exploreFileSystem(path + file.getName() + ".", file, harvestedMods, candidate, mc);
+ continue;
+ }
+ Matcher match = classFile.matcher(file.getName());
+
+ if (match.matches())
+ {
+ ASMModParser modParser = null;
+ try
+ {
+ FileInputStream fis = new FileInputStream(file);
+ modParser = new ASMModParser(fis);
+ fis.close();
+ }
+ catch (Exception e)
+ {
+ Throwables.propagate(e);
+ }
+
+ modParser.validate();
+ ModContainer container = ModContainerFactory.instance().build(modParser, candidate.getModContainer());
+ if (container!=null)
+ {
+ harvestedMods.add(container);
+ container.bindMetadata(mc);
+ }
+ }
+
+
+ }
+ }
+
+}
diff --git a/fml/common/cpw/mods/fml/common/discovery/ITypeDiscoverer.java b/fml/common/cpw/mods/fml/common/discovery/ITypeDiscoverer.java
new file mode 100644
index 0000000000..ef1c622588
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/ITypeDiscoverer.java
@@ -0,0 +1,13 @@
+package cpw.mods.fml.common.discovery;
+
+import java.util.List;
+import java.util.regex.Pattern;
+
+import cpw.mods.fml.common.ModContainer;
+
+public interface ITypeDiscoverer
+{
+ public static Pattern classFile = Pattern.compile("([^\\s$]+).class$");
+
+ public List discover(ModCandidate candidate);
+}
diff --git a/fml/common/cpw/mods/fml/common/discovery/JarDiscoverer.java b/fml/common/cpw/mods/fml/common/discovery/JarDiscoverer.java
new file mode 100644
index 0000000000..cfb571a320
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/JarDiscoverer.java
@@ -0,0 +1,73 @@
+package cpw.mods.fml.common.discovery;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import com.google.common.collect.Lists;
+
+import cpw.mods.fml.common.FMLLog;
+import cpw.mods.fml.common.MetadataCollection;
+import cpw.mods.fml.common.ModContainer;
+import cpw.mods.fml.common.ModContainerFactory;
+import cpw.mods.fml.common.discovery.asm.ASMModParser;
+
+public class JarDiscoverer implements ITypeDiscoverer
+{
+ @Override
+ public List discover(ModCandidate candidate)
+ {
+ List foundMods = Lists.newArrayList();
+ FMLLog.fine("Examining file %s for potential mods", candidate.getModContainer().getName());
+ ZipFile jar = null;
+ try
+ {
+ jar = new ZipFile(candidate.getModContainer());
+
+ ZipEntry modInfo = jar.getEntry("mcmod.info");
+ MetadataCollection mc = null;
+ if (modInfo != null)
+ {
+ FMLLog.finer("Located mcmod.info file in file %s", candidate.getModContainer().getName());
+ mc = MetadataCollection.from(jar.getInputStream(modInfo));
+ }
+ for (ZipEntry ze : Collections.list(jar.entries()))
+ {
+ Matcher match = classFile.matcher(ze.getName());
+ if (match.matches())
+ {
+ ASMModParser modParser = new ASMModParser(jar.getInputStream(ze));
+ modParser.validate();
+ ModContainer container = ModContainerFactory.instance().build(modParser, candidate.getModContainer());
+ if (container!=null)
+ {
+ foundMods.add(container);
+ container.bindMetadata(mc);
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ FMLLog.warning("Zip file %s failed to read properly, it will be ignored", candidate.getModContainer().getName());
+ }
+ finally
+ {
+ if (jar != null)
+ {
+ try
+ {
+ jar.close();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+ return foundMods;
+ }
+
+}
diff --git a/fml/common/cpw/mods/fml/common/discovery/ModCandidate.java b/fml/common/cpw/mods/fml/common/discovery/ModCandidate.java
new file mode 100644
index 0000000000..26ce3f2e51
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/ModCandidate.java
@@ -0,0 +1,46 @@
+package cpw.mods.fml.common.discovery;
+
+import java.io.File;
+import java.util.List;
+
+import cpw.mods.fml.common.ModContainer;
+
+
+public class ModCandidate
+{
+ private File classPathRoot;
+ private File modContainer;
+ private ContainerType sourceType;
+ private boolean classpath;
+
+ public ModCandidate(File classPathRoot, File modContainer, ContainerType sourceType)
+ {
+ this(classPathRoot, modContainer, sourceType, false);
+ }
+ public ModCandidate(File classPathRoot, File modContainer, ContainerType sourceType, boolean classpath)
+ {
+ this.classPathRoot = classPathRoot;
+ this.modContainer = modContainer;
+ this.sourceType = sourceType;
+ this.classpath = classpath;
+ }
+
+ public File getClassPathRoot()
+ {
+ return classPathRoot;
+ }
+
+ public File getModContainer()
+ {
+ return modContainer;
+ }
+
+ public ContainerType getSourceType()
+ {
+ return sourceType;
+ }
+ public List explore()
+ {
+ return sourceType.findMods(this);
+ }
+}
\ No newline at end of file
diff --git a/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java b/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java
new file mode 100644
index 0000000000..b6b0b67748
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java
@@ -0,0 +1,132 @@
+package cpw.mods.fml.common.discovery;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.channels.FileChannel;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Opcodes;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+import cpw.mods.fml.common.FMLLog;
+import cpw.mods.fml.common.LoaderException;
+import cpw.mods.fml.common.ModClassLoader;
+import cpw.mods.fml.common.ModContainer;
+import cpw.mods.fml.relauncher.RelaunchLibraryManager;
+
+public class ModDiscoverer
+{
+ private static Pattern zipJar = Pattern.compile("(.+).(zip|jar)$");
+
+ private List candidates = Lists.newArrayList();
+
+ public void findClasspathMods(ModClassLoader modClassLoader)
+ {
+ List knownLibraries = ImmutableList.builder().addAll(modClassLoader.getDefaultLibraries()).addAll(RelaunchLibraryManager.getLibraries()).build();
+ File[] minecraftSources = modClassLoader.getParentSources();
+ if (minecraftSources.length == 1 && minecraftSources[0].isFile())
+ {
+ FMLLog.fine("Minecraft is a file at %s, loading", minecraftSources[0].getAbsolutePath());
+ candidates.add(new ModCandidate(minecraftSources[0], minecraftSources[0], ContainerType.JAR));
+ }
+ else
+ {
+ for (int i = 0; i < minecraftSources.length; i++)
+ {
+ if (minecraftSources[i].isFile())
+ {
+ if (knownLibraries.contains(minecraftSources[i].getName()))
+ {
+ FMLLog.fine("Skipping known library file %s", minecraftSources[i].getAbsolutePath());
+ }
+ else
+ {
+ FMLLog.fine("Found a minecraft related file at %s, examining for mod candidates", minecraftSources[i].getAbsolutePath());
+ candidates.add(new ModCandidate(minecraftSources[i], minecraftSources[i], ContainerType.JAR, true));
+ }
+ }
+ else if (minecraftSources[i].isDirectory())
+ {
+ FMLLog.fine("Found a minecraft related directory at %s, examining for mod candidates", minecraftSources[i].getAbsolutePath());
+ candidates.add(new ModCandidate(minecraftSources[i], minecraftSources[i], ContainerType.DIR, true));
+ }
+ }
+ }
+
+ }
+
+ public void findModDirMods(File modsDir)
+ {
+ File[] modList = modsDir.listFiles();
+ // Sort the files into alphabetical order first
+ Arrays.sort(modList);
+
+ for (File modFile : modList)
+ {
+ if (modFile.isDirectory())
+ {
+ FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
+ candidates.add(new ModCandidate(modFile, modFile, ContainerType.DIR));
+ }
+ else
+ {
+ Matcher matcher = zipJar.matcher(modFile.getName());
+
+ if (matcher.matches())
+ {
+ FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0));
+ candidates.add(new ModCandidate(modFile, modFile, ContainerType.JAR));
+ }
+ else
+ {
+ FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName());
+ }
+ }
+ }
+ }
+
+ public List identifyMods()
+ {
+ List modList = Lists.newArrayList();
+
+ for (ModCandidate candidate : candidates)
+ {
+ try
+ {
+ List mods = candidate.explore();
+ modList.addAll(mods);
+ }
+ catch (LoaderException le)
+ {
+ FMLLog.log(Level.WARNING, le, "Identified a problem with the mod candidate %s, ignoring this source", candidate.getModContainer());
+ }
+ catch (Throwable t)
+ {
+ Throwables.propagate(t);
+ }
+ }
+
+ return modList;
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/discovery/asm/ASMModParser.java b/fml/common/cpw/mods/fml/common/discovery/asm/ASMModParser.java
new file mode 100644
index 0000000000..7ff5ee44a2
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/asm/ASMModParser.java
@@ -0,0 +1,118 @@
+package cpw.mods.fml.common.discovery.asm;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedList;
+import java.util.List;
+
+import net.minecraft.src.BaseMod;
+
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.Type;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Lists;
+
+import cpw.mods.fml.common.LoaderException;
+
+public class ASMModParser
+{
+
+ private Type asmType;
+ private int classVersion;
+ private Type asmSuperType;
+ private LinkedList annotations = Lists.newLinkedList();
+ private String baseModProperties;
+
+ static enum AnnotationType
+ {
+ CLASS, FIELD, METHOD;
+ }
+
+ public ASMModParser(InputStream stream) throws IOException
+ {
+ ClassReader reader = new ClassReader(stream);
+ reader.accept(new ModClassVisitor(this), 0);
+ }
+
+ public void beginNewTypeName(String typeQName, int classVersion, String superClassQName)
+ {
+ this.asmType = Type.getObjectType(typeQName);
+ this.classVersion = classVersion;
+ this.asmSuperType = Type.getObjectType(superClassQName);
+ }
+
+ public void startClassAnnotation(String annotationName)
+ {
+ ModAnnotation ann = new ModAnnotation(AnnotationType.CLASS, Type.getType(annotationName), this.asmType.getClassName());
+ annotations.addFirst(ann);
+ }
+
+ public void addAnnotationProperty(String key, Object value)
+ {
+ annotations.getFirst().values.put(key, value);
+ }
+
+ public void startFieldAnnotation(String fieldName, String annotationName)
+ {
+ ModAnnotation ann = new ModAnnotation(AnnotationType.FIELD, Type.getType(annotationName), fieldName);
+ annotations.addFirst(ann);
+ }
+
+ @Override
+ public String toString()
+ {
+ return Objects.toStringHelper("ASMAnnotationDiscoverer")
+ .add("className", asmType.getClassName())
+ .add("classVersion", classVersion)
+ .add("superName", asmSuperType.getClassName())
+ .add("annotations", annotations)
+ .add("isBaseMod", isBaseMod())
+ .add("baseModProperties", baseModProperties)
+ .toString();
+ }
+
+ public Type getASMType()
+ {
+ return asmType;
+ }
+
+ public int getClassVersion()
+ {
+ return classVersion;
+ }
+
+ public Type getASMSuperType()
+ {
+ return asmSuperType;
+ }
+
+ public LinkedList getAnnotations()
+ {
+ return annotations;
+ }
+
+ public void validate()
+ {
+// if (classVersion > 50.0)
+// {
+//
+// throw new LoaderException(new RuntimeException("Mod compiled for Java 7 detected"));
+// }
+ }
+
+ public boolean isBaseMod()
+ {
+ return getASMSuperType().equals(Type.getType(BaseMod.class));
+ }
+
+ public void setBaseModProperties(String foundProperties)
+ {
+ this.baseModProperties = foundProperties;
+ }
+
+ public String getBaseModProperties()
+ {
+ return this.baseModProperties;
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/discovery/asm/ModAnnotation.java b/fml/common/cpw/mods/fml/common/discovery/asm/ModAnnotation.java
new file mode 100644
index 0000000000..f9cde66fce
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/asm/ModAnnotation.java
@@ -0,0 +1,50 @@
+package cpw.mods.fml.common.discovery.asm;
+
+import java.util.Map;
+
+import org.objectweb.asm.Type;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Maps;
+
+import cpw.mods.fml.common.discovery.asm.ASMModParser.AnnotationType;
+
+public class ModAnnotation
+{
+ AnnotationType type;
+ Type asmType;
+ String member;
+ Map values = Maps.newHashMap();
+ public ModAnnotation(AnnotationType type, Type asmType, String member)
+ {
+ this.type = type;
+ this.asmType = asmType;
+ this.member = member;
+ }
+ @Override
+ public String toString()
+ {
+ return Objects.toStringHelper("Annotation")
+ .add("type",type)
+ .add("name",asmType.getClassName())
+ .add("member",member)
+ .add("values", values)
+ .toString();
+ }
+ public AnnotationType getType()
+ {
+ return type;
+ }
+ public Type getASMType()
+ {
+ return asmType;
+ }
+ public String getMember()
+ {
+ return member;
+ }
+ public Map getValues()
+ {
+ return values;
+ }
+}
\ No newline at end of file
diff --git a/fml/common/cpw/mods/fml/common/discovery/asm/ModAnnotationVisitor.java b/fml/common/cpw/mods/fml/common/discovery/asm/ModAnnotationVisitor.java
new file mode 100644
index 0000000000..e37d29466c
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/asm/ModAnnotationVisitor.java
@@ -0,0 +1,21 @@
+package cpw.mods.fml.common.discovery.asm;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Opcodes;
+
+public class ModAnnotationVisitor extends AnnotationVisitor
+{
+ private ASMModParser discoverer;
+
+ public ModAnnotationVisitor(ASMModParser discoverer)
+ {
+ super(Opcodes.ASM4);
+ this.discoverer = discoverer;
+ }
+
+ @Override
+ public void visit(String key, Object value)
+ {
+ discoverer.addAnnotationProperty(key, value);
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/discovery/asm/ModClassVisitor.java b/fml/common/cpw/mods/fml/common/discovery/asm/ModClassVisitor.java
new file mode 100644
index 0000000000..0f5a0c67ef
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/asm/ModClassVisitor.java
@@ -0,0 +1,50 @@
+package cpw.mods.fml.common.discovery.asm;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+public class ModClassVisitor extends ClassVisitor
+{
+ private ASMModParser discoverer;
+
+ public ModClassVisitor(ASMModParser discoverer)
+ {
+ super(Opcodes.ASM4);
+ this.discoverer = discoverer;
+ }
+
+
+ @Override
+ public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
+ {
+ discoverer.beginNewTypeName(name, version, superName);
+ }
+
+ @Override
+ public AnnotationVisitor visitAnnotation(String annotationName, boolean runtimeVisible)
+ {
+ discoverer.startClassAnnotation(annotationName);
+ return new ModAnnotationVisitor(discoverer);
+ }
+
+
+ @Override
+ public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
+ {
+ return new ModFieldVisitor(name, discoverer);
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
+ {
+ if (discoverer.isBaseMod() && name.equals("getPriorities") && desc.equals(Type.getMethodDescriptor(Type.getType(String.class))))
+ {
+ return new ModMethodVisitor(name, discoverer);
+ }
+ return null;
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/discovery/asm/ModFieldVisitor.java b/fml/common/cpw/mods/fml/common/discovery/asm/ModFieldVisitor.java
new file mode 100644
index 0000000000..16cedd96b0
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/asm/ModFieldVisitor.java
@@ -0,0 +1,25 @@
+package cpw.mods.fml.common.discovery.asm;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Opcodes;
+
+public class ModFieldVisitor extends FieldVisitor
+{
+
+ private String fieldName;
+ private ASMModParser discoverer;
+
+ public ModFieldVisitor(String name, ASMModParser discoverer)
+ {
+ super(Opcodes.ASM4);
+ this.fieldName = name;
+ this.discoverer = discoverer;
+ }
+ @Override
+ public AnnotationVisitor visitAnnotation(String annotationName, boolean runtimeVisible)
+ {
+ discoverer.startFieldAnnotation(fieldName, annotationName);
+ return new ModAnnotationVisitor(discoverer);
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/discovery/asm/ModMethodVisitor.java b/fml/common/cpw/mods/fml/common/discovery/asm/ModMethodVisitor.java
new file mode 100644
index 0000000000..a204091cd2
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/asm/ModMethodVisitor.java
@@ -0,0 +1,62 @@
+package cpw.mods.fml.common.discovery.asm;
+
+import java.util.LinkedList;
+
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+import com.google.common.collect.Lists;
+
+public class ModMethodVisitor extends MethodVisitor
+{
+
+ private ASMModParser discoverer;
+ private boolean inCode;
+ private LinkedList