From 1286f2807e433413017714cdd3eb659f145bf014 Mon Sep 17 00:00:00 2001 From: Christian Weeks Date: Sun, 3 Jun 2012 00:21:20 -0400 Subject: [PATCH] Update for FML- add in an info file, and change build process --- IronChests2/.gitignore | 2 + IronChests2/build.xml | 184 ++++++++++++------ .../cpw/mods/ironchest/ServerClientProxy.java | 41 ---- .../mods/ironchest/TileEntityIronChest.java | 9 +- .../common/cpw/mods/ironchest/Version.java | 60 ++++-- .../net/minecraft/src/mod_IronChest.java | 5 +- IronChests2/getversion.py | 46 +++++ IronChests2/mcmod.info | 22 +++ 8 files changed, 242 insertions(+), 127 deletions(-) delete mode 100644 IronChests2/common/cpw/mods/ironchest/ServerClientProxy.java create mode 100644 IronChests2/getversion.py create mode 100644 IronChests2/mcmod.info diff --git a/IronChests2/.gitignore b/IronChests2/.gitignore index bef1158..a5b72b5 100644 --- a/IronChests2/.gitignore +++ b/IronChests2/.gitignore @@ -2,3 +2,5 @@ /*.jpage bin/ /target +/build.properties +/build diff --git a/IronChests2/build.xml b/IronChests2/build.xml index 39b11c7..8226542 100644 --- a/IronChests2/build.xml +++ b/IronChests2/build.xml @@ -7,10 +7,8 @@ cpw ====================================================================== --> - - - Iron Chests - + + Iron Chest @@ -23,53 +21,120 @@ + + + + + + + + + + + - + + + - - - - - - - - + - + + + + + + + + + - + + - + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -88,6 +153,18 @@ + + + + + + + + + + + + @@ -98,22 +175,6 @@ - - - - - - - - - - - - - - - - @@ -132,41 +193,44 @@ - - - - - - - - - - - - - - - - - - - + + - + + + + + + - - - - + + - - - + + + + + + + + + + + + + + + + + + + + diff --git a/IronChests2/common/cpw/mods/ironchest/ServerClientProxy.java b/IronChests2/common/cpw/mods/ironchest/ServerClientProxy.java deleted file mode 100644 index 6bd1065..0000000 --- a/IronChests2/common/cpw/mods/ironchest/ServerClientProxy.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 cpw. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - * - * Contributors: - * cpw - initial API and implementation - ******************************************************************************/ -package cpw.mods.ironchest; - -import net.minecraft.src.ModLoader; -import net.minecraft.src.forge.MinecraftForge; - -public enum ServerClientProxy { - CLIENT("cpw.mods.ironchest.client.ClientProxy"), - SERVER("cpw.mods.ironchest.server.ServerProxy"); - - private String className; - private ServerClientProxy(String proxyClassName) { - className=proxyClassName; - } - - private IProxy buildProxy() { - try { - return (IProxy) Class.forName(className).newInstance(); - } catch (Exception e) { - ModLoader.getLogger().severe("A fatal error has occured initializing IronChests"); - e.printStackTrace(System.err); - throw new RuntimeException(e); - } - } - public static IProxy getProxy() { - if (MinecraftForge.isClient()) { - return CLIENT.buildProxy(); - } else { - return SERVER.buildProxy(); - } - } -} diff --git a/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java b/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java index 710f5b4..2b3d7b4 100644 --- a/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java +++ b/IronChests2/common/cpw/mods/ironchest/TileEntityIronChest.java @@ -233,7 +233,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory { super.updateEntity(); // Resynchronize clients with the server state if ((++ticksSinceSync % 20) * 4 == 0) { - worldObj.playNoteAt(xCoord, yCoord, zCoord, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7)); + worldObj.sendClientEvent(xCoord, yCoord, zCoord, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7)); if (inventoryTouched) { inventoryTouched = false; sortTopStacks(); @@ -268,8 +268,9 @@ public class TileEntityIronChest extends TileEntity implements IInventory { } } + @Override - public void onTileEntityPowered(int i, int j) + public void receiveClientEvent(int i, int j) { if (i == 1) { @@ -287,7 +288,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory { if (worldObj == null) return; numUsingPlayers++; - worldObj.playNoteAt(xCoord, yCoord, zCoord, 1, numUsingPlayers); + worldObj.sendClientEvent(xCoord, yCoord, zCoord, 1, numUsingPlayers); } @Override @@ -295,7 +296,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory { if (worldObj == null) return; numUsingPlayers--; - worldObj.playNoteAt(xCoord, yCoord, zCoord, 1, numUsingPlayers); + worldObj.sendClientEvent(xCoord, yCoord, zCoord, 1, numUsingPlayers); } public void setFacing(byte chestFacing) { diff --git a/IronChests2/common/cpw/mods/ironchest/Version.java b/IronChests2/common/cpw/mods/ironchest/Version.java index 5d8e96c..0884f5c 100644 --- a/IronChests2/common/cpw/mods/ironchest/Version.java +++ b/IronChests2/common/cpw/mods/ironchest/Version.java @@ -1,27 +1,49 @@ /******************************************************************************* - * Copyright (c) 2012 cpw. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html + * Copyright (c) 2012 cpw. All rights reserved. This program and the accompanying materials are made available under the terms of the GNU Public License v3.0 + * which accompanies this distribution, and is available at http://www.gnu.org/licenses/gpl.html * - * Contributors: - * cpw - initial API and implementation + * Contributors: cpw - initial API and implementation ******************************************************************************/ package cpw.mods.ironchest; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; +import java.util.logging.Level; + +import cpw.mods.fml.common.FMLCommonHandler; public class Version { - public static final String MAJOR="@MAJOR@"; - public static final String MINOR="@MINOR@"; - public static final String REV="@REV@"; - public static final String BUILD="@BUILD@"; - - public static final String version() { - return MAJOR+"."+MINOR; - } - - public static final String name() { - return "Iron Chest ("+MAJOR+"."+MINOR+") rev "+REV+" build "+BUILD; - } + private static String major; + private static String minor; + private static String rev; + private static String build; + private static String mcversion; + private static boolean loaded; + + private static void init() { + InputStream stream = Version.class.getClassLoader().getResourceAsStream("ironchestversion.properties"); + Properties properties = new Properties(); + + if (stream != null) { + try { + properties.load(stream); + major = properties.getProperty("ironchest.build.major.number"); + minor = properties.getProperty("ironchest.build.minor.number"); + rev = properties.getProperty("ironchest.build.revision.number"); + build = properties.getProperty("ironchest.build.build.number"); + mcversion = properties.getProperty("ironchest.build.mcversion"); + } catch (IOException ex) { + FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE, "Could not get IronChest version information - corrupted installation detected!", ex); + throw new RuntimeException(ex); + } + } + loaded = true; + } + public static final String version() { + if (!loaded) { + init(); + } + return major+"."+minor+"."+rev; + } } diff --git a/IronChests2/common/net/minecraft/src/mod_IronChest.java b/IronChests2/common/net/minecraft/src/mod_IronChest.java index 6a921d5..ba5d61a 100644 --- a/IronChests2/common/net/minecraft/src/mod_IronChest.java +++ b/IronChests2/common/net/minecraft/src/mod_IronChest.java @@ -24,13 +24,13 @@ import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.ItemChestChanger; import cpw.mods.ironchest.ItemIronChest; import cpw.mods.ironchest.PacketHandler; -import cpw.mods.ironchest.ServerClientProxy; import cpw.mods.ironchest.Version; public class mod_IronChest extends NetworkMod { public static BlockIronChest ironChestBlock; public static ItemChestChanger itemChestChanger; + @SidedProxy(clientSide="cpw.mods.ironchest.client.ClientProxy", serverSide="cpw.mods.ironchest.server.ServerProxy") public static IProxy proxy; public static mod_IronChest instance; @@ -41,9 +41,8 @@ public class mod_IronChest extends NetworkMod { @Override public void load() { - MinecraftForge.versionDetect("IronChest", 3, 0, 1); + MinecraftForge.versionDetect("IronChest", 3, 2, 4); instance = this; - proxy = ServerClientProxy.getProxy(); File cfgFile = new File(proxy.getMinecraftDir(), "config/IronChest.cfg"); Configuration cfg = new Configuration(cfgFile); try { diff --git a/IronChests2/getversion.py b/IronChests2/getversion.py new file mode 100644 index 0000000..5b10b65 --- /dev/null +++ b/IronChests2/getversion.py @@ -0,0 +1,46 @@ +import sys +import os +import commands +import fnmatch +import re +import subprocess, shlex + +def cmdsplit(args): + if os.sep == '\\': + args = args.replace('\\', '\\\\') + return shlex.split(args) + +def cleanDirs(path): + if not os.path.isdir(path): + return + + files = os.listdir(path) + if len(files): + for f in files: + fullpath = os.path.join(path, f) + if os.path.isdir(fullpath): + cleanDirs(fullpath) + + files = os.listdir(path) + if len(files) == 0: + os.rmdir(path) + +def main(): + print("Obtaining version information from git") + cmd = "git describe --long --match='[^(jenkins)]*'" + try: + process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1) + vers, _ = process.communicate() + except OSError: + print("Git not found") + vers="v1.0-0-deadbeef" + (major,minor,rev,githash)=re.match("v(\d+).(\d+)-(\d+)-(.*)",vers).groups() + with open("ironchestversion.properties","w") as f: + f.write("%s=%s\n" %("ironchest.build.major.number",major)) + f.write("%s=%s\n" %("ironchest.build.minor.number",minor)) + f.write("%s=%s\n" %("ironchest.build.revision.number",rev)) + f.write("%s=%s\n" %("ironchest.build.githash",githash)) + f.write("%s=%s\n" %("ironchest.build.mcversion","1.2.5")) + +if __name__ == '__main__': + main() diff --git a/IronChests2/mcmod.info b/IronChests2/mcmod.info new file mode 100644 index 0000000..fa25c38 --- /dev/null +++ b/IronChests2/mcmod.info @@ -0,0 +1,22 @@ +[ +{ + "modid": "mod_IronChest", + "name": "Iron Chest", + "description": "New chests with larger sizes, with in-place upgrade items. + The feature chest is the crystal chest, which is transparent - some inventory contents are visible without opening the chest", + "version": "@VERSION@", + "mcversion": "1.2.5", + "url": "http://www.minecraftforum.net/topic/981855-", + "updateUrl": "", + "authors": [ + "cpw" + ], + "credits": "By cpw, based on an original idea by Lishid", + "logo": "", + "screenshots": [ + ], + "parent":"", + "dependencies": [ + ] +} +] \ No newline at end of file