Update for FML- add in an info file, and change build process

This commit is contained in:
Christian Weeks 2012-06-03 00:21:20 -04:00
parent 77b6332387
commit 1286f2807e
8 changed files with 242 additions and 127 deletions

View File

@ -2,3 +2,5 @@
/*.jpage /*.jpage
bin/ bin/
/target /target
/build.properties
/build

View File

@ -7,10 +7,8 @@
cpw cpw
====================================================================== --> ====================================================================== -->
<project name="mod_IronChests" default="build"> <project name="IronChest" default="build">
<description> <description>Iron Chest</description>
Iron Chests
</description>
<macrodef name="side"> <macrodef name="side">
<attribute name="prop" /> <attribute name="prop" />
<attribute name="src" /> <attribute name="src" />
@ -23,53 +21,120 @@
<condition property="is.server"> <condition property="is.server">
<equals arg1="@{side}" arg2="server" /> <equals arg1="@{side}" arg2="server" />
</condition> </condition>
<condition property="is.bukkit">
<equals arg1="@{side}" arg2="bukkit" />
</condition>
</sequential> </sequential>
</macrodef> </macrodef>
<target name="writeversion" depends="buildenvsetup">
<exec executable="${python.exe}" dir="${basedir}" failonerror="true">
<arg value="${basedir}/getversion.py" />
</exec>
<propertyfile file="ironchestversion.properties">
<entry key="ironchest.build.number" type="int" value="${version.build}"/>
</propertyfile>
</target>
<target name="init"> <target name="buildenvsetup">
<tstamp> <tstamp>
<format pattern="yyMMddHHmmss" property="timestamp" /> <format pattern="yyMMddHHmmss" property="timestamp" />
</tstamp> </tstamp>
<property environment="env" /> <property environment="env" />
<property file="build.properties" />
<property file="ironchestversion.properties" />
<property name="modname" value="mod_ironchests" /> <property name="modname" value="mod_ironchests" />
<property name="version.major" value="3" /> <condition property="dev.home" value="${env.WORKSPACE}" else="${default.dev.home}">
<property name="version.minor" value="3" />
<property name="version.rev" value="1" />
<condition property="version.build" value="${env.BUILD_NUMBER}" else="0">
<isset property="env.BUILD_NUMBER" />
</condition>
<property name="version" value="${version.major}.${version.minor}.${version.rev}.${version.build}" />
<condition property="mcdev.home" value="${env.WORKSPACE}" else="/home/cpw/projects/mcworkspace">
<isset property="env.WORKSPACE" /> <isset property="env.WORKSPACE" />
</condition> </condition>
<condition property="mcp.home" value="${env.WORKSPACE}/mcpworkspace" else="${mcdev.home}/forge70"> <condition property="mcp.home" value="${env.WORKSPACE}/mcpworkspace" else="${default.mcp.home}">
<isset property="env.WORKSPACE" /> <isset property="env.WORKSPACE" />
</condition> </condition>
<condition property="python.exe" value="${mcp.home}/runtime/bin/python/python_mcp" else="python">
<os family="Windows" />
</condition>
<condition property="bukkitporting.dir" value="${env.WORKSPACE}/bukkitportingtools" else="${mcdev.home}/bukkitportingtools">
<isset property="env.WORKSPACE" />
</condition>
<property name="bukkit.tmpdir" location="${basedir}/build/bukkit" />
<property name="bukkit.mcp.srcdir" location="${bukkit.tmpdir}/src" />
<property name="mcp.obfoutput" location="${mcp.home}/reobf" /> <property name="mcp.obfoutput" location="${mcp.home}/reobf" />
<property name="client.mcp.obfoutput" location="${mcp.obfoutput}/minecraft" /> <property name="client.mcp.obfoutput" location="${mcp.obfoutput}/minecraft" />
<property name="server.mcp.obfoutput" location="${mcp.obfoutput}/minecraft_server" /> <property name="server.mcp.obfoutput" location="${mcp.obfoutput}/minecraft_server" />
<property name="mcp.srcdir" location="${mcp.home}/src" /> <property name="mcp.srcdir" location="${mcp.home}/src" />
<property name="client.mcp.srcdir" location="${mcp.srcdir}/minecraft" /> <property name="client.mcp.srcdir" location="${mcp.srcdir}/minecraft" />
<property name="server.mcp.srcdir" location="${mcp.srcdir}/minecraft_server" /> <property name="server.mcp.srcdir" location="${mcp.srcdir}/minecraft_server" />
<property name="deploy.dir" location="${user.home}/.minecraft/mods" />
<property name="common.src.dir" location="${basedir}/common" /> <property name="common.src.dir" location="${basedir}/common" />
<property name="client.src.dir" location="${basedir}/client" /> <property name="client.src.dir" location="${basedir}/client" />
<property name="server.src.dir" location="${basedir}/server" /> <property name="server.src.dir" location="${basedir}/server" />
<property name="deploy.dir" location="${user.home}/.minecraft/mods" />
<property name="bukkit.src.dir" location="${server.src.dir}" />
<property name="resource.dir" location="${basedir}/resources" /> <property name="resource.dir" location="${basedir}/resources" />
<property name="mfuploader.script" location="/home/cpw/mfuploader.py" /> <property name="bukkitporting.srgtools" location="${bukkitporting.dir}/bin/SrgTools.jar" />
<property name="bukkitporting.asm" location="${bukkitporting.dir}/bin/asm-all-3.3.1.jar" />
<property name="bukkitporting.translatedjar" location="${bukkitporting.dir}/jar/generated/craftbukkit-1.2.5-R1.1-MCPC-SNAPSHOT-73.MCP.jar" />
<property name="bukkitporting.srg" location="${bukkitporting.dir}/mappings/generated/server_mcp_bukkit_1.2.5.srg" />
<property name="bukkit.mcp.jar" location="${bukkitporting.translatedjar}" />
<condition property="version.build" value="${env.BUILD_NUMBER}" else="1">
<isset property="env.BUILD_NUMBER" />
</condition>
</target> </target>
<target name="init" depends="buildenvsetup">
<antcall target="writeversion" />
<property file="ironchestversion.properties" />
<property name="build.number" value="${ironchest.build.major.number}.${ironchest.build.minor.number}.${ironchest.build.revision.number}" />
<property name="version.minecraft" value="${ironchest.build.mcversion}" />
<property name="version.major" value="${ironchest.build.major.number}" />
<property name="version.minor" value="${ironchest.build.minor.number}" />
<property name="version.rev" value="${ironchest.build.revision.number}" />
<property name="version" value="${version.major}.${version.minor}.${version.rev}.${version.build}" />
</target>
<target name="clean"> <target name="clean">
<delete dir="${bukkit.tmpdir}"/>
<antcall target="clean-source"> <antcall target="clean-source">
<param name="side" value="client" /> <param name="side" value="client" />
</antcall> </antcall>
<antcall target="clean-source"> <antcall target="clean-source">
<param name="side" value="server" /> <param name="side" value="server" />
</antcall> </antcall>
<exec executable="${mcp.home}/updatemd5.sh" dir="${mcp.home}"> <exec executable="${python.exe}" dir="${mcp.home}">
<arg value="${mcp.home}/runtime/updatemd5.py" />
<arg value="-f" /> <arg value="-f" />
</exec> </exec>
</target> </target>
<target name="buildandreobfmcp" depends="init">
<exec executable="${python.exe}" dir="${mcp.home}" failonerror="true">
<arg value="${mcp.home}/runtime/recompile.py" />
</exec>
<exec executable="${python.exe}" dir="${mcp.home}">
<arg value="${mcp.home}/runtime/reobfuscate.py" />
</exec>
</target>
<target name="merge-client" depends="init,clean">
<antcall target="merge-source">
<param name="side" value="client" />
</antcall>
</target>
<target name="merge-server" depends="init,clean">
<antcall target="merge-source">
<param name="side" value="server" />
</antcall>
</target>
<target name="merge-source">
<side prop="merge-to" src="mcp.srcdir" side="${side}" />
<side prop="side-from" src="src.dir" side="${side}" />
<copy todir="${merge-to}" overwrite="true" verbose="true">
<fileset dir="${side-from}" includes="**/*.java" />
<fileset dir="${common.src.dir}" includes="**/*.java" />
</copy>
</target>
<target name="build-client" depends="init,clean,merge-client,buildandreobfmcp"> <target name="build-client" depends="init,clean,merge-client,buildandreobfmcp">
<antcall target="extract-built-jar"> <antcall target="extract-built-jar">
<param name="side" value="client" /> <param name="side" value="client" />
@ -88,6 +153,18 @@
<mkdir dir="${basedir}/target" /> <mkdir dir="${basedir}/target" />
<jar destfile="${basedir}/target/${jarname}.zip"> <jar destfile="${basedir}/target/${jarname}.zip">
<fileset dir="${output}" includes="**/*.class" /> <fileset dir="${output}" includes="**/*.class" />
<zipfileset dir="${basedir}" includes="ironchestversion.properties"/>
<mappedresources>
<concat>
<fileset dir="${basedir}" includes="mcmod.info" />
<filterchain>
<replacetokens>
<token key="VERSION" value="${version}" />
</replacetokens>
</filterchain>
</concat>
<mergemapper to="mcmod.info" />
</mappedresources>
<fileset dir="${resource.dir}" erroronmissingdir="false"> <fileset dir="${resource.dir}" erroronmissingdir="false">
<selector if="is.client"> <selector if="is.client">
<filename name="**/*.png" /> <filename name="**/*.png" />
@ -98,22 +175,6 @@
<target name="build" depends="merge-client,merge-server,build-client,build-server" /> <target name="build" depends="merge-client,merge-server,build-client,build-server" />
<target name="uploadartifacts" depends="build,domfupload"/>
<target name="domfupload" depends="-checkmfupload" if="${mfuploader.can.run}">
<property name="uploaddir" value="${modname}-${version}" />
<exec executable="/usr/bin/python">
<arg value="${mfuploader.script}"/>
<arg value="${uploaddir}"/>
<arg value="${basedir}/target/${modname}-client-${version}.zip"/>
<arg value="${basedir}/target/${modname}-server-${version}.zip"/>
</exec>
</target>
<target name="-checkmfupload" unless="mfuploader.can.run">
<available property="mfuploader.can.run" file="${mfuploader.script}"/>
</target>
<target name="buildandclean" depends="build"> <target name="buildandclean" depends="build">
<antcall target="clean" /> <antcall target="clean" />
</target> </target>
@ -132,41 +193,44 @@
</delete> </delete>
</target> </target>
<target name="merge-source"> <target name="compile-bukkit" depends="init">
<side prop="merge-to" src="mcp.srcdir" side="${side}" /> <mkdir dir="${bukkit.tmpdir}" />
<side prop="side-from" src="src.dir" side="${side}" />
<copy todir="${merge-to}" overwrite="true" verbose="true">
<fileset dir="${side-from}" includes="**/*.java" />
<fileset dir="${common.src.dir}" includes="**/*.java" />
<filterchain>
<replacetokens>
<token key="MAJOR" value="${version.major}" />
<token key="MINOR" value="${version.minor}" />
<token key="REV" value="${version.rev}" />
<token key="BUILD" value="${version.build}" />
</replacetokens>
</filterchain>
</copy>
</target>
<target name="merge-client" depends="init,clean">
<antcall target="merge-source"> <antcall target="merge-source">
<param name="side" value="client" /> <param name="side" value="bukkit" />
</antcall> </antcall>
<mkdir dir="${bukkit.tmpdir}/compiled" />
<javac target="1.6" source="1.6" destdir="${bukkit.tmpdir}/compiled">
<src path="${bukkit.mcp.srcdir}" />
<classpath path="${bukkit.mcp.jar}" />
</javac>
</target> </target>
<target name="merge-server" depends="init,clean"> <target name="jar-bukkit" depends="init,compile-bukkit">
<antcall target="merge-source"> <jar destfile="${bukkit.tmpdir}/${modname}-bukkit-tmp.jar" basedir="${bukkit.tmpdir}/compiled" />
<param name="side" value="server" />
</antcall>
</target> </target>
<target name="buildandreobfmcp" depends="init"> <target name="translate-bukkit" depends="init,jar-bukkit">
<exec executable="${mcp.home}/recompile.sh" dir="${mcp.home}" /> <mkdir dir="${basedir}/target" />
<exec executable="${mcp.home}/reobfuscate.sh" dir="${mcp.home}" /> <java classname="nl.hardijzer.fw.applysrg.ApplySrg" failonerror="true" fork="true">
<classpath>
<pathelement location="${bukkitporting.asm}" />
<pathelement location="${bukkitporting.srgtools}" />
</classpath>
<arg value="--srg" />
<arg value="${bukkitporting.srg}" />
<arg value="--inheritance" />
<arg value="${bukkit.mcp.jar}" />
<arg value="--inheritance" />
<arg value="${bukkit.tmpdir}/${modname}-bukkit-tmp.jar" />
<arg value="--in" />
<arg value="${bukkit.tmpdir}/${modname}-bukkit-tmp.jar" />
<arg value="--out" />
<arg value="${basedir}/target/${modname}-bukkit-${version}.jar" />
</java>
</target> </target>
<target name="build-bukkit" depends="init,translate-bukkit"/>
<target name="deploy" depends="init,build-client"> <target name="deploy" depends="init,build-client">
<property name="jarname" value="${modname}-client-${version}" /> <property name="jarname" value="${modname}-client-${version}" />
<move file="${deploy.dir}/${jarname}.zip" tofile="${deploy.dir}/${jarname}.zip.${timestamp}" failonerror="false" verbose="true" /> <move file="${deploy.dir}/${jarname}.zip" tofile="${deploy.dir}/${jarname}.zip.${timestamp}" failonerror="false" verbose="true" />

