From b51ce21b70112ba905f7565b4ce0fdea30119487 Mon Sep 17 00:00:00 2001
From: Christian
Date: Fri, 29 Jun 2012 20:18:04 -0400
Subject: [PATCH 01/50] Initial checkin. Some patches are probably missing, but
client compiles.
---
.../cpw/mods/fml/client/FMLClientHandler.java | 44 ++++----
fml/client/net/minecraft/src/BaseMod.java | 52 ++++-----
fml/getversion.py | 2 +-
.../net/minecraft/client/Minecraft.java.patch | 62 ++++-------
.../minecraft/src/BlockDispenser.java.patch | 13 ---
.../net/minecraft/src/EntityItem.java.patch | 7 +-
.../net/minecraft/src/EntityList.java.patch | 2 +-
.../net/minecraft/src/EntityPlayer.java.patch | 6 +-
.../minecraft/src/GuiCreateWorld.java.patch | 10 --
.../net/minecraft/src/GuiMainMenu.java.patch | 43 +++++---
.../minecraft/src/NetClientHandler.java.patch | 44 +++-----
.../minecraft/src/PanelCrashReport.java.patch | 22 +---
.../net/minecraft/src/RenderBlocks.java.patch | 102 ++++--------------
.../net/minecraft/src/RenderEngine.java.patch | 41 ++++---
.../net/minecraft/src/RenderPlayer.java.patch | 2 +-
.../net/minecraft/src/SlotFurnace.java.patch | 4 +-
.../minecraft/src/StringTranslate.java.patch | 6 +-
.../minecraft/src/TexturePackList.java.patch | 17 +--
.../net/minecraft/src/TileEntity.java.patch | 2 +-
.../src/TileEntityFurnace.java.patch | 15 ---
.../src/TileEntityRenderer.java.patch | 2 +-
.../net/minecraft/src/World.java.patch | 5 +-
.../net/minecraft/src/WorldType.java.patch | 4 +-
.../server/MinecraftServer.java.patch | 75 -------------
.../minecraft/src/BlockDispenser.java.patch | 12 ---
.../src/ChunkProviderServer.java.patch | 2 +-
.../net/minecraft/src/Entity.java.patch | 4 +-
.../net/minecraft/src/EntityItem.java.patch | 7 +-
.../net/minecraft/src/EntityList.java.patch | 2 +-
.../net/minecraft/src/EntityPlayer.java.patch | 17 +--
.../minecraft/src/NetLoginHandler.java.patch | 21 ----
.../minecraft/src/NetServerHandler.java.patch | 22 +---
.../src/ServerConfigurationManager.java.patch | 14 +--
.../net/minecraft/src/ServerGUI.java.patch | 2 +-
.../net/minecraft/src/SlotFurnace.java.patch | 4 +-
.../minecraft/src/StringTranslate.java.patch | 6 +-
.../net/minecraft/src/TileEntity.java.patch | 2 +-
.../src/TileEntityFurnace.java.patch | 15 ---
.../net/minecraft/src/WorldType.java.patch | 4 +-
39 files changed, 210 insertions(+), 506 deletions(-)
delete mode 100644 fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch
delete mode 100644 fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
delete mode 100644 fml/patches/minecraft_server/net/minecraft/src/NetLoginHandler.java.patch
diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
index 73d9f3dd29..adcde06239 100644
--- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java
+++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
@@ -238,11 +238,11 @@ public class FMLClientHandler implements IFMLSidedHandler
*/
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);
- }
+// 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);
+// }
}
/**
@@ -250,11 +250,11 @@ public class FMLClientHandler implements IFMLSidedHandler
*/
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);
- }
+// 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();
@@ -263,14 +263,14 @@ public class FMLClientHandler implements IFMLSidedHandler
public void onWorldLoadTick()
{
- if (client.field_6324_e != null) {
+// if (client.field_6324_e != null) {
if (firstTick)
{
loadTextures(fallbackTexturePack);
firstTick = false;
}
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLDLOAD,TickType.GUILOAD));
- }
+// }
}
public void onRenderTickStart(float partialTickTime)
@@ -531,14 +531,14 @@ public class FMLClientHandler implements IFMLSidedHandler
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);
- }
+// 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)
@@ -921,10 +921,10 @@ public class FMLClientHandler implements IFMLSidedHandler
/**
*
*/
- public void preGameLoad(String user, String sessionToken)
+ public void preGameLoad(String[] args)
{
// Currently this does nothing, but it's possible I could relaunch Minecraft in a new classloader if I wished
- Minecraft.fmlReentry(user, sessionToken);
+ Minecraft.fmlReentry(args);
}
public void onTexturePackChange(RenderEngine engine, TexturePackBase texturepack, List effects)
diff --git a/fml/client/net/minecraft/src/BaseMod.java b/fml/client/net/minecraft/src/BaseMod.java
index 827c850049..b2f99f9824 100644
--- a/fml/client/net/minecraft/src/BaseMod.java
+++ b/fml/client/net/minecraft/src/BaseMod.java
@@ -34,7 +34,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
{
this.keyboardEvent((KeyBinding)keybinding);
}
-
+
/**
* @param minecraftInstance
* @return
@@ -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);
@@ -58,11 +58,11 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
public final void onRenderHarvest(Map renderers)
{
addRenderer((Map,Render>)renderers);
-
+
}
/**
- *
+ *
*/
public final void onRegisterAnimations()
{
@@ -99,11 +99,11 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
public final void onServerLogin(Object handler) {
serverConnect((NetClientHandler) handler);
}
-
+
public final void onServerLogout() {
serverDisconnect();
}
-
+
@Override
public final void onPlayerLogin(Object player)
{
@@ -163,7 +163,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
// BASEMOD API
/**
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item
- *
+ *
* @param id
* @param metadata
* @return
@@ -180,7 +180,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Override if you wish to perform some action other than just dispensing the item from the dispenser
- *
+ *
* @param world
* @param x
* @param y
@@ -197,7 +197,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Override if you wish to generate Nether (Hell biome) blocks
- *
+ *
* @param world
* @param random
* @param chunkX
@@ -209,7 +209,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Override if you wish to generate Overworld (not hell or the end) blocks
- *
+ *
* @param world
* @param random
* @param chunkX
@@ -221,7 +221,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Return the name of your mod. Defaults to the class name
- *
+ *
* @return
*/
public String getName()
@@ -231,7 +231,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Get your mod priorities
- *
+ *
* @return
*/
public String getPriorities()
@@ -241,7 +241,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Return the version of your mod
- *
+ *
* @return
*/
public abstract String getVersion();
@@ -265,7 +265,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Handle item pickup
- *
+ *
* @param player
* @param item
*/
@@ -275,7 +275,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Ticked every game tick if you have subscribed to tick events through {@link ModLoader#setInGameHook(BaseMod, boolean, boolean)}
- *
+ *
* @param time the rendering subtick time (0.0-1.0)
* @param minecraftInstance the client
* @return true to continue receiving ticks
@@ -293,7 +293,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Only implemented on the client side
* {@link #onChatMessageReceived(EntityPlayer, Packet3Chat)}
- *
+ *
* @param text
*/
public void receiveChatPacket(String text)
@@ -304,7 +304,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Only called on the client side
* {@link #onPacket250Received(EntityPlayer, Packet250CustomPayload)}
- *
+ *
* @param packet
*/
public void receiveCustomPacket(Packet250CustomPayload packet)
@@ -329,15 +329,15 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
}
public void serverConnect(NetClientHandler handler) {
-
+
}
-
+
public void serverDisconnect() {
-
+
}
/**
* Called when someone crafts an item from a crafting table
- *
+ *
* @param player
* @param item
* @param matrix
@@ -377,7 +377,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Called when a chat message is received. Return true to stop further processing
- *
+ *
* @param source
* @param chat
* @return true if you want to consume the message so it is not available for further processing
@@ -398,7 +398,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Called when a new client logs in.
- *
+ *
* @param player
*/
public void onClientLogin(EntityPlayer player)
@@ -407,7 +407,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
/**
* Called when a client logs out of the server.
- *
+ *
* @param player
*/
public void onClientLogout(EntityPlayer player)
@@ -416,9 +416,9 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
}
/**
- *
+ *
* Called when a client changes dimensions on the server.
- *
+ *
* @param player
*/
public void onClientDimensionChanged(EntityPlayer player)
diff --git a/fml/getversion.py b/fml/getversion.py
index c86354afe2..98762d2048 100644
--- a/fml/getversion.py
+++ b/fml/getversion.py
@@ -40,7 +40,7 @@ def main():
f.write("%s=%s\n" %("fmlbuild.minor.number",minor))
f.write("%s=%s\n" %("fmlbuild.revision.number",rev))
f.write("%s=%s\n" %("fmlbuild.githash",githash))
- f.write("%s=%s\n" %("fmlbuild.mcversion","1.2.5"))
+ f.write("%s=%s\n" %("fmlbuild.mcversion","12w24a"))
if __name__ == '__main__':
main()
diff --git a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch
index 2652ff5b3a..82f67e0bd1 100644
--- a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch
+++ b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch
@@ -1,25 +1,16 @@
--- ../src-base/minecraft/net/minecraft/client/Minecraft.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/client/Minecraft.java 0000-00-00 00:00:00.000000000 -0000
-@@ -9,6 +9,7 @@
- import java.awt.Graphics;
- import java.io.File;
- import java.text.DecimalFormat;
-+import java.util.EnumSet;
- import java.util.List;
- import net.minecraft.src.AchievementList;
- import net.minecraft.src.AnvilSaveConverter;
-@@ -117,6 +118,10 @@
+@@ -120,6 +120,9 @@
import org.lwjgl.opengl.PixelFormat;
import org.lwjgl.util.glu.GLU;
+import cpw.mods.fml.client.FMLClientHandler;
+import cpw.mods.fml.common.FMLCommonHandler;
-+import cpw.mods.fml.common.TickType;
+
- public abstract class Minecraft implements Runnable
+ public abstract class Minecraft implements IPlayerUsage, Runnable
{
public static byte[] field_28006_b = new byte[10485760];
-@@ -288,6 +293,7 @@
+@@ -301,6 +304,7 @@
this.field_6315_n = new RenderEngine(this.field_6298_C, this.field_6304_y);
this.func_6257_q();
this.field_6314_o = new FontRenderer(this.field_6304_y, "/font/default.png", this.field_6315_n, false);
@@ -27,7 +18,7 @@
this.field_40007_r = new FontRenderer(this.field_6304_y, "/font/alternate.png", this.field_6315_n, false);
if (this.field_6304_y.field_44018_Q != null)
-@@ -330,6 +336,9 @@
+@@ -332,6 +336,9 @@
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
@@ -35,37 +26,23 @@
+ this.field_9231_Y.setup();
+ this.field_9232_X.setup();
this.func_6250_c("Startup");
- this.field_6286_O = new OpenGlCapsChecker();
this.field_6301_A.func_340_a(this.field_6304_y);
-@@ -744,9 +753,11 @@
- this.field_6327_b.func_6467_a(this.field_9237_P.field_1378_c);
- }
+ this.field_6315_n.func_1066_a(this.field_9231_Y);
+@@ -1337,11 +1344,13 @@
-+ FMLClientHandler.instance().onRenderTickStart(this.field_9237_P.field_1378_c);
- Profiler.func_40661_c("gameRenderer");
- this.field_9243_r.func_4136_b(this.field_9237_P.field_1378_c);
- Profiler.func_40662_b();
-+ FMLClientHandler.instance().onRenderTickEnd(this.field_9237_P.field_1378_c);
- }
-
- GL11.glFlush();
-@@ -1330,6 +1341,7 @@
-
- public void func_6246_i()
+ public void func_6246_i() throws IOException
{
+ FMLCommonHandler.instance().rescheduleTicks();
if (this.field_35001_ab > 0)
{
--this.field_35001_ab;
-@@ -1340,6 +1352,7 @@
- this.func_28001_B();
}
+ FMLClientHandler.instance().onPreWorldTick();
Profiler.func_40663_a("stats");
this.field_25001_G.func_27178_d();
Profiler.func_40661_c("gui");
-@@ -1730,6 +1743,7 @@
+@@ -1710,6 +1719,7 @@
}
Profiler.func_40662_b();
@@ -73,23 +50,22 @@
this.field_6287_N = System.currentTimeMillis();
}
-@@ -1985,6 +1999,7 @@
+@@ -1854,6 +1864,7 @@
System.gc();
this.field_6287_N = 0L;
+ FMLClientHandler.instance().onWorldLoadTick();
}
- private void func_22002_b(String p_22002_1_, String p_22002_2_)
-@@ -2250,7 +2265,11 @@
- {
- var2 = p_main_0_[1];
- }
-+ FMLClientHandler.instance().preGameLoad(var1, var2);
+ public void func_6268_a(String p_6268_1_, File p_6268_2_)
+@@ -1944,6 +1955,10 @@
+
+ public static void main(String[] p_main_0_)
+ {
++ FMLClientHandler.instance().preGameLoad(p_main_0_);
+ }
-
-+ public static void fmlReentry(String var1, String var2)
++ public static void fmlReentry(String[] p_main_0_)
+ {
- func_6269_a(var1, var2);
- }
-
+ HashMap var1 = new HashMap();
+ boolean var2 = false;
+ boolean var3 = true;
diff --git a/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch b/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch
index 7fb6086f3a..cd78099b9c 100644
--- a/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch
@@ -9,16 +9,3 @@
public class BlockDispenser extends BlockContainer
{
private Random field_28035_a = new Random();
-@@ -141,7 +143,11 @@
- }
- else
- {
-- if (var12.field_1617_c == Item.field_226_j.field_291_aS)
-+ if (FMLClientHandler.instance().tryDispensingEntity(p_21033_1_, var13, var15, var17, var9, var10, var12))
-+ {
-+ ;
-+ }
-+ else if (var12.field_1617_c == Item.field_226_j.field_291_aS)
- {
- EntityArrow var19 = new EntityArrow(p_21033_1_, var13, var15, var17);
- var19.func_408_a((double)var9, 0.10000000149011612D, (double)var10, 1.1F, 6.0F);
diff --git a/fml/patches/minecraft/net/minecraft/src/EntityItem.java.patch b/fml/patches/minecraft/net/minecraft/src/EntityItem.java.patch
index ae9fd0ba32..fd08077783 100644
--- a/fml/patches/minecraft/net/minecraft/src/EntityItem.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/EntityItem.java.patch
@@ -1,14 +1,15 @@
--- ../src-base/minecraft/net/minecraft/src/EntityItem.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/EntityItem.java 0000-00-00 00:00:00.000000000 -0000
-@@ -1,5 +1,7 @@
- package net.minecraft.src;
+@@ -2,6 +2,8 @@
+
+ import java.util.Iterator;
+import cpw.mods.fml.client.FMLClientHandler;
+
public class EntityItem extends Entity
{
public ItemStack field_801_a;
-@@ -140,6 +142,7 @@
+@@ -198,6 +200,7 @@
if (this.field_805_c == 0 && p_6378_1_.field_778_b.func_504_a(this.field_801_a))
{
diff --git a/fml/patches/minecraft/net/minecraft/src/EntityList.java.patch b/fml/patches/minecraft/net/minecraft/src/EntityList.java.patch
index eba3716675..e0677b1231 100644
--- a/fml/patches/minecraft/net/minecraft/src/EntityList.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/EntityList.java.patch
@@ -1,6 +1,6 @@
--- ../src-base/minecraft/net/minecraft/src/EntityList.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/EntityList.java 0000-00-00 00:00:00.000000000 -0000
-@@ -166,4 +166,17 @@
+@@ -174,4 +174,17 @@
func_46152_a(EntityVillager.class, "Villager", 120, 5651507, 12422002);
func_1080_a(EntityEnderCrystal.class, "EnderCrystal", 200);
}
diff --git a/fml/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch b/fml/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch
index 572f9ac61f..d79178bdaa 100644
--- a/fml/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch
@@ -10,10 +10,10 @@
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.TickType;
+
- public abstract class EntityPlayer extends EntityLiving
+ public abstract class EntityPlayer extends EntityLiving implements ICommandSender
{
public InventoryPlayer field_778_b = new InventoryPlayer(this);
-@@ -122,6 +126,7 @@
+@@ -123,6 +127,7 @@
public void func_370_e_()
{
@@ -21,7 +21,7 @@
if (this.field_34907_d != null)
{
ItemStack var1 = this.field_778_b.func_494_a();
-@@ -253,6 +258,7 @@
+@@ -246,6 +251,7 @@
{
this.field_35217_av.func_35768_a(this);
}
diff --git a/fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch b/fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch
deleted file mode 100644
index 4c659a9ded..0000000000
--- a/fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- ../src-base/minecraft/net/minecraft/src/GuiCreateWorld.java 0000-00-00 00:00:00.000000000 -0000
-+++ ../src-work/minecraft/net/minecraft/src/GuiCreateWorld.java 0000-00-00 00:00:00.000000000 -0000
-@@ -164,6 +164,7 @@
- this.field_945_b.field_6327_b = new PlayerControllerSP(this.field_945_b);
- }
-
-+ WorldType.field_48637_a[this.field_46030_z].onGUICreateWorldPress();
- this.field_945_b.func_6247_b(this.field_22132_k, this.field_22134_h.func_22071_a(), new WorldSettings(var2, var9, this.field_35365_g, this.field_40232_h, WorldType.field_48637_a[this.field_46030_z]));
- this.field_945_b.func_6272_a((GuiScreen)null);
- }
diff --git a/fml/patches/minecraft/net/minecraft/src/GuiMainMenu.java.patch b/fml/patches/minecraft/net/minecraft/src/GuiMainMenu.java.patch
index a32efb8a6b..d0d7e937ec 100644
--- a/fml/patches/minecraft/net/minecraft/src/GuiMainMenu.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/GuiMainMenu.java.patch
@@ -1,6 +1,6 @@
--- ../src-base/minecraft/net/minecraft/src/GuiMainMenu.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/GuiMainMenu.java 0000-00-00 00:00:00.000000000 -0000
-@@ -11,6 +11,9 @@
+@@ -12,6 +12,9 @@
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;
@@ -10,37 +10,46 @@
public class GuiMainMenu extends GuiScreen
{
private static final Random field_6463_h = new Random();
-@@ -91,7 +94,8 @@
- int var4 = this.field_950_d / 4 + 48;
- this.field_949_e.add(new GuiButton(1, this.field_951_c / 2 - 100, var4, var2.func_20163_a("menu.singleplayer")));
- this.field_949_e.add(this.field_25096_l = new GuiButton(2, this.field_951_c / 2 - 100, var4 + 24, var2.func_20163_a("menu.multiplayer")));
+@@ -117,7 +120,9 @@
+ this.func_55154_a(var4, 24, var2);
+ }
+
- this.field_949_e.add(new GuiButton(3, this.field_951_c / 2 - 100, var4 + 48, var2.func_20163_a("menu.mods")));
++// this.field_949_e.add(new GuiButton(3, this.field_951_c / 2 - 100, var4 + 48, var2.func_20163_a("menu.mods")));
+ this.field_949_e.add(new GuiButton(3, this.field_951_c / 2 - 100, var4 + 48, 98, 20, var2.func_20163_a("menu.mods")));
+ this.field_949_e.add(new GuiButton(6, this.field_951_c / 2 + 2, var4 + 48, 98, 20, "Mods"));
if (this.field_945_b.field_6317_l)
{
-@@ -142,6 +146,11 @@
+@@ -149,6 +154,7 @@
{
+ this.field_55155_d.field_937_g = false;
+ }
++
+ }
+
+ protected void func_572_a(GuiButton p_572_1_)
+@@ -183,6 +189,10 @@
this.field_945_b.func_6244_d();
}
-+
+
+ if (p_572_1_.field_938_f == 6)
+ {
+ this.field_945_b.func_6272_a(new GuiModList(this));
+ }
- }
+ if (p_572_1_.field_938_f == 11)
+ {
+ this.field_945_b.func_56442_a("Demo_World", DemoWorldServer.field_56874_a);
+@@ -399,7 +409,11 @@
+ var9 = var9 + " Demo";
+ }
- private void func_35355_b(int p_35355_1_, int p_35355_2_, float p_35355_3_)
-@@ -324,7 +333,10 @@
- GL11.glScalef(var8, var8, var8);
- this.func_548_a(this.field_6451_g, this.field_6462_l, 0, -8, 16776960);
- GL11.glPopMatrix();
-- this.func_547_b(this.field_6451_g, "Minecraft 1.2.5", 2, this.field_950_d - 10, 16777215);
-+ String[] brandings=FMLCommonHandler.instance().getBrandingStrings("Minecraft 1.2.5");
+- this.func_547_b(this.field_6451_g, var9, 2, this.field_950_d - 10, 16777215);
++ String[] brandings=FMLCommonHandler.instance().getBrandingStrings(var9);
+ for (int i=0; i
Date: Mon, 2 Jul 2012 12:24:37 -0400
Subject: [PATCH 02/50] Harvest MC version from MCP
---
fml/build.xml | 1 +
fml/common/cpw/mods/fml/common/Loader.java | 18 ++++++++++--------
fml/getversion.py | 18 +++++++++++++++++-
3 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/fml/build.xml b/fml/build.xml
index 785dffbe76..7a621fd60a 100644
--- a/fml/build.xml
+++ b/fml/build.xml
@@ -26,6 +26,7 @@
+
diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java
index 6e8e4c669f..89db560172 100644
--- a/fml/common/cpw/mods/fml/common/Loader.java
+++ b/fml/common/cpw/mods/fml/common/Loader.java
@@ -92,7 +92,8 @@ public class Loader
private static String minor;
private static String rev;
private static String build;
- private static String mcversion;
+ private static String mccversion;
+ private static String mcsversion;
/**
* The {@link State} of the loader
@@ -163,18 +164,19 @@ public class Loader
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");
- mcversion = properties.getProperty("fmlbuild.mcversion","none");
+ 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 %s loading", major, minor, rev, build, mcversion));
+ 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();
}
@@ -646,7 +648,7 @@ 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, mcversion))) {
+ 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)
diff --git a/fml/getversion.py b/fml/getversion.py
index 98762d2048..ff3432e454 100644
--- a/fml/getversion.py
+++ b/fml/getversion.py
@@ -5,6 +5,15 @@ import fnmatch
import re
import subprocess, shlex
+mcp_home = sys.argv[1]
+mcp_dir = os.path.abspath(mcp_home)
+
+print(mcp_dir)
+sys.path.append(mcp_dir)
+
+from runtime.commands import Commands
+Commands._version_config = os.path.join(mcp_dir,Commands._version_config)
+
def cmdsplit(args):
if os.sep == '\\':
args = args.replace('\\', '\\\\')
@@ -35,12 +44,19 @@ def main():
print("Git not found")
vers="v1.0-0-deadbeef"
(major,minor,rev,githash)=re.match("v(\d+).(\d+)-(\d+)-(.*)",vers).groups()
+
+ (mcpversion,mcclientversion,mcserverversion) = re.match("[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)",Commands.fullversion()).groups()
+
with open("fmlversion.properties","w") as f:
f.write("%s=%s\n" %("fmlbuild.major.number",major))
f.write("%s=%s\n" %("fmlbuild.minor.number",minor))
f.write("%s=%s\n" %("fmlbuild.revision.number",rev))
f.write("%s=%s\n" %("fmlbuild.githash",githash))
- f.write("%s=%s\n" %("fmlbuild.mcversion","12w24a"))
+ f.write("%s=%s\n" %("fmlbuild.mcpversion",mcpversion))
+ f.write("%s=%s\n" %("fmlbuild.mcclientversion",mcclientversion))
+ f.write("%s=%s\n" %("fmlbuild.mcserverversion",mcserverversion))
+
+ print("Version information: FML %s.%s.%s using MCP %s for c:%s, s:%s" % (major, minor, rev, mcpversion, mcclientversion, mcserverversion))
if __name__ == '__main__':
main()
From 07a1927c25bbaf18281b576978a1108f7de4b814 Mon Sep 17 00:00:00 2001
From: Christian
Date: Mon, 2 Jul 2012 23:49:40 -0400
Subject: [PATCH 03/50] Update some stuff
---
fml/build.xml | 1 +
.../cpw/mods/fml/client/FMLClientHandler.java | 39 ++++++---------
.../cpw/mods/fml/relauncher/ArgsWrapper.java | 11 +++++
.../relauncher/FMLEmbeddingRelauncher.java | 48 +++++++++++++++++++
.../fml/relauncher/RelaunchClassLoader.java | 31 ++++++++++++
fml/eclipse/FML-Client/.classpath | 1 +
.../net/minecraft/client/Minecraft.java.patch | 23 +++++----
.../net/minecraft/src/GuiMainMenu.java.patch | 2 +-
.../minecraft/src/NetClientHandler.java.patch | 4 +-
.../minecraft/src/StatFileWriter.java.patch | 34 +++++++++++++
.../net/minecraft/src/World.java.patch | 2 +-
.../src/ChunkProviderServer.java.patch | 2 +-
.../net/minecraft/src/Entity.java.patch | 2 +-
.../minecraft/src/NetServerHandler.java.patch | 2 +-
.../src/ServerConfigurationManager.java.patch | 2 +-
15 files changed, 162 insertions(+), 42 deletions(-)
create mode 100644 fml/common/cpw/mods/fml/relauncher/ArgsWrapper.java
create mode 100644 fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java
create mode 100644 fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java
create mode 100644 fml/patches/minecraft/net/minecraft/src/StatFileWriter.java.patch
diff --git a/fml/build.xml b/fml/build.xml
index f10e348832..d4351eaf7a 100644
--- a/fml/build.xml
+++ b/fml/build.xml
@@ -126,6 +126,7 @@
+
diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
index adcde06239..4ce22755bb 100644
--- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java
+++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
@@ -794,11 +794,11 @@ public class FMLClientHandler implements IFMLSidedHandler
@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 root=new JdomParser().parse(new InputStreamReader(input));
+ List lst=root.getArrayNode();
JsonNode modinfo = null;
for (JsonNode tmodinfo : lst) {
- if (mod.getName().equals(tmodinfo.func_27213_a("modid"))) {
+ if (mod.getName().equals(tmodinfo.getStringValue("modid"))) {
modinfo = tmodinfo;
break;
}
@@ -809,23 +809,23 @@ public class FMLClientHandler implements IFMLSidedHandler
}
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");
+ meta.name=modinfo.getStringValue("name");
+ meta.description=modinfo.getStringValue("description").replace("\r", "");
+ meta.version=modinfo.getStringValue("version");
+ meta.credits=modinfo.getStringValue("credits");
+ List authors=modinfo.getArrayNode("authors");
StringBuilder sb=new StringBuilder();
for (int i=0; i screenshots=modinfo.getArrayNode("screenshots");
meta.screenshots=new String[screenshots.size()];
for (int i=0; i effects)
{
FMLClientHandler.instance().pruneOldTextureFX(texturepack, effects);
diff --git a/fml/common/cpw/mods/fml/relauncher/ArgsWrapper.java b/fml/common/cpw/mods/fml/relauncher/ArgsWrapper.java
new file mode 100644
index 0000000000..141b9cdc76
--- /dev/null
+++ b/fml/common/cpw/mods/fml/relauncher/ArgsWrapper.java
@@ -0,0 +1,11 @@
+package cpw.mods.fml.relauncher;
+
+public class ArgsWrapper
+{
+ public ArgsWrapper(String[] args)
+ {
+ this.args=args;
+ }
+
+ public String[] args;
+}
diff --git a/fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java b/fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java
new file mode 100644
index 0000000000..d924f816f0
--- /dev/null
+++ b/fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java
@@ -0,0 +1,48 @@
+package cpw.mods.fml.relauncher;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URLClassLoader;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.src.WorldSettings;
+
+public class FMLEmbeddingRelauncher
+{
+ private static FMLEmbeddingRelauncher INSTANCE;
+ private RelaunchClassLoader clientLoader;
+ private RelaunchClassLoader serverLoader;
+
+ public static void relaunch(ArgsWrapper wrap)
+ {
+ INSTANCE = new FMLEmbeddingRelauncher();
+ INSTANCE.relaunchClient(wrap);
+ }
+
+ private FMLEmbeddingRelauncher()
+ {
+ URLClassLoader ucl = (URLClassLoader)getClass().getClassLoader();
+
+ clientLoader = new RelaunchClassLoader(ucl.getURLs());
+ serverLoader = new RelaunchClassLoader(ucl.getURLs());
+ }
+
+ private void relaunchClient(ArgsWrapper wrap)
+ {
+ try
+ {
+ Class> original = Class.forName("net.minecraft.client.Minecraft", false, getClass().getClassLoader());
+ Field origDir = original.getDeclaredField("field_6275_Z");
+ origDir.setAccessible(true);
+ Class client = Class.forName("net.minecraft.client.Minecraft", false, clientLoader);
+ Field homeDir = client.getDeclaredField("field_6275_Z");
+ homeDir.setAccessible(true);
+ homeDir.set(null, origDir.get(null));
+ client.getMethod("fmlReentry", ArgsWrapper.class).invoke(null, wrap);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java b/fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java
new file mode 100644
index 0000000000..5a4e720349
--- /dev/null
+++ b/fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java
@@ -0,0 +1,31 @@
+package cpw.mods.fml.relauncher;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Arrays;
+
+public class RelaunchClassLoader extends URLClassLoader
+{
+ public RelaunchClassLoader(URL[] sources)
+ {
+ super(sources);
+ System.out.println(Arrays.toString(sources));
+ }
+
+ @Override
+ public Class> loadClass(String name) throws ClassNotFoundException
+ {
+ if (name.startsWith("cpw.mods.fml.relauncher"))
+ {
+ return super.loadClass(name);
+ }
+ try
+ {
+ return findClass(name);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ return super.loadClass(name);
+ }
+ }
+}
diff --git a/fml/eclipse/FML-Client/.classpath b/fml/eclipse/FML-Client/.classpath
index d2da61e18a..d750167506 100644
--- a/fml/eclipse/FML-Client/.classpath
+++ b/fml/eclipse/FML-Client/.classpath
@@ -20,5 +20,6 @@
+
diff --git a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch
index 82f67e0bd1..8083e157aa 100644
--- a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch
+++ b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch
@@ -1,16 +1,18 @@
--- ../src-base/minecraft/net/minecraft/client/Minecraft.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/client/Minecraft.java 0000-00-00 00:00:00.000000000 -0000
-@@ -120,6 +120,9 @@
+@@ -120,6 +120,11 @@
import org.lwjgl.opengl.PixelFormat;
import org.lwjgl.util.glu.GLU;
+import cpw.mods.fml.client.FMLClientHandler;
+import cpw.mods.fml.common.FMLCommonHandler;
++import cpw.mods.fml.relauncher.ArgsWrapper;
++import cpw.mods.fml.relauncher.FMLEmbeddingRelauncher;
+
public abstract class Minecraft implements IPlayerUsage, Runnable
{
public static byte[] field_28006_b = new byte[10485760];
-@@ -301,6 +304,7 @@
+@@ -301,6 +306,7 @@
this.field_6315_n = new RenderEngine(this.field_6298_C, this.field_6304_y);
this.func_6257_q();
this.field_6314_o = new FontRenderer(this.field_6304_y, "/font/default.png", this.field_6315_n, false);
@@ -18,7 +20,7 @@
this.field_40007_r = new FontRenderer(this.field_6304_y, "/font/alternate.png", this.field_6315_n, false);
if (this.field_6304_y.field_44018_Q != null)
-@@ -332,6 +336,9 @@
+@@ -332,6 +338,9 @@
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
@@ -28,9 +30,9 @@
this.func_6250_c("Startup");
this.field_6301_A.func_340_a(this.field_6304_y);
this.field_6315_n.func_1066_a(this.field_9231_Y);
-@@ -1337,11 +1344,13 @@
+@@ -1318,11 +1327,13 @@
- public void func_6246_i() throws IOException
+ public void func_6246_i()
{
+ FMLCommonHandler.instance().rescheduleTicks();
if (this.field_35001_ab > 0)
@@ -42,7 +44,7 @@
Profiler.func_40663_a("stats");
this.field_25001_G.func_27178_d();
Profiler.func_40661_c("gui");
-@@ -1710,6 +1719,7 @@
+@@ -1691,6 +1702,7 @@
}
Profiler.func_40662_b();
@@ -50,7 +52,7 @@
this.field_6287_N = System.currentTimeMillis();
}
-@@ -1854,6 +1864,7 @@
+@@ -1849,6 +1861,7 @@
System.gc();
this.field_6287_N = 0L;
@@ -58,14 +60,15 @@
}
public void func_6268_a(String p_6268_1_, File p_6268_2_)
-@@ -1944,6 +1955,10 @@
+@@ -1940,6 +1953,11 @@
public static void main(String[] p_main_0_)
{
-+ FMLClientHandler.instance().preGameLoad(p_main_0_);
++ FMLEmbeddingRelauncher.relaunch(new ArgsWrapper(p_main_0_));
+ }
-+ public static void fmlReentry(String[] p_main_0_)
++ public static void fmlReentry(ArgsWrapper wrapper)
+ {
++ String[] p_main_0_ = wrapper.args;
HashMap var1 = new HashMap();
boolean var2 = false;
boolean var3 = true;
diff --git a/fml/patches/minecraft/net/minecraft/src/GuiMainMenu.java.patch b/fml/patches/minecraft/net/minecraft/src/GuiMainMenu.java.patch
index d0d7e937ec..f962ba9b45 100644
--- a/fml/patches/minecraft/net/minecraft/src/GuiMainMenu.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/GuiMainMenu.java.patch
@@ -39,7 +39,7 @@
+ }
if (p_572_1_.field_938_f == 11)
{
- this.field_945_b.func_56442_a("Demo_World", DemoWorldServer.field_56874_a);
+ this.field_945_b.func_58039_a("Demo_World", "Demo_World", DemoWorldServer.field_56874_a);
@@ -399,7 +409,11 @@
var9 = var9 + " Demo";
}
diff --git a/fml/patches/minecraft/net/minecraft/src/NetClientHandler.java.patch b/fml/patches/minecraft/net/minecraft/src/NetClientHandler.java.patch
index fc19b951eb..b4c7180628 100644
--- a/fml/patches/minecraft/net/minecraft/src/NetClientHandler.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/NetClientHandler.java.patch
@@ -1,6 +1,6 @@
--- ../src-base/minecraft/net/minecraft/src/NetClientHandler.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/NetClientHandler.java 0000-00-00 00:00:00.000000000 -0000
-@@ -22,6 +22,8 @@
+@@ -20,6 +20,8 @@
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
@@ -9,7 +9,7 @@
public class NetClientHandler extends NetHandler
{
private boolean field_55324_f = false;
-@@ -1157,4 +1159,13 @@
+@@ -1165,4 +1167,13 @@
{
return this.field_1213_d;
}
diff --git a/fml/patches/minecraft/net/minecraft/src/StatFileWriter.java.patch b/fml/patches/minecraft/net/minecraft/src/StatFileWriter.java.patch
new file mode 100644
index 0000000000..f88f0d3325
--- /dev/null
+++ b/fml/patches/minecraft/net/minecraft/src/StatFileWriter.java.patch
@@ -0,0 +1,34 @@
+--- ../src-base/minecraft/net/minecraft/src/StatFileWriter.java 0000-00-00 00:00:00.000000000 -0000
++++ ../src-work/minecraft/net/minecraft/src/StatFileWriter.java 0000-00-00 00:00:00.000000000 -0000
+@@ -124,17 +124,17 @@
+ {
+ String var2 = "local";
+ StringBuilder var3 = new StringBuilder();
+- JsonRootNode var4 = (new JdomParser()).func_27367_a(p_27177_0_);
+- List var5 = var4.func_27217_b(new Object[] {"stats-change"});
++ JsonRootNode var4 = (new JdomParser()).parse(p_27177_0_);
++ List var5 = var4.getArrayNode(new Object[] {"stats-change"});
+ Iterator var6 = var5.iterator();
+
+ while (var6.hasNext())
+ {
+ JsonNode var7 = (JsonNode)var6.next();
+- Map var8 = var7.func_27214_c();
++ Map var8 = var7.getFields();
+ Entry var9 = (Entry)var8.entrySet().iterator().next();
+- int var10 = Integer.parseInt(((JsonStringNode)var9.getKey()).func_27216_b());
+- int var11 = Integer.parseInt(((JsonNode)var9.getValue()).func_27216_b());
++ int var10 = Integer.parseInt(((JsonStringNode)var9.getKey()).getText());
++ int var11 = Integer.parseInt(((JsonNode)var9.getValue()).getText());
+ StatBase var12 = StatList.func_27361_a(var10);
+
+ if (var12 == null)
+@@ -152,7 +152,7 @@
+ MD5String var14 = new MD5String(var2);
+ String var15 = var14.func_27369_a(var3.toString());
+
+- if (!var15.equals(var4.func_27213_a(new Object[] {"checksum"})))
++ if (!var15.equals(var4.getNode(new Object[] {"checksum"})))
+ {
+ System.out.println("CHECKSUM MISMATCH");
+ return null;
diff --git a/fml/patches/minecraft/net/minecraft/src/World.java.patch b/fml/patches/minecraft/net/minecraft/src/World.java.patch
index 75b95e4f65..f3d419da63 100644
--- a/fml/patches/minecraft/net/minecraft/src/World.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/World.java.patch
@@ -1,6 +1,6 @@
--- ../src-base/minecraft/net/minecraft/src/World.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/World.java 0000-00-00 00:00:00.000000000 -0000
-@@ -3320,7 +3320,7 @@
+@@ -3322,7 +3322,7 @@
public double func_46068_G()
{
diff --git a/fml/patches/minecraft_server/net/minecraft/src/ChunkProviderServer.java.patch b/fml/patches/minecraft_server/net/minecraft/src/ChunkProviderServer.java.patch
index d8698962d9..76fda3edb2 100644
--- a/fml/patches/minecraft_server/net/minecraft/src/ChunkProviderServer.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/src/ChunkProviderServer.java.patch
@@ -9,7 +9,7 @@
public class ChunkProviderServer implements IChunkProvider
{
private Set field_725_a = new HashSet();
-@@ -173,6 +175,7 @@
+@@ -177,6 +179,7 @@
if (this.field_730_c != null)
{
this.field_730_c.func_4055_a(p_4055_1_, p_4055_2_, p_4055_3_);
diff --git a/fml/patches/minecraft_server/net/minecraft/src/Entity.java.patch b/fml/patches/minecraft_server/net/minecraft/src/Entity.java.patch
index 127adfd032..5beea42bde 100644
--- a/fml/patches/minecraft_server/net/minecraft/src/Entity.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/src/Entity.java.patch
@@ -1,6 +1,6 @@
--- ../src-base/minecraft_server/net/minecraft/src/Entity.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft_server/net/minecraft/src/Entity.java 0000-00-00 00:00:00.000000000 -0000
-@@ -1525,4 +1525,8 @@
+@@ -1539,4 +1539,8 @@
{
return String.format("%s[\'%s\'/%d, l=\'%s\', x=%.2f, y=%.2f, z=%.2f]", new Object[] {this.getClass().getSimpleName(), this.func_35150_Y(), Integer.valueOf(this.field_331_c), this.field_9093_l == null ? "~NULL~" : this.field_9093_l.func_22081_n().func_55310_h(), Double.valueOf(this.field_322_l), Double.valueOf(this.field_321_m), Double.valueOf(this.field_320_n)});
}
diff --git a/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch b/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch
index df87718152..ee18da9b19 100644
--- a/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch
@@ -9,7 +9,7 @@
import net.minecraft.server.MinecraftServer;
public class NetServerHandler extends NetHandler
-@@ -1011,4 +1013,9 @@
+@@ -1014,4 +1016,9 @@
}
}
}
diff --git a/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch b/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch
index 8bc2914d35..b8a3b0ac3f 100644
--- a/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch
@@ -9,7 +9,7 @@
import net.minecraft.server.MinecraftServer;
public abstract class ServerConfigurationManager
-@@ -359,6 +361,8 @@
+@@ -355,6 +357,8 @@
p_28168_1_.field_425_ad.func_35694_a(var5);
this.func_28170_a(p_28168_1_, var5);
this.func_30008_g(p_28168_1_);
From 60b50bb7f2a5d5ea40f7f86d29d7dab18d4701e9 Mon Sep 17 00:00:00 2001
From: Christian
Date: Tue, 3 Jul 2012 08:14:35 -0400
Subject: [PATCH 04/50] Tweak build xml for more cleanliness
---
fml/build.xml | 39 +++++++++++++++++++++++----------------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/fml/build.xml b/fml/build.xml
index d4351eaf7a..587bb5a053 100644
--- a/fml/build.xml
+++ b/fml/build.xml
@@ -55,6 +55,8 @@
+
+
@@ -84,6 +86,7 @@
+
@@ -95,7 +98,7 @@
-
+
@@ -126,7 +129,6 @@
-
@@ -241,20 +243,21 @@
- Moving old patched sources at ${mcp.home}/src-work out of the way
+
+ 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
@@ -265,21 +268,25 @@
-
-
+
+
-
+
+
+
+
+
-
+
From e8b09f46929dc37dbf5158060e4baeb33607ca49 Mon Sep 17 00:00:00 2001
From: Christian
Date: Thu, 5 Jul 2012 15:23:37 -0400
Subject: [PATCH 05/50] Got the relauncher downloading and injecting library
files
---
fml/build.xml | 9 +-
.../cpw/mods/fml/client/FMLClientHandler.java | 2 +-
fml/client/net/minecraft/src/ModLoader.java | 6 +-
.../cpw/mods/fml/common/ReflectionHelper.java | 94 +++++----
.../relauncher/FMLEmbeddingRelauncher.java | 36 ++--
.../mods/fml/relauncher/ReflectionHelper.java | 183 ++++++++++++++++++
.../fml/relauncher/RelaunchClassLoader.java | 7 +
.../relauncher/RelaunchLibraryManager.java | 137 +++++++++++++
fml/eclipse/Clean-Client/.classpath | 1 +
fml/eclipse/FML-Client/.classpath | 2 +-
10 files changed, 416 insertions(+), 61 deletions(-)
create mode 100644 fml/common/cpw/mods/fml/relauncher/ReflectionHelper.java
create mode 100644 fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java
diff --git a/fml/build.xml b/fml/build.xml
index 587bb5a053..eff40159e7 100644
--- a/fml/build.xml
+++ b/fml/build.xml
@@ -266,14 +266,17 @@
Moving old patched sources at ${mcp.home}/src-work out of the way
-
+
-
+
+
+
+
-
+
diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
index 4ce22755bb..eea61f0d4c 100644
--- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java
+++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
@@ -88,13 +88,13 @@ import cpw.mods.fml.common.Loader;
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.Side;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.modloader.ModLoaderHelper;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
import cpw.mods.fml.common.modloader.ModProperty;
import cpw.mods.fml.common.registry.FMLRegistry;
+import cpw.mods.fml.common.ReflectionHelper;
/**
diff --git a/fml/client/net/minecraft/src/ModLoader.java b/fml/client/net/minecraft/src/ModLoader.java
index 91be235c7d..502caebd03 100644
--- a/fml/client/net/minecraft/src/ModLoader.java
+++ b/fml/client/net/minecraft/src/ModLoader.java
@@ -26,10 +26,10 @@ import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.SpriteHelper;
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.ReflectionHelper;
public class ModLoader
{
@@ -733,7 +733,7 @@ public class ModLoader
*/
public static void setPrivateValue(Class super T> instanceclass, T instance, int fieldindex, E value)
{
- ReflectionHelper.setPrivateValue(instanceclass, instance, fieldindex, value);
+ ReflectionHelper.setPrivateValue(instanceclass, instance, value, fieldindex);
}
/**
@@ -747,7 +747,7 @@ public class ModLoader
*/
public static void setPrivateValue(Class super T> instanceclass, T instance, String field, E value)
{
- ReflectionHelper.setPrivateValue(instanceclass, instance, field, value);
+ ReflectionHelper.setPrivateValue(instanceclass, instance, value, field);
}
/**
diff --git a/fml/common/cpw/mods/fml/common/ReflectionHelper.java b/fml/common/cpw/mods/fml/common/ReflectionHelper.java
index 30bc523448..251da11835 100644
--- a/fml/common/cpw/mods/fml/common/ReflectionHelper.java
+++ b/fml/common/cpw/mods/fml/common/ReflectionHelper.java
@@ -14,9 +14,15 @@ package cpw.mods.fml.common;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.logging.Level;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.relauncher.ReflectionHelper.UnableToAccessFieldException;
+import cpw.mods.fml.relauncher.ReflectionHelper.UnableToFindFieldException;
/**
* Some reflection helper code.
- *
+ *
* @author cpw
*
*/
@@ -29,73 +35,79 @@ public class ReflectionHelper
{
try
{
- Field f = classToAccess.getDeclaredFields()[fieldIndex];
- f.setAccessible(true);
- return (T) f.get(instance);
+ return cpw.mods.fml.relauncher.ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
}
- catch (Exception e)
+ catch (UnableToAccessFieldException 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);
+ FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName()), e);
+ throw e;
}
}
@SuppressWarnings("unchecked")
- public static T getPrivateValue(Class super E > classToAccess, E instance, String fieldName)
+ public static T getPrivateValue(Class super E > classToAccess, E instance, String... fieldNames)
{
try
{
- Field f = classToAccess.getDeclaredField(fieldName);
- f.setAccessible(true);
- return (T) f.get(instance);
+ return cpw.mods.fml.relauncher.ReflectionHelper.getPrivateValue(classToAccess, instance, fieldNames);
}
- catch (Exception e)
+ catch (UnableToFindFieldException 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);
+ FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
+ throw e;
+ }
+ catch (UnableToAccessFieldException e)
+ {
+ FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("Unable to access any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
+ throw e;
}
}
+ @Deprecated
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);
- }
+ setPrivateValue(classToAccess, instance, value, fieldIndex);
}
- public static void setPrivateValue(Class super T > classToAccess, T instance, String fieldName, E value)
+ public static void setPrivateValue(Class super T > classToAccess, T instance, E value, int fieldIndex)
{
try
{
- Field f = classToAccess.getDeclaredField(fieldName);
- f.setAccessible(true);
- f.set(instance, value);
+ cpw.mods.fml.relauncher.ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
}
- catch (Exception e)
+ catch (UnableToAccessFieldException 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);
+ FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("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
+ {
+ cpw.mods.fml.relauncher.ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldNames);
+ }
+ catch (UnableToFindFieldException e)
+ {
+ FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
+ throw e;
+ }
+ catch (UnableToAccessFieldException e)
+ {
+ FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("Unable to set any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
+ throw e;
}
}
/**
- *
+ *
*/
public static void detectObfuscation(Class> clazz)
{
diff --git a/fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java b/fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java
index d924f816f0..f905984268 100644
--- a/fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java
+++ b/fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java
@@ -1,17 +1,18 @@
package cpw.mods.fml.relauncher;
+import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.URLClassLoader;
+import java.util.Arrays;
-import net.minecraft.client.Minecraft;
import net.minecraft.src.WorldSettings;
public class FMLEmbeddingRelauncher
{
private static FMLEmbeddingRelauncher INSTANCE;
private RelaunchClassLoader clientLoader;
- private RelaunchClassLoader serverLoader;
public static void relaunch(ArgsWrapper wrap)
{
@@ -24,25 +25,36 @@ public class FMLEmbeddingRelauncher
URLClassLoader ucl = (URLClassLoader)getClass().getClassLoader();
clientLoader = new RelaunchClassLoader(ucl.getURLs());
- serverLoader = new RelaunchClassLoader(ucl.getURLs());
}
private void relaunchClient(ArgsWrapper wrap)
{
+ Class super Object> mcMaster = ReflectionHelper.getClass(getClass().getClassLoader(), "net.minecraft.client.Minecraft");
+ // We force minecraft to setup it's homedir very early on so we can inject stuff into it
+ Method setupHome = ReflectionHelper.findMethod(mcMaster, null, new String[] { "func_6240_b", "getMinecraftDir", "b"} );
try
{
- Class> original = Class.forName("net.minecraft.client.Minecraft", false, getClass().getClassLoader());
- Field origDir = original.getDeclaredField("field_6275_Z");
- origDir.setAccessible(true);
- Class client = Class.forName("net.minecraft.client.Minecraft", false, clientLoader);
- Field homeDir = client.getDeclaredField("field_6275_Z");
- homeDir.setAccessible(true);
- homeDir.set(null, origDir.get(null));
- client.getMethod("fmlReentry", ArgsWrapper.class).invoke(null, wrap);
+ setupHome.invoke(null);
}
catch (Exception e)
{
- e.printStackTrace();
+ // Hmmm
+ }
+ File minecraftHome = ReflectionHelper.getPrivateValue(mcMaster, null, "field_6275_Z", "ap", "minecraftDir");
+
+ RelaunchLibraryManager.handleLaunch(minecraftHome, clientLoader);
+
+ // Now we re-inject the home into the "new" minecraft under our control
+ Class super Object> client = ReflectionHelper.getClass(clientLoader, "net.minecraft.client.Minecraft");
+ ReflectionHelper.setPrivateValue(client, null, minecraftHome, "field_6275_Z", "ap", "minecraftDir");
+
+ try
+ {
+ ReflectionHelper.findMethod(client, null, new String[] { "fmlReentry" }, ArgsWrapper.class).invoke(null, wrap);
+ }
+ catch (Exception e)
+ {
+ // Hmmm
}
}
}
diff --git a/fml/common/cpw/mods/fml/relauncher/ReflectionHelper.java b/fml/common/cpw/mods/fml/relauncher/ReflectionHelper.java
new file mode 100644
index 0000000000..f441197feb
--- /dev/null
+++ b/fml/common/cpw/mods/fml/relauncher/ReflectionHelper.java
@@ -0,0 +1,183 @@
+/*
+ * 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.relauncher;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+/**
+ * Some reflection helper code.
+ *
+ * @author cpw
+ *
+ */
+public class ReflectionHelper
+{
+ public static class UnableToFindMethodException extends RuntimeException
+ {
+ private String[] methodNames;
+
+ public UnableToFindMethodException(String[] methodNames, Exception failed)
+ {
+ super(failed);
+ this.methodNames = methodNames;
+ }
+
+ }
+
+ public static class UnableToFindClassException extends RuntimeException
+ {
+ private String[] classNames;
+
+ public UnableToFindClassException(String[] classNames, Exception err)
+ {
+ super(err);
+ this.classNames = classNames;
+ }
+
+ }
+
+ public static class UnableToAccessFieldException extends RuntimeException
+ {
+
+ private String[] fieldNameList;
+
+ public UnableToAccessFieldException(String[] fieldNames, Exception e)
+ {
+ super(e);
+ this.fieldNameList = fieldNames;
+ }
+ }
+
+ public static class UnableToFindFieldException extends RuntimeException
+ {
+ private String[] fieldNameList;
+ public UnableToFindFieldException(String[] fieldNameList, Exception e)
+ {
+ super(e);
+ this.fieldNameList = fieldNameList;
+ }
+ }
+
+ public static Field findField(Class> clazz, String... fieldNames)
+ {
+ Exception failed = null;
+ for (String fieldName : fieldNames)
+ {
+ try
+ {
+ Field f = clazz.getDeclaredField(fieldName);
+ f.setAccessible(true);
+ return f;
+ }
+ catch (Exception e)
+ {
+ failed = e;
+ }
+ }
+ throw new UnableToFindFieldException(fieldNames, failed);
+ }
+
+ @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)
+ {
+ throw new UnableToAccessFieldException(new String[0], e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static T getPrivateValue(Class super E > classToAccess, E instance, String... fieldNames)
+ {
+ try
+ {
+ return (T) findField(classToAccess, fieldNames).get(instance);
+ }
+ catch (Exception e)
+ {
+ throw new UnableToAccessFieldException(fieldNames, e);
+ }
+ }
+
+ public static void setPrivateValue(Class super T > classToAccess, T instance, E value, int fieldIndex)
+ {
+ try
+ {
+ Field f = classToAccess.getDeclaredFields()[fieldIndex];
+ f.setAccessible(true);
+ f.set(instance, value);
+ }
+ catch (Exception e)
+ {
+ throw new UnableToAccessFieldException(new String[0] , e);
+ }
+ }
+
+ public static void setPrivateValue(Class super T > classToAccess, T instance, E value, String... fieldNames)
+ {
+ try
+ {
+ findField(classToAccess, fieldNames).set(instance, value);
+ }
+ catch (Exception e)
+ {
+ throw new UnableToAccessFieldException(fieldNames, e);
+ }
+ }
+
+ public static Class super Object> getClass(ClassLoader loader, String... classNames)
+ {
+ Exception err = null;
+ for (String className : classNames)
+ {
+ try
+ {
+ return (Class super Object>) Class.forName(className, false, loader);
+ }
+ catch (Exception e)
+ {
+ err = e;
+ }
+ }
+
+ throw new UnableToFindClassException(classNames, err);
+ }
+
+
+ public static Method findMethod(Class super E> clazz, E instance, String[] methodNames, Class>... methodTypes)
+ {
+ Exception failed = null;
+ for (String methodName : methodNames)
+ {
+ try
+ {
+ Method m = clazz.getDeclaredMethod(methodName, methodTypes);
+ m.setAccessible(true);
+ return m;
+ }
+ catch (Exception e)
+ {
+ failed = e;
+ }
+ }
+ throw new UnableToFindMethodException(methodNames, failed);
+ }
+}
diff --git a/fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java b/fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java
index 5a4e720349..78546e91cc 100644
--- a/fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java
+++ b/fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java
@@ -28,4 +28,11 @@ public class RelaunchClassLoader extends URLClassLoader
return super.loadClass(name);
}
}
+
+ @Override
+ protected void addURL(URL url)
+ {
+ super.addURL(url);
+ System.out.println(Arrays.toString(getURLs()));
+ }
}
diff --git a/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java b/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java
new file mode 100644
index 0000000000..383e3682c9
--- /dev/null
+++ b/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java
@@ -0,0 +1,137 @@
+package cpw.mods.fml.relauncher;
+
+import java.awt.HeadlessException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.FileChannel;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.FileChannel.MapMode;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import javax.swing.JOptionPane;
+
+public class RelaunchLibraryManager
+{
+ private static String[] libraries = { "argo-2.25.jar","guava-12.0.jar","asm-all-4.0.jar" };
+ private static String[] checksums = { "bb672829fde76cb163004752b86b0484bd0a7f4b", "5bc66dd95b79db1e437eb08adba124a3e4088dc0", "98308890597acb64047f7e896638e0d98753ae82" };
+ private static final String HEXES = "0123456789abcdef";
+ public static void handleLaunch(File mcDir, RelaunchClassLoader actualClassLoader)
+ {
+ File libDir = new File(mcDir,"lib");
+ try
+ {
+ libDir = libDir.getCanonicalFile();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(String.format("Unable to canonicalize the lib dir at %s", mcDir.getName()),e);
+ }
+ if (!libDir.exists())
+ {
+ libDir.mkdir();
+ }
+ else if (libDir.exists() && !libDir.isDirectory())
+ {
+ throw new RuntimeException(String.format("Found a lib file in %s that's not a directory", mcDir.getName()));
+ }
+
+ for (int i=0; i> 4))
+ .append(HEXES.charAt((b & 0x0F)));
+ }
+ return hex.toString();
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ }
+ private static void downloadFile(File libFile)
+ {
+ // try
+// {
+// JOptionPane.showMessageDialog(null, String.format("Downloading required FML library %s from github.com",libName));
+// }
+// catch (HeadlessException he)
+// {
+// // Ignore
+// }
+ try
+ {
+ URL libDownload = new URL(String.format("http://cloud.github.com/downloads/cpw/FML/%s",libFile.getName()));
+ System.out.printf("Downloading %s..", libDownload.toString());
+ InputStream urlConn = libDownload.openStream();
+ ReadableByteChannel urlChannel = Channels.newChannel(urlConn);
+ FileOutputStream libFileStream = new FileOutputStream(libFile);
+ FileChannel libFileChannel = libFileStream.getChannel();
+ libFileChannel.transferFrom(urlChannel, 0, 1<<24);
+ libFileChannel.close();
+ libFileStream.close();
+ urlChannel.close();
+ urlConn.close();
+ System.out.println("download successful");
+ }
+ catch (Exception e)
+ {
+
+ }
+ }
+}
diff --git a/fml/eclipse/Clean-Client/.classpath b/fml/eclipse/Clean-Client/.classpath
index 6bf817e741..2660e24ec7 100644
--- a/fml/eclipse/Clean-Client/.classpath
+++ b/fml/eclipse/Clean-Client/.classpath
@@ -18,5 +18,6 @@
+
diff --git a/fml/eclipse/FML-Client/.classpath b/fml/eclipse/FML-Client/.classpath
index d750167506..ea960b8032 100644
--- a/fml/eclipse/FML-Client/.classpath
+++ b/fml/eclipse/FML-Client/.classpath
@@ -1,7 +1,7 @@
-
+
From 58576c2a1931e3b7bd875ac562a8cb03da69a37b Mon Sep 17 00:00:00 2001
From: Christian
Date: Thu, 5 Jul 2012 15:35:38 -0400
Subject: [PATCH 06/50] UnexpectedThrowable is now the much more awesome
CrashReport!
---
.../cpw/mods/fml/client/FMLClientHandler.java | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
index 5dcbac16cc..ba83b25981 100644
--- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java
+++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
@@ -48,6 +48,7 @@ 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;
@@ -85,6 +86,7 @@ import cpw.mods.fml.common.FMLModLoaderContainer;
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.ModContainer;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.ProxyInjector;
@@ -206,7 +208,7 @@ public class FMLClientHandler implements IFMLSidedHandler
@Override
public void haltGame(String message, Throwable t)
{
- client.func_28003_b(new UnexpectedThrowable(message, t));
+ client.func_55071_b(new CrashReport(message, t));
}
/**
* Called a bit later on during initialization to finish loading mods
@@ -947,15 +949,6 @@ public class FMLClientHandler implements IFMLSidedHandler
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);
From 4ab2a3cb6b78f7bc031c7a3c4e0824b1b46a23d8 Mon Sep 17 00:00:00 2001
From: Christian
Date: Thu, 5 Jul 2012 15:36:31 -0400
Subject: [PATCH 07/50] And we have a brand, "fml". We're definitely modded :)
---
.../minecraft/client/ClientBrandRetriever.java.patch | 10 ++++++++++
1 file changed, 10 insertions(+)
create mode 100644 fml/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch
diff --git a/fml/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch b/fml/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch
new file mode 100644
index 0000000000..e420664a96
--- /dev/null
+++ b/fml/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch
@@ -0,0 +1,10 @@
+--- ../src-base/minecraft/net/minecraft/client/ClientBrandRetriever.java 0000-00-00 00:00:00.000000000 -0000
++++ ../src-work/minecraft/net/minecraft/client/ClientBrandRetriever.java 0000-00-00 00:00:00.000000000 -0000
+@@ -4,6 +4,6 @@
+ {
+ public static String func_56462_getClientModName()
+ {
+- return "vanilla";
++ return "fml";
+ }
+ }
From 275b78957a733d72d47d8b13544231b374dd54fd Mon Sep 17 00:00:00 2001
From: Christian
Date: Thu, 5 Jul 2012 15:38:37 -0400
Subject: [PATCH 08/50] Update git ignore to ignore a fernflowerzip that's
lying around
---
fml/.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/fml/.gitignore b/fml/.gitignore
index f5d15818b6..c5a46eb4c4 100644
--- a/fml/.gitignore
+++ b/fml/.gitignore
@@ -8,3 +8,4 @@
/eclipse/.metadata/
/target
fmlbranding.properties
+/fernflower.zip
From b9466b8ee573c7d2d0dde31720960d63ead0a05f Mon Sep 17 00:00:00 2001
From: Christian
Date: Thu, 5 Jul 2012 18:13:47 -0400
Subject: [PATCH 09/50] Lots of client patch fixup
---
.../cpw/mods/fml/client/FMLClientHandler.java | 8 +-
fml/client/net/minecraft/src/BaseMod.java | 2 +-
.../cpw/mods/fml/common/IDispenseHandler.java | 2 +-
.../.settings/org.eclipse.jdt.core.prefs | 266 +++++++++++++++++-
fml/eclipse/FML-Client/.classpath | 4 +-
fml/eclipse/FML-Client/.project | 5 +
.../net/minecraft/client/Minecraft.java.patch | 20 +-
.../minecraft/src/BlockDispenser.java.patch | 11 +
.../minecraft/src/GuiCreateWorld.java.patch | 14 +
.../minecraft/src/NetClientHandler.java.patch | 18 +-
.../minecraft/src/PanelCrashReport.java.patch | 16 +-
.../net/minecraft/src/RenderBlocks.java.patch | 149 ++++++++--
.../minecraft/src/TexturePackList.java.patch | 8 +
.../src/TileEntityFurnace.java.patch | 18 ++
14 files changed, 504 insertions(+), 37 deletions(-)
create mode 100644 fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch
diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
index ba83b25981..fcfa7c7742 100644
--- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java
+++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
@@ -393,16 +393,16 @@ public class FMLClientHandler implements IFMLSidedHandler
* @param x
* @param y
* @param z
- * @param xVelocity
- * @param zVelocity
+ * @param p_56784_7_
+ * @param p_56784_8_
* @param item
* @return
*/
- public boolean tryDispensingEntity(World world, double x, double y, double z, byte xVelocity, byte zVelocity, ItemStack item)
+ public boolean tryDispensingEntity(World world, double x, double y, double z, int p_56784_7_, int p_56784_8_, ItemStack item)
{
for (ModContainer mod : Loader.getModList())
{
- if (mod.wantsToDispense() && mod.getDispenseHandler().dispense(x, y, z, xVelocity, zVelocity, world, item))
+ if (mod.wantsToDispense() && mod.getDispenseHandler().dispense(x, y, z, p_56784_7_, p_56784_8_, world, item))
{
return true;
}
diff --git a/fml/client/net/minecraft/src/BaseMod.java b/fml/client/net/minecraft/src/BaseMod.java
index 97ca8ebaa8..5affd53757 100644
--- a/fml/client/net/minecraft/src/BaseMod.java
+++ b/fml/client/net/minecraft/src/BaseMod.java
@@ -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]);
}
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/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs b/fml/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs
index 38317eb9bb..25bd856bb6 100644
--- a/fml/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs
+++ b/fml/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs
@@ -22,8 +22,45 @@ org.eclipse.jdt.core.compiler.problem.unusedImport=ignore
org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore
org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=next_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line
@@ -32,12 +69,237 @@ org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
-org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=true
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=8
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert
-org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=true
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=true
org.eclipse.jdt.core.formatter.lineSplit=160
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false
org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
org.eclipse.jdt.core.timeoutForParameterNameFromAttachedJavadoc=50
diff --git a/fml/eclipse/FML-Client/.classpath b/fml/eclipse/FML-Client/.classpath
index ea960b8032..ae16cdb736 100644
--- a/fml/eclipse/FML-Client/.classpath
+++ b/fml/eclipse/FML-Client/.classpath
@@ -20,6 +20,8 @@
-
+
+
+
diff --git a/fml/eclipse/FML-Client/.project b/fml/eclipse/FML-Client/.project
index 533d5d7a09..5f864284d6 100644
--- a/fml/eclipse/FML-Client/.project
+++ b/fml/eclipse/FML-Client/.project
@@ -30,6 +30,11 @@
2MCP_LOC/jars
+
+ lib
+ 2
+ MCP_LOC/lib
+
src2
diff --git a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch
index 8083e157aa..87179662c2 100644
--- a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch
+++ b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch
@@ -30,7 +30,19 @@
this.func_6250_c("Startup");
this.field_6301_A.func_340_a(this.field_6304_y);
this.field_6315_n.func_1066_a(this.field_9231_Y);
-@@ -1318,11 +1327,13 @@
+@@ -729,9 +738,11 @@
+
+ if (!this.field_6307_v)
+ {
++ FMLClientHandler.instance().onRenderTickStart(this.field_9237_P.field_1378_c);
+ Profiler.func_40661_c("gameRenderer");
+ this.field_9243_r.func_4136_b(this.field_9237_P.field_1378_c);
+ Profiler.func_40662_b();
++ FMLClientHandler.instance().onRenderTickEnd(this.field_9237_P.field_1378_c);
+ }
+
+ GL11.glFlush();
+@@ -1318,11 +1329,13 @@
public void func_6246_i()
{
@@ -44,7 +56,7 @@
Profiler.func_40663_a("stats");
this.field_25001_G.func_27178_d();
Profiler.func_40661_c("gui");
-@@ -1691,6 +1702,7 @@
+@@ -1691,6 +1704,7 @@
}
Profiler.func_40662_b();
@@ -52,7 +64,7 @@
this.field_6287_N = System.currentTimeMillis();
}
-@@ -1849,6 +1861,7 @@
+@@ -1849,6 +1863,7 @@
System.gc();
this.field_6287_N = 0L;
@@ -60,7 +72,7 @@
}
public void func_6268_a(String p_6268_1_, File p_6268_2_)
-@@ -1940,6 +1953,11 @@
+@@ -1940,6 +1955,11 @@
public static void main(String[] p_main_0_)
{
diff --git a/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch b/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch
index cd78099b9c..7743153560 100644
--- a/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch
@@ -9,3 +9,14 @@
public class BlockDispenser extends BlockContainer
{
private Random field_28035_a = new Random();
+@@ -276,6 +278,10 @@
+ float var15 = 1.1F;
+ byte var16 = 6;
+
++ if (FMLClientHandler.instance().tryDispensingEntity(p_56784_1_, p_56784_9_, p_56784_11_, p_56784_13_, p_56784_7_, p_56784_8_, p_56784_2_))
++ {
++ ;
++ }
+ if (p_56784_2_.field_1617_c == Item.field_226_j.field_291_aS)
+ {
+ EntityArrow var28 = new EntityArrow(p_56784_1_, p_56784_9_, p_56784_11_, p_56784_13_);
diff --git a/fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch b/fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch
new file mode 100644
index 0000000000..c72917d48e
--- /dev/null
+++ b/fml/patches/minecraft/net/minecraft/src/GuiCreateWorld.java.patch
@@ -0,0 +1,14 @@
+--- ../src-base/minecraft/net/minecraft/src/GuiCreateWorld.java 0000-00-00 00:00:00.000000000 -0000
++++ ../src-work/minecraft/net/minecraft/src/GuiCreateWorld.java 0000-00-00 00:00:00.000000000 -0000
+@@ -197,9 +197,11 @@
+ }
+ }
+
++ WorldType.field_48637_a[this.field_46030_z].onGUICreateWorldPress();
+ EnumGameType var9 = EnumGameType.func_57535_a(this.field_35364_f);
+ WorldSettings var6 = new WorldSettings(var2, var9, this.field_35365_g, this.field_40232_h, WorldType.field_48637_a[this.field_46030_z]);
+
++
+ if (this.field_55144_j && !this.field_40232_h)
+ {
+ var6.func_55250_a();
diff --git a/fml/patches/minecraft/net/minecraft/src/NetClientHandler.java.patch b/fml/patches/minecraft/net/minecraft/src/NetClientHandler.java.patch
index b4c7180628..703c43b73c 100644
--- a/fml/patches/minecraft/net/minecraft/src/NetClientHandler.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/NetClientHandler.java.patch
@@ -9,7 +9,23 @@
public class NetClientHandler extends NetHandler
{
private boolean field_55324_f = false;
-@@ -1165,4 +1167,13 @@
+@@ -132,6 +134,7 @@
+ this.field_35785_d = p_4115_1_.field_35251_h;
+ this.field_1212_e.field_56453_c.func_57521_a(p_4115_1_.field_56535_d);
+ this.func_847_a(new Packet204ClientInfo(this.field_1212_e.field_6304_y.field_44018_Q, this.field_1212_e.field_6304_y.field_1580_e, this.field_1212_e.field_6304_y.field_55382_n, this.field_1212_e.field_6304_y.field_55383_o, this.field_1212_e.field_6304_y.field_1561_w));
++ FMLClientHandler.instance().handleServerLogin(p_4115_1_, this, field_1213_d);
+ }
+
+ public void func_832_a(Packet21PickupSpawn p_832_1_)
+@@ -593,6 +596,7 @@
+
+ public void func_4113_a(Packet3Chat p_4113_1_)
+ {
++ FMLClientHandler.instance().handleChatPacket(p_4113_1_);
+ this.field_1212_e.field_6308_u.func_55092_b().func_55106_a(p_4113_1_.field_517_a);
+ }
+
+@@ -1165,4 +1169,13 @@
{
return this.field_1213_d;
}
diff --git a/fml/patches/minecraft/net/minecraft/src/PanelCrashReport.java.patch b/fml/patches/minecraft/net/minecraft/src/PanelCrashReport.java.patch
index 82d58f14a1..660f27387b 100644
--- a/fml/patches/minecraft/net/minecraft/src/PanelCrashReport.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/PanelCrashReport.java.patch
@@ -1,15 +1,27 @@
--- ../src-base/minecraft/net/minecraft/src/PanelCrashReport.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/PanelCrashReport.java 0000-00-00 00:00:00.000000000 -0000
-@@ -13,6 +13,8 @@
+@@ -10,13 +10,20 @@
+ import java.io.StringWriter;
+ import java.text.SimpleDateFormat;
+ import java.util.Date;
++import java.util.logging.Level;
++
import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
++import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.Loader;
+
public class PanelCrashReport extends Panel
{
public PanelCrashReport(CrashReport p_i1401_1_)
-@@ -39,7 +41,7 @@
+ {
++ FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, "A critical error has occurred.", p_i1401_1_.func_55363_b());
++ FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, Loader.instance().getCrashInformation());
+ this.setBackground(new Color(3028036));
+ this.setLayout(new BorderLayout());
+ StringWriter var2 = new StringWriter();
+@@ -39,7 +46,7 @@
var5 = var5 + "\n\n";
var5 = var5 + var3;
diff --git a/fml/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch b/fml/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch
index 8a00ced14d..0d5179220b 100644
--- a/fml/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch
@@ -16,7 +16,7 @@
+ public boolean field_1774_c = false;
+ public boolean field_1773_d = false;
public static boolean field_27406_a = true;
-+ public static boolean cfgGrassFix = true;
++ public static boolean cfgGrassFix = true;
public boolean field_31088_b = true;
- private int field_31087_g = 0;
- private int field_31086_h = 0;
@@ -187,7 +187,84 @@
public RenderBlocks(IBlockAccess p_i647_1_)
{
-@@ -169,7 +172,7 @@
+@@ -126,10 +129,74 @@
+ {
+ int var5 = p_1234_1_.func_210_f();
+ p_1234_1_.func_238_a(this.field_1772_a, p_1234_2_, p_1234_3_, p_1234_4_);
+- return var5 == 0 ? this.func_1228_k(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 4 ? this.func_1222_j(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 13 ? this.func_1233_l(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 1 ? this.func_1226_h(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 19 ? this.func_1232_i(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 23 ? this.func_40726_m(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 6 ? this.func_35930_l(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 2 ? this.func_1241_b(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 3 ? this.func_1235_d(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 5 ? this.func_1242_e(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 8 ? this.func_1221_g(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 7 ? this.func_1218_o(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 9 ? this.func_1216_f((BlockRail)p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 10 ? this.func_1214_n(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 27 ? this.func_41088_a((BlockDragonEgg)p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 11 ? this.func_35925_a((BlockFence)p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 12 ? this.func_1229_c(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 29 ? this.func_57334_f(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 30 ? this.func_57336_g(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 14 ? this.func_22331_p(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 15 ? this.func_22332_q(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 16 ? this.func_31074_b(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_, false) : (var5 == 17 ? this.func_31080_c(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_, true) : (var5 == 18 ? this.func_35922_a((BlockPane)p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 20 ? this.func_35929_i(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 21 ? this.func_35923_a((BlockFenceGate)p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 24 ? this.func_40728_a((BlockCauldron)p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 25 ? this.func_40730_a((BlockBrewingStand)p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 26 ? this.func_40729_s(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : (var5 == 28 ? this.func_57333_a((BlockCocoa)p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_) : false)))))))))))))))))))))))))))));
++ switch (var5)
++ {
++ case 0:
++ return this.func_1228_k(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 4:
++ return this.func_1222_j(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 13:
++ return this.func_1233_l(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 1:
++ return this.func_1226_h(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 19:
++ return this.func_1232_i(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 23:
++ return this.func_40726_m(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 6:
++ return this.func_35930_l(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 2:
++ return this.func_1241_b(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 3:
++ return this.func_1235_d(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 5:
++ return this.func_1242_e(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 8:
++ return this.func_1221_g(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 7:
++ return this.func_1218_o(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 9:
++ return this.func_1216_f((BlockRail) p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 10:
++ return this.func_1214_n(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 27:
++ return this.func_41088_a((BlockDragonEgg) p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 11:
++ return this.func_35925_a((BlockFence) p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 12:
++ return this.func_1229_c(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 29:
++ return this.func_57334_f(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 30:
++ return this.func_57336_g(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 14:
++ return this.func_22331_p(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 15:
++ return this.func_22332_q(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 16:
++ return this.func_31074_b(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_, false);
++ case 17:
++ return this.func_31080_c(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_, true);
++ case 18:
++ return this.func_35922_a((BlockPane) p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 20:
++ return this.func_35929_i(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 21:
++ return this.func_35923_a((BlockFenceGate) p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 24:
++ return this.func_40728_a((BlockCauldron) p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 25:
++ return this.func_40730_a((BlockBrewingStand) p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 26:
++ return this.func_40729_s(p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ case 28:
++ return this.func_57333_a((BlockCocoa) p_1234_1_, p_1234_2_, p_1234_3_, p_1234_4_);
++ default:
++ return FMLClientHandler.instance().renderWorldBlock(this, field_1772_a, p_1234_2_, p_1234_3_, p_1234_4_, p_1234_1_, var5);
++ }
+ }
+
+- private boolean func_40729_s(Block p_40729_1_, int p_40729_2_, int p_40729_3_, int p_40729_4_)
++ public boolean func_40729_s(Block p_40729_1_, int p_40729_2_, int p_40729_3_, int p_40729_4_)
+ {
+ int var5 = this.field_1772_a.func_602_e(p_40729_2_, p_40729_3_, p_40729_4_);
+ int var6 = var5 & 3;
+@@ -169,7 +236,7 @@
}
}
@@ -196,7 +273,7 @@
{
Tessellator var5 = Tessellator.field_1512_a;
int var6 = this.field_1772_a.func_602_e(p_22331_2_, p_22331_3_, p_22331_4_);
-@@ -310,7 +313,7 @@
+@@ -310,7 +377,7 @@
return true;
}
@@ -205,7 +282,7 @@
{
p_40730_1_.func_213_a(0.4375F, 0.0F, 0.4375F, 0.5625F, 0.875F, 0.5625F);
this.func_1228_k(p_40730_1_, p_40730_2_, p_40730_3_, p_40730_4_);
-@@ -384,7 +387,7 @@
+@@ -384,7 +451,7 @@
return true;
}
@@ -214,7 +291,7 @@
{
this.func_1228_k(p_40728_1_, p_40728_2_, p_40728_3_, p_40728_4_);
Tessellator var5 = Tessellator.field_1512_a;
-@@ -467,7 +470,7 @@
+@@ -467,7 +534,7 @@
return true;
}
@@ -223,7 +300,7 @@
{
int var5 = this.field_1772_a.func_602_e(p_22332_2_, p_22332_3_, p_22332_4_);
int var6 = var5 & 3;
-@@ -557,7 +560,7 @@
+@@ -557,7 +624,7 @@
this.field_1773_d = false;
}
@@ -232,7 +309,7 @@
{
int var6 = this.field_1772_a.func_602_e(p_31074_2_, p_31074_3_, p_31074_4_);
boolean var7 = p_31074_5_ || (var6 & 8) != 0;
-@@ -660,7 +663,7 @@
+@@ -660,7 +727,7 @@
return true;
}
@@ -241,7 +318,7 @@
{
int var16 = 108;
-@@ -683,7 +686,7 @@
+@@ -683,7 +750,7 @@
var19.func_983_a(p_31076_3_, p_31076_7_, p_31076_11_, var24, var26);
}
@@ -250,7 +327,7 @@
{
int var16 = 108;
-@@ -706,7 +709,7 @@
+@@ -706,7 +773,7 @@
var19.func_983_a(p_31081_3_, p_31081_7_, p_31081_11_, var24, var26);
}
@@ -259,7 +336,7 @@
{
int var16 = 108;
-@@ -736,7 +739,7 @@
+@@ -736,7 +803,7 @@
this.field_1773_d = false;
}
@@ -268,7 +345,7 @@
{
int var6 = this.field_1772_a.func_602_e(p_31080_2_, p_31080_3_, p_31080_4_);
int var7 = BlockPistonExtension.func_31050_c(var6);
-@@ -3244,7 +3247,7 @@
+@@ -3244,7 +3311,7 @@
}
}
@@ -277,7 +354,7 @@
{
int var5 = 0;
float var6 = 0.0F;
-@@ -3776,7 +3779,7 @@
+@@ -3776,7 +3843,7 @@
var27 = p_22330_1_.func_211_a(this.field_1772_a, p_22330_2_, p_22330_3_, p_22330_4_, 2);
this.func_1220_c(p_22330_1_, (double)p_22330_2_, (double)p_22330_3_, (double)p_22330_4_, var27);
@@ -286,7 +363,7 @@
{
this.field_22351_H *= p_22330_5_;
this.field_22350_I *= p_22330_5_;
-@@ -3899,7 +3902,7 @@
+@@ -3899,7 +3966,7 @@
var27 = p_22330_1_.func_211_a(this.field_1772_a, p_22330_2_, p_22330_3_, p_22330_4_, 3);
this.func_1225_d(p_22330_1_, (double)p_22330_2_, (double)p_22330_3_, (double)p_22330_4_, p_22330_1_.func_211_a(this.field_1772_a, p_22330_2_, p_22330_3_, p_22330_4_, 3));
@@ -295,7 +372,7 @@
{
this.field_22351_H *= p_22330_5_;
this.field_22350_I *= p_22330_5_;
-@@ -4022,7 +4025,7 @@
+@@ -4022,7 +4089,7 @@
var27 = p_22330_1_.func_211_a(this.field_1772_a, p_22330_2_, p_22330_3_, p_22330_4_, 4);
this.func_1231_e(p_22330_1_, (double)p_22330_2_, (double)p_22330_3_, (double)p_22330_4_, var27);
@@ -304,7 +381,7 @@
{
this.field_22351_H *= p_22330_5_;
this.field_22350_I *= p_22330_5_;
-@@ -4145,7 +4148,7 @@
+@@ -4145,7 +4212,7 @@
var27 = p_22330_1_.func_211_a(this.field_1772_a, p_22330_2_, p_22330_3_, p_22330_4_, 5);
this.func_1236_f(p_22330_1_, (double)p_22330_2_, (double)p_22330_3_, (double)p_22330_4_, var27);
@@ -313,7 +390,7 @@
{
this.field_22351_H *= p_22330_5_;
this.field_22350_I *= p_22330_5_;
-@@ -4169,7 +4172,7 @@
+@@ -4169,7 +4236,7 @@
return var8;
}
@@ -322,7 +399,7 @@
{
if (p_35924_1_ == 0)
{
-@@ -4251,7 +4254,7 @@
+@@ -4251,7 +4318,7 @@
var28 = p_4152_1_.func_211_a(this.field_1772_a, p_4152_2_, p_4152_3_, p_4152_4_, 2);
this.func_1220_c(p_4152_1_, (double)p_4152_2_, (double)p_4152_3_, (double)p_4152_4_, var28);
@@ -331,7 +408,7 @@
{
var8.func_987_a(var18 * p_4152_5_, var21 * p_4152_6_, var24 * p_4152_7_);
this.func_1220_c(p_4152_1_, (double)p_4152_2_, (double)p_4152_3_, (double)p_4152_4_, 38);
-@@ -4267,7 +4270,7 @@
+@@ -4267,7 +4334,7 @@
var28 = p_4152_1_.func_211_a(this.field_1772_a, p_4152_2_, p_4152_3_, p_4152_4_, 3);
this.func_1225_d(p_4152_1_, (double)p_4152_2_, (double)p_4152_3_, (double)p_4152_4_, var28);
@@ -340,7 +417,7 @@
{
var8.func_987_a(var18 * p_4152_5_, var21 * p_4152_6_, var24 * p_4152_7_);
this.func_1225_d(p_4152_1_, (double)p_4152_2_, (double)p_4152_3_, (double)p_4152_4_, 38);
-@@ -4283,7 +4286,7 @@
+@@ -4283,7 +4350,7 @@
var28 = p_4152_1_.func_211_a(this.field_1772_a, p_4152_2_, p_4152_3_, p_4152_4_, 4);
this.func_1231_e(p_4152_1_, (double)p_4152_2_, (double)p_4152_3_, (double)p_4152_4_, var28);
@@ -349,7 +426,7 @@
{
var8.func_987_a(var19 * p_4152_5_, var22 * p_4152_6_, var25 * p_4152_7_);
this.func_1231_e(p_4152_1_, (double)p_4152_2_, (double)p_4152_3_, (double)p_4152_4_, 38);
-@@ -4299,7 +4302,7 @@
+@@ -4299,7 +4366,7 @@
var28 = p_4152_1_.func_211_a(this.field_1772_a, p_4152_2_, p_4152_3_, p_4152_4_, 5);
this.func_1236_f(p_4152_1_, (double)p_4152_2_, (double)p_4152_3_, (double)p_4152_4_, var28);
@@ -358,7 +435,7 @@
{
var8.func_987_a(var19 * p_4152_5_, var22 * p_4152_6_, var25 * p_4152_7_);
this.func_1236_f(p_4152_1_, (double)p_4152_2_, (double)p_4152_3_, (double)p_4152_4_, 38);
-@@ -5963,6 +5966,10 @@
+@@ -5963,6 +6030,10 @@
p_1227_1_.func_213_a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@@ -369,3 +446,33 @@
}
else
{
+@@ -6020,6 +6091,28 @@
+
+ public static boolean func_1219_a(int p_1219_0_)
+ {
+- return p_1219_0_ == 0 ? true : (p_1219_0_ == 13 ? true : (p_1219_0_ == 10 ? true : (p_1219_0_ == 11 ? true : (p_1219_0_ == 27 ? true : (p_1219_0_ == 22 ? true : (p_1219_0_ == 21 ? true : (p_1219_0_ == 16 ? true : p_1219_0_ == 26)))))));
++ switch (p_1219_0_)
++ {
++ case 0:
++ return true;
++ case 13:
++ return true;
++ case 10:
++ return true;
++ case 11:
++ return true;
++ case 27:
++ return true;
++ case 22:
++ return true;
++ case 21:
++ return true;
++ case 16:
++ return true;
++ case 26:
++ return true;
++ default:
++ return FMLClientHandler.instance().renderItemAsFull3DBlock(p_1219_0_);
++ }
+ }
+ }
diff --git a/fml/patches/minecraft/net/minecraft/src/TexturePackList.java.patch b/fml/patches/minecraft/net/minecraft/src/TexturePackList.java.patch
index 0b15008edd..eb886ae94f 100644
--- a/fml/patches/minecraft/net/minecraft/src/TexturePackList.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/TexturePackList.java.patch
@@ -18,3 +18,11 @@
private boolean field_57509_h;
public TexturePackList(File p_i1506_1_, Minecraft p_i1506_2_)
+@@ -131,6 +133,7 @@
+ var1.add(var5);
+ }
+ }
++ FMLClientHandler.instance().onEarlyTexturePackLoad(this.field_6534_a);
+
+ this.field_6533_b.removeAll(var1);
+ var2 = this.field_6533_b.iterator();
diff --git a/fml/patches/minecraft/net/minecraft/src/TileEntityFurnace.java.patch b/fml/patches/minecraft/net/minecraft/src/TileEntityFurnace.java.patch
index 27b85b14c3..0650820d20 100644
--- a/fml/patches/minecraft/net/minecraft/src/TileEntityFurnace.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/TileEntityFurnace.java.patch
@@ -9,3 +9,21 @@
public class TileEntityFurnace extends TileEntity implements IInventory
{
private ItemStack[] field_833_a = new ItemStack[3];
+@@ -268,8 +271,15 @@
+ return 300;
+ }
+ }
+-
+- return var2 instanceof ItemTool && ((ItemTool)var2).func_56820_c().equals("WOOD") ? 200 : (var2 instanceof ItemSword && ((ItemSword)var2).func_56828_d().equals("WOOD") ? 200 : (var2 instanceof ItemHoe && ((ItemHoe)var2).func_56829_d().equals("WOOD") ? 200 : (var1 == Item.field_266_B.field_291_aS ? 100 : (var1 == Item.field_225_k.field_291_aS ? 1600 : (var1 == Item.field_258_aw.field_291_aS ? 20000 : (var1 == Block.field_333_z.field_376_bc ? 100 : (var1 == Item.field_40417_bo.field_291_aS ? 2400 : 0)))))));
++ if (var2 instanceof ItemTool && ((ItemTool) var2).func_56820_c().equals("WOOD")) return 200;
++ if (var2 instanceof ItemSword && ((ItemSword) var2).func_56828_d().equals("WOOD")) return 200;
++ if (var2 instanceof ItemHoe && ((ItemHoe) var2).func_56829_d().equals("WOOD")) return 200;
++ if (var1 == Item.field_266_B.field_291_aS) return 100;
++ if (var1 == Item.field_225_k.field_291_aS) return 1600;
++ if (var1 == Item.field_258_aw.field_291_aS) return 20000;
++ if (var1 == Block.field_333_z.field_376_bc) return 100;
++ if (var1 == Item.field_40417_bo.field_291_aS) return 2400;
++ return FMLCommonHandler.instance().fuelLookup(var1, p_488_0_.func_21179_h());
+ }
+ }
+
From 32e93213f1e9f3d8fd6394d3bc961d3ce0f97e54 Mon Sep 17 00:00:00 2001
From: Christian
Date: Thu, 5 Jul 2012 22:31:46 -0400
Subject: [PATCH 10/50] Some patches for the server
---
.../cpw/mods/fml/common/FMLCommonHandler.java | 5 ++++
.../minecraft/src/MinecraftServer.java.patch | 20 ++++++++++++++
.../server/MinecraftServer.java.patch | 20 ++++++++++++++
.../minecraft/src/DedicatedServer.java.patch | 27 +++++++++++++++++++
.../net/minecraft/src/EntityPlayer.java.patch | 17 ++++++++++--
.../minecraft/src/NetServerHandler.java.patch | 6 +++--
.../cpw/mods/fml/server/FMLServerHandler.java | 4 +--
fml/server/net/minecraft/src/BaseMod.java | 6 ++---
8 files changed, 96 insertions(+), 9 deletions(-)
create mode 100644 fml/patches/minecraft/net/minecraft/src/MinecraftServer.java.patch
create mode 100644 fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
create mode 100644 fml/patches/minecraft_server/net/minecraft/src/DedicatedServer.java.patch
diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
index 8a4d72ea4f..fa283a006b 100644
--- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
+++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
@@ -657,4 +657,9 @@ public class FMLCommonHandler
{
worldGenerators.add(generator);
}
+
+ public void onWorldLoadTick()
+ {
+ tickStart(EnumSet.of(TickType.WORLDLOAD));
+ }
}
diff --git a/fml/patches/minecraft/net/minecraft/src/MinecraftServer.java.patch b/fml/patches/minecraft/net/minecraft/src/MinecraftServer.java.patch
new file mode 100644
index 0000000000..10448a1d6d
--- /dev/null
+++ b/fml/patches/minecraft/net/minecraft/src/MinecraftServer.java.patch
@@ -0,0 +1,20 @@
+--- ../src-base/minecraft/net/minecraft/src/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000
++++ ../src-work/minecraft/net/minecraft/src/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000
+@@ -12,6 +12,8 @@
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
+
++import cpw.mods.fml.common.FMLCommonHandler;
++
+ public abstract class MinecraftServer implements ICommandSender, IPlayerUsage, Runnable
+ {
+ public static Logger field_56394_a = Logger.getLogger("Minecraft");
+@@ -317,6 +319,8 @@
+ {
+ long var1 = System.currentTimeMillis();
+
++ FMLCommonHandler.instance().onWorldLoadTick();
++
+ for (long var50 = 0L; this.field_56406_t; this.field_56383_O = true)
+ {
+ long var5 = System.currentTimeMillis();
diff --git a/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch b/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
new file mode 100644
index 0000000000..57602128fa
--- /dev/null
+++ b/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
@@ -0,0 +1,20 @@
+--- ../src-base/minecraft_server/net/minecraft/server/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000
++++ ../src-work/minecraft_server/net/minecraft/server/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000
+@@ -11,6 +11,8 @@
+ import java.util.List;
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
++
++import cpw.mods.fml.common.FMLCommonHandler;
+ import net.minecraft.src.AnvilSaveConverter;
+ import net.minecraft.src.AxisAlignedBB;
+ import net.minecraft.src.CallableMCS5;
+@@ -350,6 +352,8 @@
+ {
+ long var1 = System.currentTimeMillis();
+
++ FMLCommonHandler.instance().onWorldLoadTick();
++
+ for (long var50 = 0L; this.field_6025_n; this.field_56215_O = true)
+ {
+ long var5 = System.currentTimeMillis();
diff --git a/fml/patches/minecraft_server/net/minecraft/src/DedicatedServer.java.patch b/fml/patches/minecraft_server/net/minecraft/src/DedicatedServer.java.patch
new file mode 100644
index 0000000000..c4bcd4be64
--- /dev/null
+++ b/fml/patches/minecraft_server/net/minecraft/src/DedicatedServer.java.patch
@@ -0,0 +1,27 @@
+--- ../src-base/minecraft_server/net/minecraft/src/DedicatedServer.java 0000-00-00 00:00:00.000000000 -0000
++++ ../src-work/minecraft_server/net/minecraft/src/DedicatedServer.java 0000-00-00 00:00:00.000000000 -0000
+@@ -8,6 +8,8 @@
+ import java.util.List;
+ import java.util.Random;
+ import java.util.logging.Level;
++
++import cpw.mods.fml.server.FMLServerHandler;
+ import net.minecraft.server.MinecraftServer;
+
+ public class DedicatedServer extends MinecraftServer implements IServer
+@@ -34,6 +36,7 @@
+ var1.start();
+ ConsoleLogManager.func_641_a();
+ field_6038_a.info("Starting minecraft server version 12w26a");
++ FMLServerHandler.instance().onPreLoad(this);
+
+ if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L)
+ {
+@@ -99,6 +102,7 @@
+ field_6038_a.warning("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
+ }
+
++ FMLServerHandler.instance().onLoadComplete();
+ this.func_56197_a(new DedicatedPlayerList(this));
+ long var4 = System.nanoTime();
+
diff --git a/fml/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch b/fml/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch
index 09580c7f29..cdabd00d1a 100644
--- a/fml/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch
@@ -1,6 +1,19 @@
--- ../src-base/minecraft_server/net/minecraft/src/EntityPlayer.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft_server/net/minecraft/src/EntityPlayer.java 0000-00-00 00:00:00.000000000 -0000
-@@ -105,6 +105,7 @@
+@@ -1,8 +1,12 @@
+ package net.minecraft.src;
+
++import java.util.EnumSet;
+ import java.util.Iterator;
+ import java.util.List;
+
++import cpw.mods.fml.common.FMLCommonHandler;
++import cpw.mods.fml.common.TickType;
++
+ public abstract class EntityPlayer extends EntityLiving implements ICommandSender
+ {
+ public InventoryPlayer field_416_aj = new InventoryPlayer(this);
+@@ -105,6 +109,7 @@
public void func_106_b_()
{
@@ -8,7 +21,7 @@
if (this.field_34908_d != null)
{
ItemStack var1 = this.field_416_aj.func_213_b();
-@@ -228,6 +229,7 @@
+@@ -228,6 +233,7 @@
{
this.field_35217_m.func_35584_a(this);
}
diff --git a/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch b/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch
index ee18da9b19..b76be2bf6c 100644
--- a/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch
@@ -9,13 +9,15 @@
import net.minecraft.server.MinecraftServer;
public class NetServerHandler extends NetHandler
-@@ -1014,4 +1016,9 @@
+@@ -1014,4 +1016,11 @@
}
}
}
-+
++//TODO
++ /*
+ @Override
+ public void func_44001_a(Packet250CustomPayload p_44001_1_) {
+ FMLServerHandler.instance().handlePacket250(p_44001_1_, field_16_e);
+ }
++ */
}
diff --git a/fml/server/cpw/mods/fml/server/FMLServerHandler.java b/fml/server/cpw/mods/fml/server/FMLServerHandler.java
index 853ca4fd4a..3b14800ef8 100644
--- a/fml/server/cpw/mods/fml/server/FMLServerHandler.java
+++ b/fml/server/cpw/mods/fml/server/FMLServerHandler.java
@@ -32,7 +32,7 @@ import net.minecraft.src.EntityItem;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EntityPlayerMP;
import net.minecraft.src.IChunkProvider;
-import net.minecraft.src.ICommandListener;
+import net.minecraft.src.ICommandManager;
import net.minecraft.src.IInventory;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
@@ -508,7 +508,7 @@ public class FMLServerHandler implements IFMLSidedHandler
* @param var2
* @return
*/
- public boolean handleServerCommand(String command, String player, ICommandListener listener)
+ public boolean handleServerCommand(String command, String player, ICommandManager listener)
{
for (ModContainer mod : Loader.getModList())
{
diff --git a/fml/server/net/minecraft/src/BaseMod.java b/fml/server/net/minecraft/src/BaseMod.java
index 6c3ff8fe08..3cc93395dc 100644
--- a/fml/server/net/minecraft/src/BaseMod.java
+++ b/fml/server/net/minecraft/src/BaseMod.java
@@ -61,7 +61,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]);
}
@@ -134,7 +134,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
@Override
public final boolean handleCommand(String command, Object... data)
{
- return onServerCommand(command, (String)data[0], (ICommandListener)data[1]);
+ return onServerCommand(command, (String)data[0], (ICommandManager)data[1]);
}
// BASEMOD API
/**
@@ -359,7 +359,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
* @param command
* @return true if you want to consume the message so it is not available for further processing
*/
- public boolean onServerCommand(String command, String sender, ICommandListener listener)
+ public boolean onServerCommand(String command, String sender, ICommandManager listener)
{
return false;
}
From be59dfff54a66ec0ff67e5476ac0a8798c5c714d Mon Sep 17 00:00:00 2001
From: Christian
Date: Fri, 6 Jul 2012 01:04:33 -0400
Subject: [PATCH 11/50] Launch through the applet launcher too
---
.../relauncher/FMLEmbeddingRelauncher.java | 103 ++++++++++++++++--
.../fml/relauncher/RelaunchClassLoader.java | 6 +-
.../client/MinecraftApplet.java.patch | 35 ++++++
3 files changed, 133 insertions(+), 11 deletions(-)
create mode 100644 fml/patches/minecraft/net/minecraft/client/MinecraftApplet.java.patch
diff --git a/fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java b/fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java
index f905984268..ef75a5bffa 100644
--- a/fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java
+++ b/fml/common/cpw/mods/fml/relauncher/FMLEmbeddingRelauncher.java
@@ -1,5 +1,7 @@
package cpw.mods.fml.relauncher;
+import java.applet.Applet;
+import java.applet.AppletStub;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@@ -13,11 +15,22 @@ public class FMLEmbeddingRelauncher
{
private static FMLEmbeddingRelauncher INSTANCE;
private RelaunchClassLoader clientLoader;
+ private Object newApplet;
+ private Class super Object> appletClass;
public static void relaunch(ArgsWrapper wrap)
{
- INSTANCE = new FMLEmbeddingRelauncher();
- INSTANCE.relaunchClient(wrap);
+ instance().relaunchClient(wrap);
+ }
+
+ private static FMLEmbeddingRelauncher instance()
+ {
+ if (INSTANCE == null)
+ {
+ INSTANCE = new FMLEmbeddingRelauncher();
+ System.out.println("FML relaunch active");
+ }
+ return INSTANCE;
}
private FMLEmbeddingRelauncher()
@@ -28,6 +41,24 @@ public class FMLEmbeddingRelauncher
}
private void relaunchClient(ArgsWrapper wrap)
+ {
+ File minecraftHome = setupHome();
+
+ // Now we re-inject the home into the "new" minecraft under our control
+ Class super Object> client = ReflectionHelper.getClass(clientLoader, "net.minecraft.client.Minecraft");
+ ReflectionHelper.setPrivateValue(client, null, minecraftHome, "field_6275_Z", "ap", "minecraftDir");
+
+ try
+ {
+ ReflectionHelper.findMethod(client, null, new String[] { "fmlReentry" }, ArgsWrapper.class).invoke(null, wrap);
+ }
+ catch (Exception e)
+ {
+ // Hmmm
+ }
+ }
+
+ private File setupHome()
{
Class super Object> mcMaster = ReflectionHelper.getClass(getClass().getClassLoader(), "net.minecraft.client.Minecraft");
// We force minecraft to setup it's homedir very early on so we can inject stuff into it
@@ -43,18 +74,76 @@ public class FMLEmbeddingRelauncher
File minecraftHome = ReflectionHelper.getPrivateValue(mcMaster, null, "field_6275_Z", "ap", "minecraftDir");
RelaunchLibraryManager.handleLaunch(minecraftHome, clientLoader);
+ return minecraftHome;
+ }
- // Now we re-inject the home into the "new" minecraft under our control
- Class super Object> client = ReflectionHelper.getClass(clientLoader, "net.minecraft.client.Minecraft");
- ReflectionHelper.setPrivateValue(client, null, minecraftHome, "field_6275_Z", "ap", "minecraftDir");
+ public static void appletEntry(Applet minecraftApplet)
+ {
+ instance().relaunchApplet(minecraftApplet);
+ }
+
+ private void relaunchApplet(Applet minecraftApplet)
+ {
+ appletClass = ReflectionHelper.getClass(clientLoader, "net.minecraft.client.MinecraftApplet");
+ if (minecraftApplet.getClass().getClassLoader() == clientLoader)
+ {
+ try
+ {
+ newApplet = minecraftApplet;
+ ReflectionHelper.findMethod(appletClass, newApplet, new String[] {"fmlInitReentry"}).invoke(newApplet);
+ return;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ setupHome();
+
+ Class super Object> parentAppletClass = ReflectionHelper.getClass(getClass().getClassLoader(), "java.applet.Applet");
try
{
- ReflectionHelper.findMethod(client, null, new String[] { "fmlReentry" }, ArgsWrapper.class).invoke(null, wrap);
+ newApplet = appletClass.newInstance();
+ Object appletContainer = ReflectionHelper.getPrivateValue(ReflectionHelper.getClass(getClass().getClassLoader(), "java.awt.Component"), minecraftApplet, "parent");
+
+ Class super Object> launcherClass = ReflectionHelper.getClass(getClass().getClassLoader(), "net.minecraft.Launcher");
+ if (launcherClass.isInstance(appletContainer))
+ {
+ ReflectionHelper.findMethod(ReflectionHelper.getClass(getClass().getClassLoader(), "java.awt.Container"), minecraftApplet, new String[] { "removeAll" }).invoke(appletContainer);
+ ReflectionHelper.findMethod(launcherClass, appletContainer, new String[] { "replace" }, parentAppletClass).invoke(appletContainer, newApplet);
+ }
+ else
+ {
+ System.out.printf("Found unknown applet parent %s, unable to inject!\n", launcherClass);
+ throw new RuntimeException();
+ }
}
catch (Exception e)
{
- // Hmmm
+ throw new RuntimeException(e);
}
}
+
+ public static void appletStart(Applet applet)
+ {
+ instance().startApplet(applet);
+ }
+
+ private void startApplet(Applet applet)
+ {
+ if (applet.getClass().getClassLoader() == clientLoader)
+ {
+ try
+ {
+ ReflectionHelper.findMethod(appletClass, newApplet, new String[] {"fmlStartReentry"}).invoke(newApplet);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return;
+ }
}
diff --git a/fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java b/fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java
index 78546e91cc..adfb11333b 100644
--- a/fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java
+++ b/fml/common/cpw/mods/fml/relauncher/RelaunchClassLoader.java
@@ -9,7 +9,6 @@ public class RelaunchClassLoader extends URLClassLoader
public RelaunchClassLoader(URL[] sources)
{
super(sources);
- System.out.println(Arrays.toString(sources));
}
@Override
@@ -17,7 +16,7 @@ public class RelaunchClassLoader extends URLClassLoader
{
if (name.startsWith("cpw.mods.fml.relauncher"))
{
- return super.loadClass(name);
+ return getClass().getClassLoader().loadClass(name);
}
try
{
@@ -25,7 +24,7 @@ public class RelaunchClassLoader extends URLClassLoader
}
catch (ClassNotFoundException cnfe)
{
- return super.loadClass(name);
+ return getClass().getClassLoader().loadClass(name);
}
}
@@ -33,6 +32,5 @@ public class RelaunchClassLoader extends URLClassLoader
protected void addURL(URL url)
{
super.addURL(url);
- System.out.println(Arrays.toString(getURLs()));
}
}
diff --git a/fml/patches/minecraft/net/minecraft/client/MinecraftApplet.java.patch b/fml/patches/minecraft/net/minecraft/client/MinecraftApplet.java.patch
new file mode 100644
index 0000000000..7c49a44924
--- /dev/null
+++ b/fml/patches/minecraft/net/minecraft/client/MinecraftApplet.java.patch
@@ -0,0 +1,35 @@
+--- ../src-base/minecraft/net/minecraft/client/MinecraftApplet.java 0000-00-00 00:00:00.000000000 -0000
++++ ../src-work/minecraft/net/minecraft/client/MinecraftApplet.java 0000-00-00 00:00:00.000000000 -0000
+@@ -4,6 +4,8 @@
+ import java.awt.BorderLayout;
+ import java.awt.Canvas;
+ import java.io.File;
++
++import cpw.mods.fml.relauncher.FMLEmbeddingRelauncher;
+ import net.minecraft.src.CanvasMinecraftApplet;
+ import net.minecraft.src.MinecraftAppletImpl;
+ import net.minecraft.src.Session;
+@@ -16,6 +18,11 @@
+
+ public void init()
+ {
++ FMLEmbeddingRelauncher.appletEntry(this);
++ }
++
++ public void fmlInitReentry()
++ {
+ this.field_6235_a = new CanvasMinecraftApplet(this);
+ boolean var1 = "true".equalsIgnoreCase(this.getParameter("fullscreen"));
+ this.field_6234_b = new MinecraftAppletImpl(this, this.field_6235_a, this, this.getWidth(), this.getHeight(), var1);
+@@ -72,6 +79,11 @@
+
+ public void start()
+ {
++ FMLEmbeddingRelauncher.appletStart(this);
++ }
++
++ public void fmlStartReentry()
++ {
+ if (this.field_6234_b != null)
+ {
+ this.field_6234_b.field_6316_m = false;
From 59949849f0fa5b59258751578dd6fdc30ac358e3 Mon Sep 17 00:00:00 2001
From: Christian
Date: Fri, 6 Jul 2012 09:19:58 -0400
Subject: [PATCH 12/50] Add a "checkpatches" target and check if your patches
are up to date before running a repatch operation
---
fml/build.xml | 37 +++++++++++++------
fml/eclipse/FML-Client/.classpath | 14 +++----
fml/eclipse/FML-Client/.project | 5 +++
fml/eclipse/simpletestmod/.classpath | 2 +-
.../.settings/org.eclipse.jdt.core.prefs | 6 +--
.../server/MinecraftServer.java.patch | 10 ++++-
6 files changed, 50 insertions(+), 24 deletions(-)
diff --git a/fml/build.xml b/fml/build.xml
index eff40159e7..3afc5bdbd1 100644
--- a/fml/build.xml
+++ b/fml/build.xml
@@ -1,11 +1,11 @@
-
The Forge Mod Loader
@@ -86,7 +86,6 @@
-
@@ -207,7 +206,7 @@
-
+
@@ -243,7 +242,6 @@
- Moving old patched sources at ${patch.mcp.srcdir} out of the way
@@ -254,6 +252,7 @@
+ Creating clean patched references at ${patch.mcp.srcdir}
@@ -263,7 +262,7 @@
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
@@ -272,19 +271,33 @@
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+ A patch is out of date. Update your patches!
+
+
+
diff --git a/fml/eclipse/FML-Client/.classpath b/fml/eclipse/FML-Client/.classpath
index ae16cdb736..bd2fe28db5 100644
--- a/fml/eclipse/FML-Client/.classpath
+++ b/fml/eclipse/FML-Client/.classpath
@@ -4,24 +4,24 @@
-
+
-
+
-
+
-
-
-
-
+
+
+
+
diff --git a/fml/eclipse/FML-Client/.project b/fml/eclipse/FML-Client/.project
index 5f864284d6..77812bb3f3 100644
--- a/fml/eclipse/FML-Client/.project
+++ b/fml/eclipse/FML-Client/.project
@@ -15,6 +15,11 @@
org.eclipse.jdt.core.javanature
+
+ build.xml
+ 1
+ MCP_LOC/FML/build.xml
+
client2
diff --git a/fml/eclipse/simpletestmod/.classpath b/fml/eclipse/simpletestmod/.classpath
index 331ad7823c..294bff6e8c 100644
--- a/fml/eclipse/simpletestmod/.classpath
+++ b/fml/eclipse/simpletestmod/.classpath
@@ -1,7 +1,7 @@
-
+
diff --git a/fml/eclipse/simpletestmod/.settings/org.eclipse.jdt.core.prefs b/fml/eclipse/simpletestmod/.settings/org.eclipse.jdt.core.prefs
index 7341ab1683..8000cd6ca6 100644
--- a/fml/eclipse/simpletestmod/.settings/org.eclipse.jdt.core.prefs
+++ b/fml/eclipse/simpletestmod/.settings/org.eclipse.jdt.core.prefs
@@ -1,11 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch b/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
index 57602128fa..af2d92afee 100644
--- a/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
@@ -9,7 +9,15 @@
import net.minecraft.src.AnvilSaveConverter;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.CallableMCS5;
-@@ -350,6 +352,8 @@
+@@ -53,6 +55,7 @@
+
+ public abstract class MinecraftServer implements ICommandSender, IPlayerUsage, Runnable
+ {
++ fish;
+ public static Logger field_6038_a = Logger.getLogger("Minecraft");
+ private static MinecraftServer field_55095_w = null;
+ private final ISaveFormat field_56220_l;
+@@ -350,6 +353,8 @@
{
long var1 = System.currentTimeMillis();
From 97cfbb990db3d9f8f410f795c8057c9a29f12b08 Mon Sep 17 00:00:00 2001
From: Christian
Date: Fri, 6 Jul 2012 09:44:00 -0400
Subject: [PATCH 13/50] Server repatching
---
.../minecraft/src/BlockDispenser.java.patch | 9 ++--
.../server/MinecraftServer.java.patch | 41 +++++++++++++++----
.../minecraft/src/BlockDispenser.java.patch | 13 ++++++
.../minecraft/src/NetServerHandler.java.patch | 14 ++++++-
.../src/ServerConfigurationManager.java.patch | 21 +++++++++-
.../src/TileEntityFurnace.java.patch | 17 ++++++++
.../cpw/mods/fml/server/FMLServerHandler.java | 4 +-
7 files changed, 102 insertions(+), 17 deletions(-)
diff --git a/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch b/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch
index 7743153560..632d74ae5b 100644
--- a/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/BlockDispenser.java.patch
@@ -9,14 +9,17 @@
public class BlockDispenser extends BlockContainer
{
private Random field_28035_a = new Random();
-@@ -276,6 +278,10 @@
+@@ -276,7 +278,12 @@
float var15 = 1.1F;
byte var16 = 6;
+- if (p_56784_2_.field_1617_c == Item.field_226_j.field_291_aS)
+ if (FMLClientHandler.instance().tryDispensingEntity(p_56784_1_, p_56784_9_, p_56784_11_, p_56784_13_, p_56784_7_, p_56784_8_, p_56784_2_))
+ {
-+ ;
++ //TODO revisit
++ return 1;
+ }
- if (p_56784_2_.field_1617_c == Item.field_226_j.field_291_aS)
++ else if (p_56784_2_.field_1617_c == Item.field_226_j.field_291_aS)
{
EntityArrow var28 = new EntityArrow(p_56784_1_, p_56784_9_, p_56784_11_, p_56784_13_);
+ var28.func_408_a((double)p_56784_7_, 0.10000000149011612D, (double)p_56784_8_, var15, (float)var16);
diff --git a/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch b/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
index af2d92afee..f2c0b73843 100644
--- a/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
@@ -1,22 +1,15 @@
--- ../src-base/minecraft_server/net/minecraft/server/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft_server/net/minecraft/server/MinecraftServer.java 0000-00-00 00:00:00.000000000 -0000
-@@ -11,6 +11,8 @@
+@@ -11,6 +11,9 @@
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
+
+import cpw.mods.fml.common.FMLCommonHandler;
++import cpw.mods.fml.server.FMLServerHandler;
import net.minecraft.src.AnvilSaveConverter;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.CallableMCS5;
-@@ -53,6 +55,7 @@
-
- public abstract class MinecraftServer implements ICommandSender, IPlayerUsage, Runnable
- {
-+ fish;
- public static Logger field_6038_a = Logger.getLogger("Minecraft");
- private static MinecraftServer field_55095_w = null;
- private final ISaveFormat field_56220_l;
@@ -350,6 +353,8 @@
{
long var1 = System.currentTimeMillis();
@@ -26,3 +19,33 @@
for (long var50 = 0L; this.field_6025_n; this.field_56215_O = true)
{
long var5 = System.currentTimeMillis();
+@@ -440,9 +445,11 @@
+
+ protected void func_56174_n()
+ {
++ FMLCommonHandler.instance().rescheduleTicks();
+ long var1 = System.nanoTime();
+ AxisAlignedBB.func_58089_a().func_58066_a();
+ Vec3.func_58052_a().func_58075_a();
++ FMLServerHandler.instance().onPreServerTick();
+ ++this.field_9014_h;
+ this.func_56160_o();
+
+@@ -472,6 +479,7 @@
+ {
+ this.field_56221_m.func_56622_b();
+ }
++ FMLServerHandler.instance().onPostServerTick();
+ }
+
+ public void func_56160_o()
+@@ -489,7 +497,9 @@
+ this.field_6033_f.func_28169_a(new Packet4UpdateTime(var4.func_22080_k()), var4.field_4272_q.field_6165_g);
+ }
+
++ FMLServerHandler.instance().onPreWorldTick(var4);
+ var4.func_22077_g();
++ FMLServerHandler.instance().onPostWorldTick(var4);
+
+ while (true)
+ {
diff --git a/fml/patches/minecraft_server/net/minecraft/src/BlockDispenser.java.patch b/fml/patches/minecraft_server/net/minecraft/src/BlockDispenser.java.patch
index 2a81f8e61c..ddbc765d37 100644
--- a/fml/patches/minecraft_server/net/minecraft/src/BlockDispenser.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/src/BlockDispenser.java.patch
@@ -9,3 +9,16 @@
public class BlockDispenser extends BlockContainer
{
private Random field_28032_a = new Random();
+@@ -259,7 +261,11 @@
+ float var15 = 1.1F;
+ byte var16 = 6;
+
+- if (p_56353_2_.field_855_c == Item.field_4148_j.field_234_aS)
++ if (FMLServerHandler.instance().tryDispensingEntity(p_56353_1_, p_56353_9_, p_56353_11_, p_56353_13_, p_56353_7_, p_56353_8_, p_56353_2_))
++ {
++ return 1;
++ }
++ else if (p_56353_2_.field_855_c == Item.field_4148_j.field_234_aS)
+ {
+ EntityArrow var28 = new EntityArrow(p_56353_1_, p_56353_9_, p_56353_11_, p_56353_13_);
+ var28.func_177_a((double)p_56353_7_, 0.10000000149011612D, (double)p_56353_8_, var15, (float)var16);
diff --git a/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch b/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch
index b76be2bf6c..66b8dfe4e5 100644
--- a/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/src/NetServerHandler.java.patch
@@ -9,7 +9,19 @@
import net.minecraft.server.MinecraftServer;
public class NetServerHandler extends NetHandler
-@@ -1014,4 +1016,11 @@
+@@ -602,7 +604,10 @@
+ }
+ }
+
+- if (var2.startsWith("/"))
++ if (FMLServerHandler.instance().handleChatPacket(p_23_1_,field_16_e)) {
++ // We handled it
++ }
++ else if (var2.startsWith("/"))
+ {
+ this.func_4010_d(var2);
+ }
+@@ -1014,4 +1019,11 @@
}
}
}
diff --git a/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch b/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch
index b8a3b0ac3f..44f40b535c 100644
--- a/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch
@@ -9,11 +9,28 @@
import net.minecraft.server.MinecraftServer;
public abstract class ServerConfigurationManager
-@@ -355,6 +357,8 @@
+@@ -71,6 +73,8 @@
+ }
+
+ p_56432_2_.func_20057_k();
++ FMLServerHandler.instance().handleLogin(p_56432_1_);
++ FMLServerHandler.instance().announceLogin(p_56432_2_);
+ }
+
+ public void func_618_a(WorldServer[] p_618_1_)
+@@ -144,6 +148,7 @@
+
+ public void func_616_c(EntityPlayerMP p_616_1_)
+ {
++ FMLServerHandler.instance().announceLogout(p_616_1_);
+ this.func_56430_b(p_616_1_);
+ WorldServer var2 = p_616_1_.func_55080_H();
+ var2.func_22085_d(p_616_1_);
+@@ -355,6 +360,8 @@
p_28168_1_.field_425_ad.func_35694_a(var5);
this.func_28170_a(p_28168_1_, var5);
this.func_30008_g(p_28168_1_);
-+
++
+ FMLServerHandler.instance().announceDimensionChange(p_28168_1_);
}
diff --git a/fml/patches/minecraft_server/net/minecraft/src/TileEntityFurnace.java.patch b/fml/patches/minecraft_server/net/minecraft/src/TileEntityFurnace.java.patch
index 2c81723d4a..983ad353cb 100644
--- a/fml/patches/minecraft_server/net/minecraft/src/TileEntityFurnace.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/src/TileEntityFurnace.java.patch
@@ -8,3 +8,20 @@
public class TileEntityFurnace extends TileEntity implements IInventory
{
private ItemStack[] field_489_e = new ItemStack[3];
+@@ -254,7 +256,15 @@
+ }
+ }
+
+- return var2 instanceof ItemTool && ((ItemTool)var2).func_56458_b().equals("WOOD") ? 200 : (var2 instanceof ItemSword && ((ItemSword)var2).func_56462_b().equals("WOOD") ? 200 : (var2 instanceof ItemHoe && ((ItemHoe)var2).func_56463_b().equals("WOOD") ? 200 : (var1 == Item.field_209_B.field_234_aS ? 100 : (var1 == Item.field_168_k.field_234_aS ? 1600 : (var1 == Item.field_201_aw.field_234_aS ? 20000 : (var1 == Block.field_6047_y.field_573_bc ? 100 : (var1 == Item.field_40239_bm.field_234_aS ? 2400 : 0)))))));
++ if (var2 instanceof ItemTool && ((ItemTool) var2).func_56458_b().equals("WOOD")) return 200;
++ if (var2 instanceof ItemSword && ((ItemSword) var2).func_56462_b().equals("WOOD")) return 200;
++ if (var2 instanceof ItemHoe && ((ItemHoe) var2).func_56463_b().equals("WOOD")) return 200;
++ if (var1 == Item.field_209_B.field_234_aS) return 100;
++ if (var1 == Item.field_168_k.field_234_aS) return 1600;
++ if (var1 == Item.field_201_aw.field_234_aS) return 20000;
++ if (var1 == Block.field_6047_y.field_573_bc) return 100;
++ if (var1 == Item.field_40239_bm.field_234_aS) return 2400;
++ return FMLCommonHandler.instance().fuelLookup(var1, p_194_0_.func_21125_h());
+ }
+ }
+
diff --git a/fml/server/cpw/mods/fml/server/FMLServerHandler.java b/fml/server/cpw/mods/fml/server/FMLServerHandler.java
index 3b14800ef8..8ab323c9f3 100644
--- a/fml/server/cpw/mods/fml/server/FMLServerHandler.java
+++ b/fml/server/cpw/mods/fml/server/FMLServerHandler.java
@@ -298,7 +298,7 @@ public class FMLServerHandler implements IFMLSidedHandler
* @param item
* @return
*/
- public boolean tryDispensingEntity(World world, double x, double y, double z, byte xVelocity, byte zVelocity, ItemStack item)
+ public boolean tryDispensingEntity(World world, double x, double y, double z, int xVelocity, int zVelocity, ItemStack item)
{
for (ModContainer mod : Loader.getModList())
{
@@ -468,7 +468,7 @@ public class FMLServerHandler implements IFMLSidedHandler
* @param loginPacket
* @param networkManager
*/
- public void handleLogin(Packet1Login loginPacket, NetworkManager networkManager)
+ public void handleLogin(NetworkManager networkManager)
{
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.field_44005_a = "REGISTER";
From 0ff59e797812e995483cb6936f9374741f51ddd0 Mon Sep 17 00:00:00 2001
From: Christian
Date: Fri, 6 Jul 2012 09:52:21 -0400
Subject: [PATCH 14/50] Remove two places that are unpatchable now
---
.../minecraft/src/ChunkProvider.java.patch | 19 ----------------
.../src/ConsoleCommandHandler.java.patch | 22 -------------------
2 files changed, 41 deletions(-)
delete mode 100644 fml/patches/minecraft/net/minecraft/src/ChunkProvider.java.patch
delete mode 100644 fml/patches/minecraft_server/net/minecraft/src/ConsoleCommandHandler.java.patch
diff --git a/fml/patches/minecraft/net/minecraft/src/ChunkProvider.java.patch b/fml/patches/minecraft/net/minecraft/src/ChunkProvider.java.patch
deleted file mode 100644
index c30a340e44..0000000000
--- a/fml/patches/minecraft/net/minecraft/src/ChunkProvider.java.patch
+++ /dev/null
@@ -1,19 +0,0 @@
---- ../src-base/minecraft/net/minecraft/src/ChunkProvider.java 0000-00-00 00:00:00.000000000 -0000
-+++ ../src-work/minecraft/net/minecraft/src/ChunkProvider.java 0000-00-00 00:00:00.000000000 -0000
-@@ -6,6 +6,8 @@
- import java.util.List;
- import java.util.Set;
-
-+import cpw.mods.fml.client.FMLClientHandler;
-+
- public class ChunkProvider implements IChunkProvider
- {
- private Set field_28065_a = new HashSet();
-@@ -162,6 +164,7 @@
- if (this.field_28070_c != null)
- {
- this.field_28070_c.func_534_a(p_534_1_, p_534_2_, p_534_3_);
-+ FMLClientHandler.instance().onChunkPopulate(p_534_1_, p_534_2_, p_534_3_, field_28066_g, field_28070_c);
- var4.func_1006_f();
- }
- }
diff --git a/fml/patches/minecraft_server/net/minecraft/src/ConsoleCommandHandler.java.patch b/fml/patches/minecraft_server/net/minecraft/src/ConsoleCommandHandler.java.patch
deleted file mode 100644
index e73fb7b06c..0000000000
--- a/fml/patches/minecraft_server/net/minecraft/src/ConsoleCommandHandler.java.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- ../src-base/minecraft_server/net/minecraft/src/ConsoleCommandHandler.java 0000-00-00 00:00:00.000000000 -0000
-+++ ../src-work/minecraft_server/net/minecraft/src/ConsoleCommandHandler.java 0000-00-00 00:00:00.000000000 -0000
-@@ -3,6 +3,8 @@
- import java.util.Iterator;
- import java.util.Set;
- import java.util.logging.Logger;
-+
-+import cpw.mods.fml.server.FMLServerHandler;
- import net.minecraft.server.MinecraftServer;
-
- public class ConsoleCommandHandler
-@@ -397,6 +399,10 @@
- var6.func_2_b("Ban list:" + this.func_40648_a(this.field_22116_b.func_40025_r(), ", "));
- }
- }
-+ else if (FMLServerHandler.instance().handleServerCommand(var2, var6.func_1_c(), var6))
-+ {
-+
-+ }
- else
- {
- field_22117_a.info("Unknown console command. Type \"help\" for help.");
From 98e31e5f03aeda021b44ab496db3e282a5b13c63 Mon Sep 17 00:00:00 2001
From: Christian
Date: Fri, 6 Jul 2012 10:29:17 -0400
Subject: [PATCH 15/50] Incorporate server patches into client
---
.../cpw/mods/fml/client/FMLClientHandler.java | 32 ++++++++++++++++
.../cpw/mods/fml/common/FMLCommonHandler.java | 28 +++++++++++++-
.../src/ChunkProviderServer.java.patch | 19 ++++++++++
.../minecraft/src/DedicatedServer.java.patch | 20 ++++++++++
.../minecraft/src/MinecraftServer.java.patch | 30 +++++++++++++++
.../minecraft/src/NetServerHandler.java.patch | 26 +++++++++++++
.../src/ServerConfigurationManager.java.patch | 37 +++++++++++++++++++
.../server/MinecraftServer.java.patch | 8 ++--
.../src/ServerConfigurationManager.java.patch | 2 +-
.../cpw/mods/fml/server/FMLServerHandler.java | 33 +----------------
10 files changed, 197 insertions(+), 38 deletions(-)
create mode 100644 fml/patches/minecraft/net/minecraft/src/ChunkProviderServer.java.patch
create mode 100644 fml/patches/minecraft/net/minecraft/src/DedicatedServer.java.patch
create mode 100644 fml/patches/minecraft/net/minecraft/src/NetServerHandler.java.patch
create mode 100644 fml/patches/minecraft/net/minecraft/src/ServerConfigurationManager.java.patch
diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
index fcfa7c7742..d1c03ab8d6 100644
--- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java
+++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
@@ -584,6 +584,20 @@ public class FMLClientHandler implements IFMLSidedHandler
return client.field_6297_D;
}
+ /**
+ * @param player
+ */
+ public void announceLogin(EntityPlayer player)
+ {
+ for (ModContainer mod : Loader.getModList())
+ {
+ if (mod.wantsPlayerTracking())
+ {
+ mod.getPlayerTracker().onPlayerLogin(player);
+ }
+ }
+ }
+
/**
* @param player
*/
@@ -1168,4 +1182,22 @@ public class FMLClientHandler implements IFMLSidedHandler
{
WorldType.field_48635_b.removeBiome(biome);
}
+
+ /**
+ * Handle a login
+ *
+ * @param loginPacket
+ * @param networkManager
+ */
+ public void handleClientLogin(NetworkManager networkManager)
+ {
+ 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);
+ }
+ }
}
diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
index fa283a006b..798794c5c3 100644
--- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
+++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
@@ -658,8 +658,34 @@ public class FMLCommonHandler
worldGenerators.add(generator);
}
+ public void onPostServerTick()
+ {
+ FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.GAME));
+ }
+
+ /**
+ * Every tick just after world and other ticks occur
+ */
+ public void onPostWorldTick(Object world)
+ {
+ FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.WORLD), world);
+ }
+
+ public void onPreServerTick()
+ {
+ FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GAME));
+ }
+
+ /**
+ * Every tick just before world and other ticks occur
+ */
+ public void onPreWorldTick(Object world)
+ {
+ FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLD), world);
+ }
+
public void onWorldLoadTick()
{
- tickStart(EnumSet.of(TickType.WORLDLOAD));
+ FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLDLOAD));
}
}
diff --git a/fml/patches/minecraft/net/minecraft/src/ChunkProviderServer.java.patch b/fml/patches/minecraft/net/minecraft/src/ChunkProviderServer.java.patch
new file mode 100644
index 0000000000..bd96f4bfb8
--- /dev/null
+++ b/fml/patches/minecraft/net/minecraft/src/ChunkProviderServer.java.patch
@@ -0,0 +1,19 @@
+--- ../src-base/minecraft/net/minecraft/src/ChunkProviderServer.java 0000-00-00 00:00:00.000000000 -0000
++++ ../src-work/minecraft/net/minecraft/src/ChunkProviderServer.java 0000-00-00 00:00:00.000000000 -0000
+@@ -7,6 +7,8 @@
+ import java.util.List;
+ import java.util.Set;
+
++import cpw.mods.fml.client.FMLClientHandler;
++
+ public class ChunkProviderServer implements IChunkProvider
+ {
+ private Set field_56907_b = new HashSet();
+@@ -177,6 +179,7 @@
+ if (this.field_56905_d != null)
+ {
+ this.field_56905_d.func_534_a(p_534_1_, p_534_2_, p_534_3_);
++ FMLClientHandler.instance().onChunkPopulate(p_534_1_, p_534_2_, p_534_3_, this.field_56910_h, this.field_56905_d);
+ var4.func_1006_f();
+ }
+ }
diff --git a/fml/patches/minecraft/net/minecraft/src/DedicatedServer.java.patch b/fml/patches/minecraft/net/minecraft/src/DedicatedServer.java.patch
new file mode 100644
index 0000000000..5991dcb292
--- /dev/null
+++ b/fml/patches/minecraft/net/minecraft/src/DedicatedServer.java.patch
@@ -0,0 +1,20 @@
+--- ../src-base/minecraft/net/minecraft/src/DedicatedServer.java 0000-00-00 00:00:00.000000000 -0000
++++ ../src-work/minecraft/net/minecraft/src/DedicatedServer.java 0000-00-00 00:00:00.000000000 -0000
+@@ -33,6 +33,8 @@
+ var1.start();
+ ConsoleLogManager.func_57436_a();
+ field_56394_a.info("Starting minecraft server version 12w26a");
++ // TODO
++// FMLServerHandler.instance().onPreLoad(this);
+
+ if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L)
+ {
+@@ -98,6 +100,8 @@
+ field_56394_a.warning("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
+ }
+
++ // TODO
++// FMLServerHandler.instance().onLoadComplete();
+ this.func_56309_a(new DedicatedPlayerList(this));
+ long var4 = System.nanoTime();
+
diff --git a/fml/patches/minecraft/net/minecraft/src/MinecraftServer.java.patch b/fml/patches/minecraft/net/minecraft/src/MinecraftServer.java.patch
index 10448a1d6d..01593e581e 100644
--- a/fml/patches/minecraft/net/minecraft/src/MinecraftServer.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/MinecraftServer.java.patch
@@ -18,3 +18,33 @@
for (long var50 = 0L; this.field_56406_t; this.field_56383_O = true)
{
long var5 = System.currentTimeMillis();
+@@ -407,9 +411,11 @@
+
+ protected void func_56322_n()
+ {
++ FMLCommonHandler.instance().rescheduleTicks();
+ long var1 = System.nanoTime();
+ AxisAlignedBB.func_58144_a().func_58151_a();
+ Vec3.func_58128_a().func_58135_a();
++ FMLCommonHandler.instance().onPreServerTick();
+ ++this.field_56404_v;
+ this.func_56292_o();
+
+@@ -439,6 +445,7 @@
+ {
+ this.field_56398_m.func_57207_b();
+ }
++ FMLCommonHandler.instance().onPostServerTick();
+ }
+
+ protected void func_56292_o()
+@@ -456,7 +463,9 @@
+ this.field_56407_s.func_57105_a(new Packet4UpdateTime(var4.func_22139_r()), var4.field_4209_q.field_4218_e);
+ }
+
++ FMLCommonHandler.instance().onPreWorldTick(var4);
+ var4.func_649_g();
++ FMLCommonHandler.instance().onPostWorldTick(var4);
+
+ while (true)
+ {
diff --git a/fml/patches/minecraft/net/minecraft/src/NetServerHandler.java.patch b/fml/patches/minecraft/net/minecraft/src/NetServerHandler.java.patch
new file mode 100644
index 0000000000..f68b096f7e
--- /dev/null
+++ b/fml/patches/minecraft/net/minecraft/src/NetServerHandler.java.patch
@@ -0,0 +1,26 @@
+--- ../src-base/minecraft/net/minecraft/src/NetServerHandler.java 0000-00-00 00:00:00.000000000 -0000
++++ ../src-work/minecraft/net/minecraft/src/NetServerHandler.java 0000-00-00 00:00:00.000000000 -0000
+@@ -601,7 +601,10 @@
+ }
+ }
+
+- if (var2.startsWith("/"))
++ if (FMLServerHandler.instance().handleChatPacket(p_23_1_,field_16_e)) {
++ // We handled it
++ }
++ else if (var2.startsWith("/"))
+ {
+ this.func_56721_b(var2);
+ }
+@@ -1013,4 +1016,11 @@
+ }
+ }
+ }
++//TODO
++ /*
++ @Override
++ public void func_44001_a(Packet250CustomPayload p_44001_1_) {
++ FMLServerHandler.instance().handlePacket250(p_44001_1_, field_16_e);
++ }
++ */
+ }
diff --git a/fml/patches/minecraft/net/minecraft/src/ServerConfigurationManager.java.patch b/fml/patches/minecraft/net/minecraft/src/ServerConfigurationManager.java.patch
new file mode 100644
index 0000000000..cc0a4e8683
--- /dev/null
+++ b/fml/patches/minecraft/net/minecraft/src/ServerConfigurationManager.java.patch
@@ -0,0 +1,37 @@
+--- ../src-base/minecraft/net/minecraft/src/ServerConfigurationManager.java 0000-00-00 00:00:00.000000000 -0000
++++ ../src-work/minecraft/net/minecraft/src/ServerConfigurationManager.java 0000-00-00 00:00:00.000000000 -0000
+@@ -10,6 +10,8 @@
+ import java.util.Set;
+ import java.util.logging.Logger;
+
++import cpw.mods.fml.client.FMLClientHandler;
++
+ public abstract class ServerConfigurationManager
+ {
+ private static final SimpleDateFormat field_57132_e = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
+@@ -70,6 +72,8 @@
+ }
+
+ p_57113_2_.func_56256_h();
++ FMLClientHandler.instance().handleClientLogin(p_57113_1_);
++ FMLClientHandler.instance().announceLogin(p_57113_2_);
+ }
+
+ public void func_57096_a(WorldServer[] p_57096_1_)
+@@ -143,6 +147,7 @@
+
+ public void func_57093_e(EntityPlayerMP p_57093_1_)
+ {
++ FMLClientHandler.instance().announceLogout(p_57093_1_);
+ this.func_57118_b(p_57093_1_);
+ WorldServer var2 = p_57093_1_.func_56260_H();
+ var2.func_607_d(p_57093_1_);
+@@ -354,6 +359,8 @@
+ p_57125_1_.field_56267_c.func_57360_a(var5);
+ this.func_57120_b(p_57125_1_, var5);
+ this.func_57124_f(p_57125_1_);
++
++ FMLClientHandler.instance().announceDimensionChange(p_57125_1_);
+ }
+
+ public void func_57104_b()
diff --git a/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch b/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
index f2c0b73843..04402f4cac 100644
--- a/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/server/MinecraftServer.java.patch
@@ -27,7 +27,7 @@
long var1 = System.nanoTime();
AxisAlignedBB.func_58089_a().func_58066_a();
Vec3.func_58052_a().func_58075_a();
-+ FMLServerHandler.instance().onPreServerTick();
++ FMLCommonHandler.instance().onPreServerTick();
++this.field_9014_h;
this.func_56160_o();
@@ -35,7 +35,7 @@
{
this.field_56221_m.func_56622_b();
}
-+ FMLServerHandler.instance().onPostServerTick();
++ FMLCommonHandler.instance().onPostServerTick();
}
public void func_56160_o()
@@ -43,9 +43,9 @@
this.field_6033_f.func_28169_a(new Packet4UpdateTime(var4.func_22080_k()), var4.field_4272_q.field_6165_g);
}
-+ FMLServerHandler.instance().onPreWorldTick(var4);
++ FMLCommonHandler.instance().onPreWorldTick(var4);
var4.func_22077_g();
-+ FMLServerHandler.instance().onPostWorldTick(var4);
++ FMLCommonHandler.instance().onPostWorldTick(var4);
while (true)
{
diff --git a/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch b/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch
index 44f40b535c..12346a72be 100644
--- a/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch
+++ b/fml/patches/minecraft_server/net/minecraft/src/ServerConfigurationManager.java.patch
@@ -13,7 +13,7 @@
}
p_56432_2_.func_20057_k();
-+ FMLServerHandler.instance().handleLogin(p_56432_1_);
++ FMLServerHandler.instance().handleClientLogin(p_56432_1_);
+ FMLServerHandler.instance().announceLogin(p_56432_2_);
}
diff --git a/fml/server/cpw/mods/fml/server/FMLServerHandler.java b/fml/server/cpw/mods/fml/server/FMLServerHandler.java
index 8ab323c9f3..65ee9a43c4 100644
--- a/fml/server/cpw/mods/fml/server/FMLServerHandler.java
+++ b/fml/server/cpw/mods/fml/server/FMLServerHandler.java
@@ -18,7 +18,6 @@ import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.util.ArrayList;
-import java.util.EnumSet;
import java.util.List;
import java.util.Properties;
import java.util.Random;
@@ -55,7 +54,6 @@ import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.ProxyInjector;
import cpw.mods.fml.common.ReflectionHelper;
import cpw.mods.fml.common.Side;
-import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
import cpw.mods.fml.common.modloader.ModProperty;
import cpw.mods.fml.common.registry.FMLRegistry;
@@ -153,35 +151,6 @@ public class FMLServerHandler implements IFMLSidedHandler
throw new RuntimeException(message, exception);
}
- public void onPreServerTick()
- {
- FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GAME));
- }
-
- public void onPostServerTick()
- {
- FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.GAME));
- }
- /**
- * Every tick just before world and other ticks occur
- */
- public void onPreWorldTick(World world)
- {
- FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLD), world);
- }
-
- /**
- * Every tick just after world and other ticks occur
- */
- public void onPostWorldTick(World world)
- {
- FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.WORLD), world);
- }
-
- public void onWorldLoadTick()
- {
- FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLDLOAD));
- }
/**
* Get the server instance
*
@@ -468,7 +437,7 @@ public class FMLServerHandler implements IFMLSidedHandler
* @param loginPacket
* @param networkManager
*/
- public void handleLogin(NetworkManager networkManager)
+ public void handleClientLogin(NetworkManager networkManager)
{
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.field_44005_a = "REGISTER";
From 25fb847dc1a5838ba81709287d2fb07a6a5ac3b5 Mon Sep 17 00:00:00 2001
From: Christian
Date: Fri, 6 Jul 2012 10:42:49 -0400
Subject: [PATCH 16/50] Fixes
---
.../cpw/mods/fml/client/FMLClientHandler.java | 21 +++++++++++++++++++
.../minecraft/src/NetServerHandler.java.patch | 15 ++++++++++---
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
index d1c03ab8d6..9621b7733f 100644
--- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java
+++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
@@ -503,6 +503,27 @@ public class FMLClientHandler implements IFMLSidedHandler
return false;
}
+ /**
+ * 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, EntityPlayer player)
+ {
+ for (ModContainer mod : Loader.getModList())
+ {
+ if (mod.wantsNetworkPackets() && mod.getNetworkHandler().onChat(chat, player))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
public void handleServerLogin(Packet1Login loginPacket, NetClientHandler handler, NetworkManager networkManager)
{
this.networkClient=handler;
diff --git a/fml/patches/minecraft/net/minecraft/src/NetServerHandler.java.patch b/fml/patches/minecraft/net/minecraft/src/NetServerHandler.java.patch
index f68b096f7e..6acb74e16d 100644
--- a/fml/patches/minecraft/net/minecraft/src/NetServerHandler.java.patch
+++ b/fml/patches/minecraft/net/minecraft/src/NetServerHandler.java.patch
@@ -1,18 +1,27 @@
--- ../src-base/minecraft/net/minecraft/src/NetServerHandler.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src-work/minecraft/net/minecraft/src/NetServerHandler.java 0000-00-00 00:00:00.000000000 -0000
-@@ -601,7 +601,10 @@
+@@ -8,6 +8,8 @@
+ import java.util.Random;
+ import java.util.logging.Logger;
+
++import cpw.mods.fml.client.FMLClientHandler;
++
+ public class NetServerHandler extends NetHandler
+ {
+ public static Logger field_56728_a = Logger.getLogger("Minecraft");
+@@ -601,7 +603,10 @@
}
}
- if (var2.startsWith("/"))
-+ if (FMLServerHandler.instance().handleChatPacket(p_23_1_,field_16_e)) {
++ if (FMLClientHandler.instance().handleChatPacket(p_4113_1_,field_56725_e)) {
+ // We handled it
+ }
+ else if (var2.startsWith("/"))
{
this.func_56721_b(var2);
}
-@@ -1013,4 +1016,11 @@
+@@ -1013,4 +1018,11 @@
}
}
}
From 9d6266d85b7a49dfadd6b958510341d3a13d67ac Mon Sep 17 00:00:00 2001
From: Christian
Date: Fri, 6 Jul 2012 15:59:16 -0400
Subject: [PATCH 17/50] Fix up mod classloading delegation
---
fml/common/cpw/mods/fml/common/Loader.java | 2 +-
.../cpw/mods/fml/common/ModClassLoader.java | 66 +++++++++----------
.../fml/relauncher/RelaunchClassLoader.java | 13 +++-
.../relauncher/RelaunchLibraryManager.java | 11 ++++
4 files changed, 54 insertions(+), 38 deletions(-)
diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java
index b82c2e8c50..c223ea6dac 100644
--- a/fml/common/cpw/mods/fml/common/Loader.java
+++ b/fml/common/cpw/mods/fml/common/Loader.java
@@ -177,7 +177,7 @@ public class Loader
}
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());
}
/**
diff --git a/fml/common/cpw/mods/fml/common/ModClassLoader.java b/fml/common/cpw/mods/fml/common/ModClassLoader.java
index 44b9196fe0..526f639a2c 100644
--- a/fml/common/cpw/mods/fml/common/ModClassLoader.java
+++ b/fml/common/cpw/mods/fml/common/ModClassLoader.java
@@ -19,61 +19,55 @@ 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 cpw.mods.fml.relauncher.FMLEmbeddingRelauncher;
+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 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() {
- ClassLoader cl=getParent();
- if (cl instanceof URLClassLoader) {
- URLClassLoader ucl=(URLClassLoader) cl;
- URL[] pUrl=ucl.getURLs();
- File[] sources=new File[pUrl.length];
- try
+ List urls=mainClassLoader.getSources();
+ File[] sources=new File[urls.size()];
+ try
+ {
+ for (int i = 0; i sources;
+
public RelaunchClassLoader(URL[] sources)
{
super(sources);
+ this.sources = new ArrayList(Arrays.asList(sources));
}
@Override
@@ -29,8 +34,14 @@ public class RelaunchClassLoader extends URLClassLoader
}
@Override
- protected void addURL(URL url)
+ public void addURL(URL url)
{
super.addURL(url);
+ sources.add(url);
+ }
+
+ public List getSources()
+ {
+ return sources;
}
}
diff --git a/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java b/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java
index 383e3682c9..06ea3e2029 100644
--- a/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java
+++ b/fml/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java
@@ -19,6 +19,8 @@ import java.nio.channels.ReadableByteChannel;
import java.nio.channels.FileChannel.MapMode;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.swing.JOptionPane;
@@ -78,6 +80,15 @@ public class RelaunchLibraryManager
}
+ try
+ {
+ Class> loaderClazz = Class.forName("cpw.mods.fml.common.Loader", true, actualClassLoader);
+ }
+ catch (Exception e)
+ {
+ // Load in the Loader, make sure he's ready to roll
+ throw new RuntimeException(e);
+ }
}
private static String generateChecksum(File file)
From 48dcdca805a2b1cf9347057db8796a9208c4b8ed Mon Sep 17 00:00:00 2001
From: LexManos
Date: Thu, 12 Jul 2012 18:06:01 -0700
Subject: [PATCH 18/50] Fix Client-Clean project to use relative path to argo.
---
fml/eclipse/Clean-Client/.classpath | 2 +-
fml/eclipse/Clean-Client/.project | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/fml/eclipse/Clean-Client/.classpath b/fml/eclipse/Clean-Client/.classpath
index 2660e24ec7..136f1484d7 100644
--- a/fml/eclipse/Clean-Client/.classpath
+++ b/fml/eclipse/Clean-Client/.classpath
@@ -18,6 +18,6 @@
-
+
diff --git a/fml/eclipse/Clean-Client/.project b/fml/eclipse/Clean-Client/.project
index 7de653c48b..49ce1e885a 100644
--- a/fml/eclipse/Clean-Client/.project
+++ b/fml/eclipse/Clean-Client/.project
@@ -20,6 +20,11 @@
2MCP_LOC/jars
+
+ lib
+ 2
+ MCP_LOC/lib
+
src2
From 0a9ee584bf195b72e49ef01867cbe8e622be8458 Mon Sep 17 00:00:00 2001
From: LexManos
Date: Thu, 12 Jul 2012 18:06:39 -0700
Subject: [PATCH 19/50] Added call to clean_source to build script to fix patch
fuzz on windows.
---
fml/build.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fml/build.xml b/fml/build.xml
index 3afc5bdbd1..bab9494af8 100644
--- a/fml/build.xml
+++ b/fml/build.xml
@@ -238,6 +238,10 @@
+
+
+
+
From 2671641b833dbeb510f7a00cc7b257d29359463f Mon Sep 17 00:00:00 2001
From: LexManos
Date: Thu, 12 Jul 2012 18:07:58 -0700
Subject: [PATCH 20/50] Cleaned up the install script for the source
distrabution to setup the workspace properly, delete argo, and download all
required dependancies.
---
fml/install/download_fernflower.py | 10 -
fml/install/eclipse/Client/.classpath | 25 +++
fml/install/eclipse/Client/.project | 69 ++++++
fml/install/eclipse/Server/.classpath | 7 +
fml/install/eclipse/Server/.project | 46 ++++
fml/install/fml.py | 296 ++++++++++++++++++++++++++
fml/install/install.cmd | 44 +---
fml/install/install.py | 15 ++
fml/install/install.sh | 42 +---
fml/install/lfcr.py | 8 -
10 files changed, 461 insertions(+), 101 deletions(-)
delete mode 100755 fml/install/download_fernflower.py
create mode 100644 fml/install/eclipse/Client/.classpath
create mode 100644 fml/install/eclipse/Client/.project
create mode 100644 fml/install/eclipse/Server/.classpath
create mode 100644 fml/install/eclipse/Server/.project
create mode 100644 fml/install/fml.py
create mode 100644 fml/install/install.py
delete mode 100755 fml/install/lfcr.py
diff --git a/fml/install/download_fernflower.py b/fml/install/download_fernflower.py
deleted file mode 100755
index 8731bedd0e..0000000000
--- a/fml/install/download_fernflower.py
+++ /dev/null
@@ -1,10 +0,0 @@
-import urllib
-import zipfile
-
-if __name__ == '__main__':
- try:
- urllib.urlretrieve("http://goo.gl/PnJHp", './fernflower.zip')
- zf = zipfile.ZipFile('fernflower.zip')
- zf.extract('fernflower.jar', '../runtime/bin')
- except:
- print "Downloading Fernflower failed download manually from http://goo.gl/PnJHp"
\ No newline at end of file
diff --git a/fml/install/eclipse/Client/.classpath b/fml/install/eclipse/Client/.classpath
new file mode 100644
index 0000000000..c65206bffb
--- /dev/null
+++ b/fml/install/eclipse/Client/.classpath
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fml/install/eclipse/Client/.project b/fml/install/eclipse/Client/.project
new file mode 100644
index 0000000000..04e240e155
--- /dev/null
+++ b/fml/install/eclipse/Client/.project
@@ -0,0 +1,69 @@
+
+
+ Client
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
+
+ jars
+ 2
+ MCP_LOC/jars
+
+
+ src
+ 2
+ MCP_LOC/src/minecraft
+
+
+ lib
+ 2
+ MCP_LOC/lib
+
+
+
+
+ 1307293455427
+ jars
+ 13
+
+ org.eclipse.ui.ide.multiFilter
+ 1.0-name-matches-false-false-bin
+
+
+
+ 1307293504507
+ jars/bin
+ 5
+
+ org.eclipse.ui.ide.multiFilter
+ 1.0-name-matches-false-false-*.jar
+
+
+
+ 1307293480435
+ jars/bin/natives
+ 6
+
+ org.eclipse.ui.ide.multiFilter
+ 1.0-name-matches-false-false-*
+
+
+
+
+
+ MCP_LOC
+ $%7BPARENT-1-WORKSPACE_LOC%7D
+
+
+
diff --git a/fml/install/eclipse/Server/.classpath b/fml/install/eclipse/Server/.classpath
new file mode 100644
index 0000000000..547b2f1f3d
--- /dev/null
+++ b/fml/install/eclipse/Server/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/fml/install/eclipse/Server/.project b/fml/install/eclipse/Server/.project
new file mode 100644
index 0000000000..eed2b19594
--- /dev/null
+++ b/fml/install/eclipse/Server/.project
@@ -0,0 +1,46 @@
+
+
+ Server
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
+
+ jars
+ 2
+ MCP_LOC/jars
+
+
+ src
+ 2
+ MCP_LOC/src/minecraft_server
+
+
+
+
+ 1307293529292
+ jars
+ 13
+
+ org.eclipse.ui.ide.multiFilter
+ 1.0-name-matches-false-false-*.jar
+
+
+
+
+
+ MCP_LOC
+ $%7BPARENT-1-WORKSPACE_LOC%7D
+
+
+
diff --git a/fml/install/fml.py b/fml/install/fml.py
new file mode 100644
index 0000000000..839ae95a56
--- /dev/null
+++ b/fml/install/fml.py
@@ -0,0 +1,296 @@
+import os, os.path, sys
+import urllib, zipfile
+import shutil, glob, fnmatch
+import subprocess, logging, re
+
+def download_deps(mcp_path):
+ bin_path = os.path.normpath(os.path.join(mcp_path, 'runtime', 'bin'))
+ ff_path = os.path.normpath(os.path.join(bin_path, 'fernflower.jar'))
+ ret = True
+
+ if not os.path.isfile(ff_path):
+ try:
+ urllib.urlretrieve("http://goo.gl/PnJHp", 'fernflower.zip')
+ zf = zipfile.ZipFile('fernflower.zip')
+ zf.extract('fernflower.jar', bin_path)
+ zf.close()
+ os.remove('fernflower.zip')
+ print "Downloaded Fernflower successfully"
+ except:
+ print "Downloading Fernflower failed download manually from http://goo.gl/PnJHp"
+ ret = False
+
+ for lib in ["argo-2.25.jar", "guava-12.0.jar", "asm-all-4.0.jar"]:
+ target = os.path.normpath(os.path.join(mcp_path, 'lib', lib))
+ if not os.path.isfile(target):
+ try:
+ urllib.urlretrieve('http://cloud.github.com/downloads/cpw/FML/' + lib, target)
+ print 'Downloaded %s successfully' % lib
+ except:
+ print 'Download %s failed, download manually from http://cloud.github.com/downloads/cpw/FML/%s and place in MCP/libs' % (lib, lib)
+ ret = False
+
+ return ret
+
+def pre_decompile(mcp_dir, fml_dir):
+ bin_dir = os.path.join(mcp_dir, 'jars', 'bin')
+ back_jar = os.path.join(bin_dir, 'minecraft.jar.backup')
+ src_jar = os.path.join(bin_dir, 'minecraft.jar')
+
+ if os.path.isfile(back_jar):
+ if os.path.isfile(src_jar):
+ os.remove(src_jar)
+ shutil.move(back_jar, src_jar)
+
+def post_decompile(mcp_dir, fml_dir):
+ print 'Stripping META-INF from minecraft.jar'
+ bin_dir = os.path.join(mcp_dir, 'jars', 'bin')
+ back_jar = os.path.join(bin_dir, 'minecraft.jar.backup')
+ src_jar = os.path.join(bin_dir, 'minecraft.jar')
+
+ if os.path.isfile(back_jar):
+ os.remove(back_jar)
+
+ shutil.move(src_jar, back_jar)
+
+ zip_in = zipfile.ZipFile(back_jar, mode='a')
+ zip_out = zipfile.ZipFile(src_jar, 'w', zipfile.ZIP_DEFLATED)
+ for i in zip_in.filelist:
+ if not i.filename.startswith('META-INF'):
+ c = zip_in.read(i.filename)
+ zip_out.writestr(i.filename, c)
+ else:
+ print 'Skipping: %s' % i.filename
+ zip_out.close()
+
+def reset_logger():
+ log = logging.getLogger()
+ while len(log.handlers) > 0:
+ log.removeHandler(log.handlers[0])
+
+count = 0
+def cleanup_source(path):
+ path = os.path.normpath(path)
+ regex_cases_before = re.compile(r'((case|default).+\r?\n)\r?\n', re.MULTILINE) #Fixes newline after case before case body
+ regex_cases_after = re.compile(r'\r?\n(\r?\n[ \t]+(case|default))', re.MULTILINE) #Fixes newline after case body before new case
+
+ def updatefile(src_file):
+ global count
+ tmp_file = src_file + '.tmp'
+ count = 0
+ with open(src_file, 'r') as fh:
+ buf = fh.read()
+
+ def fix_cases(match):
+ global count
+ count += 1
+ return match.group(1)
+
+ buf = regex_cases_before.sub(fix_cases, buf)
+ buf = regex_cases_after.sub(fix_cases, buf)
+ if count > 0:
+ with open(tmp_file, 'w') as fh:
+ fh.write(buf)
+ shutil.move(tmp_file, src_file)
+
+ for path, _, filelist in os.walk(path, followlinks=True):
+ sub_dir = os.path.relpath(path, path)
+ for cur_file in fnmatch.filter(filelist, '*.java'):
+ src_file = os.path.normpath(os.path.join(path, cur_file))
+ updatefile(src_file)
+
+def setup_fml(fml_dir, mcp_dir):
+ sys.path.append(mcp_dir)
+ from runtime.decompile import decompile
+ from runtime.updatemd5 import updatemd5
+ from runtime.cleanup import cleanup
+
+ src_dir = os.path.join(mcp_dir, 'src')
+
+ if os.path.isdir(src_dir):
+ os.chdir(mcp_dir)
+ #cleanup -f
+ cleanup(None, False)
+ reset_logger()
+ os.chdir(fml_dir)
+
+ if os.path.isdir(src_dir):
+ print 'Please make sure to backup your modified files, and say yes when it asks you to do cleanup.'
+ sys.exit(1)
+
+ #download fernflower/argo/asm/guava
+ if not download_deps(mcp_dir):
+ sys.exit(1)
+
+ try:
+ pre_decompile(mcp_dir, fml_dir)
+
+ os.chdir(mcp_dir)
+ #decompile -d -n -r
+ # Conf JAD CSV -r -d -a -n -p -o -l -g
+ decompile(None, False, False, True, True, False, True, False, False, False, False)
+ reset_logger()
+ os.chdir(fml_dir)
+
+ post_decompile(mcp_dir, fml_dir)
+
+ except SystemExit, e:
+ print 'Decompile Exception: %d ' % e.code
+ raise e
+
+ if not os.path.isdir(src_dir):
+ print 'Something went wrong, src folder not found at: %s' % src_dir
+ sys.exit(1)
+
+ #cleanup_source
+ cleanup_source(src_dir)
+
+ has_client = os.path.isdir(os.path.join(mcp_dir, 'src', 'minecraft'))
+ has_server = os.path.isdir(os.path.join(mcp_dir, 'src', 'minecraft_server'))
+
+ #patch files
+ print 'Applying Forge ModLoader patches'
+ if has_client:
+ if os.path.isdir(os.path.join(fml_dir, 'patches', 'minecraft')):
+ apply_patches(mcp_dir, os.path.join(fml_dir, 'patches', 'minecraft'), src_dir)
+ if os.path.isdir(os.path.join(fml_dir, 'src', 'minecraft')):
+ copytree(os.path.join(fml_dir, 'src', 'minecraft'), os.path.join(src_dir, 'minecraft'))
+ #delete argo
+ shutil.rmtree(os.path.join(src_dir, 'minecraft', 'argo'))
+
+ if has_server:
+ if os.path.isdir(os.path.join(fml_dir, 'patches', 'minecraft_server')):
+ apply_patches(mcp_dir, os.path.join(fml_dir, 'patches', 'minecraft_server'), src_dir)
+ if os.path.isdir(os.path.join(fml_dir, 'src', 'minecraft_server')):
+ copytree(os.path.join(fml_dir, 'src', 'minecraft_server'), os.path.join(src_dir, 'minecraft_server'))
+
+ #updatemd5 -f
+ os.chdir(mcp_dir)
+ updatemd5(None, True)
+ reset_logger()
+ os.chdir(fml_dir)
+
+ #update workspace
+ print 'Fixing MCP Workspace'
+ merge_tree(os.path.join(fml_dir, 'eclipse'), os.path.join(mcp_dir, 'eclipse'))
+
+def finish_setup_fml(fml_dir, mcp_dir):
+ sys.path.append(mcp_dir)
+ from runtime.updatenames import updatenames
+ from runtime.updatemd5 import updatemd5
+ from runtime.updatemcp import updatemcp
+
+ os.chdir(mcp_dir)
+ updatemcp(None, True)
+ reset_logger()
+ updatenames(None, True)
+ reset_logger()
+ updatemd5(None, True)
+ reset_logger()
+ os.chdir(fml_dir)
+
+def apply_patches(mcp_dir, patch_dir, target_dir):
+ sys.path.append(mcp_dir)
+ from runtime.pylibs.normlines import normaliselines
+ from runtime.commands import cmdsplit
+
+ temp = os.path.abspath('temp.patch')
+ cmd = cmdsplit('patch -p2 -i "%s" ' % temp)
+ display = True
+
+ if os.name == 'nt':
+ applydiff = os.path.abspath(os.path.join(mcp_dir, 'runtime', 'bin', 'applydiff.exe'))
+ cmd = cmdsplit('"%s" -uf -p2 -i "%s"' % (applydiff, temp))
+ display = False
+
+ for path, _, filelist in os.walk(patch_dir, followlinks=True):
+ for cur_file in fnmatch.filter(filelist, '*.patch'):
+ patch_file = os.path.normpath(os.path.join(patch_dir, path[len(patch_dir)+1:], cur_file))
+ if display:
+ print 'patching file %s' % os.path.join(path[len(patch_dir)+1:], cur_file)
+ normaliselines(patch_file, temp)
+ process = subprocess.Popen(cmd, cwd=target_dir, bufsize=-1)
+ process.communicate()
+
+ if os.path.isfile(temp):
+ os.remove(temp)
+
+#Taken from: http://stackoverflow.com/questions/7545299/distutil-shutil-copytree
+def _mkdir(newdir):
+ """works the way a good mkdir should :)
+ - already exists, silently complete
+ - regular file in the way, raise an exception
+ - parent directory(ies) does not exist, make them as well
+ """
+ if os.path.isdir(newdir):
+ pass
+ elif os.path.isfile(newdir):
+ raise OSError("a file with the same name as the desired " \
+ "dir, '%s', already exists." % newdir)
+ else:
+ head, tail = os.path.split(newdir)
+ if head and not os.path.isdir(head):
+ _mkdir(head)
+ #print "_mkdir %s" % repr(newdir)
+ if tail:
+ os.mkdir(newdir)
+
+#Taken from: http://stackoverflow.com/questions/7545299/distutil-shutil-copytree
+def copytree(src, dst, verbose=0, symlinks=False):
+ """Recursively copy a directory tree using copy2().
+
+ The destination directory must not already exist.
+ If exception(s) occur, an Error is raised with a list of reasons.
+
+ If the optional symlinks flag is true, symbolic links in the
+ source tree result in symbolic links in the destination tree; if
+ it is false, the contents of the files pointed to by symbolic
+ links are copied.
+
+ XXX Consider this example code rather than the ultimate tool.
+
+ """
+
+ if verbose == -1:
+ verbose = len(os.path.abspath(dst)) - 1
+ names = os.listdir(src)
+ # os.makedirs(dst)
+ _mkdir(dst) # XXX
+ errors = []
+ for name in names:
+ srcname = os.path.join(src, name)
+ dstname = os.path.join(dst, name)
+ try:
+ if symlinks and os.path.islink(srcname):
+ linkto = os.readlink(srcname)
+ os.symlink(linkto, dstname)
+ elif os.path.isdir(srcname):
+ copytree(srcname, dstname, verbose, symlinks)
+ else:
+ shutil.copy2(srcname, dstname)
+ if verbose > 0:
+ print os.path.abspath(srcname)[verbose:]
+ # XXX What about devices, sockets etc.?
+ except (IOError, os.error), why:
+ errors.append((srcname, dstname, str(why)))
+ # catch the Error from the recursive copytree so that we can
+ # continue with other files
+ except Exception, err:
+ errors.extend(err.args[0])
+ try:
+ shutil.copystat(src, dst)
+ except WindowsError:
+ # can't copy file access times on Windows
+ pass
+
+def merge_tree(root_src_dir, root_dst_dir):
+ for src_dir, dirs, files in os.walk(root_src_dir):
+ dst_dir = src_dir.replace(root_src_dir, root_dst_dir)
+ if not os.path.exists(dst_dir):
+ os.mkdir(dst_dir)
+ for file_ in files:
+ src_file = os.path.join(src_dir, file_)
+ dst_file = os.path.join(dst_dir, file_)
+ if os.path.exists(dst_file):
+ os.remove(dst_file)
+ shutil.copy(src_file, dst_dir)
\ No newline at end of file
diff --git a/fml/install/install.cmd b/fml/install/install.cmd
index ff91c6f5d3..44f6646436 100755
--- a/fml/install/install.cmd
+++ b/fml/install/install.cmd
@@ -1,44 +1,4 @@
echo off
-
-echo Forge Mod Loader Windows Setup Program
-echo:
-
-@set PATH=%PATH%;%SystemDir%\system32;%SystemRoot%\System32
-
-if not exist "..\runtime\bin\fernflower.jar" (
- ..\runtime\bin\python\python_mcp download_fernflower.py
-)
-if not exist "..\runtime\bin\fernflower.jar" (
- echo Failed to download fernflower, install it manually and re-run setup.
- exit 1
-)
-
-pushd .. >nul
-
-if exist ".\src" (
- runtime\bin\python\python_mcp runtime\cleanup.py
-)
-if exist ".\src" (
- echo Please make sure to backup your modified files, and say yes when it asks you to do cleanup.
- exit 1
-)
-runtime\bin\python\python_mcp runtime\decompile.py -d -n -r
-
-pushd src >nul
-
- if exist ..\jars\minecraft_server.jar (
- for /f "delims=" %%a in ('dir /a -d /b /S ..\fml\patches\minecraft_server') do (
- pushd "%%a" 2>nul
- if errorlevel 1 (
- ..\runtime\bin\python\python_mcp ..\fml\lfcr.py "%%a" "%%a"
- ..\runtime\bin\applydiff.exe -uf -p1 -i "%%a"
- ) else popd
- )
- xcopy /Y /E ..\fml\src\* minecraft_server
- )
-popd >nul
-
-runtime\bin\python\python_mcp runtime\updatemcp.py -f
-runtime\bin\python\python_mcp runtime\updatenames.py -f
-runtime\bin\python\python_mcp runtime\updatemd5.py -f
+@set PATH=%PATH%;%SystemDir%\system32;%SystemRoot%\System32;..\runtime\bin\python
+python_mcp install.py
pause
diff --git a/fml/install/install.py b/fml/install/install.py
new file mode 100644
index 0000000000..323e47036c
--- /dev/null
+++ b/fml/install/install.py
@@ -0,0 +1,15 @@
+import os, os.path, sys
+
+fml_dir = os.path.dirname(os.path.abspath(__file__))
+mcp_dir = os.path.abspath('..')
+
+from fml import setup_fml, finish_setup_fml
+
+def main():
+ print '================ Forge ModLoader Setup Start ==================='
+ setup_fml(fml_dir, mcp_dir)
+ finish_setup_fml(fml_dir, mcp_dir)
+ print '================ Forge ModLoader Setup End ==================='
+
+if __name__ == '__main__':
+ main()
\ No newline at end of file
diff --git a/fml/install/install.sh b/fml/install/install.sh
index 1c4bd3d248..fe9f867435 100644
--- a/fml/install/install.sh
+++ b/fml/install/install.sh
@@ -1,42 +1,2 @@
#!/bin/bash
-
-echo "Forge Mod Loader Linux Setup Program"
-echo
-
-if [ ! -f ../runtime/bin/fernflower.jar ]
-then
- python download_fernflower.py
-fi
-
-if [ ! -f ../runtime/bin/fernflower.jar ]
-then
- echo "Failed to download fernflower, install it manually and re-run setup."
- exit 1
-fi
-
-pushd .. > /dev/null
-
-./cleanup.sh
-
-if [ -d "src" ]
-then
- echo "Failed to cleanup the MCP folder, please backup your modified files and run this script again and say yes when prompted."
- exit 1
-fi
-
-./decompile.sh -d -n -r
-
-pushd src > /dev/null
- if [ -f ../jars/minecraft_server.jar ];
- then
- for i in `find ../fml/patches/minecraft_server/ -type f`
- do
- patch -p1 -i $i
- done
- cp -r ../fml/src/minecraft_server/* minecraft_server
- fi
-popd > /dev/null
-
-./updatemcp.sh -f
-./updatenames.sh -f
-./updatemd5.sh -f
+python install.py
diff --git a/fml/install/lfcr.py b/fml/install/lfcr.py
deleted file mode 100755
index d48f17c7b9..0000000000
--- a/fml/install/lfcr.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#! /usr/bin/env python
-
-import sys, re, os
-data = open(sys.argv[1], "rb").read()
-newdata = re.sub("\r?\n", "\r\n", data)
-f = open(sys.argv[2], "wb")
-f.write(newdata)
-f.close()
\ No newline at end of file
From 3115f92ee4dfc78a0ad12033c350f1c543aaeb32 Mon Sep 17 00:00:00 2001
From: Christian
Date: Sat, 14 Jul 2012 13:58:46 -0400
Subject: [PATCH 21/50] Check in new fml mod work so far. Lots still to do.
---
fml/build.xml | 18 ++
.../cpw/mods/fml/common/FMLModContainer.java | 85 +-----
.../cpw/mods/fml/common/LoadController.java | 16 +
fml/common/cpw/mods/fml/common/Loader.java | 279 ++++++------------
.../cpw/mods/fml/common/LoaderState.java | 63 ++++
fml/common/cpw/mods/fml/common/Mod.java | 92 +++++-
.../cpw/mods/fml/common/ModContainer.java | 128 ++++----
.../cpw/mods/fml/common/ModDiscoverer.java | 220 ++++++++++++++
.../cpw/mods/fml/common/event/FMLEvent.java | 9 +
.../common/event/FMLInitializationEvent.java | 6 +
.../event/FMLPostInitializationEvent.java | 6 +
.../event/FMLPreInitializationEvent.java | 8 +
.../event/FMLServerInitializationEvent.java | 6 +
.../mods/fml/common/event/FMLStateEvent.java | 6 +
.../event/FMLUninitializationEvent.java | 6 +
.../modloader/ModLoaderModContainer.java | 13 +-
.../common/toposort/ModSortingException.java | 43 +++
.../fml/common/toposort/TopologicalSort.java | 4 +-
fml/eclipse/FML-Client/tstann.jpage | 3 +
fml/eclipse/FML-MockMod/.classpath | 7 +
fml/eclipse/FML-MockMod/.project | 17 ++
.../.settings/org.eclipse.jdt.core.prefs | 11 +
.../src/cpw/mods/mockmod/MockMod.java | 13 +
fml/eclipse/MCP-Client/.classpath | 25 ++
fml/eclipse/MCP-Client/.project | 56 ++++
.../.settings/org.eclipse.jdt.core.prefs | 11 +
26 files changed, 802 insertions(+), 349 deletions(-)
create mode 100644 fml/common/cpw/mods/fml/common/LoadController.java
create mode 100644 fml/common/cpw/mods/fml/common/LoaderState.java
create mode 100644 fml/common/cpw/mods/fml/common/ModDiscoverer.java
create mode 100644 fml/common/cpw/mods/fml/common/event/FMLEvent.java
create mode 100644 fml/common/cpw/mods/fml/common/event/FMLInitializationEvent.java
create mode 100644 fml/common/cpw/mods/fml/common/event/FMLPostInitializationEvent.java
create mode 100644 fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java
create mode 100644 fml/common/cpw/mods/fml/common/event/FMLServerInitializationEvent.java
create mode 100644 fml/common/cpw/mods/fml/common/event/FMLStateEvent.java
create mode 100644 fml/common/cpw/mods/fml/common/event/FMLUninitializationEvent.java
create mode 100644 fml/common/cpw/mods/fml/common/toposort/ModSortingException.java
create mode 100644 fml/eclipse/FML-Client/tstann.jpage
create mode 100644 fml/eclipse/FML-MockMod/.classpath
create mode 100644 fml/eclipse/FML-MockMod/.project
create mode 100644 fml/eclipse/FML-MockMod/.settings/org.eclipse.jdt.core.prefs
create mode 100644 fml/eclipse/FML-MockMod/src/cpw/mods/mockmod/MockMod.java
create mode 100644 fml/eclipse/MCP-Client/.classpath
create mode 100644 fml/eclipse/MCP-Client/.project
create mode 100644 fml/eclipse/MCP-Client/.settings/org.eclipse.jdt.core.prefs
diff --git a/fml/build.xml b/fml/build.xml
index 3afc5bdbd1..2bd8d87a0d 100644
--- a/fml/build.xml
+++ b/fml/build.xml
@@ -57,6 +57,8 @@
+
+
@@ -305,4 +307,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fml/common/cpw/mods/fml/common/FMLModContainer.java b/fml/common/cpw/mods/fml/common/FMLModContainer.java
index 5d501f6d74..2fe86dc644 100644
--- a/fml/common/cpw/mods/fml/common/FMLModContainer.java
+++ b/fml/common/cpw/mods/fml/common/FMLModContainer.java
@@ -52,18 +52,6 @@ public class FMLModContainer implements ModContainer
}
}
- @Override
- public boolean wantsPreInit()
- {
- return modDescriptor.wantsPreInit();
- }
-
- @Override
- public boolean wantsPostInit()
- {
- return modDescriptor.wantsPostInit();
- }
-
@Override
public void preInit()
{
@@ -94,17 +82,17 @@ public class FMLModContainer implements ModContainer
}
@Override
- public ModState getModState()
+ public LoaderState.ModState getModState()
{
// TODO Auto-generated method stub
return null;
}
-
+
@Override
public void nextState()
{
// TODO Auto-generated method stub
-
+
}
@Override
public String getSortingRules()
@@ -132,7 +120,7 @@ public class FMLModContainer implements ModContainer
// TODO Auto-generated method stub
return null;
}
-
+
@Override
public int lookupFuelValue(int itemId, int itemDamage)
{
@@ -140,13 +128,6 @@ public class FMLModContainer implements ModContainer
return 0;
}
- @Override
- public boolean wantsPickupNotification()
- {
- // TODO Auto-generated method stub
- return false;
- }
-
@Override
public IPickupNotifier getPickupNotifier()
{
@@ -154,16 +135,6 @@ public class FMLModContainer implements ModContainer
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()
*/
@@ -174,16 +145,6 @@ public class FMLModContainer implements ModContainer
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()
*/
@@ -233,16 +194,6 @@ public class FMLModContainer implements ModContainer
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()
*/
@@ -263,16 +214,6 @@ public class FMLModContainer implements ModContainer
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()
*/
@@ -283,16 +224,6 @@ public class FMLModContainer implements ModContainer
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()
*/
@@ -327,7 +258,7 @@ public class FMLModContainer implements ModContainer
public void setSourceType(SourceType type)
{
// TODO Auto-generated method stub
-
+
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#getMetadata()
@@ -352,7 +283,7 @@ public class FMLModContainer implements ModContainer
public void gatherRenderers(Map renderers)
{
// TODO Auto-generated method stub
-
+
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#requestAnimations()
@@ -361,7 +292,7 @@ public class FMLModContainer implements ModContainer
public void requestAnimations()
{
// TODO Auto-generated method stub
-
+
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#getVersion()
@@ -387,6 +318,6 @@ public class FMLModContainer implements ModContainer
@Override
public void keyBindEvent(Object keyBinding)
{
- // TODO Auto-generated method stub
+ // TODO Auto-generated method stub
}
}
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..bf5af0d709
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/LoadController.java
@@ -0,0 +1,16 @@
+package cpw.mods.fml.common;
+
+import com.google.common.eventbus.Subscribe;
+
+import cpw.mods.fml.common.event.FMLStateEvent;
+
+public class LoadController
+{
+ private static LoadController instance;
+
+ @Subscribe
+ public void loadController(FMLStateEvent event)
+ {
+
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java
index c223ea6dac..ce8b473930 100644
--- a/fml/common/cpw/mods/fml/common/Loader.java
+++ b/fml/common/cpw/mods/fml/common/Loader.java
@@ -14,7 +14,6 @@
package cpw.mods.fml.common;
import java.io.File;
-import java.io.FileFilter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -30,18 +29,16 @@ import java.util.logging.FileHandler;
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 cpw.mods.fml.common.toposort.ModSorter;
+import cpw.mods.fml.common.toposort.ModSortingException;
import cpw.mods.fml.common.toposort.TopologicalSort;
/**
* 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
+ *
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.
*
*
@@ -62,19 +59,6 @@ import cpw.mods.fml.common.toposort.TopologicalSort;
*/
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
- };
-
/**
* The singleton instance
*/
@@ -96,9 +80,9 @@ public class Loader
private static String mcsversion;
/**
- * The {@link State} of the loader
+ * The {@link LoaderState} of the loader
*/
- private State state;
+ private LoaderState state;
/**
* The class loader we load the mods into.
*/
@@ -119,6 +103,9 @@ public class Loader
* The canonical minecraft directory
*/
private File canonicalMinecraftDir;
+ /**
+ * The captured error
+ */
private Exception capturedError;
@@ -133,6 +120,34 @@ public class Loader
}
private Loader()
+ {
+ configureLogging();
+ 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(getClass().getClassLoader());
+ }
+
+ /**
+ * Configure the FML logger
+ */
+ private static void configureLogging()
{
FMLLogFormatter formatter=new FMLLogFormatter();
if (FMLCommonHandler.instance().getMinecraftLogger()!=null) {
@@ -158,26 +173,6 @@ public class Loader
{
// 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(getClass().getClassLoader());
}
/**
@@ -187,64 +182,69 @@ public class Loader
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);
-
try
{
- log.fine("Sorting mods into an ordered list");
- mods = sorter.sort();
- log.fine("Sorted mod list:");
+ 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);
+
+ try
+ {
+ log.fine("Sorting mods into an ordered list");
+ mods = sorter.sort();
+ }
+ catch (ModSortingException sortException)
+ {
+ log.severe("A dependency cycle was detected in the input mod set so an ordering cannot be determined");
+ log.severe(String.format("The visited mod list is %s",sortException.getExceptionData().getVisitedNodes()));
+ log.severe(String.format("The first mod in the cycle is %s",sortException.getExceptionData().getFirstBadNode()));
+ log.throwing("Loader", "sortModList", sortException);
+ throw new LoaderException(sortException);
+ }
+ }
+ finally
+ {
+ log.fine("Mod sorting data:");
for (ModContainer mod : mods)
{
log.fine(String.format("\t%s: %s (%s)", mod.getName(), mod.getSource().getName(), mod.getSortingRules()));
}
}
- 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).
+ * {@link LoaderState#PREINIT}. The mods are configured from their configuration data and instantiated (for BaseMod mods).
*/
private void preModInit()
{
- state = State.PREINIT;
+ state = state.transition(false);
log.fine("Beginning mod pre-initialization");
for (ModContainer mod : mods)
{
- if (mod.wantsPreInit())
+ log.finer(String.format("Pre-initializing %s", mod.getSource()));
+ try
{
- log.finer(String.format("Pre-initializing %s", mod.getSource()));
- try
- {
- mod.preInit();
- }
- 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.preInit();
}
+ 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
@@ -264,7 +264,7 @@ public class Loader
*/
private void modInit()
{
- state = State.INIT;
+ state = LoaderState.INIT;
log.fine("Beginning mod initialization");
for (ModContainer mod : mods)
@@ -279,17 +279,14 @@ public class Loader
private void postModInit()
{
- state = State.POSTINIT;
+ state = LoaderState.POSTINIT;
log.fine("Beginning mod post-initialization");
for (ModContainer mod : mods)
{
- if (mod.wantsPostInit())
- {
- log.finer(String.format("Post-initializing %s", mod.getName()));
- mod.postInit();
- mod.nextState();
- }
+ log.finer(String.format("Post-initializing %s", mod.getName()));
+ mod.postInit();
+ mod.nextState();
}
log.fine("Mod post-initialization complete");
@@ -379,7 +376,7 @@ public class Loader
throw loaderException;
}
- state = State.LOADING;
+ state = LoaderState.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()) {
@@ -421,7 +418,7 @@ public class Loader
}
else
{
- Matcher matcher = zipJar.matcher(modFile.getName());
+ Matcher matcher = ModDiscoverer.zipJar.matcher(modFile.getName());
if (matcher.matches())
{
@@ -440,67 +437,20 @@ public class Loader
}
}
- if (state == State.ERRORED)
+ if (state == LoaderState.ERRORED)
{
log.severe("A problem has occured during mod loading. Likely a corrupt jar is located in your mods directory");
throw new LoaderException(capturedError);
}
- log.info(String.format("Forge Mod Loader has loaded %d mods", mods.size()));
- }
-
- private boolean attemptDirLoad(File modDir, String path, SourceType sourceType)
- {
- if (path.length()==0) {
- extendClassLoader(modDir);
- }
- boolean foundAModClass = false;
- File[] content = modDir.listFiles(new FileFilter()
- {
- @Override
- public boolean accept(File file)
- {
- return (file.isFile() && modClass.matcher(file.getName()).find()) || file.isDirectory();
- }
- });
-
- // Always sort our content
- Arrays.sort(content);
- for (File file : content)
- {
- if (file.isDirectory()) {
- log.finest(String.format("Recursing into package %s", path+file.getName()));
- foundAModClass|=attemptDirLoad(file,path+file.getName()+".", sourceType);
- continue;
- }
- Matcher fname = modClass.matcher(file.getName());
- if (!fname.find()) {
- continue;
- }
- String clazzName=path+fname.group(2);
- try
- {
- log.fine(String.format("Found a mod class %s in directory %s, attempting to load it", clazzName, modDir.getName()));
- loadModClass(modDir, file.getName(), clazzName, sourceType);
- log.fine(String.format("Successfully loaded mod class %s", file.getName()));
- foundAModClass = true;
- }
- catch (Exception e)
- {
- log.severe(String.format("File %s failed to read properly", file.getName()));
- log.throwing("fml.server.Loader", "attemptDirLoad", e);
- state = State.ERRORED;
- capturedError = e;
- }
- }
-
- return foundAModClass;
+ log.info(String.format("Forge Mod Loader has identified %d mod%s to load", mods.size(), mods.size()!=0 ? "s": ""));
}
private void loadModClass(File classSource, String classFileName, String clazzName, SourceType sourceType)
{
try
{
+ ModHandler handler = modClassLoader.obtainClassHandlerFor(clazzName);
Class> clazz = Class.forName(clazzName, false, modClassLoader);
ModContainer mod=null;
@@ -550,55 +500,6 @@ public class Loader
}
}
- 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;
@@ -610,7 +511,7 @@ public class Loader
*/
public void loadMods()
{
- state = State.NOINIT;
+ state = LoaderState.NOINIT;
mods = new ArrayList();
namedMods = new HashMap();
load();
@@ -630,7 +531,7 @@ public class Loader
for (ModContainer mod : getModList()) {
mod.nextState();
}
- state = State.UP;
+ state = LoaderState.UP;
log.info(String.format("Forge Mod Loader load complete, %d mods loaded", mods.size()));
}
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..074f7b6328
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/LoaderState.java
@@ -0,0 +1,63 @@
+package cpw.mods.fml.common;
+
+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.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",null),
+ PREINITIALIZATION("Pre-initializing mods", FMLPreInitializationEvent.class),
+ INITIALIZATION("Initializing mods", FMLInitializationEvent.class),
+ POSTINITIALIZATION("Post-initializing mods", FMLPostInitializationEvent.class),
+ LOADCOMPLETE("Mod loading complete", null),
+ 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;
+ }
+ return values()[ordinal() < values().length ? ordinal()+1 : ordinal()];
+ }
+
+ public enum ModState
+ {
+ UNLOADED("Unloaded"),
+ LOADED("Loaded"),
+ CONSTRUCTED("Constructed"),
+ PREINITIALIZED("Pre-initialized"),
+ INITIALIZED("Initialized"),
+ POSTINITIALIZED("Post-initialized"),
+ AVAILABLE("Available");
+ 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/Mod.java b/fml/common/cpw/mods/fml/common/Mod.java
index ea6182a97c..f08bf86deb 100644
--- a/fml/common/cpw/mods/fml/common/Mod.java
+++ b/fml/common/cpw/mods/fml/common/Mod.java
@@ -13,23 +13,97 @@
*/
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;
/**
- * 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
+ * @return
+ */
+ String dependsOn() 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;
+
+ /**
+ * 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 class (extending Block) that should be created.
+ * @return
+ */
+ String typeClass();
+ /**
+ * The associated ItemBlock subtype for the item (can be null for an ItemBlock)
+ * @return
+ */
+ String itemTypeClass() default "";
+ }
+ /**
+ * 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();
+ }
+ /**
+ * Populate the annotated field with the mod instance.
+ * @author cpw
+ *
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.FIELD)
+ public @interface Instance {}
}
diff --git a/fml/common/cpw/mods/fml/common/ModContainer.java b/fml/common/cpw/mods/fml/common/ModContainer.java
index 2139c051cd..e828e29bda 100644
--- a/fml/common/cpw/mods/fml/common/ModContainer.java
+++ b/fml/common/cpw/mods/fml/common/ModContainer.java
@@ -21,9 +21,12 @@ import cpw.mods.fml.common.ModContainer.SourceType;
/**
* 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 +34,176 @@ 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;
-
- private ModState(String label) {
- this.label=label;
- }
- public String toString() {
- return this.label;
- }
- }
-
- public enum SourceType {
+ 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
+ *
* @return
*/
String getName();
+
/**
* The state of the mod
+ *
* @return
*/
- ModState getModState();
+ LoaderState.ModState getModState();
+
/**
* Move to the next mod state
*/
void nextState();
+
/**
* 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
+ *
* @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.
+ * 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).
+ * 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).
+ * 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
*/
ProxyInjector findSidedProxy();
-
+
void keyBindEvent(Object keyBinding);
}
diff --git a/fml/common/cpw/mods/fml/common/ModDiscoverer.java b/fml/common/cpw/mods/fml/common/ModDiscoverer.java
new file mode 100644
index 0000000000..68180db208
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/ModDiscoverer.java
@@ -0,0 +1,220 @@
+package cpw.mods.fml.common;
+
+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.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.collect.Lists;
+
+import cpw.mods.fml.common.ModContainer.SourceType;
+
+public class ModDiscoverer
+{
+ private class ClassFilter implements FileFilter
+ {
+ @Override
+ public boolean accept(File file)
+ {
+ return (file.isFile() && modClass.matcher(file.getName()).find()) || file.isDirectory();
+ }
+ }
+
+ private class ModCandidate
+ {
+ private File classPathRoot;
+ private File modContainer;
+ private String className;
+ private SourceType sourceType;
+
+ public ModCandidate(File classPathRoot, File modContainer, String className, SourceType sourceType)
+ {
+ this.classPathRoot = classPathRoot;
+ this.modContainer = modContainer;
+ this.className = className;
+ this.sourceType = sourceType;
+ }
+ }
+
+ private Logger log;
+
+ private File modsDir;
+
+ private static Pattern zipJar = Pattern.compile("(.+).(zip|jar)$");
+ private static Pattern classFile = Pattern.compile("([^\\s$]+).class$");
+ private static Pattern modClass = Pattern.compile("(.+/|)(mod\\_[^\\s$]+).class$");
+
+ private List candidates = Lists.newArrayList();
+
+ private void attemptDirLoad(File modDir, String path, SourceType sourceType, File dirRoot)
+ {
+ if (path.length() == 0)
+ {
+ dirRoot = modDir;
+ }
+ boolean foundAModClass = false;
+ File[] content = modDir.listFiles(new ClassFilter());
+
+ // Always sort our content
+ Arrays.sort(content);
+ for (File file : content)
+ {
+ if (file.isDirectory())
+ {
+ log.finest(String.format("Recursing into package %s", path + file.getName()));
+ attemptDirLoad(file, path + file.getName() + ".", sourceType, dirRoot);
+ continue;
+ }
+ Matcher fname = modClass.matcher(file.getName());
+ if (!fname.find())
+ {
+ continue;
+ }
+ String clazzName = path + fname.group(2);
+ log.fine(String.format("Candidate mod %s found in directory %s", clazzName, dirRoot.getName()));
+ candidates.add(new ModCandidate(dirRoot, dirRoot, clazzName, sourceType));
+ foundAModClass = true;
+ }
+ }
+
+ private void attemptFileLoad(File modFile, SourceType sourceType)
+ {
+ ZipFile jar = null;
+ try
+ {
+ jar = new ZipFile(modFile);
+
+ ZipEntry modInfo = jar.getEntry("mcmod.info");
+ if (modInfo != null)
+ {
+
+ }
+ for (ZipEntry ze : Collections.list(jar.entries()))
+ {
+ Matcher match = classFile.matcher(ze.getName());
+ if (match.matches())
+ {
+ AnnotationFinder finder = new AnnotationFinder(jar.getInputStream(ze));
+ }
+
+ match = modClass.matcher(ze.getName());
+
+ if (match.matches())
+ {
+ String pkg = match.group(1).replace('/', '.');
+ String clazzName = pkg + match.group(2);
+ log.fine(String.format("Candidate mod %s found in mod file %s", clazzName, modFile.getName()));
+ candidates.add(new ModCandidate(modFile, modFile, clazzName, sourceType));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.warning(String.format("Zip file %s failed to read properly, it will be ignored", modFile.getName()));
+ }
+ finally
+ {
+ if (jar != null)
+ {
+ try
+ {
+ jar.close();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+ }
+
+
+ public static class AnnotationFinder extends ClassVisitor
+ {
+
+ public AnnotationFinder(InputStream stream) throws IOException
+ {
+ super(Opcodes.ASM4);
+ ClassReader reader = new ClassReader(stream);
+ reader.accept(this, ClassReader.SKIP_CODE);
+ }
+
+ @Override
+ public void visit(int arg0, int arg1, String arg2, String arg3, String arg4, String[] arg5)
+ {
+ System.out.printf("ClassVisit.visit %d %d %s %s %s %s\n", arg0, arg1, arg2, arg3, arg4, Arrays.asList(arg5));
+ super.visit(arg0, arg1, arg2, arg3, arg4, arg5);
+ }
+
+ @Override
+ public void visitOuterClass(String arg0, String arg1, String arg2)
+ {
+ System.out.printf("ClassVisit.visitOuterClass %s %s %s\n", arg0, arg1, arg2);
+ super.visitOuterClass(arg0, arg1, arg2);
+ }
+
+ @Override
+ public void visitAttribute(Attribute arg0)
+ {
+ System.out.printf("ClassVisit.visitAttribute %s\n", arg0);
+ super.visitAttribute(arg0);
+ }
+
+ @Override
+ public FieldVisitor visitField(int arg0, String arg1, String arg2, String arg3, Object arg4)
+ {
+ System.out.printf("ClassVisit.visitField %d %s %s %s %s\n", arg0, arg1, arg2, arg3, arg4);
+ return new FieldVisitor(Opcodes.ASM4)
+ {
+ @Override
+ public AnnotationVisitor visitAnnotation(String arg0, boolean arg1)
+ {
+ System.out.printf("FieldVisitor.visit %s %s\n", arg0, arg1);
+ return new AnnotationVisitor(Opcodes.ASM4)
+ {
+ @Override
+ public void visit(String arg0, Object arg1)
+ {
+ System.out.printf("FieldAnnotationVisitor.visit %s %s\n", arg0, arg1);
+ super.visit(arg0, arg1);
+ }
+ };
+
+ }
+ };
+ }
+
+ @Override
+ public AnnotationVisitor visitAnnotation(String arg0, boolean arg1)
+ {
+ System.out.printf("ClassVisit.visitAnnotation %s %b\n", arg0, arg1);
+ return new AnnotationVisitor(Opcodes.ASM4)
+ {
+ @Override
+ public void visit(String arg0, Object arg1)
+ {
+ System.out.printf("ClassAnnotationVisitor.visit %s %s\n", arg0, arg1);
+ super.visit(arg0, arg1);
+ }
+
+ };
+ }
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/event/FMLEvent.java b/fml/common/cpw/mods/fml/common/event/FMLEvent.java
new file mode 100644
index 0000000000..4014f7c7e3
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/event/FMLEvent.java
@@ -0,0 +1,9 @@
+package cpw.mods.fml.common.event;
+
+public class FMLEvent
+{
+ public final String getEventType()
+ {
+ return getClass().getSimpleName();
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/event/FMLInitializationEvent.java b/fml/common/cpw/mods/fml/common/event/FMLInitializationEvent.java
new file mode 100644
index 0000000000..b136c3a4ff
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/event/FMLInitializationEvent.java
@@ -0,0 +1,6 @@
+package cpw.mods.fml.common.event;
+
+public class FMLInitializationEvent extends FMLStateEvent
+{
+
+}
diff --git a/fml/common/cpw/mods/fml/common/event/FMLPostInitializationEvent.java b/fml/common/cpw/mods/fml/common/event/FMLPostInitializationEvent.java
new file mode 100644
index 0000000000..55ea1bea34
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/event/FMLPostInitializationEvent.java
@@ -0,0 +1,6 @@
+package cpw.mods.fml.common.event;
+
+public class FMLPostInitializationEvent extends FMLStateEvent
+{
+
+}
diff --git a/fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java b/fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java
new file mode 100644
index 0000000000..244352ac16
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java
@@ -0,0 +1,8 @@
+package cpw.mods.fml.common.event;
+
+import com.google.common.eventbus.EventBus;
+
+public class FMLPreInitializationEvent extends FMLStateEvent
+{
+
+}
diff --git a/fml/common/cpw/mods/fml/common/event/FMLServerInitializationEvent.java b/fml/common/cpw/mods/fml/common/event/FMLServerInitializationEvent.java
new file mode 100644
index 0000000000..caf9f8cea3
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/event/FMLServerInitializationEvent.java
@@ -0,0 +1,6 @@
+package cpw.mods.fml.common.event;
+
+public class FMLServerInitializationEvent extends FMLStateEvent
+{
+
+}
diff --git a/fml/common/cpw/mods/fml/common/event/FMLStateEvent.java b/fml/common/cpw/mods/fml/common/event/FMLStateEvent.java
new file mode 100644
index 0000000000..121b7dfe87
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/event/FMLStateEvent.java
@@ -0,0 +1,6 @@
+package cpw.mods.fml.common.event;
+
+public class FMLStateEvent extends FMLEvent
+{
+
+}
diff --git a/fml/common/cpw/mods/fml/common/event/FMLUninitializationEvent.java b/fml/common/cpw/mods/fml/common/event/FMLUninitializationEvent.java
new file mode 100644
index 0000000000..a42704d607
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/event/FMLUninitializationEvent.java
@@ -0,0 +1,6 @@
+package cpw.mods.fml.common.event;
+
+public class FMLUninitializationEvent extends FMLStateEvent
+{
+
+}
diff --git a/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java b/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java
index 06855ae5ed..e66d185e5d 100644
--- a/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java
+++ b/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java
@@ -43,8 +43,9 @@ import cpw.mods.fml.common.IPlayerTracker;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.LoaderException;
+import cpw.mods.fml.common.LoaderState;
+import cpw.mods.fml.common.LoaderState.ModState;
import cpw.mods.fml.common.ModContainer;
-import cpw.mods.fml.common.ModContainer.ModState;
import cpw.mods.fml.common.ModContainer.SourceType;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.ProxyInjector;
@@ -60,7 +61,7 @@ public class ModLoaderModContainer implements ModContainer
private ArrayList preDependencies;
private ArrayList postDependencies;
private ArrayList keyHandlers;
- private ModState state;
+ private LoaderState.ModState state;
private SourceType sourceType;
private ModMetadata metadata;
private ProxyInjector sidedProxy;
@@ -121,7 +122,7 @@ public class ModLoaderModContainer implements ModContainer
}
@Override
- public ModState getModState()
+ public LoaderState.ModState getModState()
{
return state;
}
@@ -130,11 +131,11 @@ public class ModLoaderModContainer implements ModContainer
public void nextState()
{
if (state==null) {
- state=ModState.UNLOADED;
+ state=LoaderState.ModState.UNLOADED;
return;
}
- if (state.ordinal()+1
+ {
+ public SortingExceptionData(T node, Set visitedNodes)
+ {
+ this.firstBadNode = node;
+ this.visitedNodes = visitedNodes;
+ }
+
+ private T firstBadNode;
+ private Set visitedNodes;
+
+ public T getFirstBadNode()
+ {
+ return firstBadNode;
+ }
+ public Set getVisitedNodes()
+ {
+ return visitedNodes;
+ }
+ }
+
+ private SortingExceptionData sortingExceptionData;
+
+ public ModSortingException(String string, T node, Set visitedNodes)
+ {
+ super(string);
+ this.sortingExceptionData = new SortingExceptionData(node, visitedNodes);
+ }
+
+ public SortingExceptionData getExceptionData()
+ {
+ return sortingExceptionData;
+ }
+
+}
diff --git a/fml/common/cpw/mods/fml/common/toposort/TopologicalSort.java b/fml/common/cpw/mods/fml/common/toposort/TopologicalSort.java
index f3a03ae1d2..48a9bac688 100644
--- a/fml/common/cpw/mods/fml/common/toposort/TopologicalSort.java
+++ b/fml/common/cpw/mods/fml/common/toposort/TopologicalSort.java
@@ -39,7 +39,7 @@ public class TopologicalSort
{
private final Map> graph = new HashMap>();
private List orderedNodes = new ArrayList();
-
+
public boolean addNode(T node)
{
// Ignore nodes already added
@@ -176,7 +176,7 @@ public class TopologicalSort
}
System.out.printf("%s: %s\n%s\n%s\n", node, sortedResult, visitedNodes, expandedNodes);
- throw new IllegalArgumentException("There was a cycle detected in the input graph, sorting is not possible");
+ throw new ModSortingException("There was a cycle detected in the input graph, sorting is not possible", node, visitedNodes);
}
// Visit this node
diff --git a/fml/eclipse/FML-Client/tstann.jpage b/fml/eclipse/FML-Client/tstann.jpage
new file mode 100644
index 0000000000..bdd5a53500
--- /dev/null
+++ b/fml/eclipse/FML-Client/tstann.jpage
@@ -0,0 +1,3 @@
+java.io.FileInputStream fis = new java.io.FileInputStream(new java.io.File("/home/cpw/projects/FML/mcsnapshot/FML/eclipse/FML-MockMod/bin/cpw/mods/mockmod/MockMod.class"));
+
+cpw.mods.fml.common.ModDiscoverer.AnnotationFinder ann = new cpw.mods.fml.common.ModDiscoverer.AnnotationFinder(fis);
diff --git a/fml/eclipse/FML-MockMod/.classpath b/fml/eclipse/FML-MockMod/.classpath
new file mode 100644
index 0000000000..9fae2ab383
--- /dev/null
+++ b/fml/eclipse/FML-MockMod/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/fml/eclipse/FML-MockMod/.project b/fml/eclipse/FML-MockMod/.project
new file mode 100644
index 0000000000..cbfeeb52ee
--- /dev/null
+++ b/fml/eclipse/FML-MockMod/.project
@@ -0,0 +1,17 @@
+
+
+ FML-MockMod
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/fml/eclipse/FML-MockMod/.settings/org.eclipse.jdt.core.prefs b/fml/eclipse/FML-MockMod/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..8000cd6ca6
--- /dev/null
+++ b/fml/eclipse/FML-MockMod/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/fml/eclipse/FML-MockMod/src/cpw/mods/mockmod/MockMod.java b/fml/eclipse/FML-MockMod/src/cpw/mods/mockmod/MockMod.java
new file mode 100644
index 0000000000..c708357be9
--- /dev/null
+++ b/fml/eclipse/FML-MockMod/src/cpw/mods/mockmod/MockMod.java
@@ -0,0 +1,13 @@
+package cpw.mods.mockmod;
+
+import com.google.common.eventbus.Subscribe;
+
+import cpw.mods.fml.common.Mod;
+import cpw.mods.fml.common.Mod.Block;
+
+@Mod(modid="MockMod", name="Mock Mod",version="1.2.3", dependsOn="noone", useMetadata=true)
+public class MockMod
+{
+ @Block(typeClass="myclass",itemTypeClass="",name="MyBlock")
+ private Object myBlock;
+}
diff --git a/fml/eclipse/MCP-Client/.classpath b/fml/eclipse/MCP-Client/.classpath
new file mode 100644
index 0000000000..5618678ff1
--- /dev/null
+++ b/fml/eclipse/MCP-Client/.classpath
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fml/eclipse/MCP-Client/.project b/fml/eclipse/MCP-Client/.project
new file mode 100644
index 0000000000..1d77050e3f
--- /dev/null
+++ b/fml/eclipse/MCP-Client/.project
@@ -0,0 +1,56 @@
+
+
+ MCP-Client
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
+
+ jars
+ 2
+ MCP_LOC/jars
+
+
+ lib
+ 2
+ MCP_LOC/lib
+
+
+ minecraft
+ 2
+ MCP_LOC/src-renamed/minecraft
+
+
+ minecraft/fmlversion.properties
+ 1
+ MCP_LOC/FML/fmlversion.properties
+
+
+
+
+ 1341586110750
+ jars
+ 13
+
+ org.eclipse.ui.ide.multiFilter
+ 1.0-name-matches-false-false-bin
+
+
+
+
+
+ MCP_LOC
+ $%7BPARENT-2-WORKSPACE_LOC%7D
+
+
+
diff --git a/fml/eclipse/MCP-Client/.settings/org.eclipse.jdt.core.prefs b/fml/eclipse/MCP-Client/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..8000cd6ca6
--- /dev/null
+++ b/fml/eclipse/MCP-Client/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
From 2a19eca517b86d2958facba90a4927cb15cfe750 Mon Sep 17 00:00:00 2001
From: Christian
Date: Sun, 22 Jul 2012 11:56:38 -0230
Subject: [PATCH 22/50] Check in a lot of recent work
---
.../cpw/mods/fml/client/FMLClientHandler.java | 8 +-
.../cpw/mods/fml/client/GuiModList.java | 2 +-
.../mods/fml/client/OptifineModContainer.java | 5 +-
fml/client/net/minecraft/src/ModLoader.java | 18 +-
.../mods/fml/common/DummyModContainer.java | 113 ++++
.../cpw/mods/fml/common/FMLCommonHandler.java | 63 +-
.../mods/fml/common/FMLDummyContainer.java | 44 ++
.../cpw/mods/fml/common/FMLModContainer.java | 368 ++++-------
.../fml/common/FMLModLoaderContainer.java | 77 ---
.../cpw/mods/fml/common/LoadController.java | 109 +++-
fml/common/cpw/mods/fml/common/Loader.java | 575 ++++++++----------
.../cpw/mods/fml/common/LoaderState.java | 26 +-
.../mods/fml/common/MetadataCollection.java | 77 +++
fml/common/cpw/mods/fml/common/Mod.java | 4 +-
.../cpw/mods/fml/common/ModContainer.java | 241 +++-----
.../mods/fml/common/ModContainerFactory.java | 34 ++
.../cpw/mods/fml/common/ModDiscoverer.java | 220 -------
.../cpw/mods/fml/common/ModMetadata.java | 133 ++--
.../common/ObfuscationReflectionHelper.java | 122 ++++
.../cpw/mods/fml/common/ReflectionHelper.java | 117 ----
.../fml/common/discovery/ContainerType.java | 32 +
.../common/discovery/DirectoryDiscoverer.java | 57 ++
.../fml/common/discovery/ITypeDiscoverer.java | 14 +
.../fml/common/discovery/JarDiscoverer.java | 84 +++
.../fml/common/discovery/ModCandidate.java | 46 ++
.../fml/common/discovery/ModDiscoverer.java | 110 ++++
.../common/discovery/asm/ASMModParser.java | 113 ++++
.../common/discovery/asm/ModAnnotation.java | 50 ++
.../discovery/asm/ModAnnotationVisitor.java | 21 +
.../common/discovery/asm/ModClassVisitor.java | 50 ++
.../common/discovery/asm/ModFieldVisitor.java | 25 +
.../discovery/asm/ModMethodVisitor.java | 62 ++
.../common/event/FMLConstructionEvent.java | 25 +
.../common/event/FMLInitializationEvent.java | 8 +
.../event/FMLPostInitializationEvent.java | 8 +
.../event/FMLPreInitializationEvent.java | 8 +
.../event/FMLServerInitializationEvent.java | 6 -
.../mods/fml/common/event/FMLStateEvent.java | 11 +-
.../event/FMLUninitializationEvent.java | 6 -
.../fml/common/functions/ModIdFunction.java | 13 +
.../fml/common/functions/ModNameFunction.java | 15 +
.../modloader/ModLoaderModContainer.java | 349 +++--------
.../mods/fml/common/toposort/ModSorter.java | 13 +-
.../fml/relauncher/IClassTransformer.java | 6 +
.../fml/relauncher/RelaunchClassLoader.java | 89 ++-
.../relauncher/RelaunchLibraryManager.java | 6 +-
fml/eclipse/FML-Client/.classpath | 4 +-
fml/eclipse/FML-Client/tstann.jpage | 7 +-
.../src/net/minecraft/src/mod_testMod.java | 6 +
49 files changed, 2040 insertions(+), 1560 deletions(-)
create mode 100644 fml/common/cpw/mods/fml/common/DummyModContainer.java
create mode 100644 fml/common/cpw/mods/fml/common/FMLDummyContainer.java
delete mode 100644 fml/common/cpw/mods/fml/common/FMLModLoaderContainer.java
create mode 100644 fml/common/cpw/mods/fml/common/MetadataCollection.java
create mode 100644 fml/common/cpw/mods/fml/common/ModContainerFactory.java
delete mode 100644 fml/common/cpw/mods/fml/common/ModDiscoverer.java
create mode 100644 fml/common/cpw/mods/fml/common/ObfuscationReflectionHelper.java
delete mode 100644 fml/common/cpw/mods/fml/common/ReflectionHelper.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/ContainerType.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/ITypeDiscoverer.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/JarDiscoverer.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/ModCandidate.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/asm/ASMModParser.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/asm/ModAnnotation.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/asm/ModAnnotationVisitor.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/asm/ModClassVisitor.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/asm/ModFieldVisitor.java
create mode 100644 fml/common/cpw/mods/fml/common/discovery/asm/ModMethodVisitor.java
create mode 100644 fml/common/cpw/mods/fml/common/event/FMLConstructionEvent.java
delete mode 100644 fml/common/cpw/mods/fml/common/event/FMLServerInitializationEvent.java
delete mode 100644 fml/common/cpw/mods/fml/common/event/FMLUninitializationEvent.java
create mode 100644 fml/common/cpw/mods/fml/common/functions/ModIdFunction.java
create mode 100644 fml/common/cpw/mods/fml/common/functions/ModNameFunction.java
create mode 100644 fml/common/cpw/mods/fml/relauncher/IClassTransformer.java
diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
index 9621b7733f..46fb6dccbc 100644
--- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java
+++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java
@@ -82,7 +82,7 @@ import net.minecraft.src.WorldType;
import argo.jdom.JdomParser;
import argo.jdom.JsonNode;
import cpw.mods.fml.common.FMLCommonHandler;
-import cpw.mods.fml.common.FMLModLoaderContainer;
+import cpw.mods.fml.common.FMLDummyContainer;
import cpw.mods.fml.common.IFMLSidedHandler;
import cpw.mods.fml.common.IKeyHandler;
import cpw.mods.fml.common.Loader;
@@ -90,7 +90,7 @@ import cpw.mods.fml.common.LoaderException;
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;
@@ -167,7 +167,7 @@ public class FMLClientHandler implements IFMLSidedHandler
public void onPreLoad(Minecraft minecraft)
{
client = minecraft;
- ReflectionHelper.detectObfuscation(World.class);
+ ObfuscationReflectionHelper.detectObfuscation(World.class);
FMLCommonHandler.instance().beginLoading(this);
FMLRegistry.registerRegistry(new ClientRegistry());
try
@@ -1159,7 +1159,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);
}
diff --git a/fml/client/cpw/mods/fml/client/GuiModList.java b/fml/client/cpw/mods/fml/client/GuiModList.java
index 3ce6203c16..3d32c1f633 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;
diff --git a/fml/client/cpw/mods/fml/client/OptifineModContainer.java b/fml/client/cpw/mods/fml/client/OptifineModContainer.java
index 944dca941d..2908e05d23 100644
--- a/fml/client/cpw/mods/fml/client/OptifineModContainer.java
+++ b/fml/client/cpw/mods/fml/client/OptifineModContainer.java
@@ -19,6 +19,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
+import cpw.mods.fml.common.DummyModContainer;
import cpw.mods.fml.common.FMLModContainer;
import cpw.mods.fml.common.IConsoleHandler;
import cpw.mods.fml.common.ICraftingHandler;
@@ -35,7 +36,7 @@ import cpw.mods.fml.common.ModMetadata;
* @author cpw
*
*/
-public class OptifineModContainer extends FMLModContainer
+public class OptifineModContainer extends DummyModContainer
{
private String optifineVersion;
private ModMetadata metadata;
@@ -44,7 +45,7 @@ public class OptifineModContainer extends FMLModContainer
*/
public OptifineModContainer(Class> optifineConfig)
{
- super("Optifine");
+ super();
try
{
optifineVersion = (String) optifineConfig.getField("VERSION").get(null);
diff --git a/fml/client/net/minecraft/src/ModLoader.java b/fml/client/net/minecraft/src/ModLoader.java
index 502caebd03..1a15c4be8c 100644
--- a/fml/client/net/minecraft/src/ModLoader.java
+++ b/fml/client/net/minecraft/src/ModLoader.java
@@ -29,7 +29,7 @@ import cpw.mods.fml.common.Loader;
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.ReflectionHelper;
+import cpw.mods.fml.common.ObfuscationReflectionHelper;
public class ModLoader
{
@@ -375,7 +375,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 +384,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 +398,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);
}
/**
@@ -724,7 +724,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 +733,12 @@ public class ModLoader
*/
public static void setPrivateValue(Class super T> instanceclass, T instance, int fieldindex, E value)
{
- ReflectionHelper.setPrivateValue(instanceclass, instance, value, fieldindex);
+ 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 +747,7 @@ public class ModLoader
*/
public static void setPrivateValue(Class super T> instanceclass, T instance, String field, E value)
{
- ReflectionHelper.setPrivateValue(instanceclass, instance, value, field);
+ ObfuscationReflectionHelper.setPrivateValue(instanceclass, instance, value, field);
}
/**
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..cedcee3e21
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/DummyModContainer.java
@@ -0,0 +1,113 @@
+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;
+
+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;
+ }
+
+}
diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
index 798794c5c3..ee54ea2f4b 100644
--- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
+++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java
@@ -38,7 +38,8 @@ import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
-import cpw.mods.fml.common.ModContainer.SourceType;
+import cpw.mods.fml.common.discovery.ContainerType;
+
/**
* The main class for non-obfuscated hook handling code
@@ -550,66 +551,6 @@ public class FMLCommonHandler
return brandings.toArray(new String[brandings.size()]);
}
- /**
- * @param mod
- */
- public void loadMetadataFor(ModContainer mod)
- {
- 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);
- }
- }
- }
-
/**
* @return
*/
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/FMLModContainer.java b/fml/common/cpw/mods/fml/common/FMLModContainer.java
index 2fe86dc644..e9b76efafb 100644
--- a/fml/common/cpw/mods/fml/common/FMLModContainer.java
+++ b/fml/common/cpw/mods/fml/common/FMLModContainer.java
@@ -17,95 +17,55 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Lists;
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+
+import cpw.mods.fml.common.LoaderState.ModState;
+import cpw.mods.fml.common.discovery.ContainerType;
+import cpw.mods.fml.common.event.FMLConstructionEvent;
+
public class FMLModContainer implements ModContainer
{
private Mod modDescriptor;
private Object modInstance;
private File source;
private ModMetadata modMetadata;
+ private String className;
+ private String modId;
+ private Map descriptor;
+ private boolean enabled;
+ private List requirements;
+ private List dependencies;
+ private List dependants;
+ private boolean overridesMetadata;
+ private EventBus eventBus;
+ private LoadController controller;
- 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 void preInit()
+ public String getModId()
{
- }
-
- @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 LoaderState.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
@@ -114,210 +74,112 @@ 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 IPickupNotifier getPickupNotifier()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (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#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#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#getConsoleHandler()
- */
- @Override
- public IConsoleHandler getConsoleHandler()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (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)
- {
- this.modMetadata=meta;
- }
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#gatherRenderers(java.util.Map)
- */
- @Override
- public void gatherRenderers(Map renderers)
- {
- // TODO Auto-generated method stub
- }
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#requestAnimations()
- */
@Override
- public void requestAnimations()
+ public void bindMetadata(MetadataCollection mc)
{
- // TODO Auto-generated method stub
+ modMetadata = mc.getMetadataForId(getModId());
+
+ 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#getVersion()
- */
@Override
- public String getVersion()
+ public void setEnabledState(boolean enabled)
{
- // TODO Auto-generated method stub
- return null;
+ this.enabled = enabled;
}
- /* (non-Javadoc)
- * @see cpw.mods.fml.common.ModContainer#findSidedProxy()
- */
+
+ @Override
+ public List getRequirements()
+ {
+ return modMetadata.requiredMods;
+ }
+
+ @Override
+ public List getDependencies()
+ {
+ return modMetadata.dependencies;
+ }
+
+ @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)
+ {
+ this.eventBus = bus;
+ this.controller = controller;
+ eventBus.register(this);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ @Subscribe
+ void constructMod(FMLConstructionEvent event)
+ {
+ try
+ {
+ ModClassLoader modClassLoader = event.getModClassLoader();
+ modClassLoader.addFile(source);
+ modInstance = Class.forName(className, true, modClassLoader).newInstance();
+ }
+ catch (Exception e)
+ {
+ controller.errorOccurred(this, e);
+ Throwables.propagateIfPossible(e);
+ }
}
}
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/LoadController.java b/fml/common/cpw/mods/fml/common/LoadController.java
index bf5af0d709..8b57807341 100644
--- a/fml/common/cpw/mods/fml/common/LoadController.java
+++ b/fml/common/cpw/mods/fml/common/LoadController.java
@@ -1,16 +1,117 @@
package cpw.mods.fml.common;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Maps;
+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.FMLConstructionEvent;
import cpw.mods.fml.common.event.FMLStateEvent;
public class LoadController
{
- private static LoadController instance;
-
- @Subscribe
- public void loadController(FMLStateEvent event)
+ private Loader loader;
+ private EventBus masterChannel;
+ private ImmutableMap eventChannels;
+ private LoaderState state;
+ private Multimap modStates = HashMultimap.create();
+ private Multimap errors = HashMultimap.create();
+ private Logger log;
+ private Map modList;
+
+ public LoadController(Loader loader)
{
+ this.loader = loader;
+ this.modList = loader.getIndexedModList();
+ this.masterChannel = new EventBus("FMLMainChannel");
+ this.masterChannel.register(this);
+ this.log = Loader.log;
+
+ Builder eventBus = ImmutableMap.builder();
+
+ for (ModContainer mod : Loader.getModList())
+ {
+ EventBus bus = new EventBus(mod.getModId());
+ boolean isActive = mod.registerBus(bus, this);
+ if (isActive)
+ {
+ modStates.put(mod.getModId(), ModState.UNLOADED);
+ eventBus.put(mod.getModId(), bus);
+ }
+ else
+ {
+ modStates.put(mod.getModId(), ModState.UNLOADED);
+ modStates.put(mod.getModId(), ModState.DISABLED);
+ }
+ }
+
+ eventChannels = eventBus.build();
+
+ state = LoaderState.CONSTRUCTING;
+ }
+ public void runNextPhase(Object... eventData)
+ {
+ if (state.hasEvent())
+ {
+ masterChannel.post(state.getEvent(eventData));
+ }
+ }
+
+ public void transition()
+ {
+ state = state.transition(!errors.isEmpty());
+ }
+
+ @Subscribe
+ void propogateStateMessage(FMLStateEvent stateEvent)
+ {
+ for (Map.Entry entry : eventChannels.entrySet())
+ {
+ entry.getValue().post(stateEvent);
+ if (errors.isEmpty())
+ {
+ modStates.put(entry.getKey(), stateEvent.getModState());
+ }
+ else
+ {
+ modStates.put(entry.getKey(), ModState.ERRORED);
+ }
+ }
+ }
+
+ public void errorOccurred(ModContainer modContainer, Throwable exception)
+ {
+ errors.put(modContainer, exception);
+ }
+
+ public void log(Level level, String message, Object... rest)
+ {
+ log.log(level, String.format(message,rest));
+ }
+
+ public void log(Level level, Throwable error, String message, Object... rest)
+ {
+ log.log(level, String.format(message,rest), error);
+ }
+
+ 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));
+ }
}
}
diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java
index ce8b473930..b3fb7ad9a8 100644
--- a/fml/common/cpw/mods/fml/common/Loader.java
+++ b/fml/common/cpw/mods/fml/common/Loader.java
@@ -14,6 +14,8 @@
package cpw.mods.fml.common;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -30,45 +32,69 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
-import cpw.mods.fml.common.ModContainer.SourceType;
+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.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;
/**
* The loader class performs the actual loading of the mod code from disk.
- *
- *
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.
- *
+ *
+ *
+ * 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 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.
+ * 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.
*/
@@ -107,7 +133,8 @@ public class Loader
* The captured error
*/
private Exception capturedError;
-
+ private File canonicalModsDir;
+ private LoadController modController;
public static Loader instance()
{
@@ -122,25 +149,32 @@ public class Loader
private Loader()
{
configureLogging();
- InputStream stream = Loader.class.getClassLoader().getResourceAsStream("fmlversion.properties");
+
+ InputStream stream = getClass().getClassLoader().getResourceAsStream("fmlversion.properties");
Properties properties = new Properties();
- if (stream != null) {
- try {
+ 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);
+ }
+ catch (IOException ex)
+ {
+ Loader.log.log(Level.SEVERE, "Could not get FML version information - corrupted installation detected!", ex);
throw new LoaderException(ex);
}
}
+ major = properties.getProperty("fmlbuild.major.number", "missing");
+ minor = properties.getProperty("fmlbuild.minor.number", "missing");
+ rev = properties.getProperty("fmlbuild.revision.number", "missing");
+ build = properties.getProperty("fmlbuild.build.number", "missing");
+ mccversion = properties.getProperty("fmlbuild.mcclientversion", "missing");
+ mcsversion = properties.getProperty("fmlbuild.mcserverversion", "missing");
+
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(getClass().getClassLoader());
}
@@ -149,11 +183,14 @@ public class Loader
*/
private static void configureLogging()
{
- FMLLogFormatter formatter=new FMLLogFormatter();
- if (FMLCommonHandler.instance().getMinecraftLogger()!=null) {
+ FMLLogFormatter formatter = new FMLLogFormatter();
+ if (FMLCommonHandler.instance().getMinecraftLogger() != null)
+ {
Loader.log.setParent(FMLCommonHandler.instance().getMinecraftLogger());
- } else {
- ConsoleHandler ch=new ConsoleHandler();
+ }
+ else
+ {
+ ConsoleHandler ch = new ConsoleHandler();
Loader.log.setUseParentHandlers(false);
Loader.log.addHandler(ch);
ch.setFormatter(formatter);
@@ -162,9 +199,8 @@ public class Loader
Loader.log.setLevel(Level.ALL);
try
{
- File logPath=new File(FMLCommonHandler.instance().getMinecraftRootDirectory().getCanonicalPath(),"ForgeModLoader-%g.log");
+ 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);
@@ -176,38 +212,39 @@ public class Loader
}
/**
- * 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");
+ log.fine("Verifying mod requirements are satisfied");
try
{
for (ModContainer mod : mods)
{
- if (!namedMods.keySet().containsAll(mod.getDependencies()))
+ if (!namedMods.keySet().containsAll(mod.getRequirements()))
{
- 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);
+ log.log(Level.SEVERE, String.format("The mod %s (%s) requires mods %s to be available, one or more are not", mod.getModId(), mod.getName(), mod.getRequirements()));
throw new LoaderException();
}
}
- log.fine("All dependencies are satisfied");
+ log.fine("All mod requirements are satisfied");
+
ModSorter sorter = new ModSorter(mods, namedMods);
try
{
log.fine("Sorting mods into an ordered list");
mods = sorter.sort();
+ log.fine("Mod sorting completed successfully");
}
catch (ModSortingException sortException)
{
log.severe("A dependency cycle was detected in the input mod set so an ordering cannot be determined");
- log.severe(String.format("The visited mod list is %s",sortException.getExceptionData().getVisitedNodes()));
- log.severe(String.format("The first mod in the cycle is %s",sortException.getExceptionData().getFirstBadNode()));
+ log.severe(String.format("The visited mod list is %s", sortException.getExceptionData().getVisitedNodes()));
+ log.severe(String.format("The first mod in the cycle is %s", sortException.getExceptionData().getFirstBadNode()));
log.throwing("Loader", "sortModList", sortException);
throw new LoaderException(sortException);
}
@@ -217,98 +254,52 @@ public class Loader
log.fine("Mod sorting data:");
for (ModContainer mod : mods)
{
- log.fine(String.format("\t%s: %s (%s)", mod.getName(), mod.getSource().getName(), mod.getSortingRules()));
+ log.fine(String.format("\t%s(%s): %s (%s)", mod.getModId(), mod.getName(), mod.getSource().getName(), mod.getSortingRules()));
}
}
}
- /**
- * The first mod initialization stage, performed immediately after the jar files and mod classes are loaded,
- * {@link LoaderState#PREINIT}. The mods are configured from their configuration data and instantiated (for BaseMod mods).
- */
- private void preModInit()
- {
- state = state.transition(false);
- log.fine("Beginning mod pre-initialization");
-
- for (ModContainer mod : mods)
- {
- log.finer(String.format("Pre-initializing %s", mod.getSource()));
- try
- {
- mod.preInit();
- }
- 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");
- }
-
- /**
- * The main mod initialization stage, performed on the sorted mod list.
- */
- private void modInit()
- {
- state = LoaderState.INIT;
- log.fine("Beginning mod initialization");
-
- 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 = LoaderState.POSTINIT;
- log.fine("Beginning mod post-initialization");
-
- for (ModContainer mod : mods)
- {
- log.finer(String.format("Post-initializing %s", mod.getName()));
- mod.postInit();
- mod.nextState();
- }
-
- 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
- *
- * 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.
- *
- * Finally, if they are successfully loaded as classes, they are then added to the available mod list.
+ *
+ * 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.
+ *
+ * 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.
*/
- private void load()
+ private void identifyMods()
+ {
+ ModDiscoverer discoverer = new ModDiscoverer();
+ log.fine("Attempting to load mods contained in the minecraft jar file and associated classes");
+ discoverer.findClasspathMods(modClassLoader);
+ log.fine("Minecraft jar mods loaded successfully");
+
+ log.info(String.format("Searching %s for mods", canonicalModsDir.getAbsolutePath()));
+ discoverer.findModDirMods(canonicalModsDir);
+
+ mods = discoverer.identifyMods();
+ namedMods = Maps.uniqueIndex(mods, new ModIdFunction());
+ log.info(String.format("Forge Mod Loader has identified %d mod%s to load", mods.size(), mods.size() != 0 ? "s" : ""));
+ }
+
+ /**
+ * @return
+ */
+ private void initializeLoader()
{
File minecraftDir = FMLCommonHandler.instance().getMinecraftRootDirectory();
File modsDir = new File(minecraftDir, "mods");
@@ -322,222 +313,129 @@ 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);
+ log.log(Level.SEVERE,
+ String.format("Failed to resolve loader directories: mods : %s ; config %s", canonicalModsDir.getAbsolutePath(),
+ configDir.getAbsolutePath()), ioe);
throw new LoaderException(ioe);
}
- if (!modsDir.exists())
+ if (!canonicalModsDir.exists())
{
- log.fine(String.format("No mod directory found, creating one: %s", canonicalModsPath));
-
- try
+ log.log(Level.INFO, String.format("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);
+ log.log(Level.SEVERE, String.format("Unable to create the mod directory %s", canonicalModsPath));
+ throw new LoaderException();
}
+ log.log(Level.INFO, "Mod directory created successfully");
}
- if (!configDir.exists())
+ if (!canonicalConfigDir.exists())
{
log.fine(String.format("No config directory found, creating one: %s", canonicalConfigPath));
-
- try
+ boolean dirMade = canonicalConfigDir.mkdir();
+ if (!dirMade)
{
- configDir.mkdir();
- }
- catch (Exception e)
- {
- log.throwing("fml.server.Loader", "initialize", e);
- throw new LoaderException(e);
+ log.log(Level.SEVERE, String.format("Unable to create the config directory %s", canonicalConfigPath));
+ throw new LoaderException();
}
+ log.log(Level.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;
+ log.log(Level.SEVERE, String.format("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 = LoaderState.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);
- }
- }
-
- private void extendClassLoader(File file)
- {
- try
- {
- modClassLoader.addFile(file);
- }
- catch (MalformedURLException e)
- {
- throw new LoaderException(e);
+ log.log(Level.SEVERE, String.format("Attempting to load configuration from %s, which is not a directory", canonicalConfigPath));
+ throw new LoaderException();
}
}
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()
{
+ initializeLoader();
state = LoaderState.NOINIT;
mods = new ArrayList();
namedMods = new HashMap();
- load();
- preModInit();
+ state = LoaderState.LOADING;
+ identifyMods();
+ disableRequestedMods();
sortModList();
- // Make mod list immutable
- mods = Collections.unmodifiableList(mods);
+ mods = ImmutableList.copyOf(mods);
+ modController = new LoadController(this);
+ modController.runNextPhase(modClassLoader);
}
- /**
- * 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", "");
+ log.log(Level.FINE, String.format("Received a system property request \'%s\'",disabledModList));
+ Map sysPropertyStateList = Splitter.on(CharMatcher.anyOf(";:"))
+ .omitEmptyStrings().trimResults().withKeyValueSeparator("=")
+ .split(disabledModList);
+ log.log(Level.FINE, String.format("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())
+ {
+ log.log(Level.FINE, String.format("Found a mod state file %s", disabledModFile.getName()));
+ try
+ {
+ disabledModListProperties.load(new FileReader(disabledModFile));
+ log.log(Level.FINE, String.format("Loaded states for %d mods from file", disabledModListProperties.size()));
+ }
+ catch (Exception e)
+ {
+ log.log(Level.INFO, "An error occurred reading the fmlModState.properties file", e);
+ }
+ log.log(Level.FINE, String.format("Found a mod state file %s", disabledModFile.getName()));
+ }
+ modStates.putAll(Maps.fromProperties(disabledModListProperties));
+ modStates.putAll(sysPropertyStateList);
+ log.log(Level.FINE, String.format("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()))
+ {
+ log.log(Level.INFO, String.format("Setting mod %s to enabled state %b", entry.getKey(), entry.getValue()));
+ namedMods.get(entry.getKey()).setEnabledState(entry.getValue());
+ }
}
- state = LoaderState.UP;
- log.info(String.format("Forge Mod Loader load complete, %d mods loaded", mods.size()));
}
/**
* Query if we know of a mod named modname
- *
+ *
* @param modname
* @return
*/
@@ -556,14 +454,9 @@ 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)
- {
- ret.append(String.format("\t%s : %s (%s)\n",mod.getName(), mod.getModState(), mod.getSource().getName()));
- }
+ StringBuilder ret = new StringBuilder();
+ Joiner.on('\n').appendTo(ret, FMLCommonHandler.instance().getBrandingStrings(getFMLVersionString()));
+ modController.printModStates(ret);
return ret.toString();
}
@@ -582,4 +475,68 @@ 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));
+ String instruction = depparts.get(0);
+ String target = depparts.get(1);
+ boolean targetIsAll = target.equals("*");
+ // If we don't have two parts to each substring, this is an invalid dependency string
+ if (depparts.size() != 2)
+ {
+ 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(target);
+ }
+ else
+ {
+ 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(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(target);
+ }
+ else
+ {
+ parseFailure=true;
+ }
+ }
+
+ if (parseFailure)
+ {
+ throw new LoaderException();
+ }
+ }
+
+ public Map getIndexedModList()
+ {
+ return ImmutableMap.copyOf(namedMods);
+ }
}
diff --git a/fml/common/cpw/mods/fml/common/LoaderState.java b/fml/common/cpw/mods/fml/common/LoaderState.java
index 074f7b6328..b7e2741024 100644
--- a/fml/common/cpw/mods/fml/common/LoaderState.java
+++ b/fml/common/cpw/mods/fml/common/LoaderState.java
@@ -1,5 +1,8 @@
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.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@@ -14,7 +17,7 @@ public enum LoaderState
{
NOINIT("Uninitialized",null),
LOADING("Loading",null),
- CONSTRUCTING("Constructing mods",null),
+ CONSTRUCTING("Constructing mods",FMLConstructionEvent.class),
PREINITIALIZATION("Pre-initializing mods", FMLPreInitializationEvent.class),
INITIALIZATION("Initializing mods", FMLInitializationEvent.class),
POSTINITIALIZATION("Post-initializing mods", FMLPostInitializationEvent.class),
@@ -39,6 +42,22 @@ public enum LoaderState
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(eventData);
+ }
+ catch (Exception e)
+ {
+ throw Throwables.propagate(e);
+ }
+ }
public enum ModState
{
UNLOADED("Unloaded"),
@@ -47,7 +66,10 @@ public enum LoaderState
PREINITIALIZED("Pre-initialized"),
INITIALIZED("Initialized"),
POSTINITIALIZED("Post-initialized"),
- AVAILABLE("Available");
+ AVAILABLE("Available"),
+ DISABLED("Disabled"),
+ ERRORED("Errored");
+
private String label;
private ModState(String label)
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..589a799f2c
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/MetadataCollection.java
@@ -0,0 +1,77 @@
+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 Logger log = Loader.log;
+ private static JdomParser parser = new JdomParser();
+ private Map metadatas = Maps.newHashMap();
+ private int metadataVersion = 1;
+
+ public static MetadataCollection from(InputStream inputStream)
+ {
+ 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)
+ {
+ 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 f08bf86deb..c94a47ae49 100644
--- a/fml/common/cpw/mods/fml/common/Mod.java
+++ b/fml/common/cpw/mods/fml/common/Mod.java
@@ -44,10 +44,10 @@ public @interface Mod
*/
String version() default "";
/**
- * A simple dependency string for this mod
+ * A simple dependency string for this mod (see modloader's "priorities" string specification)
* @return
*/
- String dependsOn() default "";
+ 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.
diff --git a/fml/common/cpw/mods/fml/common/ModContainer.java b/fml/common/cpw/mods/fml/common/ModContainer.java
index e828e29bda..36298bd781 100644
--- a/fml/common/cpw/mods/fml/common/ModContainer.java
+++ b/fml/common/cpw/mods/fml/common/ModContainer.java
@@ -15,9 +15,8 @@ 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;
/**
* The container that wraps around mods in the system.
@@ -27,183 +26,121 @@ import cpw.mods.fml.common.ModContainer.SourceType;
* 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
- *
+ *
*/
public interface ModContainer
{
- public enum SourceType
- {
- JAR, CLASSPATH, DIR;
- }
-
/**
- * 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
- *
+ * The globally unique modid for this mod
+ *
* @return
*/
+ String getModId();
+
+ /**
+ * A human readable name
+ *
+ * @return
+ */
+
String getName();
/**
- * The state of the mod
- *
+ * A human readable version identifier
+ *
* @return
*/
- LoaderState.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);
-
- /**
- * The pickup notifier for this mod.
- *
- * @return
- */
- IPickupNotifier getPickupNotifier();
-
- /**
- * The dispensing handler.
- *
- * @return
- */
- IDispenseHandler getDispenseHandler();
-
- /**
- * 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();
-
- /**
- * The network handler for this mod.
- *
- * @return
- */
- INetworkHandler getNetworkHandler();
-
- /**
- * Does this mod own this channel?
- *
- * @param channel
- * @return
- */
- boolean ownsNetworkChannel(String channel);
-
- IConsoleHandler getConsoleHandler();
-
- 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
- */
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..9f1623fef1
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/ModContainerFactory.java
@@ -0,0 +1,34 @@
+package cpw.mods.fml.common;
+
+import java.io.File;
+
+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 ModContainerFactory INSTANCE = new ModContainerFactory();
+ public static ModContainerFactory instance() {
+ return INSTANCE;
+ }
+ public ModContainer build(ASMModParser modParser, File modSource)
+ {
+ if (modParser.getASMSuperType().equals(Type.getType("BaseMod")))
+ {
+ return new ModLoaderModContainer(modParser.getASMType().getClassName(), modSource);
+ }
+
+ for (ModAnnotation ann : modParser.getAnnotations())
+ {
+ if (ann.getASMType().equals(Type.getType(Mod.class)))
+ {
+ return new FMLModContainer(modParser.getASMType().getClassName(), modSource, ann.getValues());
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/fml/common/cpw/mods/fml/common/ModDiscoverer.java b/fml/common/cpw/mods/fml/common/ModDiscoverer.java
deleted file mode 100644
index 68180db208..0000000000
--- a/fml/common/cpw/mods/fml/common/ModDiscoverer.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package cpw.mods.fml.common;
-
-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.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.collect.Lists;
-
-import cpw.mods.fml.common.ModContainer.SourceType;
-
-public class ModDiscoverer
-{
- private class ClassFilter implements FileFilter
- {
- @Override
- public boolean accept(File file)
- {
- return (file.isFile() && modClass.matcher(file.getName()).find()) || file.isDirectory();
- }
- }
-
- private class ModCandidate
- {
- private File classPathRoot;
- private File modContainer;
- private String className;
- private SourceType sourceType;
-
- public ModCandidate(File classPathRoot, File modContainer, String className, SourceType sourceType)
- {
- this.classPathRoot = classPathRoot;
- this.modContainer = modContainer;
- this.className = className;
- this.sourceType = sourceType;
- }
- }
-
- private Logger log;
-
- private File modsDir;
-
- private static Pattern zipJar = Pattern.compile("(.+).(zip|jar)$");
- private static Pattern classFile = Pattern.compile("([^\\s$]+).class$");
- private static Pattern modClass = Pattern.compile("(.+/|)(mod\\_[^\\s$]+).class$");
-
- private List candidates = Lists.newArrayList();
-
- private void attemptDirLoad(File modDir, String path, SourceType sourceType, File dirRoot)
- {
- if (path.length() == 0)
- {
- dirRoot = modDir;
- }
- boolean foundAModClass = false;
- File[] content = modDir.listFiles(new ClassFilter());
-
- // Always sort our content
- Arrays.sort(content);
- for (File file : content)
- {
- if (file.isDirectory())
- {
- log.finest(String.format("Recursing into package %s", path + file.getName()));
- attemptDirLoad(file, path + file.getName() + ".", sourceType, dirRoot);
- continue;
- }
- Matcher fname = modClass.matcher(file.getName());
- if (!fname.find())
- {
- continue;
- }
- String clazzName = path + fname.group(2);
- log.fine(String.format("Candidate mod %s found in directory %s", clazzName, dirRoot.getName()));
- candidates.add(new ModCandidate(dirRoot, dirRoot, clazzName, sourceType));
- foundAModClass = true;
- }
- }
-
- private void attemptFileLoad(File modFile, SourceType sourceType)
- {
- ZipFile jar = null;
- try
- {
- jar = new ZipFile(modFile);
-
- ZipEntry modInfo = jar.getEntry("mcmod.info");
- if (modInfo != null)
- {
-
- }
- for (ZipEntry ze : Collections.list(jar.entries()))
- {
- Matcher match = classFile.matcher(ze.getName());
- if (match.matches())
- {
- AnnotationFinder finder = new AnnotationFinder(jar.getInputStream(ze));
- }
-
- match = modClass.matcher(ze.getName());
-
- if (match.matches())
- {
- String pkg = match.group(1).replace('/', '.');
- String clazzName = pkg + match.group(2);
- log.fine(String.format("Candidate mod %s found in mod file %s", clazzName, modFile.getName()));
- candidates.add(new ModCandidate(modFile, modFile, clazzName, sourceType));
- }
- }
- }
- catch (Exception e)
- {
- log.warning(String.format("Zip file %s failed to read properly, it will be ignored", modFile.getName()));
- }
- finally
- {
- if (jar != null)
- {
- try
- {
- jar.close();
- }
- catch (Exception e)
- {
- }
- }
- }
- }
-
-
- public static class AnnotationFinder extends ClassVisitor
- {
-
- public AnnotationFinder(InputStream stream) throws IOException
- {
- super(Opcodes.ASM4);
- ClassReader reader = new ClassReader(stream);
- reader.accept(this, ClassReader.SKIP_CODE);
- }
-
- @Override
- public void visit(int arg0, int arg1, String arg2, String arg3, String arg4, String[] arg5)
- {
- System.out.printf("ClassVisit.visit %d %d %s %s %s %s\n", arg0, arg1, arg2, arg3, arg4, Arrays.asList(arg5));
- super.visit(arg0, arg1, arg2, arg3, arg4, arg5);
- }
-
- @Override
- public void visitOuterClass(String arg0, String arg1, String arg2)
- {
- System.out.printf("ClassVisit.visitOuterClass %s %s %s\n", arg0, arg1, arg2);
- super.visitOuterClass(arg0, arg1, arg2);
- }
-
- @Override
- public void visitAttribute(Attribute arg0)
- {
- System.out.printf("ClassVisit.visitAttribute %s\n", arg0);
- super.visitAttribute(arg0);
- }
-
- @Override
- public FieldVisitor visitField(int arg0, String arg1, String arg2, String arg3, Object arg4)
- {
- System.out.printf("ClassVisit.visitField %d %s %s %s %s\n", arg0, arg1, arg2, arg3, arg4);
- return new FieldVisitor(Opcodes.ASM4)
- {
- @Override
- public AnnotationVisitor visitAnnotation(String arg0, boolean arg1)
- {
- System.out.printf("FieldVisitor.visit %s %s\n", arg0, arg1);
- return new AnnotationVisitor(Opcodes.ASM4)
- {
- @Override
- public void visit(String arg0, Object arg1)
- {
- System.out.printf("FieldAnnotationVisitor.visit %s %s\n", arg0, arg1);
- super.visit(arg0, arg1);
- }
- };
-
- }
- };
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(String arg0, boolean arg1)
- {
- System.out.printf("ClassVisit.visitAnnotation %s %b\n", arg0, arg1);
- return new AnnotationVisitor(Opcodes.ASM4)
- {
- @Override
- public void visit(String arg0, Object arg1)
- {
- System.out.printf("ClassAnnotationVisitor.visit %s %s\n", arg0, arg1);
- super.visit(arg0, arg1);
- }
-
- };
- }
- }
-}
diff --git a/fml/common/cpw/mods/fml/common/ModMetadata.java b/fml/common/cpw/mods/fml/common/ModMetadata.java
index c0a99422be..877950e3a8 100644
--- a/fml/common/cpw/mods/fml/common/ModMetadata.java
+++ b/fml/common/cpw/mods/fml/common/ModMetadata.java
@@ -20,53 +20,101 @@ 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 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 = Lists.newArrayList();
+ public List dependencies = Lists.newArrayList();
+ public List dependants = Lists.newArrayList();
/**
* @param mod2
* @param type2
*/
- public ModMetadata(ModContainer mod)
+ public ModMetadata(JsonNode node)
{
- this.mod=mod;
- this.type=(mod instanceof FMLModContainer ? ModType.FML : ModType.MODLOADER);
+ 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 = Optional.fromNullable((List)processedFields.get(aStringBuilder("requiredMods"))).or(requiredMods);
+ dependencies = Optional.fromNullable((List)processedFields.get(aStringBuilder("dependencies"))).or(dependencies);
+ dependants = Optional.fromNullable((List)processedFields.get(aStringBuilder("dependants"))).or(dependants);
+ useDependencyInformation = Boolean.parseBoolean(Strings.nullToEmpty((String)processedFields.get(aStringBuilder("useDependencyInformation"))));
}
-
- 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;
- }
- }
+
+ ModMetadata()
+ {
}
/**
@@ -74,31 +122,24 @@ public class ModMetadata
*/
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)
+ {
+ FMLCommonHandler.instance().getFMLLogger()
+ .log(Level.SEVERE, String.format("There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName()), e);
+ 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)
+ {
+ FMLCommonHandler.instance().getFMLLogger()
+ .log(Level.SEVERE, String.format("Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
+ throw e;
+ }
+ catch (UnableToAccessFieldException e)
+ {
+ FMLCommonHandler.instance().getFMLLogger()
+ .log(Level.SEVERE, String.format("Unable to access any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
+ 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)
+ {
+ FMLCommonHandler.instance().getFMLLogger()
+ .log(Level.SEVERE, String.format("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)
+ {
+ FMLCommonHandler.instance().getFMLLogger()
+ .log(Level.SEVERE, String.format("Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
+ throw e;
+ }
+ catch (UnableToAccessFieldException e)
+ {
+ FMLCommonHandler.instance().getFMLLogger()
+ .log(Level.SEVERE, String.format("Unable to set any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
+ 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 251da11835..0000000000
--- a/fml/common/cpw/mods/fml/common/ReflectionHelper.java
+++ /dev/null
@@ -1,117 +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;
-import java.util.Arrays;
-import java.util.logging.Level;
-
-import cpw.mods.fml.common.FMLCommonHandler;
-import cpw.mods.fml.relauncher.ReflectionHelper.UnableToAccessFieldException;
-import cpw.mods.fml.relauncher.ReflectionHelper.UnableToFindFieldException;
-/**
- * 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
- {
- return cpw.mods.fml.relauncher.ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
- }
- catch (UnableToAccessFieldException e)
- {
- FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName()), e);
- throw e;
- }
- }
-
- @SuppressWarnings("unchecked")
- public static T getPrivateValue(Class super E > classToAccess, E instance, String... fieldNames)
- {
- try
- {
- return cpw.mods.fml.relauncher.ReflectionHelper.getPrivateValue(classToAccess, instance, fieldNames);
- }
- catch (UnableToFindFieldException e)
- {
- FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
- throw e;
- }
- catch (UnableToAccessFieldException e)
- {
- FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("Unable to access any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
- 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
- {
- cpw.mods.fml.relauncher.ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
- }
- catch (UnableToAccessFieldException e)
- {
- FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("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
- {
- cpw.mods.fml.relauncher.ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldNames);
- }
- catch (UnableToFindFieldException e)
- {
- FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
- throw e;
- }
- catch (UnableToAccessFieldException e)
- {
- FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, String.format("Unable to set any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()), e);
- throw e;
- }
- }
-
- /**
- *
- */
- public static void detectObfuscation(Class> clazz)
- {
- obfuscation=!clazz.getSimpleName().equals("World");
- }
-
-}
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..f5743f0520
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java
@@ -0,0 +1,57 @@
+package cpw.mods.fml.common.discovery;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+
+import cpw.mods.fml.common.ModContainer;
+
+public class DirectoryDiscoverer implements ITypeDiscoverer
+{
+ private class ClassFilter implements FileFilter
+ {
+ @Override
+ public boolean accept(File file)
+ {
+ return (file.isFile() && modClass.matcher(file.getName()).find()) || file.isDirectory();
+ }
+ }
+
+ @Override
+ public List discover(ModCandidate candidate)
+ {
+ if (path.length() == 0)
+ {
+ dirRoot = modDir;
+
+ }
+ boolean foundAModClass = false;
+ File[] content = modDir.listFiles(new ClassFilter());
+
+ // Always sort our content
+ Arrays.sort(content);
+ for (File file : content)
+ {
+ if (file.isDirectory())
+ {
+ log.finest(String.format("Recursing into package %s", path + file.getName()));
+ attemptDirLoad(file, path + file.getName() + ".", sourceType, dirRoot);
+ continue;
+ }
+ Matcher fname = modClass.matcher(file.getName());
+ if (!fname.find())
+ {
+ continue;
+ }
+ String clazzName = path + fname.group(2);
+ log.fine(String.format("Candidate mod %s found in directory %s", clazzName, dirRoot.getName()));
+ candidates.add(new ModCandidate(sourceType, dirRoot, dirRoot, clazzName, sourceType));
+ foundAModClass = true;
+ }
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
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..d548863711
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/ITypeDiscoverer.java
@@ -0,0 +1,14 @@
+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 static Pattern modClass = Pattern.compile("(.+/|)(mod\\_[^\\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..3300d00366
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/JarDiscoverer.java
@@ -0,0 +1,84 @@
+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.Loader;
+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
+{
+ private static Logger log = Loader.log;
+ @Override
+ public List discover(ModCandidate candidate)
+ {
+ List foundMods = Lists.newArrayList();
+ log.fine(String.format("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)
+ {
+ log.finer(String.format("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);
+ if (mc!=null)
+ {
+ container.bindMetadata(mc);
+ }
+ }
+ }
+
+ match = modClass.matcher(ze.getName());
+
+ if (match.matches())
+ {
+ log.warning(String.format("Candidate mod %s found in mod file %s but is missing mod information", ze.getName().replace("/","."), candidate.getModContainer().getName()));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.warning(String.format("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..343a1e3389
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java
@@ -0,0 +1,110 @@
+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.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.collect.Lists;
+
+import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.common.ModClassLoader;
+import cpw.mods.fml.common.ModContainer;
+
+public class ModDiscoverer
+{
+ private Logger log = Loader.log;
+
+ private static Pattern zipJar = Pattern.compile("(.+).(zip|jar)$");
+
+ private List candidates = Lists.newArrayList();
+
+ public void findClasspathMods(ModClassLoader modClassLoader)
+ {
+ 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()));
+ candidates.add(new ModCandidate(minecraftSources[0], minecraftSources[0], ContainerType.JAR));
+ }
+ else
+ {
+ for (int i = 0; i < minecraftSources.length; i++)
+ {
+ if (minecraftSources[i].isFile())
+ {
+ log.fine(String.format("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())
+ {
+ log.fine(String.format("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())
+ {
+ log.fine(String.format("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())
+ {
+ log.fine(String.format("Found a candidate zip or jar file %s", matcher.group(0)));
+ candidates.add(new ModCandidate(modFile, modFile, ContainerType.JAR));
+ }
+ else
+ {
+ log.fine(String.format("Ignoring unknown file %s in mods directory", modFile.getName()));
+ }
+ }
+ }
+ }
+
+ public List identifyMods()
+ {
+ List modList = Lists.newArrayList();
+
+ for (ModCandidate candidate : candidates)
+ {
+ List mods = candidate.explore();
+ modList.addAll(mods);
+ }
+
+ 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..6ce727b1aa
--- /dev/null
+++ b/fml/common/cpw/mods/fml/common/discovery/asm/ASMModParser.java
@@ -0,0 +1,113 @@
+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;
+ }
+}
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