View File

@ -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();
}
}
}

View File

@ -233,7 +233,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
super.updateEntity(); super.updateEntity();
// Resynchronize clients with the server state // Resynchronize clients with the server state
if ((++ticksSinceSync % 20) * 4 == 0) { 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) { if (inventoryTouched) {
inventoryTouched = false; inventoryTouched = false;
sortTopStacks(); sortTopStacks();
@ -268,8 +268,9 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
} }
} }
@Override @Override
public void onTileEntityPowered(int i, int j) public void receiveClientEvent(int i, int j)
{ {
if (i == 1) if (i == 1)
{ {
@ -287,7 +288,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
if (worldObj == null) if (worldObj == null)
return; return;
numUsingPlayers++; numUsingPlayers++;
worldObj.playNoteAt(xCoord, yCoord, zCoord, 1, numUsingPlayers); worldObj.sendClientEvent(xCoord, yCoord, zCoord, 1, numUsingPlayers);
} }
@Override @Override
@ -295,7 +296,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
if (worldObj == null) if (worldObj == null)
return; return;
numUsingPlayers--; numUsingPlayers--;
worldObj.playNoteAt(xCoord, yCoord, zCoord, 1, numUsingPlayers); worldObj.sendClientEvent(xCoord, yCoord, zCoord, 1, numUsingPlayers);
} }
public void setFacing(byte chestFacing) { public void setFacing(byte chestFacing) {

View File

@ -1,27 +1,49 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 cpw. * 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
* All rights reserved. This program and the accompanying materials * which accompanies this distribution, and is available at http://www.gnu.org/licenses/gpl.html
* 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: * Contributors: cpw - initial API and implementation
* cpw - initial API and implementation
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest; 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 class Version {
public static final String MAJOR="@MAJOR@"; private static String major;
public static final String MINOR="@MINOR@"; private static String minor;
public static final String REV="@REV@"; private static String rev;
public static final String BUILD="@BUILD@"; private static String build;
private static String mcversion;
public static final String version() { private static boolean loaded;
return MAJOR+"."+MINOR;
} private static void init() {
InputStream stream = Version.class.getClassLoader().getResourceAsStream("ironchestversion.properties");
public static final String name() { Properties properties = new Properties();
return "Iron Chest ("+MAJOR+"."+MINOR+") rev "+REV+" build "+BUILD;
} 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;
}
} }

View File

@ -24,13 +24,13 @@ import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.ItemChestChanger; import cpw.mods.ironchest.ItemChestChanger;
import cpw.mods.ironchest.ItemIronChest; import cpw.mods.ironchest.ItemIronChest;
import cpw.mods.ironchest.PacketHandler; import cpw.mods.ironchest.PacketHandler;
import cpw.mods.ironchest.ServerClientProxy;
import cpw.mods.ironchest.Version; import cpw.mods.ironchest.Version;
public class mod_IronChest extends NetworkMod { public class mod_IronChest extends NetworkMod {
public static BlockIronChest ironChestBlock; public static BlockIronChest ironChestBlock;
public static ItemChestChanger itemChestChanger; public static ItemChestChanger itemChestChanger;
@SidedProxy(clientSide="cpw.mods.ironchest.client.ClientProxy", serverSide="cpw.mods.ironchest.server.ServerProxy")
public static IProxy proxy; public static IProxy proxy;
public static mod_IronChest instance; public static mod_IronChest instance;
@ -41,9 +41,8 @@ public class mod_IronChest extends NetworkMod {
@Override @Override
public void load() { public void load() {
MinecraftForge.versionDetect("IronChest", 3, 0, 1); MinecraftForge.versionDetect("IronChest", 3, 2, 4);
instance = this; instance = this;
proxy = ServerClientProxy.getProxy();
File cfgFile = new File(proxy.getMinecraftDir(), "config/IronChest.cfg"); File cfgFile = new File(proxy.getMinecraftDir(), "config/IronChest.cfg");
Configuration cfg = new Configuration(cfgFile); Configuration cfg = new Configuration(cfgFile);
try { try {

46
IronChests2/getversion.py Normal file
View File

@ -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()

22
IronChests2/mcmod.info Normal file
View File

@ -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": [
]
}
]