mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-14 09:05:17 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25981706ef | ||
|
|
82d896a35e | ||
|
|
e7dd728f95 | ||
|
|
8f2e675581 | ||
|
|
ff75416a32 | ||
|
|
95afc95b24 | ||
|
|
34493b0d99 | ||
|
|
e77d2547ad | ||
|
|
40a34af431 | ||
|
|
352117fd78 | ||
|
|
81328b6684 | ||
|
|
b5af446d71 | ||
|
|
d0c6e92900 | ||
|
|
2a9c485edc | ||
|
|
a13598b17e | ||
|
|
40b54013b4 | ||
|
|
1c9a853868 | ||
|
|
da70cdd35a | ||
|
|
b993cf4a98 | ||
|
|
ac065ff5f7 | ||
|
|
913f6f6d36 | ||
|
|
9468e41bbf | ||
|
|
ffdd056a18 | ||
|
|
f157e7a6ec | ||
|
|
4a9d0f9bd5 | ||
|
|
0398916666 | ||
|
|
dec9a3924d | ||
|
|
2470120680 | ||
|
|
ba90b61607 | ||
|
|
9a5e24e338 | ||
|
|
29ef3d5ab4 | ||
|
|
f46a538b41 | ||
|
|
182aa9c0cb | ||
|
|
1857064afa | ||
|
|
cb05c8c4aa | ||
|
|
f275a24b43 | ||
|
|
1d84e8063e | ||
|
|
57befa89bb | ||
|
|
10b16d32da | ||
|
|
3f21a2c1b4 | ||
|
|
b2958c9066 | ||
|
|
9520978b81 | ||
|
|
4981aa3421 | ||
|
|
c48b48ee15 | ||
|
|
9947ba8503 | ||
|
|
a3f48734ff | ||
|
|
0378355c37 | ||
|
|
c625ef3009 | ||
|
|
d4b30422b6 | ||
|
|
6de36d78f5 | ||
|
|
7348929819 | ||
|
|
b9f4b02cb0 | ||
|
|
20e93a412e | ||
|
|
e44e8b3112 | ||
|
|
bab4d87ce7 | ||
|
|
bc9d1fe657 | ||
|
|
d4d522c597 | ||
|
|
97269a5e3d | ||
|
|
c913258ca3 | ||
|
|
c7ab872c85 | ||
|
|
e91431fb70 | ||
|
|
dfa3a2665d | ||
|
|
4fa375683f | ||
|
|
0db4624b27 | ||
|
|
c997f2adbc | ||
|
|
26e5f4b4ff | ||
|
|
2336002f20 | ||
|
|
e88a0cd13f | ||
|
|
dbf5fe38ce | ||
|
|
c47d08c89d | ||
|
|
7af5c21d74 | ||
|
|
6f96d89e2b | ||
|
|
111b0216fd | ||
|
|
1d0384f8f6 | ||
|
|
adc8972277 | ||
|
|
5990e29af7 | ||
|
|
2676c8999c | ||
|
|
3a200e901e | ||
|
|
c97ac284a5 | ||
|
|
54e06e841d | ||
|
|
7ce84491d1 | ||
|
|
532bee7ce1 | ||
|
|
e24f949517 | ||
|
|
4545beb49d | ||
|
|
3f4bf61ae6 | ||
|
|
155e846818 | ||
|
|
ba3707af22 | ||
|
|
ad79b9ed86 | ||
|
|
5f7df5e742 | ||
|
|
7aa7221756 | ||
|
|
8844554da6 | ||
|
|
6f0eedc9a6 | ||
|
|
f21cd286ca | ||
|
|
f1b533ad87 | ||
|
|
5a97d183df | ||
|
|
fbd57b3264 | ||
|
|
efc369ee83 | ||
|
|
91ecf71109 | ||
|
|
9b6525e805 | ||
|
|
dc7d02ebf6 | ||
|
|
7037184a4e | ||
|
|
bf38d94756 | ||
|
|
3d17434510 | ||
|
|
29d6c875d0 | ||
|
|
902772ed0c | ||
|
|
1229c4c4ea | ||
|
|
7fecf2ad6b | ||
|
|
c418da353f | ||
|
|
110cf372eb | ||
|
|
7a004087f7 | ||
|
|
70cfe24e67 | ||
|
|
8960f6869f | ||
|
|
71a92de5d9 | ||
|
|
3f15cd54c2 | ||
|
|
12c928c538 | ||
|
|
7406b38d8a | ||
|
|
ef646d3146 | ||
|
|
18371bd8c9 | ||
|
|
e35e4b16ff | ||
|
|
3711da9c45 | ||
|
|
6a318ddb78 | ||
|
|
2766f9a293 | ||
|
|
2e3f2461fa | ||
|
|
95f7345ff7 | ||
|
|
bc02f3e67b | ||
|
|
8db42c44bf | ||
|
|
404e6f1cc0 | ||
|
|
5741f669d5 | ||
|
|
6a67149b16 | ||
|
|
c8d934bafd | ||
|
|
075e240303 | ||
|
|
d00665ee65 | ||
|
|
ebb74a5f30 | ||
|
|
5b0117ec76 | ||
|
|
e06d9d0fbc | ||
|
|
ab91647546 | ||
|
|
b236a4a4db | ||
|
|
a480a83a98 | ||
|
|
3a9f123a16 | ||
|
|
8d27fb0692 | ||
|
|
d369fe1c25 | ||
|
|
98b71f2dd4 | ||
|
|
fef0f6422d | ||
|
|
2eb81ac88b | ||
|
|
e02a91f008 | ||
|
|
ced1b95155 | ||
|
|
8f910dfa5d | ||
|
|
05a854cd2a | ||
|
|
22738de028 | ||
|
|
cd0466395a | ||
|
|
24c4056651 | ||
|
|
59fe905695 | ||
|
|
6f3da97365 | ||
|
|
edc1fb24e2 | ||
|
|
f1d68ed4c8 | ||
|
|
ac97370f94 | ||
|
|
82e9de8641 | ||
|
|
843a13c1ab | ||
|
|
3bf50c4bbe | ||
|
|
4922e90d81 | ||
|
|
a3a920437f | ||
|
|
787c0c4a6a | ||
|
|
8517a824e5 | ||
|
|
2cca7aa759 | ||
|
|
23b070c7d0 | ||
|
|
49111e9c5c | ||
|
|
c0cca7f41d | ||
|
|
99bb50d8f8 | ||
|
|
00f00b17bf | ||
|
|
62fdbad74c | ||
|
|
f0bba74a47 | ||
|
|
cf9b5b445b | ||
|
|
aa200923f0 | ||
|
|
ddadf93ca1 | ||
|
|
781c681216 | ||
|
|
cfda7fc738 | ||
|
|
58ba24add2 | ||
|
|
dcf069ca52 | ||
|
|
c3fda11d10 | ||
|
|
11ac46daeb | ||
|
|
2dcabe0123 | ||
|
|
42f1d87955 | ||
|
|
334a76de75 | ||
|
|
677a6e578e | ||
|
|
a3b5eaacfd | ||
|
|
b3d4ea05ec | ||
|
|
8f35adca7a | ||
|
|
394f424185 | ||
|
|
ada52078c7 | ||
|
|
0daf1a6df4 | ||
|
|
edffd04ed2 | ||
|
|
7aea09f4ca | ||
|
|
5673c1dd29 | ||
|
|
1774e2bf30 | ||
|
|
4836b3272a | ||
|
|
a31607ae7d | ||
|
|
57ad221cc6 | ||
|
|
00c7883088 | ||
|
|
1de89525cc | ||
|
|
704a70902f | ||
|
|
570faeb790 | ||
|
|
8b8837c9ff | ||
|
|
eff464cf0e | ||
|
|
26ccb9106e | ||
|
|
0d84487412 | ||
|
|
2bc6a0666f | ||
|
|
82bc9f1b35 | ||
|
|
d73ac867df | ||
|
|
ede93d438f | ||
|
|
5e1949eb0e | ||
|
|
2d368c4c2e | ||
|
|
d9db27275e | ||
|
|
591a25722b | ||
|
|
d1ff1967b5 |
No files matched your search
@@ -12,3 +12,9 @@ fmlbranding.properties
|
||||
/mcp
|
||||
/eclipse
|
||||
/deobfuscation_data*.zip
|
||||
/binpatch
|
||||
/mcp_data/
|
||||
/map_client.txt
|
||||
/*.lzma
|
||||
**/*.lzma
|
||||
/installer_base.jar
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"id": "FML152",
|
||||
"time": "2013-03-20T12:00:00-04:00",
|
||||
"releaseTime": "2013-03-20T12:00:00-04:00",
|
||||
"type": "release",
|
||||
"minecraftArguments": "${auth_player_name} ${auth_session} --gameDir ${game_directory} --assetsDir ${game_assets} --tweakClass cpw.mods.fml.common.launcher.FMLTweaker",
|
||||
"libraries": [
|
||||
{
|
||||
"name": "cpw.mods:fml:5.2"
|
||||
},
|
||||
{
|
||||
"name": "net.minecraft:launchwrapper:1.3"
|
||||
},
|
||||
{
|
||||
"name": "net.sf.jopt-simple:jopt-simple:4.5"
|
||||
},
|
||||
{
|
||||
"name": "argo:argo:2.25_fixed"
|
||||
},
|
||||
{
|
||||
"name": "org.ow2.asm:asm-all:4.1"
|
||||
},
|
||||
{
|
||||
"name": "org.lwjgl.lwjgl:lwjgl:2.9.0"
|
||||
},
|
||||
{
|
||||
"name": "org.lwjgl.lwjgl:lwjgl_util:2.9.0"
|
||||
},
|
||||
{
|
||||
"name": "net.java.jinput:jinput:2.0.5"
|
||||
},
|
||||
{
|
||||
"name": "org.bouncycastle:bcprov-jdk15on:1.47"
|
||||
},
|
||||
{
|
||||
"name": "com.google.guava:guava:14.0"
|
||||
},
|
||||
{
|
||||
"name": "net.java.jutils:jutils:1.0.0"
|
||||
},
|
||||
{
|
||||
"name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.0",
|
||||
"natives": {
|
||||
"linux": "natives-linux",
|
||||
"windows": "natives-windows",
|
||||
"osx": "natives-osx"
|
||||
},
|
||||
"extract": {
|
||||
"exclude": [
|
||||
"META-INF/"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "net.java.jinput:jinput-platform:2.0.5",
|
||||
"natives": {
|
||||
"linux": "natives-linux",
|
||||
"windows": "natives-windows",
|
||||
"osx": "natives-osx"
|
||||
},
|
||||
"extract": {
|
||||
"exclude": [
|
||||
"META-INF/"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"mainClass": "net.minecraft.launchwrapper.Launch"
|
||||
}
|
||||
@@ -9,6 +9,12 @@ included based on guidelines at
|
||||
http://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html
|
||||
with notices intact. The only change is a non-functional change of package name.
|
||||
|
||||
This software contains a partial repackaging of javaxdelta, a BSD licensed program for generating
|
||||
binary differences and applying them, sourced from the subversion at http://sourceforge.net/projects/javaxdelta/
|
||||
authored by genman, heikok, pivot.
|
||||
The only changes are to replace some Trove collection types with standard Java collections, and repackaged.
|
||||
|
||||
|
||||
=== MCP Data ===
|
||||
This software includes data from the Minecraft Coder Pack (MCP), with kind permission
|
||||
from them. The license to MCP data is not transitive - distribution of this data by
|
||||
@@ -16,6 +22,14 @@ third parties requires independent licensing from the MCP team. This data is not
|
||||
redistributable without permission from the MCP team.
|
||||
|
||||
=== Sharing ===
|
||||
I grant permission for some parts of FML to be redistributed outside the terms of the LGPL, for the benefit of
|
||||
the minecraft modding community. All contributions to these parts should be licensed under the same additional grant.
|
||||
|
||||
-- Runtime patcher --
|
||||
License is granted to redistribute the runtime patcher code (common/cpw/mods/fml/patcher and subdirectories) under
|
||||
any alternative open source license as classified by the OSI (http://opensource.org/licenses)
|
||||
|
||||
-- ASM transformers --
|
||||
License is granted to redistribute the ASM transformer code (common/cpw/mods/fml/common/asm/ and subdirectories)
|
||||
under any alternative open source license as classified by the OSI (http://opensource.org/licenses)
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
<arg value="${mcp.home}" />
|
||||
</exec>
|
||||
<propertyfile file="fmlversion.properties">
|
||||
<entry key="fmlbuild.build.number" type="int" value="${version.build}"/>
|
||||
<entry key="fmlbuild.deobfuscation.hash" type="string" value="${deobf.checksum}"/>
|
||||
<entry key="fmlbuild.build.number" type="int" value="${version.build}" />
|
||||
<entry key="fmlbuild.deobfuscation.hash" type="string" value="${deobf.checksum}" />
|
||||
</propertyfile>
|
||||
</target>
|
||||
|
||||
@@ -30,15 +30,19 @@
|
||||
<isset property="env.WORKSPACE" />
|
||||
</condition>
|
||||
<property name="fml.python.dir" location="${basedir}/python" />
|
||||
<property name="fml.lzma.dir" location="${basedir}/lzmabin" />
|
||||
<condition property="python.exe" value="${fml.python.dir}/python_fml" else="python">
|
||||
<os family="Windows" />
|
||||
</condition>
|
||||
<condition property="mcp.exists">
|
||||
<available file="${mcp.home}/runtime/commands.py"/>
|
||||
<condition property="lzma.exe" value="${fml.lzma.dir}/xz.exe" else="xz">
|
||||
<os family="Windows" />
|
||||
</condition>
|
||||
<condition property="mcp.exists">
|
||||
<available file="${mcp.home}/runtime/commands.py" />
|
||||
</condition>
|
||||
<condition property="signature.exists">
|
||||
<available file="${env.JENKINS_HOME}/fmlsigned.properties" />
|
||||
</condition>
|
||||
<condition property="signature.exists">
|
||||
<available file="${env.JENKINS_HOME}/fmlsigned.properties"/>
|
||||
</condition>
|
||||
<property name="mcp.obfoutput" location="${mcp.home}/reobf" />
|
||||
<property name="client.mcp.obfoutput" location="${mcp.obfoutput}/minecraft" />
|
||||
<property name="mcp.srcdir" location="${mcp.home}/src" />
|
||||
@@ -54,7 +58,7 @@
|
||||
<condition property="version.build" value="${env.BUILD_NUMBER}" else="1">
|
||||
<isset property="env.BUILD_NUMBER" />
|
||||
</condition>
|
||||
<available file="eclipse" property="eclipse.exists"/>
|
||||
<available file="eclipse" property="eclipse.exists" />
|
||||
</target>
|
||||
|
||||
<target name="makeversion" depends="buildenvsetup">
|
||||
@@ -79,8 +83,11 @@
|
||||
<target name="clean" depends="buildenvsetup,makeclean" if="mcp.exists">
|
||||
<exec executable="${python.exe}" dir="${mcp.home}">
|
||||
<arg value="${basedir}/decompile.py" />
|
||||
<arg value="--mcp-dir" />
|
||||
<arg value="${mcp.home}" />
|
||||
<arg value="--fml-dir" />
|
||||
<arg value="${basedir}" />
|
||||
<arg value="--gen-conf" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
@@ -89,19 +96,19 @@
|
||||
<arg value="${mcp.home}/runtime/reobfuscate.py" />
|
||||
</exec>
|
||||
<fail message="Reobfuscation failed">
|
||||
<condition>
|
||||
<not>
|
||||
<and>
|
||||
<available file="${mcp.home}/temp/client.md5"/>
|
||||
<available file="${mcp.home}/temp/client_reobf.md5"/>
|
||||
</and>
|
||||
</not>
|
||||
</condition>
|
||||
<condition>
|
||||
<not>
|
||||
<and>
|
||||
<available file="${mcp.home}/temp/client.md5" />
|
||||
<available file="${mcp.home}/temp/client_reobf.md5" />
|
||||
</and>
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<exec executable="${python.exe}" dir="${mcp.home}">
|
||||
<arg value="${basedir}/generatechangedfilelist.py"/>
|
||||
<arg value="${mcp.home}"/>
|
||||
<arg value="${basedir}/difflist.txt"/>
|
||||
<arg value="${basedir}/generatechangedfilelist.py" />
|
||||
<arg value="${mcp.home}" />
|
||||
<arg value="${basedir}/difflist.txt" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
@@ -110,11 +117,11 @@
|
||||
<arg value="${mcp.home}/runtime/recompile.py" />
|
||||
</exec>
|
||||
<fail message="Compilation failed">
|
||||
<condition>
|
||||
<not>
|
||||
<available file="${mcp.home}/bin/minecraft/net/minecraft/client/Minecraft.class"/>
|
||||
</not>
|
||||
</condition>
|
||||
<condition>
|
||||
<not>
|
||||
<available file="${mcp.home}/bin/minecraft/net/minecraft/client/Minecraft.class" />
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
</target>
|
||||
|
||||
@@ -124,35 +131,49 @@
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="merge-common">
|
||||
<target name="merge-common" depends="buildenvsetup,build-deobf-data">
|
||||
<copy todir="${client.mcp.srcdir}" overwrite="true" verbose="true">
|
||||
<fileset dir="${common.src.dir}" includes="**/*.java" />
|
||||
<fileset dir="${basedir}" includes="deobfuscation_data-${version.minecraft}.lzma"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="merge-source" depends="buildenvsetup,merge-client,merge-common" />
|
||||
|
||||
<target name="build-universal" depends="buildenvsetup,merge-client,merge-common,reobfuscate,makeversion">
|
||||
<target name="build-universal" depends="buildenvsetup,merge-client,merge-common,reobfuscate,makeversion,makebinpatches">
|
||||
<condition property="universal.jarname" value="${modname}-universal-${version.minecraft}-${version}" else="${modname}-universal-${version.minecraft}-${version}-${version.branch}">
|
||||
<equals arg1="${version.branch}" arg2="master" />
|
||||
</condition>
|
||||
|
||||
<mkdir dir="${basedir}/target" />
|
||||
<jar destfile="${basedir}/target/${universal.jarname}.zip" duplicate="preserve">
|
||||
<path id="server.classpath">
|
||||
<pathelement path="${mcp.home}/jars/libraries/net/minecraft/launchwrapper/1.3/launchwrapper-1.3.jar"/>
|
||||
<pathelement path="${mcp.home}/jars/libraries/org/ow2/asm/asm-all/4.1/asm-all-4.1.jar"/>
|
||||
<pathelement path="${mcp.home}/jars/libraries/lzma/lzma/0.0.1/lzma-0.0.1.jar"/>
|
||||
<pathelement path="${mcp.home}/jars/libraries/net/sf/jopt-simple/jopt-simple/4.5/jopt-simple-4.5.jar"/>
|
||||
<pathelement path="${mcp.home}/jars/libraries/org/scala-lang/scala-library/2.10.2/scala-library-2.10.2.jar"/>
|
||||
<pathelement path="${mcp.home}/jars/libraries/org/scala-lang/scala-compiler/2.10.2/scala-compiler-2.10.2.jar"/>
|
||||
<pathelement path="${mcp.home}/jars/minecraft_server.${version.minecraft}.jar"/>
|
||||
</path>
|
||||
<manifestclasspath property="server.jar.classpath" jarfile="${mcp.home}/jars/minecraft_server.jar">
|
||||
<classpath refid="server.classpath" />
|
||||
</manifestclasspath>
|
||||
<jar destfile="${basedir}/target/${universal.jarname}.jar" duplicate="preserve">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="net.minecraft.server.MinecraftServer"/>
|
||||
<attribute name="Class-Path" value="minecraft_server.jar"/>
|
||||
<attribute name="Main-Class" value="cpw.mods.fml.relauncher.ServerLaunchWrapper" />
|
||||
<attribute name="Class-Path" value="${server.jar.classpath}" />
|
||||
</manifest>
|
||||
<fileset dir="${client.mcp.obfoutput}" includes="**/*.class" excludes="*.class"/>
|
||||
<fileset dir="${client.mcp.obfoutput}" includes="**/*.class" excludes="*.class,net/minecraft/**/*.class" />
|
||||
</jar>
|
||||
<antcall target="signjar"/>
|
||||
<zip update="true" destfile="${basedir}/target/${universal.jarname}.zip" >
|
||||
<fileset dir="${client.mcp.obfoutput}" includes="*.class"/>
|
||||
<zipfileset dir="${basedir}" includes="fmlversion.properties"/>
|
||||
<antcall target="signjar" />
|
||||
<zip update="true" destfile="${basedir}/target/${universal.jarname}.jar">
|
||||
<fileset dir="${basedir}" includes="binpatches.pack.lzma,deobfuscation_data-${version.minecraft}.lzma"/>
|
||||
<fileset dir="${client.mcp.obfoutput}" includes="*.class" />
|
||||
<zipfileset dir="${basedir}" includes="fmlversion.properties" />
|
||||
<zipfileset dir="${basedir}" includes="LICENSE-fml.txt" />
|
||||
<zipfileset dir="${common.src.dir}" includes="mcpmod.info" />
|
||||
<zipfileset dir="${client.src.dir}" includes="mcp.png" />
|
||||
<zipfileset dir="${basedir}" includes="install/CREDITS-fml.txt" fullpath="CREDITS-fml.txt"/>
|
||||
<zipfileset dir="${common.src.dir}" includes="mcpmod.info" />
|
||||
<zipfileset dir="${client.src.dir}" includes="mcplogo.png" />
|
||||
<zipfileset dir="${basedir}" includes="install/CREDITS-fml.txt" fullpath="CREDITS-fml.txt" />
|
||||
<zipfileset dir="${common.src.dir}" includes="*.cfg" />
|
||||
<mappedresources>
|
||||
<concat>
|
||||
@@ -172,10 +193,39 @@
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="build-installer" depends="build-universal">
|
||||
<condition property="version.fullname" value="${version.minecraft}-${version}" else="${version.minecraft}-${version}-${version.branch}">
|
||||
<equals arg1="${version.branch}" arg2="master" />
|
||||
</condition>
|
||||
<tstamp>
|
||||
<format property="current.time" pattern="yyyy-MM-dd'T'HH:mm:ssZ" />
|
||||
</tstamp>
|
||||
|
||||
<delete file="${basedir}/installer_base.jar" />
|
||||
<delete file="${basedir}/install_profile.json" />
|
||||
<get src="http://files.minecraftforge.net/installer/forge-installer-1.3-shrunk.jar" dest="${basedir}/installer_base.jar" />
|
||||
<copy file="${basedir}/jsons/${version.minecraft}-rel.json" tofile="${basedir}/install_profile.json" />
|
||||
<copy file="${basedir}/installer_base.jar" tofile="${basedir}/target/${modname}-installer-${version.fullname}.jar" />
|
||||
<replace file="${basedir}/install_profile.json">
|
||||
<replaceFilter token="@version@" value="${version}" />
|
||||
<replaceFilter token="@minecraft_version@" value="${version.minecraft}" />
|
||||
<replaceFilter token="@timestamp@" value="${current.time}" />
|
||||
<replaceFilter token="@universal_jar@" value="${modname}-universal-${version.fullname}.jar" />
|
||||
</replace>
|
||||
<jar destfile="${basedir}/target/${modname}-installer-${version.fullname}.jar" update="true">
|
||||
<zipfileset dir="${basedir}" includes="install_profile.json" />
|
||||
<zipfileset dir="${basedir}/jsons" includes="big_logo.png" />
|
||||
<zipfileset dir="${basedir}/target" includes="${modname}-universal-${version.fullname}.jar" />
|
||||
</jar>
|
||||
<delete file="${basedir}/install_profile.json" />
|
||||
</target>
|
||||
|
||||
<target name="build-source-pack" depends="makeversion">
|
||||
<property name="srcpack.jarname" value="${modname}-src-${version.minecraft}-${version}-${version.branch}" />
|
||||
<zip destfile="${basedir}/target/${srcpack.jarname}.zip">
|
||||
<zipfileset dir="${basedir}" includes="LICENSE-fml.txt,difflist.txt,commands.patch,mcp_merge.cfg,mc_versions.cfg" prefix="fml" />
|
||||
<zipfileset dir="${basedir}/jsons" includes="${version.minecraft}-dev.json" fullpath="fml/fml.json"/>
|
||||
<zipfileset dir="${basedir}" includes="deobfuscation_data-${version.minecraft}.lzma" prefix="fml/common" />
|
||||
<zipfileset dir="${common.src.dir}" includes="**/*.java" prefix="fml/common" />
|
||||
<zipfileset dir="${client.src.dir}" includes="**/*.java" prefix="fml/client" />
|
||||
<zipfileset dir="${client.src.dir}" includes="mcp.png" prefix="fml/client" />
|
||||
@@ -205,25 +255,28 @@
|
||||
</target>
|
||||
|
||||
<target name="build-deobf-data" depends="makeversion">
|
||||
<mkdir dir="build-tmp-deobf"/>
|
||||
<mkdir dir="build-tmp-deobf" />
|
||||
<copy todir="build-tmp-deobf">
|
||||
<mappedresources>
|
||||
<fileset dir="${mcp.home}/conf" includes="packaged.srg"/>
|
||||
<globmapper from="packaged.srg" to="joined.srg"/>
|
||||
<fileset dir="${mcp.home}/conf" includes="packaged.srg" />
|
||||
<globmapper from="packaged.srg" to="deobfuscation_data-${version.minecraft}" />
|
||||
</mappedresources>
|
||||
</copy>
|
||||
<touch millis="0" file="build-tmp-deobf/joined.srg"/>
|
||||
<zip file="deobfuscation_data_${version.minecraft}.zip" encoding="UTF-8">
|
||||
<fileset dir="build-tmp-deobf" includes="joined.srg"/>
|
||||
</zip>
|
||||
<checksum algorithm="SHA1" property="deobf.checksum" file="deobfuscation_data_${version.minecraft}.zip"/>
|
||||
<antcall target="writeversion"/>
|
||||
<exec executable="${lzma.exe}">
|
||||
<arg line="--format=lzma"/>
|
||||
<arg line="build-tmp-deobf/deobfuscation_data-${version.minecraft}"/>
|
||||
<arg line="-v"/>
|
||||
</exec>
|
||||
<copy todir="${basedir}">
|
||||
<fileset dir="build-tmp-deobf" includes="*.lzma" />
|
||||
</copy>
|
||||
<antcall target="writeversion" />
|
||||
<delete dir="build-tmp-deobf" />
|
||||
</target>
|
||||
|
||||
<target name="build" depends="buildenvsetup,merge-client,merge-common,build-deobf-data,build-universal,build-source-pack" />
|
||||
<target name="build" depends="buildenvsetup,build-deobf-data,merge-client,merge-common,build-universal,build-installer,build-source-pack" />
|
||||
|
||||
<target name="jenkinsbuild" depends="buildenvsetup,jenkinsfmldecompile,patch,build"/>
|
||||
<target name="jenkinsbuild" depends="buildenvsetup,jenkinsfmldecompile,patch,build" />
|
||||
|
||||
<target name="patch" depends="buildenvsetup">
|
||||
<exec executable="${python.exe}" dir="${basedir}">
|
||||
@@ -242,87 +295,98 @@
|
||||
</condition>
|
||||
<fail if="do.not.continue">You have decided not to continue. This script will stop now.</fail>
|
||||
<echo>Preparing the MCP environment at ${mcp.home}</echo>
|
||||
<antcall target="fmldecompile"/>
|
||||
<antcall target="fmldecompile" />
|
||||
<echo>Moving old patched sources at ${patch.mcp.srcdir} out of the way</echo>
|
||||
<move todir="${mcp.home}/src-work${timestamp}" failonerror="false" verbose="true">
|
||||
<fileset dir="${patch.mcp.srcdir}"/>
|
||||
<fileset dir="${patch.mcp.srcdir}" />
|
||||
</move>
|
||||
<echo>Deleting old patch references at ${clean.mcp.srcdir}</echo>
|
||||
<delete dir="${clean.mcp.srcdir}" failonerror="false"/>
|
||||
<delete dir="${clean.mcp.srcdir}" failonerror="false" />
|
||||
<echo>Creating new patch references at ${clean.mcp.srcdir}</echo>
|
||||
<copy todir="${clean.mcp.srcdir}">
|
||||
<fileset dir="${mcp.srcdir}"/>
|
||||
<fileset dir="${mcp.srcdir}" />
|
||||
</copy>
|
||||
<antcall target="cleanargo"/>
|
||||
<antcall target="patch"/>
|
||||
<antcall target="cleanargo" />
|
||||
<antcall target="patch" />
|
||||
<echo>Creating clean patched references at ${patch.mcp.srcdir}</echo>
|
||||
<copy todir="${patch.mcp.srcdir}">
|
||||
<fileset dir="${mcp.srcdir}"/>
|
||||
<fileset dir="${mcp.srcdir}" />
|
||||
</copy>
|
||||
<antcall target="writeversion"/>
|
||||
<antcall target="makeeclipse"/>
|
||||
<antcall target="writeversion" />
|
||||
<delete>
|
||||
<fileset dir="${basedir}" includes="deobfuscation_data-*.lzma" />
|
||||
</delete>
|
||||
<antcall target="build-deobf-data" />
|
||||
<copy todir="${common.src.dir}">
|
||||
<fileset dir="${basedir}" includes="deobfuscation_data-*.lzma" />
|
||||
</copy>
|
||||
<antcall target="makeeclipse" />
|
||||
<echo>Setup complete! You should now be able to open ${basedir}/eclipse as a workspace in eclipse and import/refresh the FML project</echo>
|
||||
</target>
|
||||
|
||||
<target name="fmldecompile" depends="buildenvsetup,makeclean">
|
||||
<exec executable="${python.exe}" dir="${basedir}">
|
||||
<arg value="${basedir}/decompile.py" />
|
||||
<arg value="--mcp-dir" />
|
||||
<arg value="${mcp.home}" />
|
||||
<arg value="--fml-dir" />
|
||||
<arg value="${basedir}" />
|
||||
<arg value="--gen-conf" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="jenkinsfmldecompile" depends="buildenvsetup,makeclean">
|
||||
<exec executable="${python.exe}" dir="${basedir}">
|
||||
<arg value="${basedir}/decompile.py" />
|
||||
<arg value="--mcp-dir" />
|
||||
<arg value="${mcp.home}" />
|
||||
<arg value="--fml-dir" />
|
||||
<arg value="${basedir}" />
|
||||
<arg value="-no_gen_conf" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="repatch" depends="buildenvsetup,checkpatches">
|
||||
<echo>Moving old patched sources at ${mcp.home}/src-work out of the way</echo>
|
||||
<move todir="${mcp.home}/src-work${timestamp}" failonerror="false" verbose="true">
|
||||
<fileset dir="${patch.mcp.srcdir}"/>
|
||||
<fileset dir="${patch.mcp.srcdir}" />
|
||||
</move>
|
||||
<delete dir="${mcp.srcdir}"/>
|
||||
<delete dir="${mcp.srcdir}" />
|
||||
<copy todir="${mcp.srcdir}">
|
||||
<fileset dir="${clean.mcp.srcdir}"/>
|
||||
<fileset dir="${clean.mcp.srcdir}" />
|
||||
</copy>
|
||||
|
||||
<antcall target="cleanargo"/>
|
||||
<antcall target="cleanargo" />
|
||||
|
||||
<antcall target="patch"/>
|
||||
<antcall target="patch" />
|
||||
<copy todir="${patch.mcp.srcdir}">
|
||||
<fileset dir="${mcp.srcdir}"/>
|
||||
<fileset dir="${mcp.srcdir}" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="repatchclean" depends="buildenvsetup">
|
||||
<delete dir="${mcp.srcdir}"/>
|
||||
<delete dir="${mcp.srcdir}" />
|
||||
<copy todir="${mcp.srcdir}">
|
||||
<fileset dir="${clean.mcp.srcdir}"/>
|
||||
<fileset dir="${clean.mcp.srcdir}" />
|
||||
</copy>
|
||||
|
||||
<antcall target="cleanargo"/>
|
||||
<antcall target="cleanargo" />
|
||||
|
||||
<antcall target="patch"/>
|
||||
<antcall target="patch" />
|
||||
</target>
|
||||
|
||||
<target name="cleanargo" depends="buildenvsetup">
|
||||
<delete dir="${client.mcp.srcdir}/argo"/>
|
||||
<delete dir="${client.mcp.srcdir}/org"/>
|
||||
<delete dir="${client.mcp.srcdir}/argo" />
|
||||
<delete dir="${client.mcp.srcdir}/org" />
|
||||
</target>
|
||||
|
||||
<target name="checkpatches" depends="buildenvsetup">
|
||||
<uptodate property="checkUptodate.uptodate">
|
||||
<srcfiles dir="${patch.mcp.srcdir}" includes="**/*.java">
|
||||
<present targetdir="${patch.src.dir}">
|
||||
<globmapper from="*.java" to="*.java.patch"/>
|
||||
<globmapper from="*.java" to="*.java.patch" />
|
||||
</present>
|
||||
</srcfiles>
|
||||
<globmapper from="*.java" to="${patch.src.dir}/*.java.patch"/>
|
||||
<globmapper from="*.java" to="${patch.src.dir}/*.java.patch" />
|
||||
</uptodate>
|
||||
<fail unless="checkUptodate.uptodate">
|
||||
A patch is out of date. Update your patches!
|
||||
@@ -332,8 +396,8 @@
|
||||
<target name="updatepatches" depends="buildenvsetup">
|
||||
<exec executable="${python.exe}" dir="${basedir}">
|
||||
<arg value="${basedir}/update_patches.py" />
|
||||
<arg value="${mcp.home}"/>
|
||||
<arg value="${basedir}"/>
|
||||
<arg value="${mcp.home}" />
|
||||
<arg value="${basedir}" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
@@ -341,30 +405,69 @@
|
||||
<echo>
|
||||
Extracting fresh eclipse workspace to ${basedir}/eclipse
|
||||
</echo>
|
||||
<unzip src="${basedir}/eclipse-workspace-dev.zip" dest="${basedir}"/>
|
||||
<unzip src="${basedir}/eclipse-workspace-dev.zip" dest="${basedir}" />
|
||||
</target>
|
||||
|
||||
<target name="makerenamedsource" depends="buildenvsetup,repatch,merge-client,merge-common,reobfuscate">
|
||||
<copy todir="${tmp.mcp.srcdir}">
|
||||
<fileset dir="${mcp.srcdir}"/>
|
||||
<fileset dir="${mcp.srcdir}" />
|
||||
</copy>
|
||||
<exec executable="${python.exe}" dir="${mcp.home}">
|
||||
<arg value="${mcp.home}/runtime/updatenames.py" />
|
||||
<arg value="-f" />
|
||||
</exec>
|
||||
<copy todir="${renamed.mcp.srcdir}">
|
||||
<fileset dir="${mcp.srcdir}"/>
|
||||
<fileset dir="${mcp.srcdir}" />
|
||||
</copy>
|
||||
<move todir="${mcp.srcdir}">
|
||||
<fileset dir="${tmp.mcp.srcdir}"/>
|
||||
<fileset dir="${tmp.mcp.srcdir}" />
|
||||
</move>
|
||||
</target>
|
||||
<target name="signjar" depends="buildenvsetup,makeversion" if="signature.exists">
|
||||
<condition property="universal.jarname" value="${modname}-universal-${version.minecraft}-${version}" else="${modname}-universal-${version.minecraft}-${version}-${version.branch}">
|
||||
<equals arg1="${version.branch}" arg2="master" />
|
||||
</condition>
|
||||
<property file="${env.JENKINS_HOME}/fmlsigned.properties" prefix="sign"/>
|
||||
<echo>${env.JENKINS_HOME} ${universal.jarname} ${sign.KEYPASS}</echo>
|
||||
<signjar alias="FML" jar="${basedir}/target/${universal.jarname}.zip" keypass="${sign.KEYPASS}" keystore="${env.JENKINS_HOME}/${sign.KEYSTORE}" storepass="${sign.STOREPASS}" verbose="true"/>
|
||||
<property file="${env.JENKINS_HOME}/fmlsigned.properties" prefix="sign" />
|
||||
<echo>${env.JENKINS_HOME} ${universal.jarname} ${sign.KEYPASS}</echo>
|
||||
<signjar alias="FML" jar="${basedir}/target/${universal.jarname}.zip" keypass="${sign.KEYPASS}" keystore="${env.JENKINS_HOME}/${sign.KEYSTORE}" storepass="${sign.STOREPASS}" verbose="true" />
|
||||
</target>
|
||||
<target name="makebinpatches" depends="buildenvsetup,makeversion">
|
||||
<path id="diffset.libs">
|
||||
<pathelement path="${mcp.home}/jars/libraries/com/google/guava/guava/14.0/guava-14.0.jar"/>
|
||||
<pathelement path="${mcp.home}/jars/libraries/org/ow2/asm/asm-debug-all/4.1/asm-debug-all-4.1.jar"/>
|
||||
<pathelement path="${mcp.home}/jars/libraries/lzma/lzma/0.0.1/lzma-0.0.1.jar"/>
|
||||
<pathelement path="${mcp.obfoutput}/minecraft"/>
|
||||
</path>
|
||||
<delete dir="${basedir}/binpatch" verbose="true"/>
|
||||
<java classname="cpw.mods.fml.common.patcher.GenDiffSet" classpathref="diffset.libs">
|
||||
<arg path="${mcp.home}/jars/versions/${version.minecraft}/${version.minecraft}.jar.backup"/>
|
||||
<arg path="${mcp.obfoutput}/minecraft"/>
|
||||
<arg path="${basedir}/deobfuscation_data-${version.minecraft}.lzma"/>
|
||||
<arg path="${basedir}/binpatch/client"/>
|
||||
<arg value="false"/>
|
||||
</java>
|
||||
<java classname="cpw.mods.fml.common.patcher.GenDiffSet" classpathref="diffset.libs">
|
||||
<arg path="${mcp.home}/jars/minecraft_server.${version.minecraft}.jar.backup"/>
|
||||
<arg path="${mcp.obfoutput}/minecraft"/>
|
||||
<arg path="${basedir}/deobfuscation_data-${version.minecraft}.lzma"/>
|
||||
<arg path="${basedir}/binpatch/server"/>
|
||||
<arg value="true"/>
|
||||
</java>
|
||||
<mkdir dir="binpatch-tmp"/>
|
||||
<zip destfile="binpatch-tmp/binpatches.jar" basedir="${basedir}">
|
||||
<include name="binpatch/**/*.binpatch"/>
|
||||
</zip>
|
||||
<apply executable="pack200">
|
||||
<arg line="--no-gzip"/>
|
||||
<arg line="binpatch-tmp/binpatches.pack"/>
|
||||
<fileset dir="binpatch-tmp" includes="binpatches.jar"/>
|
||||
</apply>
|
||||
<apply executable="${lzma.exe}">
|
||||
<arg line="--format=lzma"/>
|
||||
<arg line="-v"/>
|
||||
<fileset dir="binpatch-tmp" includes="binpatches.pack"/>
|
||||
</apply>
|
||||
<move file="binpatch-tmp/binpatches.pack.lzma" todir="${basedir}"/>
|
||||
<delete dir="binpatch-tmp" failonerror="false"/>
|
||||
</target>
|
||||
</project>
|
||||
@@ -12,6 +12,8 @@
|
||||
*/
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -28,6 +30,11 @@ import net.minecraft.client.multiplayer.NetClientHandler;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.resources.FileResourcePack;
|
||||
import net.minecraft.client.resources.FolderResourcePack;
|
||||
import net.minecraft.client.resources.ReloadableResourceManager;
|
||||
import net.minecraft.client.resources.ResourcePack;
|
||||
import net.minecraft.client.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
@@ -44,6 +51,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.MapDifference;
|
||||
import com.google.common.collect.MapDifference.ValueDifference;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import cpw.mods.fml.client.modloader.ModLoaderClientHelper;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
@@ -71,13 +79,14 @@ import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import cpw.mods.fml.common.registry.IThrowableEntity;
|
||||
import cpw.mods.fml.common.registry.ItemData;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.common.toposort.ModSortingException;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
|
||||
/**
|
||||
* Handles primary communication from hooked code into the system
|
||||
*
|
||||
* The FML entry point is {@link #beginMinecraftLoading(Minecraft)} called from
|
||||
* The FML entry point is {@link #beginMinecraftLoading(Minecraft, List)} called from
|
||||
* {@link Minecraft}
|
||||
*
|
||||
* Obfuscated code should focus on this class and other members of the "server"
|
||||
@@ -113,7 +122,9 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
|
||||
private MissingModsException modsMissing;
|
||||
|
||||
private boolean loading;
|
||||
private ModSortingException modSorting;
|
||||
|
||||
private boolean loading = true;
|
||||
|
||||
private WrongMinecraftVersionException wrongMC;
|
||||
|
||||
@@ -123,14 +134,25 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
|
||||
private boolean serverShouldBeKilledQuietly;
|
||||
|
||||
private List<ResourcePack> resourcePackList;
|
||||
|
||||
private ReloadableResourceManager resourceManager;
|
||||
|
||||
private Map<String, ResourcePack> resourcePackMap;
|
||||
|
||||
/**
|
||||
* Called to start the whole game off
|
||||
*
|
||||
* @param minecraft The minecraft instance being launched
|
||||
* @param resourcePackList The resource pack list we will populate with mods
|
||||
* @param resourceManager The resource manager
|
||||
*/
|
||||
public void beginMinecraftLoading(Minecraft minecraft)
|
||||
public void beginMinecraftLoading(Minecraft minecraft, List resourcePackList, ReloadableResourceManager resourceManager)
|
||||
{
|
||||
client = minecraft;
|
||||
this.resourcePackList = resourcePackList;
|
||||
this.resourceManager = resourceManager;
|
||||
this.resourcePackMap = Maps.newHashMap();
|
||||
if (minecraft.func_71355_q())
|
||||
{
|
||||
FMLLog.severe("DEMO MODE DETECTED, FML will not work. Finishing now.");
|
||||
@@ -138,7 +160,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
return;
|
||||
}
|
||||
|
||||
loading = true;
|
||||
// TextureFXManager.instance().setClient(client);
|
||||
FMLCommonHandler.instance().beginLoading(this);
|
||||
new ModLoaderClientHelper(client);
|
||||
@@ -171,6 +192,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
{
|
||||
modsMissing = missing;
|
||||
}
|
||||
catch (ModSortingException sorting)
|
||||
{
|
||||
modSorting = sorting;
|
||||
}
|
||||
catch (CustomModLoadingErrorDisplayException custom)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, custom, "A custom exception was thrown by a mod, the game will now halt");
|
||||
@@ -197,7 +222,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
@SuppressWarnings("deprecation")
|
||||
public void finishMinecraftLoading()
|
||||
{
|
||||
if (modsMissing != null || wrongMC != null || customError!=null || dupesFound!=null)
|
||||
if (modsMissing != null || wrongMC != null || customError!=null || dupesFound!=null || modSorting!=null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -216,7 +241,8 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
haltGame("There was a severe problem during mod loading that has caused the game to fail", le);
|
||||
return;
|
||||
}
|
||||
LanguageRegistry.reloadLanguageTable();
|
||||
// Reload resources
|
||||
client.func_110436_a();
|
||||
RenderingRegistry.instance().loadEntityRenderers((Map<Class<? extends Entity>, Render>)RenderManager.field_78727_a.field_78729_o);
|
||||
|
||||
loading = false;
|
||||
@@ -237,14 +263,18 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
{
|
||||
client.func_71373_a(new GuiDupesFound(dupesFound));
|
||||
}
|
||||
else if (customError != null)
|
||||
else if (modSorting != null)
|
||||
{
|
||||
client.func_71373_a(new GuiSortingProblem(modSorting));
|
||||
}
|
||||
else if (customError != null)
|
||||
{
|
||||
client.func_71373_a(new GuiCustomModLoadingErrorScreen(customError));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Force renderengine to reload and re-initialize all textures
|
||||
client.field_71446_o.func_78352_b();
|
||||
// client.field_71446_o.func_78352_b();
|
||||
// TextureFXManager.instance().loadTextures(client.field_71418_C.func_77292_e());
|
||||
}
|
||||
}
|
||||
@@ -528,4 +558,58 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
// Show error screen
|
||||
warnIDMismatch(s, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this GUI type open?
|
||||
*
|
||||
* @param gui The type of GUI to test for
|
||||
* @return if a GUI of this type is open
|
||||
*/
|
||||
public boolean isGUIOpen(Class<? extends GuiScreen> gui)
|
||||
{
|
||||
return client.field_71462_r != null && client.field_71462_r.getClass().equals(gui);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addModAsResource(ModContainer container)
|
||||
{
|
||||
Class<?> resourcePackType = container.getCustomResourcePackClass();
|
||||
if (resourcePackType != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResourcePack pack = (ResourcePack) resourcePackType.getConstructor(ModContainer.class).newInstance(container);
|
||||
resourcePackList.add(pack);
|
||||
resourcePackMap.put(container.getModId(), pack);
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, "The container %s (type %s) returned an invalid class for it's resource pack.", container.getName(), container.getClass().getName());
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, "An unexpected exception occurred constructing the custom resource pack for %s", container.getName());
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateResourcePackList()
|
||||
{
|
||||
client.func_110436_a();
|
||||
}
|
||||
|
||||
public ResourcePack getResourcePackFor(String modId)
|
||||
{
|
||||
return resourcePackMap.get(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentLanguage()
|
||||
{
|
||||
return client.func_135016_M().func_135041_c().func_135034_a();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
|
||||
import net.minecraft.client.resources.FileResourcePack;
|
||||
|
||||
public class FMLFileResourcePack extends FileResourcePack {
|
||||
|
||||
private ModContainer container;
|
||||
|
||||
public FMLFileResourcePack(ModContainer container)
|
||||
{
|
||||
super(container.getSource());
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_130077_b()
|
||||
{
|
||||
return "FMLFileResourcePack:"+container.getName();
|
||||
}
|
||||
@Override
|
||||
protected InputStream func_110591_a(String resourceName) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
return super.func_110591_a(resourceName);
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
if ("pack.mcmeta".equals(resourceName))
|
||||
{
|
||||
FMLLog.log(container.getName(), Level.WARNING, "Mod %s is missing a pack.mcmeta file, things may not work well", container.getName());
|
||||
return new ByteArrayInputStream(("{\n" +
|
||||
" \"pack\": {\n"+
|
||||
" \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+
|
||||
" \"pack_format\": 1\n"+
|
||||
"}\n" +
|
||||
"}").getBytes(Charsets.UTF_8));
|
||||
}
|
||||
else throw ioe;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedImage func_110586_a() throws IOException
|
||||
{
|
||||
return ImageIO.read(func_110591_a(container.getMetadata().logoFile));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.minecraft.client.resources.FolderResourcePack;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
|
||||
public class FMLFolderResourcePack extends FolderResourcePack {
|
||||
|
||||
private ModContainer container;
|
||||
|
||||
public FMLFolderResourcePack(ModContainer container)
|
||||
{
|
||||
super(container.getSource());
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_130077_b()
|
||||
{
|
||||
return "FMLFileResourcePack:"+container.getName();
|
||||
}
|
||||
@Override
|
||||
protected InputStream func_110591_a(String resourceName) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
return super.func_110591_a(resourceName);
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
if ("pack.mcmeta".equals(resourceName))
|
||||
{
|
||||
FMLLog.log(container.getName(), Level.WARNING, "Mod %s is missing a pack.mcmeta file, things may not work well", container.getName());
|
||||
return new ByteArrayInputStream(("{\n" +
|
||||
" \"pack\": {\n"+
|
||||
" \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+
|
||||
" \"pack_format\": 1\n"+
|
||||
"}\n" +
|
||||
"}").getBytes(Charsets.UTF_8));
|
||||
}
|
||||
else throw ioe;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedImage func_110586_a() throws IOException
|
||||
{
|
||||
return ImageIO.read(func_110591_a(container.getMetadata().logoFile));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -21,6 +21,7 @@ public class GuiCustomModLoadingErrorScreen extends GuiErrorScreen
|
||||
private CustomModLoadingErrorDisplayException customException;
|
||||
public GuiCustomModLoadingErrorScreen(CustomModLoadingErrorDisplayException customException)
|
||||
{
|
||||
super(null,null);
|
||||
this.customException = customException;
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -29,6 +29,7 @@ public class GuiDupesFound extends GuiErrorScreen
|
||||
|
||||
public GuiDupesFound(DuplicateModsFoundException dupes)
|
||||
{
|
||||
super(null,null);
|
||||
this.dupes = dupes;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -17,6 +17,7 @@ import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -37,13 +38,13 @@ public class GuiIdMismatchScreen extends GuiYesNo {
|
||||
field_73942_a = this;
|
||||
for (Entry<Integer, ItemData> entry : idDifferences.entriesOnlyOnLeft().entrySet())
|
||||
{
|
||||
missingIds.add(String.format("ID %d (ModID: %s, type %s) is missing", entry.getValue().getItemId(), entry.getValue().getModId(), entry.getValue().getItemType()));
|
||||
missingIds.add(String.format("ID %d from Mod %s is missing", entry.getValue().getItemId(), entry.getValue().getModId(), entry.getValue().getItemType()));
|
||||
}
|
||||
for (Entry<Integer, ValueDifference<ItemData>> entry : idDifferences.entriesDiffering().entrySet())
|
||||
{
|
||||
ItemData world = entry.getValue().leftValue();
|
||||
ItemData game = entry.getValue().rightValue();
|
||||
mismatchedIds.add(String.format("ID %d is mismatched. World: (ModID: %s, type %s, ordinal %d) Game (ModID: %s, type %s, ordinal %d)", world.getItemId(), world.getModId(), world.getItemType(), world.getOrdinal(), game.getModId(), game.getItemType(), game.getOrdinal()));
|
||||
mismatchedIds.add(String.format("ID %d is mismatched between world and game", world.getItemId()));
|
||||
}
|
||||
this.allowContinue = allowContinue;
|
||||
}
|
||||
@@ -62,37 +63,44 @@ public class GuiIdMismatchScreen extends GuiYesNo {
|
||||
{
|
||||
field_73887_h.remove(0);
|
||||
}
|
||||
int offset = Math.max(85 - missingIds.size() * 10 + mismatchedIds.size() * 30, 10);
|
||||
this.func_73732_a(this.field_73886_k, "Forge Mod Loader has found world ID mismatches", this.field_73880_f / 2, offset, 0xFFFFFF);
|
||||
offset += 10;
|
||||
int offset = Math.max(85 - (missingIds.size() + mismatchedIds.size()) * 10, 30);
|
||||
this.func_73732_a(this.field_73886_k, "Forge Mod Loader has found ID mismatches", this.field_73880_f / 2, 10, 0xFFFFFF);
|
||||
this.func_73732_a(this.field_73886_k, "Complete details are in the log file", this.field_73880_f / 2, 20, 0xFFFFFF);
|
||||
int maxLines = 20;
|
||||
for (String s: missingIds) {
|
||||
this.func_73732_a(this.field_73886_k, s, this.field_73880_f / 2, offset, 0xEEEEEE);
|
||||
offset += 10;
|
||||
maxLines --;
|
||||
if (maxLines < 0) break;
|
||||
if (offset >= this.field_73881_g - 30) break;
|
||||
}
|
||||
for (String s: mismatchedIds) {
|
||||
this.func_73732_a(this.field_73886_k, s, this.field_73880_f / 2, offset, 0xEEEEEE);
|
||||
offset += 10;
|
||||
if (maxLines > 0 && offset < this.field_73881_g - 30)
|
||||
{
|
||||
for (String s: mismatchedIds) {
|
||||
this.func_73732_a(this.field_73886_k, s, this.field_73880_f / 2, offset, 0xEEEEEE);
|
||||
offset += 10;
|
||||
maxLines --;
|
||||
if (maxLines < 0) break;
|
||||
if (offset >= this.field_73881_g - 30) break;
|
||||
}
|
||||
}
|
||||
offset += 10;
|
||||
if (allowContinue)
|
||||
{
|
||||
this.func_73732_a(this.field_73886_k, "Do you wish to continue loading?", this.field_73880_f / 2, offset, 0xFFFFFF);
|
||||
offset += 10;
|
||||
this.func_73732_a(this.field_73886_k, "Do you wish to continue loading?", this.field_73880_f / 2, this.field_73881_g - 30, 0xFFFFFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.func_73732_a(this.field_73886_k, "You cannot connect to this server", this.field_73880_f / 2, offset, 0xFFFFFF);
|
||||
offset += 10;
|
||||
this.func_73732_a(this.field_73886_k, "You cannot connect to this server", this.field_73880_f / 2, this.field_73881_g - 30, 0xFFFFFF);
|
||||
}
|
||||
// super.super. Grrr
|
||||
for (int var4 = 0; var4 < this.field_73887_h.size(); ++var4)
|
||||
{
|
||||
GuiButton var5 = (GuiButton)this.field_73887_h.get(var4);
|
||||
var5.field_73743_d = Math.min(offset + 10, this.field_73881_g - 20);
|
||||
var5.field_73743_d = this.field_73881_g - 20;
|
||||
if (!allowContinue)
|
||||
{
|
||||
var5.field_73746_c = this.field_73880_f / 2 - 75;
|
||||
var5.field_73744_e = StringTranslate.func_74808_a().func_74805_b("gui.done");
|
||||
var5.field_73744_e = I18n.func_135053_a("gui.done");
|
||||
}
|
||||
var5.func_73737_a(this.field_73882_e, p_73863_1_, p_73863_2_);
|
||||
}
|
||||
|
||||
@@ -15,14 +15,26 @@
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiSmallButton;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureObject;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.resources.ResourcePack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -80,8 +92,7 @@ public class GuiModList extends GuiScreen
|
||||
listWidth=Math.max(listWidth,getFontRenderer().func_78256_a(mod.getVersion()) + 10);
|
||||
}
|
||||
listWidth=Math.min(listWidth, 150);
|
||||
StringTranslate translations = StringTranslate.func_74808_a();
|
||||
this.field_73887_h.add(new GuiSmallButton(6, this.field_73880_f / 2 - 75, this.field_73881_g - 38, translations.func_74805_b("gui.done")));
|
||||
this.field_73887_h.add(new GuiSmallButton(6, this.field_73880_f / 2 - 75, this.field_73881_g - 38, I18n.func_135053_a("gui.done")));
|
||||
this.modList=new GuiSlotModList(this, mods, listWidth);
|
||||
this.modList.registerScrollButtons(this.field_73887_h, 7, 8);
|
||||
}
|
||||
@@ -120,27 +131,53 @@ public class GuiModList extends GuiScreen
|
||||
if (!logoFile.isEmpty())
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.field_73882_e.field_71446_o.func_98187_b(logoFile);
|
||||
Dimension dim = TextureFXManager.instance().getTextureDimensions(logoFile);
|
||||
double scaleX = dim.width / 200.0;
|
||||
double scaleY = dim.height / 65.0;
|
||||
double scale = 1.0;
|
||||
if (scaleX > 1 || scaleY > 1)
|
||||
TextureManager tm = field_73882_e.func_110434_K();
|
||||
ResourcePack pack = FMLClientHandler.instance().getResourcePackFor(selectedMod.getModId());
|
||||
try
|
||||
{
|
||||
scale = 1.0 / Math.max(scaleX, scaleY);
|
||||
}
|
||||
dim.width *= scale;
|
||||
dim.height *= scale;
|
||||
int top = 32;
|
||||
Tessellator tess = Tessellator.field_78398_a;
|
||||
tess.func_78382_b();
|
||||
tess.func_78374_a(offset, top + dim.height, field_73735_i, 0, 1);
|
||||
tess.func_78374_a(offset + dim.width, top + dim.height, field_73735_i, 1, 1);
|
||||
tess.func_78374_a(offset + dim.width, top, field_73735_i, 1, 0);
|
||||
tess.func_78374_a(offset, top, field_73735_i, 0, 0);
|
||||
tess.func_78381_a();
|
||||
BufferedImage logo = null;
|
||||
if (pack!=null)
|
||||
{
|
||||
logo = pack.func_110586_a();
|
||||
}
|
||||
else
|
||||
{
|
||||
InputStream logoResource = getClass().getResourceAsStream(logoFile);
|
||||
if (logoResource != null)
|
||||
{
|
||||
logo = ImageIO.read(logoResource);
|
||||
}
|
||||
}
|
||||
if (logo != null)
|
||||
{
|
||||
ResourceLocation rl = tm.func_110578_a("modlogo", new DynamicTexture(logo));
|
||||
this.field_73882_e.field_71446_o.func_110577_a(rl);
|
||||
Dimension dim = new Dimension(logo.getWidth(), logo.getHeight());
|
||||
double scaleX = dim.width / 200.0;
|
||||
double scaleY = dim.height / 65.0;
|
||||
double scale = 1.0;
|
||||
if (scaleX > 1 || scaleY > 1)
|
||||
{
|
||||
scale = 1.0 / Math.max(scaleX, scaleY);
|
||||
}
|
||||
dim.width *= scale;
|
||||
dim.height *= scale;
|
||||
int top = 32;
|
||||
Tessellator tess = Tessellator.field_78398_a;
|
||||
tess.func_78382_b();
|
||||
tess.func_78374_a(offset, top + dim.height, field_73735_i, 0, 1);
|
||||
tess.func_78374_a(offset + dim.width, top + dim.height, field_73735_i, 1, 1);
|
||||
tess.func_78374_a(offset + dim.width, top, field_73735_i, 1, 0);
|
||||
tess.func_78374_a(offset, top, field_73735_i, 0, 0);
|
||||
tess.func_78381_a();
|
||||
|
||||
shifty += 65;
|
||||
shifty += 65;
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
this.field_73886_k.func_78261_a(selectedMod.getMetadata().name, offset, shifty, 0xFFFFFF);
|
||||
shifty += 12;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -15,6 +15,7 @@ package cpw.mods.fml.client;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import cpw.mods.fml.common.MissingModsException;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
|
||||
public class GuiModsMissing extends GuiErrorScreen
|
||||
{
|
||||
@@ -23,6 +24,7 @@ public class GuiModsMissing extends GuiErrorScreen
|
||||
|
||||
public GuiModsMissing(MissingModsException modsMissing)
|
||||
{
|
||||
super(null,null);
|
||||
this.modsMissing = modsMissing;
|
||||
}
|
||||
|
||||
@@ -43,6 +45,15 @@ public class GuiModsMissing extends GuiErrorScreen
|
||||
for (ArtifactVersion v : modsMissing.missingMods)
|
||||
{
|
||||
offset+=10;
|
||||
if (v instanceof DefaultArtifactVersion)
|
||||
{
|
||||
DefaultArtifactVersion dav = (DefaultArtifactVersion)v;
|
||||
if (dav.getRange() != null && dav.getRange().isUnboundedAbove())
|
||||
{
|
||||
this.func_73732_a(this.field_73886_k, String.format("%s : minimum version required is %s", v.getLabel(), dav.getRange().getLowerBoundString()), this.field_73880_f / 2, offset, 0xEEEEEE);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
this.func_73732_a(this.field_73886_k, String.format("%s : %s", v.getLabel(), v.getRangeString()), this.field_73880_f / 2, offset, 0xEEEEEE);
|
||||
}
|
||||
offset+=20;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -15,6 +15,7 @@ package cpw.mods.fml.client;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiSmallButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
import cpw.mods.fml.common.network.ModMissingPacket;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
@@ -31,8 +32,7 @@ public class GuiModsMissingForServer extends GuiScreen
|
||||
@Override
|
||||
public void func_73866_w_()
|
||||
{
|
||||
StringTranslate translations = StringTranslate.func_74808_a();
|
||||
this.field_73887_h.add(new GuiSmallButton(1, this.field_73880_f / 2 - 75, this.field_73881_g - 38, translations.func_74805_b("gui.done")));
|
||||
this.field_73887_h.add(new GuiSmallButton(1, this.field_73880_f / 2 - 75, this.field_73881_g - 38, I18n.func_135053_a("gui.done")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -15,6 +15,7 @@ package cpw.mods.fml.client;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
@@ -264,7 +265,7 @@ public abstract class GuiScrollingList
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_FOG);
|
||||
Tessellator var18 = Tessellator.field_78398_a;
|
||||
this.client.field_71446_o.func_98187_b("/gui/background.png");
|
||||
this.client.field_71446_o.func_110577_a(Gui.field_110325_k);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
float var17 = 32.0F;
|
||||
var18.func_78382_b();
|
||||
@@ -397,7 +398,7 @@ public abstract class GuiScrollingList
|
||||
private void overlayBackground(int p_22239_1_, int p_22239_2_, int p_22239_3_, int p_22239_4_)
|
||||
{
|
||||
Tessellator var5 = Tessellator.field_78398_a;
|
||||
this.client.field_71446_o.func_98187_b("/gui/background.png");
|
||||
this.client.field_71446_o.func_110577_a(Gui.field_110325_k);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
float var6 = 32.0F;
|
||||
var5.func_78382_b();
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.toposort.ModSortingException;
|
||||
import cpw.mods.fml.common.toposort.ModSortingException.SortingExceptionData;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class GuiSortingProblem extends GuiScreen {
|
||||
private ModSortingException modSorting;
|
||||
private SortingExceptionData<ModContainer> failedList;
|
||||
|
||||
public GuiSortingProblem(ModSortingException modSorting)
|
||||
{
|
||||
this.modSorting = modSorting;
|
||||
this.failedList = modSorting.getExceptionData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_73866_w_()
|
||||
{
|
||||
super.func_73866_w_();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_73863_a(int p_73863_1_, int p_73863_2_, float p_73863_3_)
|
||||
{
|
||||
this.func_73873_v_();
|
||||
int offset = Math.max(85 - (failedList.getVisitedNodes().size() + 3) * 10, 10);
|
||||
this.func_73732_a(this.field_73886_k, "Forge Mod Loader has found a problem with your minecraft installation", this.field_73880_f / 2, offset, 0xFFFFFF);
|
||||
offset+=10;
|
||||
this.func_73732_a(this.field_73886_k, "A mod sorting cycle was detected and loading cannot continue", this.field_73880_f / 2, offset, 0xFFFFFF);
|
||||
offset+=10;
|
||||
this.func_73732_a(this.field_73886_k, String.format("The first mod in the cycle is %s", failedList.getFirstBadNode()), this.field_73880_f / 2, offset, 0xFFFFFF);
|
||||
offset+=10;
|
||||
this.func_73732_a(this.field_73886_k, "The remainder of the cycle involves these mods", this.field_73880_f / 2, offset, 0xFFFFFF);
|
||||
offset+=5;
|
||||
for (ModContainer mc : failedList.getVisitedNodes())
|
||||
{
|
||||
offset+=10;
|
||||
this.func_73732_a(this.field_73886_k, String.format("%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()), this.field_73880_f / 2, offset, 0xEEEEEE);
|
||||
}
|
||||
offset+=20;
|
||||
this.func_73732_a(this.field_73886_k, "The file 'ForgeModLoader-client-0.log' contains more information", this.field_73880_f / 2, offset, 0xFFFFFF);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -22,6 +22,7 @@ public class GuiWrongMinecraft extends GuiErrorScreen
|
||||
private WrongMinecraftVersionException wrongMC;
|
||||
public GuiWrongMinecraft(WrongMinecraftVersionException wrongMC)
|
||||
{
|
||||
super(null,null);
|
||||
this.wrongMC = wrongMC;
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import net.minecraft.client.renderer.RenderEngine;
|
||||
import net.minecraft.client.texturepacks.ITexturePack;
|
||||
|
||||
public interface ITextureFX
|
||||
{
|
||||
public void onTexturePackChanged(RenderEngine engine, ITexturePack texturepack, Dimension dimensions);
|
||||
|
||||
public void onTextureDimensionsUpdate(int width, int height);
|
||||
|
||||
public void setErrored(boolean errored);
|
||||
|
||||
public boolean getErrored();
|
||||
}
|
||||
@@ -20,10 +20,14 @@ import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.lwjgl.opengl.ContextCapabilities;
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderEngine;
|
||||
|
||||
public class TextureFXManager
|
||||
{
|
||||
@@ -34,24 +38,26 @@ public class TextureFXManager
|
||||
private Map<Integer,TextureHolder> texturesById = Maps.newHashMap();
|
||||
private Map<String, TextureHolder> texturesByName = Maps.newHashMap();
|
||||
|
||||
// private TextureHelper helper;
|
||||
|
||||
void setClient(Minecraft client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine, String path) throws IOException
|
||||
{
|
||||
InputStream image=client.field_71418_C.func_77292_e().func_77532_a(path);
|
||||
if (image==null) {
|
||||
throw new RuntimeException(String.format("The requested image path %s is not found",path));
|
||||
}
|
||||
BufferedImage result=ImageIO.read(image);
|
||||
if (result==null)
|
||||
{
|
||||
throw new RuntimeException(String.format("The requested image path %s appears to be corrupted",path));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine, String path) throws IOException
|
||||
// {
|
||||
// InputStream image=client.field_71418_C.func_77292_e().func_77532_a(path);
|
||||
// if (image==null) {
|
||||
// throw new RuntimeException(String.format("The requested image path %s is not found",path));
|
||||
// }
|
||||
// BufferedImage result=ImageIO.read(image);
|
||||
// if (result==null)
|
||||
// {
|
||||
// throw new RuntimeException(String.format("The requested image path %s appears to be corrupted",path));
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
public static TextureFXManager instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
@@ -102,4 +108,35 @@ public class TextureFXManager
|
||||
{
|
||||
return texturesByName.containsKey(texture) ? new Dimension(texturesByName.get(texture).x, texturesByName.get(texture).y) : new Dimension(1,1);
|
||||
}
|
||||
|
||||
|
||||
// public TextureHelper getHelper()
|
||||
// {
|
||||
// if (helper == null)
|
||||
// {
|
||||
// ContextCapabilities capabilities = GLContext.getCapabilities();
|
||||
// boolean has43 = false;
|
||||
// try
|
||||
// {
|
||||
// has43 = capabilities.getClass().getField("GL_ARB_copy_image").getBoolean(capabilities);
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// //e.printStackTrace();
|
||||
// // NOOP - LWJGL needs updating
|
||||
// FMLLog.info("Forge Mod Loader has detected an older LWJGL version, new advanced texture animation features are disabled");
|
||||
// }
|
||||
//// if (has43 && Boolean.parseBoolean(System.getProperty("fml.useGL43","true")))
|
||||
//// {
|
||||
//// FMLLog.info("Using the new OpenGL 4.3 advanced capability for animations");
|
||||
//// helper = new OpenGL43TextureHelper();
|
||||
//// }
|
||||
//// else
|
||||
// {
|
||||
// FMLLog.info("Not using advanced OpenGL 4.3 advanced capability for animations : OpenGL 4.3 is %s", has43 ? "available" : "not available");
|
||||
//// helper = new CopySubimageTextureHelper();
|
||||
// }
|
||||
// }
|
||||
// return helper;
|
||||
// }
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -172,6 +172,10 @@ public class KeyBindingRegistry
|
||||
|
||||
private Set<KeyHandler> keyHandlers = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* Deprecated as it should not be used by client code
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static KeyBindingRegistry instance()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -48,9 +48,8 @@ public class RenderingRegistry
|
||||
*/
|
||||
public static int addNewArmourRendererPrefix(String armor)
|
||||
{
|
||||
RenderPlayer.field_77110_j = ObjectArrays.concat(RenderPlayer.field_77110_j, armor);
|
||||
RenderBiped.field_82424_k = RenderPlayer.field_77110_j;
|
||||
return RenderPlayer.field_77110_j.length - 1;
|
||||
RenderBiped.field_82424_k = ObjectArrays.concat(RenderBiped.field_82424_k, armor);
|
||||
return RenderBiped.field_82424_k.length - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
@@ -448,6 +448,7 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseModPr
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(CLIENT)
|
||||
public void clientCustomPayload(NetClientHandler handler, Packet250CustomPayload packet)
|
||||
{
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -19,8 +19,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderEngine;
|
||||
import net.minecraft.client.texturepacks.ITexturePack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import cpw.mods.fml.client.TextureFXManager;
|
||||
@@ -70,4 +68,9 @@ public class FMLRenderAccessLibrary
|
||||
{
|
||||
return RenderingRegistry.instance().renderItemAsFull3DBlock(modelId);
|
||||
}
|
||||
|
||||
// public static void doTextureCopy(Texture atlas, Texture source, int targetX, int targetY)
|
||||
// {
|
||||
// TextureFXManager.instance().getHelper().doTextureCopy(atlas, source, targetX, targetY);
|
||||
// }
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import net.minecraft.client.*;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.multiplayer.NetClientHandler;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderEngine;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
@@ -541,7 +540,7 @@ public class ModLoader
|
||||
@SideOnly(CLIENT)
|
||||
public static boolean isGUIOpen(Class<? extends GuiScreen> gui)
|
||||
{
|
||||
return FMLClientHandler.instance().getClient().field_71462_r != null && FMLClientHandler.instance().getClient().field_71462_r.equals(gui);
|
||||
return FMLClientHandler.instance().isGUIOpen(gui);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -564,11 +563,11 @@ public class ModLoader
|
||||
{
|
||||
}
|
||||
|
||||
@SideOnly(CLIENT)
|
||||
public static BufferedImage loadImage(RenderEngine renderEngine, String path) throws Exception
|
||||
{
|
||||
return TextureFXManager.instance().loadImageFromTexturePack(renderEngine, path);
|
||||
}
|
||||
// @SideOnly(CLIENT)
|
||||
// public static BufferedImage loadImage(RenderEngine renderEngine, String path) throws Exception
|
||||
// {
|
||||
// return TextureFXManager.instance().loadImageFromTexturePack(renderEngine, path);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Call in from elsewhere. Unimplemented here.
|
||||
@@ -616,17 +615,18 @@ public class ModLoader
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SideOnly(CLIENT)
|
||||
public static void registerAllTextureOverrides(RenderEngine cache)
|
||||
{
|
||||
}
|
||||
// @Deprecated
|
||||
// @SideOnly(CLIENT)
|
||||
// public static void registerAllTextureOverrides(RenderEngine cache)
|
||||
// {
|
||||
// }
|
||||
|
||||
/**
|
||||
* Register a new block
|
||||
*
|
||||
* @param block
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void registerBlock(Block block)
|
||||
{
|
||||
GameRegistry.registerBlock(block);
|
||||
@@ -638,6 +638,7 @@ public class ModLoader
|
||||
* @param block
|
||||
* @param itemclass
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass)
|
||||
{
|
||||
GameRegistry.registerBlock(block, itemclass);
|
||||
@@ -810,14 +811,12 @@ public class ModLoader
|
||||
@Deprecated
|
||||
public static void serverChat(String text)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@SideOnly(CLIENT)
|
||||
public static void serverLogin(NetClientHandler handler, Packet1Login loginPacket)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
public static void serverSendPacket(NetServerHandler handler, Packet packet)
|
||||
|
||||
+60
-104
@@ -1,24 +1,15 @@
|
||||
--- commands.py
|
||||
+++ commands.py
|
||||
@@ -58,6 +58,8 @@
|
||||
|
||||
|
||||
def reallyrmtree(path):
|
||||
+ if os.path.isfile(os.path.join(path, 'asm-4.1.tar.gz')): #Check if asm exists, indicating the libs folder, if so, don't delete it
|
||||
+ return
|
||||
if not sys.platform.startswith('win'):
|
||||
if os.path.exists(path):
|
||||
shutil.rmtree(path)
|
||||
@@ -139,6 +141,8 @@
|
||||
@@ -141,6 +141,8 @@
|
||||
fieldnames = csvreader.fieldnames
|
||||
return set(fieldnames)
|
||||
|
||||
+def commands_sanity_check():
|
||||
+ print 'Commands patch applied successfully'
|
||||
+ print ' Commands patch applied successfully'
|
||||
|
||||
class Commands(object):
|
||||
"""Contains the commands and initialisation for a full mcp run"""
|
||||
@@ -796,6 +800,8 @@
|
||||
@@ -952,6 +954,8 @@
|
||||
binlk = {CLIENT: self.binclient, SERVER: self.binserver}
|
||||
testlk = {CLIENT: self.testclient, SERVER: self.testserver}
|
||||
|
||||
@@ -27,75 +18,73 @@
|
||||
if not os.path.exists(os.path.join(binlk[side], os.path.normpath(testlk[side] + '.class'))):
|
||||
return False
|
||||
return True
|
||||
@@ -1037,6 +1043,9 @@
|
||||
@@ -1283,23 +1287,34 @@
|
||||
pathbinlk = {CLIENT: self.binclient, SERVER: self.binserver}
|
||||
pathsrclk = {CLIENT: self.srcclient, SERVER: self.srcserver}
|
||||
pathlog = {CLIENT: self.clientrecomplog, SERVER: self.serverrecomplog}
|
||||
|
||||
+
|
||||
+ if side == SERVER: #Warn about server because FML recombines it into client
|
||||
+ self.logger.info('Server side recompiling might be skipped, this is normal, do not complain to FML/Forge team about server side.')
|
||||
+
|
||||
|
||||
if not os.path.exists(pathbinlk[side]):
|
||||
os.makedirs(pathbinlk[side])
|
||||
|
||||
@@ -1070,7 +1079,7 @@
|
||||
# HINT: We create the list of source directories based on the list of packages
|
||||
# on windows we just pass wildcards, otherwise we pass the full file list
|
||||
- if self.osname == 'win':
|
||||
+ if self.osname == 'win' and False == True: #FML: Disable for windows we write to file now
|
||||
all_files = False
|
||||
append_pattern = True
|
||||
else:
|
||||
all_files = True
|
||||
append_pattern = False
|
||||
pkglist = filterdirs(pathsrclk[side], '*.java', append_pattern=append_pattern, all_files=all_files)
|
||||
+ from tempfile import NamedTemporaryFile
|
||||
if self.cmdrecompscala: # Compile scala before java as scala scans java files, but not vice-versa
|
||||
pkglistscala = pkglist[:]
|
||||
pkglistscala.extend(filterdirs(pathsrclk[side], '*.scala', append_pattern=append_pattern, all_files=all_files))
|
||||
- dirs = ' '.join(pkglistscala)
|
||||
+ f = NamedTemporaryFile(mode='wb', suffix='.txt', prefix ='scala_src_path_', delete=False) #FML: We write to a temporary file just in case the command is to long
|
||||
+ for line in pkglistscala:
|
||||
+ if os.sep == '\\':
|
||||
+ f.write('"%s"\n' % os.path.abspath(line).replace(os.sep, os.sep + os.sep))
|
||||
+ else:
|
||||
+ f.write('"%s"\n' % os.path.abspath(line))
|
||||
+ f.close()
|
||||
+ dirs = '@"%s"' % f.name
|
||||
classpath = os.pathsep.join(cplk[side])
|
||||
forkcmd = self.cmdrecompscala.format(classpath=classpath, sourcepath=pathsrclk[side], outpath=pathbinlk[side], pkgs=dirs)
|
||||
try:
|
||||
@@ -1319,7 +1334,15 @@
|
||||
self.logger.error('================================')
|
||||
self.logger.error('')
|
||||
raise
|
||||
- dirs = ' '.join(pkglist)
|
||||
+ os.unlink(f.name)
|
||||
+ f = NamedTemporaryFile(mode='wb', suffix='.txt', prefix ='java_src_path_', delete=False) #FML: We write to a temporary file just in case the command is to long
|
||||
+ for line in pkglist:
|
||||
+ if os.sep == '\\':
|
||||
+ f.write('"%s"\n' % os.path.abspath(line).replace('\\', '\\\\'))
|
||||
+ else:
|
||||
+ f.write('"%s"\n' % os.path.abspath(line))
|
||||
+ f.close()
|
||||
+ dirs = '@"%s"' % f.name
|
||||
classpath = os.pathsep.join(cplk[side])
|
||||
forkcmd = self.cmdrecomp.format(classpath=classpath, sourcepath=pathsrclk[side], outpath=pathbinlk[side],
|
||||
pkgs=dirs)
|
||||
@@ -1338,9 +1361,10 @@
|
||||
self.logger.error('==================')
|
||||
self.logger.error('')
|
||||
raise
|
||||
+ os.unlink(f.name)
|
||||
|
||||
def startserver(self):
|
||||
def startserver(self, mainclass, extraargs):
|
||||
- classpath = [self.binserver] + self.cpathserver
|
||||
+ classpath = [self.binclient, self.srcclient] + self.cpathserver
|
||||
+ classpath = [self.binclient, self.srcclient] + self.cpathserver + self.cpathclient
|
||||
classpath = [os.path.join('..', p) for p in classpath]
|
||||
classpath = os.pathsep.join(classpath)
|
||||
os.chdir(self.dirjars)
|
||||
@@ -1078,7 +1087,7 @@
|
||||
self.runmc(forkcmd)
|
||||
|
||||
def startclient(self):
|
||||
- classpath = [self.binclient] + self.cpathclient
|
||||
+ classpath = [self.binclient, self.srcclient] + self.cpathclient
|
||||
classpath = [os.path.join('..', p) for p in classpath]
|
||||
classpath = os.pathsep.join(classpath)
|
||||
natives = os.path.join('..', self.dirnatives)
|
||||
@@ -1205,20 +1214,20 @@
|
||||
with open(self.csvmethods, 'rb') as fh:
|
||||
methodsreader = csv.DictReader(fh)
|
||||
for row in methodsreader:
|
||||
- if int(row['side']) == side:
|
||||
+ if int(row['side']) == side or int(row['side']) == 2:
|
||||
if row['name'] != row['searge']:
|
||||
names['methods'][row['searge']] = row['name']
|
||||
with open(self.csvfields, 'rb') as fh:
|
||||
fieldsreader = csv.DictReader(fh)
|
||||
for row in fieldsreader:
|
||||
- if int(row['side']) == side:
|
||||
+ if int(row['side']) == side or int(row['side']) == 2:
|
||||
if row['name'] != row['searge']:
|
||||
names['fields'][row['searge']] = row['name']
|
||||
if self.has_param_csv:
|
||||
with open(self.csvparams, 'rb') as fh:
|
||||
paramsreader = csv.DictReader(fh)
|
||||
for row in paramsreader:
|
||||
- if int(row['side']) == side:
|
||||
+ if int(row['side']) == side or int(row['side']) == 2:
|
||||
names['params'][row['param']] = row['name']
|
||||
|
||||
regexps = {
|
||||
@@ -1352,13 +1361,13 @@
|
||||
methods = {}
|
||||
for row in methodsreader:
|
||||
#HINT: Only include methods that have a non-empty description
|
||||
- if int(row['side']) == side and row['desc']:
|
||||
+ if (int(row['side']) == side or int(row['side']) == 2) and row['desc']:
|
||||
methods[row['searge']] = row['desc'].replace('*/', '* /')
|
||||
|
||||
fields = {}
|
||||
for row in fieldsreader:
|
||||
#HINT: Only include fields that have a non-empty description
|
||||
- if int(row['side']) == side and row['desc']:
|
||||
+ if (int(row['side']) == side or int(row['side']) == 2) and row['desc']:
|
||||
fields[row['searge']] = row['desc'].replace('*/', '* /')
|
||||
|
||||
regexps = {
|
||||
@@ -1435,7 +1444,7 @@
|
||||
@@ -1705,7 +1729,7 @@
|
||||
self.runcmd(forkcmd)
|
||||
return True
|
||||
|
||||
@@ -104,7 +93,7 @@
|
||||
if not reobf:
|
||||
md5lk = {CLIENT: self.md5client, SERVER: self.md5server}
|
||||
else:
|
||||
@@ -1450,6 +1459,9 @@
|
||||
@@ -1720,6 +1744,9 @@
|
||||
class_path = ''
|
||||
else:
|
||||
class_path += '/'
|
||||
@@ -114,40 +103,7 @@
|
||||
for class_file in fnmatch.filter(filelist, '*.class'):
|
||||
class_name = class_path + os.path.splitext(class_file)[0]
|
||||
bin_file = os.path.normpath(os.path.join(path, class_file))
|
||||
@@ -1546,6 +1558,8 @@
|
||||
if not os.path.exists(outpathlk[side]):
|
||||
os.makedirs(outpathlk[side])
|
||||
|
||||
+ reserved = ['CON', 'PRN', 'AUX', 'NUL', 'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9', 'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9']
|
||||
+
|
||||
# HINT: We extract the modified class files
|
||||
with closing(zipfile.ZipFile(jarlk[side])) as zipjar:
|
||||
for in_class in trgclasses:
|
||||
@@ -1559,6 +1573,23 @@
|
||||
out_class = out_class.replace(self.nullpkg, '')
|
||||
if out_class[0] == '/':
|
||||
out_class = out_class[1:]
|
||||
+
|
||||
+ rename = False
|
||||
+ for res in reserved:
|
||||
+ if out_class.upper().startswith(res):
|
||||
+ rename = True
|
||||
+ break
|
||||
+
|
||||
+ if rename:
|
||||
+ try:
|
||||
+ f = open(os.path.join(outpathlk[side], '_' + out_class), 'wb')
|
||||
+ f.write(zipjar.read(out_class))
|
||||
+ f.close()
|
||||
+ self.logger.info('> Outputted %s to %s as %s', in_class.ljust(35), outpathlk[side], '_' + out_class)
|
||||
+ except IOError:
|
||||
+ self.logger.error('* File %s failed extracting for %s', out_class, in_class)
|
||||
+ continue
|
||||
+
|
||||
try:
|
||||
zipjar.extract(out_class, outpathlk[side])
|
||||
self.logger.info('> Outputted %s to %s as %s', in_class.ljust(35), outpathlk[side], out_class)
|
||||
@@ -1605,6 +1636,9 @@
|
||||
@@ -1892,6 +1919,9 @@
|
||||
sys.exit(1)
|
||||
|
||||
for entry in newfiles:
|
||||
@@ -157,7 +113,7 @@
|
||||
if entry[3] == 'U':
|
||||
self.logger.info('Retrieving file from server : %s', entry[0])
|
||||
cur_file = os.path.normpath(entry[0])
|
||||
@@ -1625,6 +1659,9 @@
|
||||
@@ -1912,6 +1942,9 @@
|
||||
md5reoblk = {CLIENT: self.md5reobfclient, SERVER: self.md5reobfserver}
|
||||
outpathlk = {CLIENT: self.srcmodclient, SERVER: self.srcmodserver}
|
||||
src = {CLIENT: self.srcclient, SERVER: self.srcserver}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -16,6 +16,7 @@ import java.io.File;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
@@ -28,12 +29,17 @@ public class DummyModContainer implements ModContainer
|
||||
{
|
||||
private ModMetadata md;
|
||||
private ArtifactVersion processedVersion;
|
||||
private String label;
|
||||
|
||||
public DummyModContainer(ModMetadata md)
|
||||
{
|
||||
this.md = md;
|
||||
}
|
||||
|
||||
public DummyModContainer(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
public DummyModContainer()
|
||||
{
|
||||
}
|
||||
@@ -157,4 +163,21 @@ public class DummyModContainer implements ModContainer
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return md != null ? getModId() : "Dummy Container ("+label+") @" + System.identityHashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCustomModProperties()
|
||||
{
|
||||
return EMPTY_PROPERTIES;
|
||||
}
|
||||
@Override
|
||||
public Class<?> getCustomResourcePackClass()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -38,6 +38,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -244,12 +245,9 @@ public class FMLCommonHandler
|
||||
{
|
||||
brd.addAll(sidedDelegate.getAdditionalBrandingInformation());
|
||||
}
|
||||
try {
|
||||
Properties props=new Properties();
|
||||
props.load(getClass().getClassLoader().getResourceAsStream("fmlbranding.properties"));
|
||||
brd.add(props.getProperty("fmlbranding"));
|
||||
} catch (Exception ex) {
|
||||
// Ignore - no branding file found
|
||||
if (Loader.instance().getFMLBrandingProperties().containsKey("fmlbranding"))
|
||||
{
|
||||
brd.add(Loader.instance().getFMLBrandingProperties().get("fmlbranding"));
|
||||
}
|
||||
int tModCount = Loader.instance().getModList().size();
|
||||
int aModCount = Loader.instance().getActiveModList().size();
|
||||
@@ -467,6 +465,41 @@ public class FMLCommonHandler
|
||||
|
||||
public void handleServerStopped()
|
||||
{
|
||||
MinecraftServer server = getMinecraftServerInstance();
|
||||
Loader.instance().serverStopped();
|
||||
// FORCE the internal server to stop: hello optifine workaround!
|
||||
if (server!=null) ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, false, "field_71316_v", "u", "serverStopped");
|
||||
}
|
||||
|
||||
public String getModName()
|
||||
{
|
||||
List<String> modNames = Lists.newArrayListWithExpectedSize(3);
|
||||
modNames.add("fml");
|
||||
if (!noForge)
|
||||
{
|
||||
modNames.add("forge");
|
||||
}
|
||||
|
||||
if (Loader.instance().getFMLBrandingProperties().containsKey("snooperbranding"))
|
||||
{
|
||||
modNames.add(Loader.instance().getFMLBrandingProperties().get("snooperbranding"));
|
||||
}
|
||||
return Joiner.on(',').join(modNames);
|
||||
}
|
||||
|
||||
public void addModToResourcePack(ModContainer container)
|
||||
{
|
||||
sidedDelegate.addModAsResource(container);
|
||||
}
|
||||
|
||||
public void updateResourcePackList()
|
||||
{
|
||||
sidedDelegate.updateResourcePackList();
|
||||
}
|
||||
|
||||
public String getCurrentLanguage()
|
||||
{
|
||||
|
||||
return sidedDelegate.getCurrentLanguage();
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,14 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
@@ -26,6 +27,9 @@ import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
import cpw.mods.fml.client.FMLFileResourcePack;
|
||||
import cpw.mods.fml.client.FMLFolderResourcePack;
|
||||
import cpw.mods.fml.common.asm.FMLSanityChecker;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.ItemData;
|
||||
@@ -123,4 +127,15 @@ public class FMLDummyContainer extends DummyModContainer implements WorldAccessC
|
||||
Certificate[] certificates = getClass().getProtectionDomain().getCodeSource().getCertificates();
|
||||
return certificates != null ? certificates[0] : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getSource()
|
||||
{
|
||||
return FMLSanityChecker.fmlLocation;
|
||||
}
|
||||
@Override
|
||||
public Class<?> getCustomResourcePackClass()
|
||||
{
|
||||
return getSource().isDirectory() ? FMLFolderResourcePack.class : FMLFileResourcePack.class;
|
||||
}
|
||||
}
|
||||
@@ -38,8 +38,10 @@ import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableList.Builder;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
@@ -47,6 +49,7 @@ import com.google.common.collect.Sets;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import cpw.mods.fml.common.Mod.CustomProperty;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.Metadata;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
@@ -83,10 +86,10 @@ public class FMLModContainer implements ModContainer
|
||||
private boolean overridesMetadata;
|
||||
private EventBus eventBus;
|
||||
private LoadController controller;
|
||||
private Multimap<Class<? extends Annotation>, Object> annotations;
|
||||
private DefaultArtifactVersion processedVersion;
|
||||
private boolean isNetworkMod;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final BiMap<Class<? extends FMLEvent>, Class<? extends Annotation>> modAnnotationTypes = ImmutableBiMap.<Class<? extends FMLEvent>, Class<? extends Annotation>>builder()
|
||||
.put(FMLPreInitializationEvent.class, Mod.PreInit.class)
|
||||
.put(FMLInitializationEvent.class, Mod.Init.class)
|
||||
@@ -107,35 +110,17 @@ public class FMLModContainer implements ModContainer
|
||||
private Certificate certificate;
|
||||
private String modLanguage;
|
||||
private ILanguageAdapter languageAdapter;
|
||||
private ListMultimap<Class<? extends FMLEvent>,Method> eventMethods;
|
||||
private Map<String, String> customModProperties;
|
||||
|
||||
public static interface ILanguageAdapter {
|
||||
public Object getNewInstance(FMLModContainer container, Class<?> objectClass, ClassLoader classLoader) throws Exception;
|
||||
}
|
||||
|
||||
public static class ScalaAdapter implements ILanguageAdapter {
|
||||
@Override
|
||||
public Object getNewInstance(FMLModContainer container, Class<?> scalaObjectClass, ClassLoader classLoader) throws Exception
|
||||
{
|
||||
System.out.println("Scala class : "+ scalaObjectClass);
|
||||
Class<?> sObjectClass = Class.forName(scalaObjectClass.getName()+"$",true,classLoader);
|
||||
return sObjectClass.getField("MODULE$").get(null);
|
||||
}
|
||||
}
|
||||
|
||||
public static class JavaAdapter implements ILanguageAdapter {
|
||||
@Override
|
||||
public Object getNewInstance(FMLModContainer container, Class<?> objectClass, ClassLoader classLoader) throws Exception
|
||||
{
|
||||
return objectClass.newInstance();
|
||||
}
|
||||
}
|
||||
public FMLModContainer(String className, File modSource, Map<String,Object> modDescriptor)
|
||||
{
|
||||
this.className = className;
|
||||
this.source = modSource;
|
||||
this.descriptor = modDescriptor;
|
||||
this.modLanguage = (String) modDescriptor.get("modLanguage");
|
||||
this.languageAdapter = "scala".equals(modLanguage) ? new ScalaAdapter() : new JavaAdapter();
|
||||
this.languageAdapter = "scala".equals(modLanguage) ? new ILanguageAdapter.ScalaAdapter() : new ILanguageAdapter.JavaAdapter();
|
||||
this.eventMethods = ArrayListMultimap.create();
|
||||
}
|
||||
|
||||
private ILanguageAdapter getLanguageAdapter()
|
||||
@@ -333,10 +318,9 @@ public class FMLModContainer implements ModContainer
|
||||
}
|
||||
}
|
||||
|
||||
private Multimap<Class<? extends Annotation>, Object> gatherAnnotations(Class<?> clazz) throws Exception
|
||||
private Method gatherAnnotations(Class<?> clazz) throws Exception
|
||||
{
|
||||
Multimap<Class<? extends Annotation>,Object> anns = ArrayListMultimap.create();
|
||||
|
||||
Method factoryMethod = null;
|
||||
for (Method m : clazz.getDeclaredMethods())
|
||||
{
|
||||
for (Annotation a : m.getAnnotations())
|
||||
@@ -344,20 +328,47 @@ public class FMLModContainer implements ModContainer
|
||||
if (modTypeAnnotations.containsKey(a.annotationType()))
|
||||
{
|
||||
Class<?>[] paramTypes = new Class[] { modTypeAnnotations.get(a.annotationType()) };
|
||||
|
||||
if (Arrays.equals(m.getParameterTypes(), paramTypes))
|
||||
{
|
||||
m.setAccessible(true);
|
||||
anns.put(a.annotationType(), m);
|
||||
eventMethods.put(modTypeAnnotations.get(a.annotationType()), m);
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log(getModId(), Level.SEVERE,"The mod %s appears to have an invalid method annotation %s. This annotation can only apply to methods with argument types %s -it will not be called", getModId(), a.annotationType().getSimpleName(), Arrays.toString(paramTypes));
|
||||
}
|
||||
}
|
||||
else if (a.annotationType().equals(Mod.EventHandler.class))
|
||||
{
|
||||
if (m.getParameterTypes().length == 1 && modAnnotationTypes.containsKey(m.getParameterTypes()[0]))
|
||||
{
|
||||
m.setAccessible(true);
|
||||
eventMethods.put((Class<? extends FMLEvent>) m.getParameterTypes()[0],m);
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log(getModId(), Level.SEVERE,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName());
|
||||
}
|
||||
}
|
||||
else if (a.annotationType().equals(Mod.InstanceFactory.class))
|
||||
{
|
||||
if (Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0 && factoryMethod == null)
|
||||
{
|
||||
m.setAccessible(true);
|
||||
factoryMethod = m;
|
||||
}
|
||||
else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0))
|
||||
{
|
||||
FMLLog.log(getModId(), Level.SEVERE, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes()));
|
||||
}
|
||||
else if (factoryMethod != null)
|
||||
{
|
||||
FMLLog.log(getModId(), Level.SEVERE, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return anns;
|
||||
return factoryMethod;
|
||||
}
|
||||
|
||||
private void processFieldAnnotations(ASMDataTable asmDataTable) throws Exception
|
||||
@@ -482,14 +493,30 @@ public class FMLModContainer implements ModContainer
|
||||
}
|
||||
}
|
||||
|
||||
annotations = gatherAnnotations(clazz);
|
||||
CustomProperty[] props = (CustomProperty[]) descriptor.get("customProperties");
|
||||
if (props!=null && props.length > 0)
|
||||
{
|
||||
com.google.common.collect.ImmutableMap.Builder<String, String> builder = ImmutableMap.<String,String>builder();
|
||||
for (CustomProperty p : props)
|
||||
{
|
||||
builder.put(p.k(),p.v());
|
||||
}
|
||||
customModProperties = builder.build();
|
||||
}
|
||||
else
|
||||
{
|
||||
customModProperties = EMPTY_PROPERTIES;
|
||||
}
|
||||
|
||||
|
||||
Method factoryMethod = gatherAnnotations(clazz);
|
||||
isNetworkMod = FMLNetworkHandler.instance().registerNetworkMod(this, clazz, event.getASMHarvestedData());
|
||||
modInstance = getLanguageAdapter().getNewInstance(this,clazz, modClassLoader);
|
||||
modInstance = getLanguageAdapter().getNewInstance(this,clazz, modClassLoader, factoryMethod);
|
||||
if (fingerprintNotPresent)
|
||||
{
|
||||
eventBus.post(new FMLFingerprintViolationEvent(source.isDirectory(), source, ImmutableSet.copyOf(this.sourceFingerprints), expectedFingerprint));
|
||||
}
|
||||
ProxyInjector.inject(this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide());
|
||||
ProxyInjector.inject(this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide(), getLanguageAdapter());
|
||||
processFieldAnnotations(event.getASMHarvestedData());
|
||||
}
|
||||
catch (Throwable e)
|
||||
@@ -502,23 +529,20 @@ public class FMLModContainer implements ModContainer
|
||||
@Subscribe
|
||||
public void handleModStateEvent(FMLEvent event)
|
||||
{
|
||||
Class<? extends Annotation> annotation = modAnnotationTypes.get(event.getClass());
|
||||
if (annotation == null)
|
||||
if (!eventMethods.containsKey(event.getClass()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
for (Object o : annotations.get(annotation))
|
||||
for (Method m : eventMethods.get(event.getClass()))
|
||||
{
|
||||
Method m = (Method) o;
|
||||
m.invoke(modInstance, event);
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
controller.errorOccurred(this, t);
|
||||
Throwables.propagateIfPossible(t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,4 +584,29 @@ public class FMLModContainer implements ModContainer
|
||||
{
|
||||
return certificate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "FMLMod:"+getModId()+"{"+getVersion()+"}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCustomModProperties()
|
||||
{
|
||||
return customModProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getCustomResourcePackClass()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getSource().isDirectory() ? Class.forName("cpw.mods.fml.client.FMLFolderResourcePack", true, getClass().getClassLoader()) : Class.forName("cpw.mods.fml.client.FMLFileResourcePack",true, getClass().getClassLoader());
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -62,4 +62,10 @@ public interface IFMLSidedHandler
|
||||
boolean shouldServerShouldBeKilledQuietly();
|
||||
|
||||
void disconnectIDMismatch(MapDifference<Integer, ItemData> s, NetHandler toKill, INetworkManager mgr);
|
||||
|
||||
void addModAsResource(ModContainer container);
|
||||
|
||||
void updateResourcePackList();
|
||||
|
||||
String getCurrentLanguage();
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public interface ILanguageAdapter {
|
||||
public Object getNewInstance(FMLModContainer container, Class<?> objectClass, ClassLoader classLoader, Method factoryMarkedAnnotation) throws Exception;
|
||||
public boolean supportsStatics();
|
||||
public void setProxy(Field target, Class<?> proxyTarget, Object proxy) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException;
|
||||
public void setInternalProxies(ModContainer mod, Side side, ClassLoader loader);
|
||||
|
||||
public static class ScalaAdapter implements ILanguageAdapter {
|
||||
@Override
|
||||
public Object getNewInstance(FMLModContainer container, Class<?> scalaObjectClass, ClassLoader classLoader, Method factoryMarkedAnnotation) throws Exception
|
||||
{
|
||||
Class<?> sObjectClass = Class.forName(scalaObjectClass.getName()+"$",true,classLoader);
|
||||
return sObjectClass.getField("MODULE$").get(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsStatics()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProxy(Field target, Class<?> proxyTarget, Object proxy) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get the actual singleton class. The two variants are from
|
||||
// whether the @SidedProxy is declared in a the class block
|
||||
// of the object directly, or in the object block, i.e.
|
||||
// whether it's:
|
||||
// class ModName {
|
||||
// @SidedProxy ...
|
||||
// }
|
||||
// object ModName extends ModName {}
|
||||
// which leads to us getting the outer class, or
|
||||
// object ModName {
|
||||
// @SidedProxy ...
|
||||
// }
|
||||
// which leads to us getting the inner class.
|
||||
if (!proxyTarget.getName().endsWith("$"))
|
||||
{
|
||||
// Get internal class generated by Scala.
|
||||
proxyTarget = Class.forName(proxyTarget.getName() + "$", true, proxyTarget.getClassLoader());
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
// Not a singleton, look for @Instance field as a fallback.
|
||||
FMLLog.log(Level.INFO, e, "An error occured trying to load a proxy into %s.%s. Did you declare your mod as 'class' instead of 'object'?", proxyTarget.getSimpleName(), target.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the instance via the MODULE$ field which is
|
||||
// automatically generated by the Scala compiler for
|
||||
// singletons.
|
||||
Object targetInstance = proxyTarget.getField("MODULE$").get(null);
|
||||
|
||||
try
|
||||
{
|
||||
// Find setter function. We do it this way because we can't
|
||||
// necessarily use proxyTarget.getMethod(proxy.getClass()), as
|
||||
// it might be a subclass and not the exact parameter type.
|
||||
// All fields are private in Scala, wrapped by a getter and
|
||||
// setter named <fieldname> and <fieldname>_$eq. To those
|
||||
// familiar with scala.reflect.BeanProperty: these will always
|
||||
// be there, set<Fieldname> and get<Fieldname> will always
|
||||
// only be generated *additionally*.
|
||||
final String setterName = target.getName() + "_$eq";
|
||||
for (Method setter : proxyTarget.getMethods())
|
||||
{
|
||||
Class<?>[] setterParameters = setter.getParameterTypes();
|
||||
if (setterName.equals(setter.getName()) &&
|
||||
// Some more validation.
|
||||
setterParameters.length == 1 &&
|
||||
setterParameters[0].isAssignableFrom(proxy.getClass()))
|
||||
{
|
||||
// Here goes nothing...
|
||||
setter.invoke(targetInstance, proxy);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, "An error occured trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName());
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
|
||||
// If we come here we could not find a setter for this proxy.
|
||||
FMLLog.severe("Failed loading proxy into %s.%s, could not find setter function. Did you declare the field with 'val' instead of 'var'?", proxyTarget.getSimpleName(), target.getName());
|
||||
throw new LoaderException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInternalProxies(ModContainer mod, Side side, ClassLoader loader)
|
||||
{
|
||||
// For Scala mods, we want to enable authors to write them like so:
|
||||
// object ModName {
|
||||
// @SidedProxy(...)
|
||||
// var proxy: ModProxy = null
|
||||
// }
|
||||
// For this to work, we have to search inside the inner class Scala
|
||||
// generates for singletons, which is in called ModName$. These are
|
||||
// not automatically handled, because the mod discovery code ignores
|
||||
// internal classes.
|
||||
// Note that it is alternatively possible to write this like so:
|
||||
// class ModName {
|
||||
// @SidedProxy(...)
|
||||
// var proxy: ModProxy = null
|
||||
// }
|
||||
// object ModName extends ModName { ... }
|
||||
// which will fall back to the normal injection code which calls
|
||||
// setProxy in turn.
|
||||
|
||||
// Get the actual mod implementation, which will be the inner class
|
||||
// if we have a singleton.
|
||||
Class<?> proxyTarget = mod.getMod().getClass();
|
||||
if (proxyTarget.getName().endsWith("$"))
|
||||
{
|
||||
// So we have a singleton class, check if there are targets.
|
||||
for (Field target : proxyTarget.getDeclaredFields())
|
||||
{
|
||||
// This will not turn up anything if the alternative
|
||||
// approach was taken (manually declaring the class).
|
||||
// So we don't initialize the field twice.
|
||||
if (target.getAnnotation(SidedProxy.class) != null)
|
||||
{
|
||||
String targetType = side.isClient() ? target.getAnnotation(SidedProxy.class).clientSide() : target.getAnnotation(SidedProxy.class).serverSide();
|
||||
try
|
||||
{
|
||||
Object proxy = Class.forName(targetType, true, loader).newInstance();
|
||||
|
||||
if (!target.getType().isAssignableFrom(proxy.getClass()))
|
||||
{
|
||||
FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, proxyTarget.getSimpleName(), target.getName());
|
||||
throw new LoaderException();
|
||||
}
|
||||
|
||||
setProxy(target, proxyTarget, proxy);
|
||||
}
|
||||
catch (Exception e) {
|
||||
FMLLog.log(Level.SEVERE, e, "An error occured trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName());
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.finer("Mod does not appear to be a singleton.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class JavaAdapter implements ILanguageAdapter {
|
||||
@Override
|
||||
public Object getNewInstance(FMLModContainer container, Class<?> objectClass, ClassLoader classLoader, Method factoryMarkedMethod) throws Exception
|
||||
{
|
||||
if (factoryMarkedMethod != null)
|
||||
{
|
||||
return factoryMarkedMethod.invoke(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
return objectClass.newInstance();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsStatics()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProxy(Field target, Class<?> proxyTarget, Object proxy) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException,
|
||||
SecurityException
|
||||
{
|
||||
target.set(null, proxy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInternalProxies(ModContainer mod, Side side, ClassLoader loader)
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -15,6 +15,7 @@ package cpw.mods.fml.common;
|
||||
import java.io.File;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
@@ -25,11 +26,11 @@ import cpw.mods.fml.common.versioning.VersionRange;
|
||||
public class InjectedModContainer implements ModContainer
|
||||
{
|
||||
private File source;
|
||||
private ModContainer wrappedContainer;
|
||||
public final ModContainer wrappedContainer;
|
||||
|
||||
public InjectedModContainer(ModContainer mc, File source)
|
||||
{
|
||||
this.source = source;
|
||||
this.source = source != null ? source : new File("minecraft.jar");
|
||||
this.wrappedContainer = mc;
|
||||
}
|
||||
|
||||
@@ -148,4 +149,22 @@ public class InjectedModContainer implements ModContainer
|
||||
{
|
||||
return wrappedContainer.getSigningCertificate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Wrapped{"+wrappedContainer.toString()+"}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCustomModProperties()
|
||||
{
|
||||
return wrappedContainer.getCustomModProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getCustomResourcePackClass()
|
||||
{
|
||||
return wrappedContainer.getCustomResourcePackClass();
|
||||
}
|
||||
}
|
||||
@@ -13,15 +13,18 @@
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
@@ -36,6 +39,8 @@ import cpw.mods.fml.common.event.FMLEvent;
|
||||
import cpw.mods.fml.common.event.FMLLoadEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLStateEvent;
|
||||
import cpw.mods.fml.common.functions.ArtifactVersionNameFunction;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
|
||||
public class LoadController
|
||||
{
|
||||
@@ -79,6 +84,7 @@ public class LoadController
|
||||
activeModList.add(mod);
|
||||
modStates.put(mod.getModId(), ModState.UNLOADED);
|
||||
eventBus.put(mod.getModId(), bus);
|
||||
FMLCommonHandler.instance().addModToResourcePack(mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -89,6 +95,7 @@ public class LoadController
|
||||
}
|
||||
|
||||
eventChannels = eventBus.build();
|
||||
FMLCommonHandler.instance().updateResourcePackList();
|
||||
}
|
||||
|
||||
public void distributeStateMessage(LoaderState state, Object... eventData)
|
||||
@@ -99,11 +106,11 @@ public class LoadController
|
||||
}
|
||||
}
|
||||
|
||||
public void transition(LoaderState desiredState)
|
||||
public void transition(LoaderState desiredState, boolean forceState)
|
||||
{
|
||||
LoaderState oldState = state;
|
||||
state = state.transition(!errors.isEmpty());
|
||||
if (state != desiredState)
|
||||
if (state != desiredState && !forceState)
|
||||
{
|
||||
Throwable toThrow = null;
|
||||
FMLLog.severe("Fatal errors were detected during the transition from %s to %s. Loading cannot continue", oldState, desiredState);
|
||||
@@ -142,6 +149,12 @@ public class LoadController
|
||||
throw new LoaderException(toThrow);
|
||||
}
|
||||
}
|
||||
else if (state != desiredState && forceState)
|
||||
{
|
||||
FMLLog.info("The state engine was in incorrect state %s and forced into state %s. Errors may have been discarded.", state, desiredState);
|
||||
forceState(desiredState);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ModContainer activeContainer()
|
||||
@@ -158,23 +171,38 @@ public class LoadController
|
||||
}
|
||||
for (ModContainer mc : activeModList)
|
||||
{
|
||||
activeContainer = mc;
|
||||
String modId = mc.getModId();
|
||||
stateEvent.applyModContainer(activeContainer());
|
||||
FMLLog.log(modId, Level.FINEST, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
|
||||
eventChannels.get(modId).post(stateEvent);
|
||||
FMLLog.log(modId, Level.FINEST, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
|
||||
activeContainer = null;
|
||||
if (stateEvent instanceof FMLStateEvent)
|
||||
sendEventToModContainer(stateEvent, mc);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
|
||||
{
|
||||
String modId = mc.getModId();
|
||||
Collection<String> requirements = Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction());
|
||||
for (ArtifactVersion av : mc.getDependencies())
|
||||
{
|
||||
if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED))
|
||||
{
|
||||
if (!errors.containsKey(modId))
|
||||
{
|
||||
modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
|
||||
}
|
||||
else
|
||||
{
|
||||
modStates.put(modId, ModState.ERRORED);
|
||||
}
|
||||
FMLLog.log(modId, Level.SEVERE, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
|
||||
modStates.put(modId, ModState.ERRORED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
activeContainer = mc;
|
||||
stateEvent.applyModContainer(activeContainer());
|
||||
FMLLog.log(modId, Level.FINEST, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
|
||||
eventChannels.get(modId).post(stateEvent);
|
||||
FMLLog.log(modId, Level.FINEST, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
|
||||
activeContainer = null;
|
||||
if (stateEvent instanceof FMLStateEvent)
|
||||
{
|
||||
if (!errors.containsKey(modId))
|
||||
{
|
||||
modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
|
||||
}
|
||||
else
|
||||
{
|
||||
modStates.put(modId, ModState.ERRORED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,7 +244,7 @@ public class LoadController
|
||||
{
|
||||
for (ModContainer mc : loader.getModList())
|
||||
{
|
||||
ret.append("\n\t").append(mc.getModId()).append(" [").append(mc.getName()).append("] (").append(mc.getSource().getName()).append(") ");
|
||||
ret.append("\n\t").append(mc.getModId()).append("{").append(mc.getVersion()).append("} [").append(mc.getName()).append("] (").append(mc.getSource().getName()).append(") ");
|
||||
Joiner.on("->"). appendTo(ret, modStates.get(mc.getModId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
@@ -26,15 +27,20 @@ import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.crash.CallableMinecraftVersion;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Joiner.MapJoiner;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ImmutableListMultimap.Builder;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultiset;
|
||||
import com.google.common.collect.Iterables;
|
||||
@@ -47,17 +53,21 @@ import com.google.common.collect.Multiset.Entry;
|
||||
import com.google.common.collect.Multisets;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.collect.Sets.SetView;
|
||||
import com.google.common.collect.Table;
|
||||
import com.google.common.collect.TreeMultimap;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import cpw.mods.fml.common.LoaderState.ModState;
|
||||
import cpw.mods.fml.common.discovery.ModDiscoverer;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.event.FMLLoadEvent;
|
||||
import cpw.mods.fml.common.functions.ArtifactVersionNameFunction;
|
||||
import cpw.mods.fml.common.functions.ModIdFunction;
|
||||
import cpw.mods.fml.common.modloader.BaseModProxy;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.toposort.ModSorter;
|
||||
import cpw.mods.fml.common.toposort.ModSortingException;
|
||||
import cpw.mods.fml.common.toposort.ModSortingException.SortingExceptionData;
|
||||
import cpw.mods.fml.common.toposort.TopologicalSort;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.VersionParser;
|
||||
@@ -144,6 +154,7 @@ public class Loader
|
||||
private static File minecraftDir;
|
||||
private static List<String> injectedContainers;
|
||||
private File loggingProperties;
|
||||
private ImmutableMap<String, String> fmlBrandingProperties;
|
||||
|
||||
public static Loader instance()
|
||||
{
|
||||
@@ -204,13 +215,7 @@ public class Loader
|
||||
FMLLog.severe("The mod %s does not wish to run in Minecraft version %s. You will have to remove it to play.", mod.getModId(), getMCVersionString());
|
||||
throw new WrongMinecraftVersionException(mod);
|
||||
}
|
||||
Map<String,ArtifactVersion> names = Maps.uniqueIndex(mod.getRequirements(), new Function<ArtifactVersion, String>()
|
||||
{
|
||||
public String apply(ArtifactVersion v)
|
||||
{
|
||||
return v.getLabel();
|
||||
}
|
||||
});
|
||||
Map<String,ArtifactVersion> names = Maps.uniqueIndex(mod.getRequirements(), new ArtifactVersionNameFunction());
|
||||
Set<ArtifactVersion> versionMissingMods = Sets.newHashSet();
|
||||
Set<String> missingMods = Sets.difference(names.keySet(), modVersions.keySet());
|
||||
if (!missingMods.isEmpty())
|
||||
@@ -260,10 +265,15 @@ public class Loader
|
||||
catch (ModSortingException sortException)
|
||||
{
|
||||
FMLLog.severe("A dependency cycle was detected in the input mod set so an ordering cannot be determined");
|
||||
FMLLog.severe("The visited mod list is %s", sortException.getExceptionData().getVisitedNodes());
|
||||
FMLLog.severe("The first mod in the cycle is %s", sortException.getExceptionData().getFirstBadNode());
|
||||
SortingExceptionData<ModContainer> exceptionData = sortException.getExceptionData();
|
||||
FMLLog.severe("The first mod in the cycle is %s", exceptionData.getFirstBadNode());
|
||||
FMLLog.severe("The mod cycle involves");
|
||||
for (ModContainer mc : exceptionData.getVisitedNodes())
|
||||
{
|
||||
FMLLog.severe("%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies());
|
||||
}
|
||||
FMLLog.log(Level.SEVERE, sortException, "The full error");
|
||||
throw new LoaderException(sortException);
|
||||
throw sortException;
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -312,7 +322,6 @@ public class Loader
|
||||
FMLLog.fine("Building injected Mod Containers %s", injectedContainers);
|
||||
// Add in the MCP mod container
|
||||
mods.add(new InjectedModContainer(mcp,new File("minecraft.jar")));
|
||||
File coremod = new File(minecraftDir,"coremods");
|
||||
for (String cont : injectedContainers)
|
||||
{
|
||||
ModContainer mc;
|
||||
@@ -325,7 +334,7 @@ public class Loader
|
||||
FMLLog.log(Level.SEVERE, e, "A problem occured instantiating the injected mod container %s", cont);
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
mods.add(new InjectedModContainer(mc,coremod));
|
||||
mods.add(new InjectedModContainer(mc,mc.getSource()));
|
||||
}
|
||||
ModDiscoverer discoverer = new ModDiscoverer();
|
||||
FMLLog.fine("Attempting to load mods contained in the minecraft jar file and associated classes");
|
||||
@@ -334,6 +343,12 @@ public class Loader
|
||||
|
||||
FMLLog.info("Searching %s for mods", canonicalModsDir.getAbsolutePath());
|
||||
discoverer.findModDirMods(canonicalModsDir);
|
||||
File versionSpecificModsDir = new File(canonicalModsDir,mccversion);
|
||||
if (versionSpecificModsDir.isDirectory())
|
||||
{
|
||||
FMLLog.info("Also searching %s for mods", versionSpecificModsDir);
|
||||
discoverer.findModDirMods(versionSpecificModsDir);
|
||||
}
|
||||
|
||||
mods.addAll(discoverer.identifyMods());
|
||||
identifyDuplicates(mods);
|
||||
@@ -466,7 +481,7 @@ public class Loader
|
||||
mods = Lists.newArrayList();
|
||||
namedMods = Maps.newHashMap();
|
||||
modController = new LoadController(this);
|
||||
modController.transition(LoaderState.LOADING);
|
||||
modController.transition(LoaderState.LOADING, false);
|
||||
ModDiscoverer disc = identifyMods();
|
||||
disableRequestedMods();
|
||||
FMLLog.fine("Reloading logging properties from %s", loggingProperties.getPath());
|
||||
@@ -490,7 +505,7 @@ public class Loader
|
||||
}
|
||||
}
|
||||
}
|
||||
modController.transition(LoaderState.CONSTRUCTING);
|
||||
modController.transition(LoaderState.CONSTRUCTING, false);
|
||||
modController.distributeStateMessage(LoaderState.CONSTRUCTING, modClassLoader, disc.getASMTable());
|
||||
FMLLog.fine("Mod signature data");
|
||||
for (ModContainer mod : getActiveModList())
|
||||
@@ -501,9 +516,9 @@ public class Loader
|
||||
{
|
||||
FMLLog.fine("No user mod signature data found");
|
||||
}
|
||||
modController.transition(LoaderState.PREINITIALIZATION);
|
||||
modController.transition(LoaderState.PREINITIALIZATION, false);
|
||||
modController.distributeStateMessage(LoaderState.PREINITIALIZATION, disc.getASMTable(), canonicalConfigDir);
|
||||
modController.transition(LoaderState.INITIALIZATION);
|
||||
modController.transition(LoaderState.INITIALIZATION, false);
|
||||
}
|
||||
|
||||
private void disableRequestedMods()
|
||||
@@ -679,13 +694,15 @@ public class Loader
|
||||
{
|
||||
// Mod controller should be in the initialization state here
|
||||
modController.distributeStateMessage(LoaderState.INITIALIZATION);
|
||||
modController.transition(LoaderState.POSTINITIALIZATION);
|
||||
modController.transition(LoaderState.POSTINITIALIZATION, false);
|
||||
// Construct the "mod object table" so mods can refer to it in IMC and postinit
|
||||
GameData.buildModObjectTable();
|
||||
modController.distributeStateMessage(FMLInterModComms.IMCEvent.class);
|
||||
modController.distributeStateMessage(LoaderState.POSTINITIALIZATION);
|
||||
modController.transition(LoaderState.AVAILABLE);
|
||||
modController.transition(LoaderState.AVAILABLE, false);
|
||||
modController.distributeStateMessage(LoaderState.AVAILABLE);
|
||||
// Dump the custom registry data map, if necessary
|
||||
GameData.dumpRegistry(minecraftDir);
|
||||
FMLLog.info("Forge Mod Loader has successfully loaded %d mod%s", mods.size(), mods.size()==1 ? "" : "s");
|
||||
}
|
||||
|
||||
@@ -726,7 +743,7 @@ public class Loader
|
||||
try
|
||||
{
|
||||
modController.distributeStateMessage(LoaderState.SERVER_STARTING, server);
|
||||
modController.transition(LoaderState.SERVER_STARTING);
|
||||
modController.transition(LoaderState.SERVER_STARTING, false);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -739,13 +756,13 @@ public class Loader
|
||||
public void serverStarted()
|
||||
{
|
||||
modController.distributeStateMessage(LoaderState.SERVER_STARTED);
|
||||
modController.transition(LoaderState.SERVER_STARTED);
|
||||
modController.transition(LoaderState.SERVER_STARTED, false);
|
||||
}
|
||||
|
||||
public void serverStopping()
|
||||
{
|
||||
modController.distributeStateMessage(LoaderState.SERVER_STOPPING);
|
||||
modController.transition(LoaderState.SERVER_STOPPING);
|
||||
modController.transition(LoaderState.SERVER_STOPPING, false);
|
||||
}
|
||||
|
||||
public BiMap<ModContainer, Object> getModObjectList()
|
||||
@@ -784,16 +801,8 @@ public class Loader
|
||||
public void serverStopped()
|
||||
{
|
||||
modController.distributeStateMessage(LoaderState.SERVER_STOPPED);
|
||||
try
|
||||
{
|
||||
modController.transition(LoaderState.SERVER_STOPPED);
|
||||
}
|
||||
catch (LoaderException e)
|
||||
{
|
||||
modController.forceState(LoaderState.SERVER_STOPPED);
|
||||
// Discard any exceptions here - they mask other, real, exceptions
|
||||
}
|
||||
modController.transition(LoaderState.AVAILABLE);
|
||||
modController.transition(LoaderState.SERVER_STOPPED, true);
|
||||
modController.transition(LoaderState.AVAILABLE, true);
|
||||
}
|
||||
|
||||
public boolean serverAboutToStart(Object server)
|
||||
@@ -801,7 +810,7 @@ public class Loader
|
||||
try
|
||||
{
|
||||
modController.distributeStateMessage(LoaderState.SERVER_ABOUT_TO_START, server);
|
||||
modController.transition(LoaderState.SERVER_ABOUT_TO_START);
|
||||
modController.transition(LoaderState.SERVER_ABOUT_TO_START, false);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -810,4 +819,28 @@ public class Loader
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Map<String,String> getFMLBrandingProperties()
|
||||
{
|
||||
if (fmlBrandingProperties == null)
|
||||
{
|
||||
Properties loaded = new Properties();
|
||||
try
|
||||
{
|
||||
loaded.load(getClass().getClassLoader().getResourceAsStream("fmlbranding.properties"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// File not found - ignore
|
||||
}
|
||||
fmlBrandingProperties = Maps.fromProperties(loaded);
|
||||
}
|
||||
return fmlBrandingProperties;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> getCustomModProperties(String modId)
|
||||
{
|
||||
return getIndexedModList().get(modId).getCustomModProperties();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -18,12 +18,59 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLEvent;
|
||||
import cpw.mods.fml.common.event.FMLFingerprintViolationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartedEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||
import cpw.mods.fml.common.event.FMLStateEvent;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
/**
|
||||
* The new mod style in FML 1.3
|
||||
* This defines a Mod to FML.
|
||||
* Any class found with this annotation applied will be loaded as a Mod. The instance that is loaded will
|
||||
* represent the mod to other Mods in the system. It will be sent various subclasses of {@link FMLEvent}
|
||||
* at pre-defined times during the loading of the game, based on where you have applied the {@link EventHandler}
|
||||
* annotation.
|
||||
*
|
||||
* This annotation is usually paired with a second annotation {@link NetworkMod}, which declares the
|
||||
* network related properties of this mod.
|
||||
*
|
||||
* <p>This is a simple example of a Mod. It has the modId of "MyModId", the name of "My example mod", it is
|
||||
* version 1.0, and depends on FML being loaded. It has the {@link NetworkMod} annotation as well, declaring it uses channel
|
||||
* "MyModChannel" and {@link IPacketHandler} class PacketHandler.
|
||||
* <pre>{@code
|
||||
* package mymod;
|
||||
* // Declare that this is a mod with modId "MyModId", name "My example mod", version "1.0" and dependency on FML.
|
||||
* {@literal @}Mod(modId="MyModId",name="My example mod",version="1.0",dependencies="required-after:FML")
|
||||
* // Declare that this is a network mod using the {@link Packet250CustomPayload} channel "MyModChannel", required on the client if it's present
|
||||
* // on the server, with {@link IPacketHandler} class PacketHandler.
|
||||
* {@literal @}NetworkMod(channels = { "MyModChannel" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
||||
* public class MyMod {
|
||||
* // Populate this field with the instance of the mod created by FML
|
||||
* {@literal @}Instance("MyModId")
|
||||
* public MyMod instance;
|
||||
*
|
||||
* // Mark this method for receiving an {@link FMLEvent} (in this case, it's the {@link FMLPreInitializationEvent})
|
||||
* {@literal @}EventHandler public void preInit(FMLPreInitializationEvent event)
|
||||
* {
|
||||
* // Do stuff in pre-init phase (read config, create blocks and items, register them)
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
@@ -65,10 +112,14 @@ public @interface Mod
|
||||
* An optional bukkit plugin that will be injected into the bukkit plugin framework if
|
||||
* this mod is loaded into the FML framework and the bukkit coremod is present.
|
||||
* Instances of the bukkit plugin can be obtained via the {@link BukkitPluginRef} annotation on fields.
|
||||
*
|
||||
* This may be implemented by a bukkit integration. It is not provided with vanilla FML or MinecraftForge.
|
||||
*
|
||||
* @return The name of the plugin to load for this mod
|
||||
*/
|
||||
String bukkitPlugin() default "";
|
||||
/**
|
||||
* NOT YET IMPLEMENTED.</br>
|
||||
* Mods that this mod will <strong>not</strong> load with.
|
||||
* An optional comma separated string of (+|-)(*|modid[@value]) which specify mods that
|
||||
* this mod will refuse to load with, resulting in the game failing to start.
|
||||
@@ -98,34 +149,109 @@ public @interface Mod
|
||||
*
|
||||
* @return A string listing modids to exclude from loading with this mod.
|
||||
*/
|
||||
@Deprecated
|
||||
String modExclusionList() default "";
|
||||
/**
|
||||
* Specifying this field allows for a mod to expect a signed jar with a fingerprint matching this value.
|
||||
* The fingerprint should be SHA-1 encoded, lowercase with ':' removed. An empty value indicates that
|
||||
* the mod is not expecting to be signed.
|
||||
*
|
||||
* Any incorrectness of the fingerprint, be it missing or wrong, will result in the {@link FingerprintWarning}
|
||||
* method firing <i>prior to any other event on the mod</i>.
|
||||
* Any incorrectness of the fingerprint, be it missing or wrong, will result in the {@link FMLFingerprintViolationEvent}
|
||||
* event firing <i>prior to any other event on the mod</i>.
|
||||
*
|
||||
* @return A certificate fingerprint that is expected for this mod.
|
||||
*/
|
||||
String certificateFingerprint() default "";
|
||||
|
||||
/**
|
||||
* The language the mod is authored in. This will be used to control certain libraries being downloaded.
|
||||
* The language the mod is authored in. This will be used to control certain compatibility behaviours for this mod.
|
||||
* Valid values are currently "java", "scala"
|
||||
*
|
||||
* @return The language the mod is authored in
|
||||
*/
|
||||
String modLanguage() default "java";
|
||||
/**
|
||||
* NOT YET IMPLEMENTED. </br>
|
||||
* An optional ASM hook class, that can be used to apply ASM to classes loaded from this mod. It is also given
|
||||
* the ASM tree of the class declaring {@link Mod} to with what it will.
|
||||
* the ASM tree of the class declaring {@link Mod} to do with what it will.
|
||||
*
|
||||
* @return The name of a class to be loaded and executed. Must implement {@link IASMHook}.
|
||||
*/
|
||||
@Deprecated
|
||||
String asmHookClass() default "";
|
||||
|
||||
/**
|
||||
* A list of custom properties for this mod. Completely up to the mod author if/when they
|
||||
* want to put anything in here.
|
||||
* @return an optional list of custom properties
|
||||
*/
|
||||
CustomProperty[] customProperties() default {};
|
||||
|
||||
/**
|
||||
* A custom key => value property pair for use with {@link Mod#customProperties()}
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({})
|
||||
public @interface CustomProperty
|
||||
{
|
||||
/**
|
||||
* A key. Should be unique.
|
||||
* @return A key
|
||||
*/
|
||||
String k();
|
||||
/**
|
||||
* A value. Can be anything.
|
||||
* @return A value
|
||||
*/
|
||||
String v();
|
||||
}
|
||||
/**
|
||||
* Marks the associated method as handling an FML lifecycle event.
|
||||
* The method must have a single parameter, one of the following types. This annotation
|
||||
* replaces the multiple different annotations that previously were used.
|
||||
*
|
||||
* Current event classes. This first section is standard lifecycle events. They are dispatched
|
||||
* at various phases as the game starts. Each event should have information useful to that
|
||||
* phase of the lifecycle. They are fired in this order.
|
||||
*
|
||||
* These suggestions are mostly just suggestions on what to do in each event.
|
||||
* <ul>
|
||||
* <li> {@link FMLPreInitializationEvent} : Run before anything else. Read your config, create blocks,
|
||||
* items, etc, and register them with the {@link GameRegistry}.</li>
|
||||
* <li> {@link FMLInitializationEvent} : Do your mod setup. Build whatever data structures you care about. Register recipes,
|
||||
* send {@link FMLInterModComms} messages to other mods.</li>
|
||||
* <li> {@link FMLPostInitializationEvent} : Handle interaction with other mods, complete your setup based on this.</li>
|
||||
* </ul>
|
||||
* <p>These are the server lifecycle events. They are fired whenever a server is running, or about to run. Each time a server
|
||||
* starts they will be fired in this sequence.
|
||||
* <ul>
|
||||
* <li> {@link FMLServerAboutToStartEvent} : Use if you need to handle something before the server has even been created.</li>
|
||||
* <li> {@link FMLServerStartingEvent} : Do stuff you need to do to set up the server. register commands, tweak the server.</li>
|
||||
* <li> {@link FMLServerStartedEvent} : Do what you need to with the running server.</li>
|
||||
* <li> {@link FMLServerStoppingEvent} : Do what you need to before the server has started it's shutdown sequence.</li>
|
||||
* <li> {@link FMLServerStoppedEvent} : Do whatever cleanup you need once the server has shutdown. Generally only useful
|
||||
* on the integrated server.</li>
|
||||
* </ul>
|
||||
* The second set of events are more specialized, for receiving notification of specific
|
||||
* information.
|
||||
* <ul>
|
||||
* <li> {@link FMLFingerprintViolationEvent} : Sent just before {@link FMLPreInitializationEvent}
|
||||
* if something is wrong with your mod signature</li>
|
||||
* <li> {@link IMCEvent} : Sent just after {@link FMLInitializationEvent} if you have IMC messages waiting
|
||||
* from other mods</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface EventHandler{}
|
||||
|
||||
/**
|
||||
* Deprecated for {@link EventHandler}<br/>
|
||||
* Mark the designated method as to be called at if there is something wrong with the certificate fingerprint of
|
||||
* the mod's jar, or it is missing, or otherwise a problem.
|
||||
* @author cpw
|
||||
@@ -133,72 +259,90 @@ public @interface Mod
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Deprecated
|
||||
public @interface FingerprintWarning {}
|
||||
/**
|
||||
* Deprecated for {@link EventHandler}<br/>
|
||||
* Mark the designated method as being called at the "pre-initialization" phase
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Deprecated
|
||||
public @interface PreInit {}
|
||||
/**
|
||||
* Deprecated for {@link EventHandler}<br/>
|
||||
* Mark the designated method as being called at the "initialization" phase
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Deprecated
|
||||
public @interface Init {}
|
||||
/**
|
||||
* Deprecated for {@link EventHandler}<br/>
|
||||
* Mark the designated method as being called at the "post-initialization" phase
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Deprecated
|
||||
public @interface PostInit {}
|
||||
/**
|
||||
* Deprecated for {@link EventHandler}<br/>
|
||||
* Mark the designated method as being called at the "server-about-to-start" phase
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Deprecated
|
||||
public @interface ServerAboutToStart {}
|
||||
/**
|
||||
* Deprecated for {@link EventHandler}<br/>
|
||||
* Mark the designated method as being called at the "server-starting" phase
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Deprecated
|
||||
public @interface ServerStarting {}
|
||||
/**
|
||||
* Deprecated for {@link EventHandler}<br/>
|
||||
* Mark the designated method as being called at the "server-started" phase
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Deprecated
|
||||
public @interface ServerStarted {}
|
||||
/**
|
||||
* Deprecated for {@link EventHandler}<br/>
|
||||
* Mark the designated method as being called at the "server-stopping" phase
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Deprecated
|
||||
public @interface ServerStopping {}
|
||||
/**
|
||||
* Deprecated for {@link EventHandler}<br/>
|
||||
* Mark the designated method as being called at the "server-stopped" phase
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Deprecated
|
||||
public @interface ServerStopped {}
|
||||
/**
|
||||
* Deprecated for {@link EventHandler}<br/>
|
||||
* Mark the designated method as the receiver for {@link FMLInterModComms} messages
|
||||
* Called between {@link Init} and {@link PostInit}
|
||||
* @author cpw
|
||||
@@ -206,9 +350,11 @@ public @interface Mod
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Deprecated
|
||||
public @interface IMCCallback {}
|
||||
/**
|
||||
* Populate the annotated field with the mod instance.
|
||||
* Populate the annotated field with the mod instance based on the specified ModId. This can be used
|
||||
* to retrieve instances of other mods.
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@@ -234,12 +380,14 @@ public @interface Mod
|
||||
String value() default "";
|
||||
}
|
||||
/**
|
||||
* Populate the annotated field with an instance of the Block as specified
|
||||
* NOT IMPLEMENTED AND SCHEDULED FOR REMOVAL.<br/>
|
||||
* Populate the annotated field with an instance of the Block as specified. This never worked. It will be removed.
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Deprecated
|
||||
public @interface Block {
|
||||
/**
|
||||
* The block's name
|
||||
@@ -251,12 +399,14 @@ public @interface Mod
|
||||
Class<?> itemTypeClass() default ItemBlock.class;
|
||||
}
|
||||
/**
|
||||
* Populate the annotated field with an Item
|
||||
* NOT IMPLEMENTED AND SCHEDULED FOR REMOVAL.<br/>
|
||||
* Populate the annotated field with an Item. This never worked. It will be removed.
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@Deprecated
|
||||
public @interface Item {
|
||||
/**
|
||||
* The name of the item
|
||||
@@ -267,4 +417,14 @@ public @interface Mod
|
||||
*/
|
||||
String typeClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mod instance factory method. Should return an instance of the mod. Applies only to static methods on the same class as {@link Mod}.
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface InstanceFactory {
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -20,12 +20,14 @@ import java.net.URLClassLoader;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import cpw.mods.fml.common.asm.ASMTransformer;
|
||||
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
|
||||
import cpw.mods.fml.common.modloader.BaseModProxy;
|
||||
import cpw.mods.fml.relauncher.RelaunchClassLoader;
|
||||
|
||||
/**
|
||||
* A simple delegating class loader used to load mods into the system
|
||||
@@ -37,16 +39,16 @@ import cpw.mods.fml.relauncher.RelaunchClassLoader;
|
||||
public class ModClassLoader extends URLClassLoader
|
||||
{
|
||||
private static final List<String> STANDARD_LIBRARIES = ImmutableList.of("jinput.jar", "lwjgl.jar", "lwjgl_util.jar");
|
||||
private RelaunchClassLoader mainClassLoader;
|
||||
private LaunchClassLoader mainClassLoader;
|
||||
|
||||
public ModClassLoader(ClassLoader parent) {
|
||||
super(new URL[0], null);
|
||||
this.mainClassLoader = (RelaunchClassLoader)parent;
|
||||
this.mainClassLoader = (LaunchClassLoader)parent;
|
||||
}
|
||||
|
||||
public void addFile(File modFile) throws MalformedURLException
|
||||
{
|
||||
URL url = modFile.toURI().toURL();
|
||||
URL url = modFile.toURI().toURL();
|
||||
mainClassLoader.addURL(url);
|
||||
}
|
||||
|
||||
@@ -81,8 +83,21 @@ public class ModClassLoader extends URLClassLoader
|
||||
|
||||
public Class<? extends BaseModProxy> loadBaseModClass(String modClazzName) throws Exception
|
||||
{
|
||||
AccessTransformer transformer = (AccessTransformer)mainClassLoader.getTransformers().get(0);
|
||||
transformer.ensurePublicAccessFor(modClazzName);
|
||||
AccessTransformer accessTransformer = null;
|
||||
for (IClassTransformer transformer : mainClassLoader.getTransformers())
|
||||
{
|
||||
if (transformer instanceof AccessTransformer)
|
||||
{
|
||||
accessTransformer = (AccessTransformer) transformer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (accessTransformer == null)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, "No access transformer found");
|
||||
throw new LoaderException();
|
||||
}
|
||||
accessTransformer.ensurePublicAccessFor(modClazzName);
|
||||
return (Class<? extends BaseModProxy>) Class.forName(modClazzName, true, this);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -15,8 +15,10 @@ package cpw.mods.fml.common;
|
||||
import java.io.File;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
@@ -131,4 +133,9 @@ public interface ModContainer
|
||||
VersionRange acceptableMinecraftVersionRange();
|
||||
|
||||
Certificate getSigningCertificate();
|
||||
|
||||
public static final Map<String,String> EMPTY_PROPERTIES = ImmutableMap.of();
|
||||
Map<String,String> getCustomModProperties();
|
||||
|
||||
public Class<?> getCustomResourcePackClass();
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -17,6 +17,8 @@ import java.lang.reflect.Modifier;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable.ASMData;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -27,7 +29,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
*/
|
||||
public class ProxyInjector
|
||||
{
|
||||
public static void inject(ModContainer mod, ASMDataTable data, Side side)
|
||||
public static void inject(ModContainer mod, ASMDataTable data, Side side, ILanguageAdapter languageAdapter)
|
||||
{
|
||||
FMLLog.fine("Attempting to inject @SidedProxy classes into %s", mod.getModId());
|
||||
Set<ASMData> targets = data.getAnnotationsFor(mod).get(SidedProxy.class.getName());
|
||||
@@ -46,10 +48,16 @@ public class ProxyInjector
|
||||
throw new LoaderException();
|
||||
}
|
||||
|
||||
String targetType = side.isClient() ? target.getAnnotation(SidedProxy.class).clientSide() : target.getAnnotation(SidedProxy.class).serverSide();
|
||||
SidedProxy annotation = target.getAnnotation(SidedProxy.class);
|
||||
if (!Strings.isNullOrEmpty(annotation.modId()) && !annotation.modId().equals(mod.getModId()))
|
||||
{
|
||||
FMLLog.fine("Skipping proxy injection for %s.%s since it is not for mod %s", targ.getClassName(), targ.getObjectName(), mod.getModId());
|
||||
continue;
|
||||
}
|
||||
String targetType = side.isClient() ? annotation.clientSide() : annotation.serverSide();
|
||||
Object proxy=Class.forName(targetType, true, mcl).newInstance();
|
||||
|
||||
if ((target.getModifiers() & Modifier.STATIC) == 0 )
|
||||
if (languageAdapter.supportsStatics() && (target.getModifiers() & Modifier.STATIC) == 0 )
|
||||
{
|
||||
FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the field is not static", targetType, targ.getClassName(), targ.getObjectName());
|
||||
throw new LoaderException();
|
||||
@@ -59,7 +67,7 @@ public class ProxyInjector
|
||||
FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, targ.getClassName(), targ.getObjectName());
|
||||
throw new LoaderException();
|
||||
}
|
||||
target.set(null, proxy);
|
||||
languageAdapter.setProxy(target, proxyTarget, proxy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -67,5 +75,8 @@ public class ProxyInjector
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// Allow language specific proxy injection.
|
||||
languageAdapter.setInternalProxies(mod, side, mcl);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -18,6 +18,30 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Sided proxies are loaded based on the specific environment they find themselves loaded into.
|
||||
* They are used to ensure that client-specific code (such as GUIs) is only loaded into the game
|
||||
* on the client side.
|
||||
* It is applied to static fields of a class, anywhere in your mod code. FML will scan
|
||||
* and load any classes with this annotation at mod construction time.
|
||||
*
|
||||
* <p>
|
||||
* This example will load a CommonProxy on the server side, and a ClientProxy on the client side.
|
||||
*
|
||||
* <pre>{@code
|
||||
* public class MySidedProxyHolder {
|
||||
* {@literal @}SidedProxy(modId="MyModId",clientSide="mymod.ClientProxy", serverSide="mymod.CommonProxy")
|
||||
* public static CommonProxy proxy;
|
||||
* }
|
||||
*
|
||||
* public class CommonProxy {
|
||||
* // Common or server stuff here that needs to be overridden on the client
|
||||
* }
|
||||
*
|
||||
* public class ClientProxy extends CommonProxy {
|
||||
* // Override common stuff with client specific stuff here
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@@ -35,8 +59,17 @@ public @interface SidedProxy
|
||||
*/
|
||||
String serverSide() default "";
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* Not implemented
|
||||
* The name of a special bukkit plugin class to load and populate
|
||||
*/
|
||||
String bukkitSide() default "";
|
||||
|
||||
/**
|
||||
* The (optional) name of a mod to load this proxy for. This will help ensure correct behaviour when loading a combined
|
||||
* scala/java mod package. It is almost never going to be required, unless you ship both Scala and Java {@link Mod} content
|
||||
* in a single jar.
|
||||
*/
|
||||
String modId() default "";
|
||||
}
|
||||
@@ -5,13 +5,15 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.asm;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
@@ -19,7 +21,6 @@ import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import cpw.mods.fml.common.registry.BlockProxy;
|
||||
import cpw.mods.fml.relauncher.IClassTransformer;
|
||||
|
||||
public class ASMTransformer implements IClassTransformer
|
||||
{
|
||||
|
||||
@@ -14,10 +14,13 @@ package cpw.mods.fml.common.asm;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.ObjectInputStream.GetField;
|
||||
import java.io.StringReader;
|
||||
import java.net.JarURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.CodeSource;
|
||||
import java.security.cert.CertPath;
|
||||
@@ -30,25 +33,38 @@ import java.security.cert.TrustAnchor;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import cpw.mods.fml.common.CertificateHelper;
|
||||
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
import cpw.mods.fml.common.patcher.ClassPatchManager;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import cpw.mods.fml.relauncher.IFMLCallHook;
|
||||
import cpw.mods.fml.relauncher.RelaunchClassLoader;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class FMLSanityChecker implements IFMLCallHook
|
||||
{
|
||||
private static final String FMLFINGERPRINT = "AE:F6:54:79:96:E9:1B:D1:59:70:6C:B4:6B:F5:4A:89:C5:CE:08:1D".toLowerCase().replace(":","");
|
||||
private static final String FORGEFINGERPRINT = "DE:4C:F8:A3:F3:BC:15:63:58:10:04:4C:39:24:0B:F9:68:04:EA:7D".toLowerCase().replace(":", "");
|
||||
private static final String FMLFINGERPRINT = "51:0A:FB:4C:AF:A4:A0:F2:F5:CF:C5:0E:B4:CC:3C:30:24:4A:E3:8E".toLowerCase().replace(":", "");
|
||||
private static final String FORGEFINGERPRINT = "E3:C3:D5:0C:7C:98:6D:F7:4C:64:5C:0A:C5:46:39:74:1C:90:A5:57".toLowerCase().replace(":", "");
|
||||
private static final String MCFINGERPRINT = "CD:99:95:96:56:F7:53:DC:28:D8:63:B4:67:69:F7:F8:FB:AE:FC:FC".toLowerCase().replace(":", "");
|
||||
static class MLDetectorClassVisitor extends ClassVisitor
|
||||
{
|
||||
private boolean foundMarker = false;
|
||||
@@ -68,15 +84,18 @@ public class FMLSanityChecker implements IFMLCallHook
|
||||
}
|
||||
}
|
||||
|
||||
private RelaunchClassLoader cl;
|
||||
private LaunchClassLoader cl;
|
||||
public static File fmlLocation;
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception
|
||||
{
|
||||
CodeSource codeSource = getClass().getProtectionDomain().getCodeSource();
|
||||
boolean goodFML = false;
|
||||
boolean fmlIsJar = false;
|
||||
if (codeSource.getLocation().getProtocol().equals("jar"))
|
||||
{
|
||||
fmlIsJar = true;
|
||||
Certificate[] certificates = codeSource.getCertificates();
|
||||
if (certificates!=null)
|
||||
{
|
||||
@@ -105,6 +124,88 @@ public class FMLSanityChecker implements IFMLCallHook
|
||||
{
|
||||
goodFML = true;
|
||||
}
|
||||
|
||||
boolean goodMC = FMLLaunchHandler.side() == Side.SERVER; //Server is not signed, so assume it's good.
|
||||
int certCount = 0;
|
||||
try
|
||||
{
|
||||
Class cbr = Class.forName("net.minecraft.client.ClientBrandRetriever",false, cl);
|
||||
codeSource = cbr.getProtectionDomain().getCodeSource();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Probably a development environment, or the server (the server is not signed)
|
||||
goodMC = true;
|
||||
}
|
||||
JarFile mcJarFile = null;
|
||||
if (fmlIsJar && !goodMC && codeSource.getLocation().getProtocol().equals("jar"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String mcPath = codeSource.getLocation().getPath().substring(5);
|
||||
mcPath = mcPath.substring(0, mcPath.lastIndexOf('!'));
|
||||
mcPath = URLDecoder.decode(mcPath, Charsets.UTF_8.name());
|
||||
mcJarFile = new JarFile(mcPath,true);
|
||||
mcJarFile.getManifest();
|
||||
JarEntry cbrEntry = mcJarFile.getJarEntry("net/minecraft/client/ClientBrandRetriever.class");
|
||||
ByteStreams.toByteArray(mcJarFile.getInputStream(cbrEntry));
|
||||
Certificate[] certificates = cbrEntry.getCertificates();
|
||||
certCount = certificates != null ? certificates.length : 0;
|
||||
if (certificates!=null)
|
||||
{
|
||||
|
||||
for (Certificate cert : certificates)
|
||||
{
|
||||
String fingerprint = CertificateHelper.getFingerprint(cert);
|
||||
if (fingerprint.equals(MCFINGERPRINT))
|
||||
{
|
||||
FMLRelaunchLog.info("Found valid fingerprint for Minecraft. Certificate fingerprint %s", fingerprint);
|
||||
goodMC = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, e, "A critical error occurred trying to read the minecraft jar file");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (mcJarFile != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
mcJarFile.close();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
// Noise
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
goodMC = true;
|
||||
}
|
||||
if (!goodMC)
|
||||
{
|
||||
FMLRelaunchLog.severe("The minecraft jar %s appears to be corrupt! There has been CRITICAL TAMPERING WITH MINECRAFT, it is highly unlikely minecraft will work! STOP NOW, get a clean copy and try again!",codeSource.getLocation().getFile());
|
||||
if (!Boolean.parseBoolean(System.getProperty("fml.ignoreInvalidMinecraftCertificates","false")))
|
||||
{
|
||||
FMLRelaunchLog.severe("For your safety, FML will not launch minecraft. You will need to fetch a clean version of the minecraft jar file");
|
||||
FMLRelaunchLog.severe("Technical information: The class net.minecraft.client.ClientBrandRetriever should have been associated with the minecraft jar file, " +
|
||||
"and should have returned us a valid, intact minecraft jar location. This did not work. Either you have modified the minecraft jar file (if so " +
|
||||
"run the forge installer again), or you are using a base editing jar that is changing this class (and likely others too). If you REALLY " +
|
||||
"want to run minecraft in this configuration, add the flag -Dfml.ignoreInvalidMinecraftCertificates=true to the 'JVM settings' in your launcher profile.");
|
||||
System.exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLRelaunchLog.severe("FML has been ordered to ignore the invalid or missing minecraft certificate. This is very likely to cause a problem!");
|
||||
FMLRelaunchLog.severe("Technical information: ClientBrandRetriever was at %s, there were %d certificates for it", codeSource.getLocation(), certCount);
|
||||
}
|
||||
}
|
||||
if (!goodFML)
|
||||
{
|
||||
FMLRelaunchLog.severe("FML appears to be missing any signature data. This is not a good thing");
|
||||
@@ -137,8 +238,11 @@ public class FMLSanityChecker implements IFMLCallHook
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data)
|
||||
{
|
||||
cl = (RelaunchClassLoader) data.get("classLoader");
|
||||
FMLDeobfuscatingRemapper.INSTANCE.setup((File)data.get("mcLocation"), cl, (String) data.get("deobfuscationFileName"));
|
||||
cl = (LaunchClassLoader) data.get("classLoader");
|
||||
File mcDir = (File)data.get("mcLocation");
|
||||
fmlLocation = (File)data.get("coremodLocation");
|
||||
FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName"));
|
||||
ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,8 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
@@ -48,7 +50,7 @@ import com.google.common.io.LineProcessor;
|
||||
import com.google.common.io.Resources;
|
||||
|
||||
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
import cpw.mods.fml.relauncher.IClassTransformer;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
|
||||
public class AccessTransformer implements IClassTransformer
|
||||
{
|
||||
@@ -152,9 +154,9 @@ public class AccessTransformer implements IClassTransformer
|
||||
return true;
|
||||
}
|
||||
});
|
||||
System.out.printf("Loaded %d rules from AccessTransformer config file %s\n", modifiers.size(), rulesFile);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] bytes)
|
||||
{
|
||||
@@ -163,7 +165,7 @@ public class AccessTransformer implements IClassTransformer
|
||||
|
||||
if (DEBUG)
|
||||
{
|
||||
System.out.printf("Considering all methods and fields on %s (%s): %b\n", name, transformedName, makeAllPublic);
|
||||
FMLRelaunchLog.fine("Considering all methods and fields on %s (%s): %b\n", name, transformedName, makeAllPublic);
|
||||
}
|
||||
if (!makeAllPublic && !modifiers.containsKey(name)) { return bytes; }
|
||||
|
||||
@@ -209,7 +211,7 @@ public class AccessTransformer implements IClassTransformer
|
||||
}
|
||||
if (m.desc.isEmpty())
|
||||
{
|
||||
for (FieldNode n : (List<FieldNode>) classNode.fields)
|
||||
for (FieldNode n : classNode.fields)
|
||||
{
|
||||
if (n.name.equals(m.name) || m.name.equals("*"))
|
||||
{
|
||||
@@ -228,7 +230,7 @@ public class AccessTransformer implements IClassTransformer
|
||||
}
|
||||
else
|
||||
{
|
||||
for (MethodNode n : (List<MethodNode>) classNode.methods)
|
||||
for (MethodNode n : classNode.methods)
|
||||
{
|
||||
if ((n.name.equals(m.name) && n.desc.equals(m.desc)) || m.name.equals("*"))
|
||||
{
|
||||
@@ -282,7 +284,7 @@ public class AccessTransformer implements IClassTransformer
|
||||
}
|
||||
|
||||
// Clear the "final" marker on fields only if specified in control field
|
||||
if (target.changeFinal && target.desc == "")
|
||||
if (target.changeFinal)
|
||||
{
|
||||
if (target.markFinal)
|
||||
{
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.asm.transformers;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassNameTransformer;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
@@ -20,8 +23,6 @@ import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
import cpw.mods.fml.common.asm.transformers.deobf.FMLRemappingAdapter;
|
||||
import cpw.mods.fml.relauncher.IClassNameTransformer;
|
||||
import cpw.mods.fml.relauncher.IClassTransformer;
|
||||
|
||||
public class DeobfuscationTransformer implements IClassTransformer, IClassNameTransformer {
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -58,6 +58,7 @@ public class MCPMerger
|
||||
private static HashSet<String> copyToServer = new HashSet<String>();
|
||||
private static HashSet<String> copyToClient = new HashSet<String>();
|
||||
private static HashSet<String> dontAnnotate = new HashSet<String>();
|
||||
private static HashSet<String> dontProcess = new HashSet<String>();
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
public static void main(String[] args)
|
||||
@@ -71,9 +72,8 @@ public class MCPMerger
|
||||
File map_file = new File(args[0]);
|
||||
File client_jar = new File(args[1]);
|
||||
File server_jar = new File(args[2]);
|
||||
File client_jar_tmp = new File(args[1] + ".MergeBack");
|
||||
File server_jar_tmp = new File(args[2] + ".MergeBack");
|
||||
|
||||
File client_jar_tmp = new File(args[1] + ".backup_merge");
|
||||
File server_jar_tmp = new File(args[2] + ".backup_merge");
|
||||
|
||||
if (client_jar_tmp.exists() && !client_jar_tmp.delete())
|
||||
{
|
||||
@@ -150,12 +150,13 @@ public class MCPMerger
|
||||
line = line.split("#")[0];
|
||||
char cmd = line.charAt(0);
|
||||
line = line.substring(1).trim();
|
||||
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case '!': dontAnnotate.add(line); break;
|
||||
case '<': copyToClient.add(line); break;
|
||||
case '>': copyToServer.add(line); break;
|
||||
case '>': copyToServer.add(line); break;
|
||||
case '^': dontProcess.add(line); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,19 +334,30 @@ public class MCPMerger
|
||||
return ann;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Hashtable<String, ZipEntry> getClassEntries(ZipFile inFile, ZipOutputStream outFile) throws IOException
|
||||
{
|
||||
Hashtable<String, ZipEntry> ret = new Hashtable<String, ZipEntry>();
|
||||
for (ZipEntry entry : Collections.list((Enumeration<ZipEntry>)inFile.entries()))
|
||||
for (ZipEntry entry : Collections.list(inFile.entries()))
|
||||
{
|
||||
if (entry.isDirectory())
|
||||
{
|
||||
outFile.putNextEntry(entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
String entryName = entry.getName();
|
||||
if (!entryName.endsWith(".class") || entryName.startsWith("."))
|
||||
|
||||
boolean filtered = false;
|
||||
for (String filter : dontProcess)
|
||||
{
|
||||
if (entryName.startsWith(filter))
|
||||
{
|
||||
filtered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (filtered || !entryName.endsWith(".class") || entryName.startsWith("."))
|
||||
{
|
||||
ZipEntry newEntry = new ZipEntry(entry.getName());
|
||||
outFile.putNextEntry(newEntry);
|
||||
@@ -410,7 +422,6 @@ public class MCPMerger
|
||||
return classNode;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void processFields(ClassNode cClass, ClassNode sClass, ClassInfo info)
|
||||
{
|
||||
List<FieldNode> cFields = cClass.fields;
|
||||
@@ -524,7 +535,6 @@ public class MCPMerger
|
||||
return Objects.toStringHelper(this).add("name", node.name).add("desc",node.desc).add("server",server).add("client",client).toString();
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void processMethods(ClassNode cClass, ClassNode sClass, ClassInfo info)
|
||||
{
|
||||
List<MethodNode> cMethods = (List<MethodNode>)cClass.methods;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -26,6 +26,8 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
@@ -39,8 +41,6 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.io.LineProcessor;
|
||||
import com.google.common.io.Resources;
|
||||
|
||||
import cpw.mods.fml.relauncher.IClassTransformer;
|
||||
|
||||
public class MarkerTransformer implements IClassTransformer
|
||||
{
|
||||
private ListMultimap<String, String> markers = ArrayListMultimap.create();
|
||||
@@ -97,7 +97,6 @@ public class MarkerTransformer implements IClassTransformer
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] bytes)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package cpw.mods.fml.common.asm.transformers;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import cpw.mods.fml.common.patcher.ClassPatchManager;
|
||||
|
||||
public class PatchingTransformer implements IClassTransformer {
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] bytes)
|
||||
{
|
||||
return ClassPatchManager.INSTANCE.applyPatch(name, transformedName, bytes);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -15,6 +15,8 @@ package cpw.mods.fml.common.asm.transformers;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Type;
|
||||
@@ -23,15 +25,13 @@ import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLRelauncher;
|
||||
import cpw.mods.fml.relauncher.IClassTransformer;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SideTransformer implements IClassTransformer
|
||||
{
|
||||
private static String SIDE = FMLRelauncher.side();
|
||||
private static String SIDE = FMLLaunchHandler.side().name();
|
||||
private static final boolean DEBUG = false;
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] bytes)
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package cpw.mods.fml.common.asm.transformers.deobf;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -23,9 +24,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
|
||||
@@ -38,7 +42,9 @@ import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -48,7 +54,8 @@ import com.google.common.io.InputSupplier;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import cpw.mods.fml.relauncher.RelaunchClassLoader;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
|
||||
public class FMLDeobfuscatingRemapper extends Remapper {
|
||||
public static final FMLDeobfuscatingRemapper INSTANCE = new FMLDeobfuscatingRemapper();
|
||||
@@ -62,7 +69,7 @@ public class FMLDeobfuscatingRemapper extends Remapper {
|
||||
private Map<String,Map<String,String>> fieldNameMaps;
|
||||
private Map<String,Map<String,String>> methodNameMaps;
|
||||
|
||||
private RelaunchClassLoader classLoader;
|
||||
private LaunchClassLoader classLoader;
|
||||
|
||||
private FMLDeobfuscatingRemapper()
|
||||
{
|
||||
@@ -70,17 +77,61 @@ public class FMLDeobfuscatingRemapper extends Remapper {
|
||||
mcpNameBiMap=ImmutableBiMap.of();
|
||||
}
|
||||
|
||||
public void setup(File mcDir, RelaunchClassLoader classLoader, String deobfFileName)
|
||||
public void setupLoadOnly(String deobfFileName, boolean loadAll)
|
||||
{
|
||||
try
|
||||
{
|
||||
File mapData = new File(deobfFileName);
|
||||
LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData));
|
||||
InputSupplier<InputStreamReader> srgSupplier = CharStreams.newReaderSupplier(zis,Charsets.UTF_8);
|
||||
List<String> srgList = CharStreams.readLines(srgSupplier);
|
||||
rawMethodMaps = Maps.newHashMap();
|
||||
rawFieldMaps = Maps.newHashMap();
|
||||
Builder<String, String> builder = ImmutableBiMap.<String,String>builder();
|
||||
Builder<String, String> mcpBuilder = ImmutableBiMap.<String,String>builder();
|
||||
Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
|
||||
for (String line : srgList)
|
||||
{
|
||||
String[] parts = Iterables.toArray(splitter.split(line),String.class);
|
||||
String typ = parts[0];
|
||||
if ("CL".equals(typ))
|
||||
{
|
||||
parseClass(builder, parts);
|
||||
parseMCPClass(mcpBuilder,parts);
|
||||
}
|
||||
else if ("MD".equals(typ) && loadAll)
|
||||
{
|
||||
parseMethod(parts);
|
||||
}
|
||||
else if ("FD".equals(typ) && loadAll)
|
||||
{
|
||||
parseField(parts);
|
||||
}
|
||||
}
|
||||
classNameBiMap = builder.build();
|
||||
// Special case some mappings for modloader mods
|
||||
mcpBuilder.put("BaseMod","net/minecraft/src/BaseMod");
|
||||
mcpBuilder.put("ModLoader","net/minecraft/src/ModLoader");
|
||||
mcpBuilder.put("EntityRendererProxy","net/minecraft/src/EntityRendererProxy");
|
||||
mcpBuilder.put("MLProp","net/minecraft/src/MLProp");
|
||||
mcpBuilder.put("TradeEntry","net/minecraft/src/TradeEntry");
|
||||
mcpNameBiMap = mcpBuilder.build();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
Logger.getLogger("FML").log(Level.SEVERE, "An error occurred loading the deobfuscation map data", ioe);
|
||||
}
|
||||
methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
|
||||
fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
|
||||
|
||||
}
|
||||
public void setup(File mcDir, LaunchClassLoader classLoader, String deobfFileName)
|
||||
{
|
||||
this.classLoader = classLoader;
|
||||
try
|
||||
{
|
||||
File libDir = new File(mcDir, "lib");
|
||||
File mapData = new File(libDir, deobfFileName);
|
||||
mapData = mapData.getCanonicalFile();
|
||||
ZipFile mapZip = new ZipFile(mapData);
|
||||
ZipEntry classData = mapZip.getEntry("joined.srg");
|
||||
ZipInputSupplier zis = new ZipInputSupplier(mapZip, classData);
|
||||
InputStream classData = getClass().getResourceAsStream(deobfFileName);
|
||||
LZMAInputSupplier zis = new LZMAInputSupplier(classData);
|
||||
InputSupplier<InputStreamReader> srgSupplier = CharStreams.newReaderSupplier(zis,Charsets.UTF_8);
|
||||
List<String> srgList = CharStreams.readLines(srgSupplier);
|
||||
rawMethodMaps = Maps.newHashMap();
|
||||
@@ -125,7 +176,8 @@ public class FMLDeobfuscatingRemapper extends Remapper {
|
||||
|
||||
public boolean isRemappedClass(String className)
|
||||
{
|
||||
return classNameBiMap.containsKey(className) || mcpNameBiMap.containsKey(className);
|
||||
className = className.replace('.', '/');
|
||||
return classNameBiMap.containsKey(className) || mcpNameBiMap.containsKey(className) || (!classNameBiMap.isEmpty() && className.indexOf('/') == -1);
|
||||
}
|
||||
|
||||
private void parseField(String[] parts)
|
||||
@@ -141,7 +193,46 @@ public class FMLDeobfuscatingRemapper extends Remapper {
|
||||
{
|
||||
rawFieldMaps.put(cl, Maps.<String,String>newHashMap());
|
||||
}
|
||||
rawFieldMaps.get(cl).put(oldName, newName);
|
||||
rawFieldMaps.get(cl).put(oldName + ":" + getFieldType(cl, oldName), newName);
|
||||
rawFieldMaps.get(cl).put(oldName + ":null", newName);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cache the field descriptions for classes so we don't repeatedly reload the same data again and again
|
||||
*/
|
||||
private Map<String,Map<String,String>> fieldDescriptions = Maps.newHashMap();
|
||||
|
||||
private String getFieldType(String owner, String name)
|
||||
{
|
||||
if (fieldDescriptions.containsKey(owner))
|
||||
{
|
||||
return fieldDescriptions.get(owner).get(name);
|
||||
}
|
||||
synchronized (fieldDescriptions)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] classBytes = classLoader.getClassBytes(owner);
|
||||
if (classBytes == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ClassReader cr = new ClassReader(classBytes);
|
||||
ClassNode classNode = new ClassNode();
|
||||
cr.accept(classNode, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||
Map<String,String> resMap = Maps.newHashMap();
|
||||
for (FieldNode fieldNode : (List<FieldNode>) classNode.fields) {
|
||||
resMap.put(fieldNode.name, fieldNode.desc);
|
||||
}
|
||||
fieldDescriptions.put(owner, resMap);
|
||||
return resMap.get(name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE,e, "A critical exception occured reading a class file %s", owner);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void parseClass(Builder<String, String> builder, String[] parts)
|
||||
@@ -180,7 +271,7 @@ public class FMLDeobfuscatingRemapper extends Remapper {
|
||||
return name;
|
||||
}
|
||||
Map<String, String> fieldMap = getFieldMap(owner);
|
||||
return fieldMap!=null && fieldMap.containsKey(name) ? fieldMap.get(name) : name;
|
||||
return fieldMap!=null && fieldMap.containsKey(name+":"+desc) ? fieldMap.get(name+":"+desc) : name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -319,4 +410,9 @@ public class FMLDeobfuscatingRemapper extends Remapper {
|
||||
fieldNameMaps.put(name, ImmutableMap.copyOf(fieldMap));
|
||||
// System.out.printf("Maps: %s %s\n", name, methodMap);
|
||||
}
|
||||
|
||||
public Set<String> getObfedClasses()
|
||||
{
|
||||
return ImmutableSet.copyOf(classNameBiMap.keySet());
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -17,22 +17,22 @@ import java.io.InputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import LZMA.LzmaInputStream;
|
||||
|
||||
import com.google.common.io.InputSupplier;
|
||||
|
||||
public class ZipInputSupplier implements InputSupplier<InputStream> {
|
||||
private ZipFile zipFile;
|
||||
private ZipEntry zipEntry;
|
||||
public class LZMAInputSupplier implements InputSupplier<InputStream> {
|
||||
private InputStream compressedData;
|
||||
|
||||
public ZipInputSupplier(ZipFile zip, ZipEntry entry)
|
||||
public LZMAInputSupplier(InputStream compressedData)
|
||||
{
|
||||
this.zipFile = zip;
|
||||
this.zipEntry = entry;
|
||||
this.compressedData = compressedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInput() throws IOException
|
||||
{
|
||||
return zipFile.getInputStream(zipEntry);
|
||||
return new LzmaInputStream(this.compressedData);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -14,10 +14,10 @@ package cpw.mods.fml.common.discovery;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@@ -35,11 +35,16 @@ public class JarDiscoverer implements ITypeDiscoverer
|
||||
{
|
||||
List<ModContainer> foundMods = Lists.newArrayList();
|
||||
FMLLog.fine("Examining file %s for potential mods", candidate.getModContainer().getName());
|
||||
ZipFile jar = null;
|
||||
JarFile jar = null;
|
||||
try
|
||||
{
|
||||
jar = new ZipFile(candidate.getModContainer());
|
||||
jar = new JarFile(candidate.getModContainer());
|
||||
|
||||
if (jar.getManifest()!=null && (jar.getManifest().getMainAttributes().get("FMLCorePlugin") != null || jar.getManifest().getMainAttributes().get("TweakClass") != null))
|
||||
{
|
||||
FMLLog.finest("Ignoring coremod or tweak system %s", candidate.getModContainer());
|
||||
return foundMods;
|
||||
}
|
||||
ZipEntry modInfo = jar.getEntry("mcmod.info");
|
||||
MetadataCollection mc = null;
|
||||
if (modInfo != null)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -27,7 +27,7 @@ import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.LoaderException;
|
||||
import cpw.mods.fml.common.ModClassLoader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.relauncher.RelaunchLibraryManager;
|
||||
import cpw.mods.fml.relauncher.CoreModManager;
|
||||
|
||||
public class ModDiscoverer
|
||||
{
|
||||
@@ -41,7 +41,14 @@ public class ModDiscoverer
|
||||
|
||||
public void findClasspathMods(ModClassLoader modClassLoader)
|
||||
{
|
||||
List<String> knownLibraries = ImmutableList.<String>builder().addAll(modClassLoader.getDefaultLibraries()).addAll(RelaunchLibraryManager.getLibraries()).build();
|
||||
List<String> knownLibraries = ImmutableList.<String>builder()
|
||||
// skip default libs
|
||||
.addAll(modClassLoader.getDefaultLibraries())
|
||||
// skip loaded coremods
|
||||
.addAll(CoreModManager.getLoadedCoremods())
|
||||
// skip reparse coremods here
|
||||
.addAll(CoreModManager.getReparseableCoremods())
|
||||
.build();
|
||||
File[] minecraftSources = modClassLoader.getParentSources();
|
||||
if (minecraftSources.length == 1 && minecraftSources[0].isFile())
|
||||
{
|
||||
@@ -82,7 +89,12 @@ public class ModDiscoverer
|
||||
|
||||
for (File modFile : modList)
|
||||
{
|
||||
if (modFile.isDirectory())
|
||||
// skip loaded coremods
|
||||
if (CoreModManager.getLoadedCoremods().contains(modFile.getName()))
|
||||
{
|
||||
FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName());
|
||||
}
|
||||
else if (modFile.isDirectory())
|
||||
{
|
||||
FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
|
||||
candidates.add(new ModCandidate(modFile, modFile, ContainerType.DIR));
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package cpw.mods.fml.common.functions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
|
||||
public class ArtifactVersionNameFunction implements Function<ArtifactVersion, String> {
|
||||
public String apply(ArtifactVersion v)
|
||||
{
|
||||
return v.getLabel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cpw.mods.fml.common.launcher;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
public class FMLServerTweaker extends FMLTweaker {
|
||||
@Override
|
||||
public String getLaunchTarget()
|
||||
{
|
||||
return "net.minecraft.server.MinecraftServer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader)
|
||||
{
|
||||
classLoader.addTransformerExclusion("cpw.mods.fml.repackage.");
|
||||
classLoader.addTransformerExclusion("cpw.mods.fml.relauncher.");
|
||||
classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers.");
|
||||
classLoader.addClassLoaderExclusion("LZMA.");
|
||||
FMLLaunchHandler.configureForServerLaunch(classLoader, this);
|
||||
FMLLaunchHandler.appendCoreMods();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package cpw.mods.fml.common.launcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import joptsimple.ArgumentAcceptingOptionSpec;
|
||||
import joptsimple.NonOptionArgumentSpec;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
public class FMLTweaker implements ITweaker {
|
||||
private List<String> args;
|
||||
private File gameDir;
|
||||
private File assetsDir;
|
||||
private String profile;
|
||||
private static URI jarLocation;
|
||||
|
||||
@Override
|
||||
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
|
||||
{
|
||||
this.gameDir = (gameDir == null ? new File(".") : gameDir);
|
||||
this.assetsDir = assetsDir;
|
||||
this.profile = profile;
|
||||
this.args = args;
|
||||
try
|
||||
{
|
||||
jarLocation = getClass().getProtectionDomain().getCodeSource().getLocation().toURI();
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
Logger.getLogger("FMLTWEAK").log(Level.SEVERE, "Missing URI information for FML tweak");
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader)
|
||||
{
|
||||
classLoader.addTransformerExclusion("cpw.mods.fml.repackage.");
|
||||
classLoader.addTransformerExclusion("cpw.mods.fml.relauncher.");
|
||||
classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers.");
|
||||
classLoader.addClassLoaderExclusion("LZMA.");
|
||||
FMLLaunchHandler.configureForClientLaunch(classLoader, this);
|
||||
FMLLaunchHandler.appendCoreMods();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLaunchTarget()
|
||||
{
|
||||
return "net.minecraft.client.main.Main";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getLaunchArguments()
|
||||
{
|
||||
List<String> blackboardArgs = (List<String>) Launch.blackboard.get("ArgumentList");
|
||||
|
||||
String[] launchArgsArray = args.toArray(new String[args.size()]);
|
||||
|
||||
if (gameDir != null && !blackboardArgs.contains("--gameDir"))
|
||||
{
|
||||
launchArgsArray = ObjectArrays.concat(gameDir.getAbsolutePath(),launchArgsArray);
|
||||
launchArgsArray = ObjectArrays.concat("--gameDir",launchArgsArray);
|
||||
}
|
||||
|
||||
if (assetsDir != null && !blackboardArgs.contains("--assetsDir"))
|
||||
{
|
||||
launchArgsArray = ObjectArrays.concat(assetsDir.getAbsolutePath(),launchArgsArray);
|
||||
launchArgsArray = ObjectArrays.concat("--assetsDir",launchArgsArray);
|
||||
}
|
||||
if (!blackboardArgs.contains("--version"))
|
||||
{
|
||||
launchArgsArray = ObjectArrays.concat(profile != null ? profile : "UnknownFMLProfile",launchArgsArray);
|
||||
launchArgsArray = ObjectArrays.concat("--version",launchArgsArray);
|
||||
}
|
||||
return launchArgsArray;
|
||||
}
|
||||
|
||||
public File getGameDir()
|
||||
{
|
||||
return gameDir;
|
||||
}
|
||||
|
||||
public static URI getJarLocation()
|
||||
{
|
||||
return jarLocation;
|
||||
}
|
||||
|
||||
public void injectCascadingTweak(String tweakClassName)
|
||||
{
|
||||
List<String> tweakClasses = (List<String>) Launch.blackboard.get("TweakClasses");
|
||||
tweakClasses.add(tweakClassName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class ModLoaderFuelHelper implements IFuelHandler
|
||||
@Override
|
||||
public int getBurnTime(ItemStack fuel)
|
||||
{
|
||||
return mod.addFuel(fuel.field_77993_c, fuel.field_77993_c);
|
||||
return mod.addFuel(fuel.field_77993_c, fuel.func_77960_j());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,6 +40,7 @@ import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.ILanguageAdapter;
|
||||
import cpw.mods.fml.common.LoadController;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.LoaderException;
|
||||
@@ -496,7 +497,7 @@ public class ModLoaderModContainer implements ModContainer
|
||||
{
|
||||
dummyHandler.setBaseMod(mod);
|
||||
}
|
||||
ProxyInjector.inject(this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide());
|
||||
ProxyInjector.inject(this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide(), new ILanguageAdapter.JavaAdapter());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -614,4 +615,16 @@ public class ModLoaderModContainer implements ModContainer
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCustomModProperties()
|
||||
{
|
||||
return EMPTY_PROPERTIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getCustomResourcePackClass()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -184,8 +184,7 @@ public class EntitySpawnPacket extends FMLPacket
|
||||
ModContainer mc = nmh.getContainer();
|
||||
|
||||
EntityRegistration registration = EntityRegistry.instance().lookupModSpawn(mc, modEntityId);
|
||||
Class<? extends Entity> cls = registration.getEntityClass();
|
||||
if (cls == null)
|
||||
if (registration == null || registration.getEntityClass() == null)
|
||||
{
|
||||
FMLLog.log(Level.WARNING, "Missing mod entity information for %s : %d", mc.getModId(), modEntityId);
|
||||
return;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -41,6 +41,7 @@ import com.google.common.hash.Hashing;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.InjectedModContainer;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
@@ -269,6 +270,10 @@ public class FMLNetworkHandler
|
||||
|
||||
public NetworkModHandler findNetworkModHandler(Object mc)
|
||||
{
|
||||
if (mc instanceof InjectedModContainer)
|
||||
{
|
||||
return networkModHandlers.get(((InjectedModContainer)mc).wrappedContainer);
|
||||
}
|
||||
if (mc instanceof ModContainer)
|
||||
{
|
||||
return networkModHandlers.get(mc);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -96,6 +96,10 @@ public class NetworkModHandler
|
||||
}
|
||||
}
|
||||
|
||||
configureNetworkMod(container);
|
||||
}
|
||||
protected void configureNetworkMod(ModContainer container)
|
||||
{
|
||||
if (this.checkHandler == null)
|
||||
{
|
||||
String versionBounds = mod.versionBounds();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package cpw.mods.fml.common.patcher;
|
||||
|
||||
public class ClassPatch {
|
||||
public final String name;
|
||||
public final String sourceClassName;
|
||||
public final String targetClassName;
|
||||
public final boolean existsAtTarget;
|
||||
public final byte[] patch;
|
||||
public final int inputChecksum;
|
||||
public ClassPatch(String name, String sourceClassName, String targetClassName, boolean existsAtTarget, int inputChecksum, byte[] patch)
|
||||
{
|
||||
this.name = name;
|
||||
this.sourceClassName = sourceClassName;
|
||||
this.targetClassName = targetClassName;
|
||||
this.existsAtTarget = existsAtTarget;
|
||||
this.inputChecksum = inputChecksum;
|
||||
this.patch = patch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s : %s => %s (%b) size %d", name, sourceClassName, targetClassName, existsAtTarget, patch.length);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package cpw.mods.fml.common.patcher;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.CodeSource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.JarInputStream;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Pack200;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import LZMA.LzmaInputStream;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import cpw.mods.fml.common.launcher.FMLTweaker;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.repackage.com.nothome.delta.GDiffPatcher;
|
||||
|
||||
public class ClassPatchManager {
|
||||
public static final ClassPatchManager INSTANCE = new ClassPatchManager();
|
||||
|
||||
public static final boolean dumpPatched = Boolean.parseBoolean(System.getProperty("fml.dumpPatchedClasses", "false"));
|
||||
|
||||
private GDiffPatcher patcher = new GDiffPatcher();
|
||||
private ListMultimap<String, ClassPatch> patches;
|
||||
|
||||
private File tempDir;
|
||||
private ClassPatchManager()
|
||||
{
|
||||
if (dumpPatched)
|
||||
{
|
||||
tempDir = Files.createTempDir();
|
||||
FMLRelaunchLog.info("Dumping patched classes to %s",tempDir.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] applyPatch(String name, String mappedName, byte[] inputData)
|
||||
{
|
||||
if (patches == null)
|
||||
{
|
||||
return inputData;
|
||||
}
|
||||
List<ClassPatch> list = patches.get(name);
|
||||
if (list.isEmpty())
|
||||
{
|
||||
return inputData;
|
||||
}
|
||||
boolean ignoredError = false;
|
||||
FMLRelaunchLog.fine("Runtime patching class %s (input size %d), found %d patch%s", mappedName, (inputData == null ? 0 : inputData.length), list.size(), list.size()!=1 ? "es" : "");
|
||||
for (ClassPatch patch: list)
|
||||
{
|
||||
if (!patch.targetClassName.equals(mappedName))
|
||||
{
|
||||
FMLRelaunchLog.warning("Binary patch found %s for wrong class %s", patch.targetClassName, mappedName);
|
||||
}
|
||||
if (!patch.existsAtTarget && (inputData == null || inputData.length == 0))
|
||||
{
|
||||
inputData = new byte[0];
|
||||
}
|
||||
else if (!patch.existsAtTarget)
|
||||
{
|
||||
FMLRelaunchLog.warning("Patcher expecting empty class data file for %s, but received non-empty", patch.targetClassName);
|
||||
}
|
||||
else
|
||||
{
|
||||
int inputChecksum = Hashing.adler32().hashBytes(inputData).asInt();
|
||||
if (patch.inputChecksum != inputChecksum)
|
||||
{
|
||||
FMLRelaunchLog.severe("There is a binary discrepency between the expected input class %s (%s) and the actual class. Checksum on disk is %x, in patch %x. Things are probably about to go very wrong. Did you put something into the jar file?", mappedName, name, inputChecksum, patch.inputChecksum);
|
||||
if (!Boolean.parseBoolean(System.getProperty("fml.ignorePatchDiscrepancies","false")))
|
||||
{
|
||||
FMLRelaunchLog.severe("The game is going to exit, because this is a critical error, and it is very improbable that the modded game will work, please obtain clean jar files.");
|
||||
System.exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLRelaunchLog.severe("FML is going to ignore this error, note that the patch will not be applied, and there is likely to be a malfunctioning behaviour, including not running at all");
|
||||
ignoredError = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
synchronized (patcher)
|
||||
{
|
||||
try
|
||||
{
|
||||
inputData = patcher.patch(inputData, patch.patch);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, e, "Encountered problem runtime patching class %s", name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ignoredError)
|
||||
{
|
||||
FMLRelaunchLog.fine("Successfully applied runtime patches for %s (new size %d)", mappedName, inputData.length);
|
||||
}
|
||||
if (dumpPatched)
|
||||
{
|
||||
try
|
||||
{
|
||||
Files.write(inputData, new File(tempDir,mappedName));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, e, "Failed to write %s to %s", mappedName, tempDir.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
return inputData;
|
||||
}
|
||||
|
||||
public void setup(Side side)
|
||||
{
|
||||
Pattern binpatchMatcher = Pattern.compile(String.format("binpatch/%s/.*.binpatch", side.toString().toLowerCase(Locale.ENGLISH)));
|
||||
JarInputStream jis;
|
||||
try
|
||||
{
|
||||
InputStream binpatchesCompressed = getClass().getResourceAsStream("/binpatches.pack.lzma");
|
||||
if (binpatchesCompressed==null)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, "The binary patch set is missing. Either you are in a development environment, or things are not going to work!");
|
||||
return;
|
||||
}
|
||||
LzmaInputStream binpatchesDecompressed = new LzmaInputStream(binpatchesCompressed);
|
||||
ByteArrayOutputStream jarBytes = new ByteArrayOutputStream();
|
||||
JarOutputStream jos = new JarOutputStream(jarBytes);
|
||||
Pack200.newUnpacker().unpack(binpatchesDecompressed, jos);
|
||||
jis = new JarInputStream(new ByteArrayInputStream(jarBytes.toByteArray()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, e, "Error occurred reading binary patches. Expect severe problems!");
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
|
||||
patches = ArrayListMultimap.create();
|
||||
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
JarEntry entry = jis.getNextJarEntry();
|
||||
if (entry == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (binpatchMatcher.matcher(entry.getName()).matches())
|
||||
{
|
||||
ClassPatch cp = readPatch(entry, jis);
|
||||
if (cp != null)
|
||||
{
|
||||
patches.put(cp.sourceClassName, cp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jis.closeEntry();
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
} while (true);
|
||||
FMLRelaunchLog.fine("Read %d binary patches", patches.size());
|
||||
FMLRelaunchLog.fine("Patch list :\n\t%s", Joiner.on("\t\n").join(patches.asMap().entrySet()));
|
||||
}
|
||||
|
||||
private ClassPatch readPatch(JarEntry patchEntry, JarInputStream jis)
|
||||
{
|
||||
FMLRelaunchLog.finest("Reading patch data from %s", patchEntry.getName());
|
||||
ByteArrayDataInput input;
|
||||
try
|
||||
{
|
||||
input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.WARNING, e, "Unable to read binpatch file %s - ignoring", patchEntry.getName());
|
||||
return null;
|
||||
}
|
||||
String name = input.readUTF();
|
||||
String sourceClassName = input.readUTF();
|
||||
String targetClassName = input.readUTF();
|
||||
boolean exists = input.readBoolean();
|
||||
int inputChecksum = 0;
|
||||
if (exists)
|
||||
{
|
||||
inputChecksum = input.readInt();
|
||||
}
|
||||
int patchLength = input.readInt();
|
||||
byte[] patchBytes = new byte[patchLength];
|
||||
input.readFully(patchBytes);
|
||||
|
||||
return new ClassPatch(name, sourceClassName, targetClassName, exists, inputChecksum, patchBytes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package cpw.mods.fml.common.patcher;
|
||||
|
||||
public class ClassPatchingTransformer {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package cpw.mods.fml.common.patcher;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
import cpw.mods.fml.repackage.com.nothome.delta.Delta;
|
||||
|
||||
public class GenDiffSet {
|
||||
|
||||
private static final List<String> RESERVED_NAMES = Arrays.asList("CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9");
|
||||
|
||||
public static void main(String[] args) throws IOException
|
||||
{
|
||||
String sourceJar = args[0]; //Clean Vanilla jar minecraft.jar or minecraft_server.jar
|
||||
String targetDir = args[1]; //Directory containing obfed output classes, typically mcp/reobf/minecraft
|
||||
String deobfData = args[2]; //Path to FML's deobfusication_data.lzma
|
||||
String outputDir = args[3]; //Path to place generated .binpatch
|
||||
String killTarget = args[4]; //"true" if we should destroy the target file if it generated a successful .binpatch
|
||||
|
||||
Logger.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", outputDir, sourceJar, targetDir));
|
||||
Delta delta = new Delta();
|
||||
FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE;
|
||||
remapper.setupLoadOnly(deobfData, false);
|
||||
JarFile sourceZip = new JarFile(sourceJar);
|
||||
boolean kill = killTarget.equalsIgnoreCase("true");
|
||||
|
||||
File f = new File(outputDir);
|
||||
f.mkdirs();
|
||||
|
||||
for (String name : remapper.getObfedClasses())
|
||||
{
|
||||
// Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name));
|
||||
String fileName = name;
|
||||
String jarName = name;
|
||||
if (RESERVED_NAMES.contains(name.toUpperCase(Locale.ENGLISH)))
|
||||
{
|
||||
fileName = "_"+name;
|
||||
}
|
||||
File targetFile = new File(targetDir, fileName.replace('/', File.separatorChar) + ".class");
|
||||
jarName = jarName+".class";
|
||||
if (targetFile.exists())
|
||||
{
|
||||
String sourceClassName = name.replace('/', '.');
|
||||
String targetClassName = remapper.map(name).replace('/', '.');
|
||||
JarEntry entry = sourceZip.getJarEntry(jarName);
|
||||
|
||||
byte[] vanillaBytes = entry != null ? ByteStreams.toByteArray(sourceZip.getInputStream(entry)) : new byte[0];
|
||||
byte[] patchedBytes = Files.toByteArray(targetFile);
|
||||
|
||||
byte[] diff = delta.compute(vanillaBytes, patchedBytes);
|
||||
|
||||
|
||||
ByteArrayDataOutput diffOut = ByteStreams.newDataOutput(diff.length + 50);
|
||||
// Original name
|
||||
diffOut.writeUTF(name);
|
||||
// Source name
|
||||
diffOut.writeUTF(sourceClassName);
|
||||
// Target name
|
||||
diffOut.writeUTF(targetClassName);
|
||||
// exists at original
|
||||
diffOut.writeBoolean(entry != null);
|
||||
if (entry != null)
|
||||
{
|
||||
diffOut.writeInt(Hashing.adler32().hashBytes(vanillaBytes).asInt());
|
||||
}
|
||||
// length of patch
|
||||
diffOut.writeInt(diff.length);
|
||||
// patch
|
||||
diffOut.write(diff);
|
||||
|
||||
File target = new File(outputDir, targetClassName+".binpatch");
|
||||
target.getParentFile().mkdirs();
|
||||
Files.write(diffOut.toByteArray(), target);
|
||||
Logger.getLogger("GENDIFF").info(String.format("Wrote patch for %s (%s) at %s",name, targetClassName, target.getAbsolutePath()));
|
||||
if (kill)
|
||||
{
|
||||
targetFile.delete();
|
||||
Logger.getLogger("GENDIFF").info(String.format(" Deleted target: %s", targetFile.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceZip.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,11 +25,17 @@ import java.util.logging.Level;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSand;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.base.Joiner.MapJoiner;
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableTable;
|
||||
import com.google.common.collect.ImmutableTable.Builder;
|
||||
@@ -40,11 +46,13 @@ import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.Table;
|
||||
import com.google.common.collect.Table.Cell;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.LoaderState;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
||||
|
||||
public class GameData {
|
||||
private static Map<Integer, ItemData> idMap = Maps.newHashMap();
|
||||
@@ -54,6 +62,7 @@ public class GameData {
|
||||
private static boolean shouldContinue = true;
|
||||
private static boolean isSaveValid = true;
|
||||
private static ImmutableTable<String, String, Integer> modObjectTable;
|
||||
private static Table<String, String, ItemStack> customItemStacks = HashBasedTable.create();
|
||||
private static Map<String,String> ignoredMods;
|
||||
|
||||
private static boolean isModIgnoredForIdValidation(String modId)
|
||||
@@ -277,7 +286,7 @@ public class GameData {
|
||||
}
|
||||
static Item findItem(String modId, String name)
|
||||
{
|
||||
if (modObjectTable == null)
|
||||
if (modObjectTable == null || !modObjectTable.contains(modId, name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -293,10 +302,89 @@ public class GameData {
|
||||
}
|
||||
|
||||
Integer blockId = modObjectTable.get(modId, name);
|
||||
if (blockId >= Block.field_71973_m.length)
|
||||
if (blockId == null || blockId >= Block.field_71973_m.length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return Block.field_71973_m[blockId];
|
||||
}
|
||||
|
||||
static ItemStack findItemStack(String modId, String name)
|
||||
{
|
||||
ItemStack is = customItemStacks.get(modId, name);
|
||||
if (is == null)
|
||||
{
|
||||
Item i = findItem(modId, name);
|
||||
if (i != null)
|
||||
{
|
||||
is = new ItemStack(i, 0 ,0);
|
||||
}
|
||||
}
|
||||
if (is == null)
|
||||
{
|
||||
Block b = findBlock(modId, name);
|
||||
if (b != null)
|
||||
{
|
||||
is = new ItemStack(b, 0, Short.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
static void registerCustomItemStack(String name, ItemStack itemStack)
|
||||
{
|
||||
customItemStacks.put(Loader.instance().activeModContainer().getModId(), name, itemStack);
|
||||
}
|
||||
|
||||
public static void dumpRegistry(File minecraftDir)
|
||||
{
|
||||
if (customItemStacks == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Boolean.valueOf(System.getProperty("fml.dumpRegistry", "false")).booleanValue())
|
||||
{
|
||||
ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
|
||||
for (String modId : customItemStacks.rowKeySet())
|
||||
{
|
||||
builder.putAll(modId, customItemStacks.row(modId).keySet());
|
||||
}
|
||||
|
||||
File f = new File(minecraftDir, "itemStackRegistry.csv");
|
||||
MapJoiner mapJoiner = Joiner.on("\n").withKeyValueSeparator(",");
|
||||
try
|
||||
{
|
||||
Files.write(mapJoiner.join(builder.build().entries()), f, Charsets.UTF_8);
|
||||
FMLLog.log(Level.INFO, "Dumped item registry data to %s", f.getAbsolutePath());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, "Failed to write registry data to %s", f.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static UniqueIdentifier getUniqueName(Block block)
|
||||
{
|
||||
if (block == null) return null;
|
||||
ItemData itemData = idMap.get(block.field_71990_ca);
|
||||
if (itemData == null || !itemData.isOveridden() || customItemStacks.contains(itemData.getModId(), itemData.getItemType()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new UniqueIdentifier(itemData.getModId(), itemData.getItemType());
|
||||
}
|
||||
|
||||
static UniqueIdentifier getUniqueName(Item item)
|
||||
{
|
||||
if (item == null) return null;
|
||||
ItemData itemData = idMap.get(item.field_77779_bT);
|
||||
if (itemData == null || !itemData.isOveridden() || customItemStacks.contains(itemData.getModId(), itemData.getItemType()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new UniqueIdentifier(itemData.getModId(), itemData.getItemType());
|
||||
}
|
||||
}
|
||||
@@ -95,10 +95,11 @@ public class GameRegistry
|
||||
Random fmlRandom = new Random(worldSeed);
|
||||
long xSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
fmlRandom.setSeed((xSeed * chunkX + zSeed * chunkZ) ^ worldSeed);
|
||||
long chunkSeed = (xSeed * chunkX + zSeed * chunkZ) ^ worldSeed;
|
||||
|
||||
for (IWorldGenerator generator : worldGenerators)
|
||||
{
|
||||
fmlRandom.setSeed(chunkSeed);
|
||||
generator.generate(fmlRandom, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
|
||||
}
|
||||
}
|
||||
@@ -221,7 +222,7 @@ public class GameRegistry
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
itemCtor = itemclass.getConstructor(int.class, Block.class);
|
||||
itemCtor = itemclass.getConstructor(int.class, net.minecraft.block.Block.class);
|
||||
i = itemCtor.newInstance(blockItemId, block);
|
||||
}
|
||||
GameRegistry.registerItem(i,name, modId);
|
||||
@@ -275,7 +276,7 @@ public class GameRegistry
|
||||
public static void registerTileEntityWithAlternatives(Class<? extends TileEntity> tileEntityClass, String id, String... alternatives)
|
||||
{
|
||||
TileEntity.func_70306_a(tileEntityClass, id);
|
||||
Map<String,Class> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_70326_a", "a");
|
||||
Map<String,Class> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_a", "field_70326_a", "a");
|
||||
for (String s: alternatives)
|
||||
{
|
||||
if (!teMappings.containsKey(s))
|
||||
@@ -350,26 +351,55 @@ public class GameRegistry
|
||||
|
||||
public static void onPlayerLogin(EntityPlayer player)
|
||||
{
|
||||
for(IPlayerTracker tracker : playerTrackers)
|
||||
tracker.onPlayerLogin(player);
|
||||
for (IPlayerTracker tracker : playerTrackers)
|
||||
try
|
||||
{
|
||||
tracker.onPlayerLogin(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, "A critical error occured handling the onPlayerLogin event with player tracker %s", tracker.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static void onPlayerLogout(EntityPlayer player)
|
||||
{
|
||||
for(IPlayerTracker tracker : playerTrackers)
|
||||
tracker.onPlayerLogout(player);
|
||||
for (IPlayerTracker tracker : playerTrackers)
|
||||
try
|
||||
{
|
||||
tracker.onPlayerLogout(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, "A critical error occured handling the onPlayerLogout event with player tracker %s", tracker.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static void onPlayerChangedDimension(EntityPlayer player)
|
||||
{
|
||||
for(IPlayerTracker tracker : playerTrackers)
|
||||
tracker.onPlayerChangedDimension(player);
|
||||
for (IPlayerTracker tracker : playerTrackers)
|
||||
try
|
||||
{
|
||||
tracker.onPlayerChangedDimension(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, "A critical error occured handling the onPlayerChangedDimension event with player tracker %s", tracker.getClass()
|
||||
.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static void onPlayerRespawn(EntityPlayer player)
|
||||
{
|
||||
for(IPlayerTracker tracker : playerTrackers)
|
||||
tracker.onPlayerRespawn(player);
|
||||
for (IPlayerTracker tracker : playerTrackers)
|
||||
try
|
||||
{
|
||||
tracker.onPlayerRespawn(player);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, "A critical error occured handling the onPlayerRespawn event with player tracker %s", tracker.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -394,4 +424,82 @@ public class GameRegistry
|
||||
{
|
||||
return GameData.findItem(modId, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually register a custom item stack with FML for later tracking. It is automatically scoped with the active modid
|
||||
*
|
||||
* @param name The name to register it under
|
||||
* @param itemStack The itemstack to register
|
||||
*/
|
||||
public static void registerCustomItemStack(String name, ItemStack itemStack)
|
||||
{
|
||||
GameData.registerCustomItemStack(name, itemStack);
|
||||
}
|
||||
/**
|
||||
* Lookup an itemstack based on mod and name. It will create "default" itemstacks from blocks and items if no
|
||||
* explicit itemstack is found.
|
||||
*
|
||||
* If it is built from a block, the metadata is by default the "wildcard" value.
|
||||
*
|
||||
* Custom itemstacks can be dumped from minecraft by setting the system property fml.dumpRegistry to true
|
||||
* (-Dfml.dumpRegistry=true on the command line will work)
|
||||
*
|
||||
* @param modId The modid of the stack owner
|
||||
* @param name The name of the stack
|
||||
* @param stackSize The size of the stack returned
|
||||
* @return The custom itemstack or null if no such itemstack was found
|
||||
*/
|
||||
public static ItemStack findItemStack(String modId, String name, int stackSize)
|
||||
{
|
||||
ItemStack foundStack = GameData.findItemStack(modId, name);
|
||||
if (foundStack != null)
|
||||
{
|
||||
ItemStack is = foundStack.func_77946_l();
|
||||
is.field_77994_a = Math.min(stackSize, is.func_77976_d());
|
||||
return is;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class UniqueIdentifier
|
||||
{
|
||||
public final String modId;
|
||||
public final String name;
|
||||
UniqueIdentifier(String modId, String name)
|
||||
{
|
||||
this.modId = modId;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up the mod identifier data for a block.
|
||||
* Returns null if there is no mod specified mod identifier data, or it is part of a
|
||||
* custom itemstack definition {@link #registerCustomItemStack}
|
||||
*
|
||||
* Note: uniqueness and persistence is only guaranteed by mods using the game registry
|
||||
* correctly.
|
||||
*
|
||||
* @param block to lookup
|
||||
* @return a {@link UniqueIdentifier} for the block or null
|
||||
*/
|
||||
public static UniqueIdentifier findUniqueIdentifierFor(net.minecraft.block.Block block)
|
||||
{
|
||||
return GameData.getUniqueName(block);
|
||||
}
|
||||
/**
|
||||
* Look up the mod identifier data for an item.
|
||||
* Returns null if there is no mod specified mod identifier data, or it is part of a
|
||||
* custom itemstack definition {@link #registerCustomItemStack}
|
||||
*
|
||||
* Note: uniqueness and persistence is only guaranteed by mods using the game registry
|
||||
* correctly.
|
||||
*
|
||||
* @param item to lookup
|
||||
* @return a {@link UniqueIdentifier} for the item or null
|
||||
*/
|
||||
public static UniqueIdentifier findUniqueIdentifierFor(net.minecraft.item.Item item)
|
||||
{
|
||||
return GameData.getUniqueName(item);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -23,11 +23,13 @@ import java.util.logging.Level;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
@@ -45,7 +47,7 @@ public class LanguageRegistry
|
||||
|
||||
public String getStringLocalization(String key)
|
||||
{
|
||||
return getStringLocalization(key, StringTranslate.func_74808_a().func_74811_c());
|
||||
return getStringLocalization(key, FMLCommonHandler.instance().getCurrentLanguage());
|
||||
}
|
||||
|
||||
public String getStringLocalization(String key, String lang)
|
||||
@@ -93,9 +95,9 @@ public class LanguageRegistry
|
||||
|
||||
public static void reloadLanguageTable()
|
||||
{
|
||||
// reload language table by forcing lang to null and reloading the properties file
|
||||
String lang = StringTranslate.func_74808_a().func_74811_c();
|
||||
StringTranslate.func_74808_a().func_74810_a(lang, true);
|
||||
// // reload language table by forcing lang to null and reloading the properties file
|
||||
// String lang = StringTranslate.func_74808_a().func_74811_c();
|
||||
// StringTranslate.func_74808_a().func_74810_a(lang, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,17 +122,17 @@ public class LanguageRegistry
|
||||
instance().addNameForObject(objectToName, "en_US", name);
|
||||
}
|
||||
|
||||
public void loadLanguageTable(Properties languagePack, String lang)
|
||||
public void loadLanguageTable(Map field_135032_a, String lang)
|
||||
{
|
||||
Properties usPack=modLanguageData.get("en_US");
|
||||
if (usPack!=null) {
|
||||
languagePack.putAll(usPack);
|
||||
field_135032_a.putAll(usPack);
|
||||
}
|
||||
Properties langPack=modLanguageData.get(lang);
|
||||
if (langPack==null) {
|
||||
return;
|
||||
}
|
||||
languagePack.putAll(langPack);
|
||||
field_135032_a.putAll(langPack);
|
||||
}
|
||||
|
||||
public void loadLocalization(String localizationFile, String lang, boolean isXML)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -13,14 +13,15 @@
|
||||
package cpw.mods.fml.common.registry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import net.minecraft.world.gen.structure.ComponentVillageStartPiece;
|
||||
@@ -32,6 +33,8 @@ import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Registry for villager trading control
|
||||
@@ -45,8 +48,9 @@ public class VillagerRegistry
|
||||
|
||||
private Multimap<Integer, IVillageTradeHandler> tradeHandlers = ArrayListMultimap.create();
|
||||
private Map<Class<?>, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap();
|
||||
private Map<Integer, String> newVillagers = Maps.newHashMap();
|
||||
private List<Integer> newVillagerIds = Lists.newArrayList();
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Map<Integer, ResourceLocation> newVillagers;
|
||||
|
||||
/**
|
||||
* Allow access to the {@link net.minecraft.world.gen.structure.StructureVillagePieces} array controlling new village
|
||||
@@ -110,21 +114,33 @@ public class VillagerRegistry
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register your villager id
|
||||
* @param id
|
||||
*/
|
||||
public void registerVillagerId(int id)
|
||||
{
|
||||
if (newVillagerIds.contains(id))
|
||||
{
|
||||
FMLLog.severe("Attempt to register duplicate villager id %d", id);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
newVillagerIds.add(id);
|
||||
}
|
||||
/**
|
||||
* Register a new skin for a villager type
|
||||
*
|
||||
* @param villagerId
|
||||
* @param villagerSkin
|
||||
*/
|
||||
public void registerVillagerType(int villagerId, String villagerSkin)
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerVillagerSkin(int villagerId, ResourceLocation villagerSkin)
|
||||
{
|
||||
if (newVillagers.containsKey(villagerId))
|
||||
if (newVillagers == null)
|
||||
{
|
||||
FMLLog.severe("Attempt to register duplicate villager id %d", villagerId);
|
||||
throw new RuntimeException();
|
||||
newVillagers = Maps.newHashMap();
|
||||
}
|
||||
newVillagers.put(villagerId, villagerSkin);
|
||||
newVillagerIds.add(villagerId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,9 +170,10 @@ public class VillagerRegistry
|
||||
* @param villagerType
|
||||
* @param defaultSkin
|
||||
*/
|
||||
public static String getVillagerSkin(int villagerType, String defaultSkin)
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static ResourceLocation getVillagerSkin(int villagerType, ResourceLocation defaultSkin)
|
||||
{
|
||||
if (instance().newVillagers.containsKey(villagerType))
|
||||
if (instance().newVillagers != null && instance().newVillagers.containsKey(villagerType))
|
||||
{
|
||||
return instance().newVillagers.get(villagerType);
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ public class ModSorter
|
||||
{
|
||||
private DirectedGraph<ModContainer> modGraph;
|
||||
|
||||
private ModContainer beforeAll = new DummyModContainer();
|
||||
private ModContainer afterAll = new DummyModContainer();
|
||||
private ModContainer before = new DummyModContainer();
|
||||
private ModContainer after = new DummyModContainer();
|
||||
private ModContainer beforeAll = new DummyModContainer("BeforeAll");
|
||||
private ModContainer afterAll = new DummyModContainer("AfterAll");
|
||||
private ModContainer before = new DummyModContainer("Before");
|
||||
private ModContainer after = new DummyModContainer("After");
|
||||
|
||||
public ModSorter(List<ModContainer> modList, Map<String, ModContainer> nameLookup)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -25,6 +25,11 @@ import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.Sets.SetView;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
/**
|
||||
* Topological sort for mod loading
|
||||
*
|
||||
@@ -174,8 +179,14 @@ public class TopologicalSort
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.printf("%s: %s\n%s\n%s\n", node, sortedResult, visitedNodes, expandedNodes);
|
||||
throw new ModSortingException("There was a cycle detected in the input graph, sorting is not possible", node, visitedNodes);
|
||||
FMLLog.severe("Mod Sorting failed.");
|
||||
FMLLog.severe("Visting node %s", node);
|
||||
FMLLog.severe("Current sorted list : %s", sortedResult);
|
||||
FMLLog.severe("Visited set for this node : %s", visitedNodes);
|
||||
FMLLog.severe("Explored node set : %s", expandedNodes);
|
||||
SetView<T> cycleList = Sets.difference(visitedNodes, expandedNodes);
|
||||
FMLLog.severe("Likely cycle is in : %s", cycleList);
|
||||
throw new ModSortingException("There was a cycle detected in the input graph, sorting is not possible", node, cycleList);
|
||||
}
|
||||
|
||||
// Visit this node
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -98,4 +98,9 @@ public class DefaultArtifactVersion implements ArtifactVersion
|
||||
{
|
||||
return label == null ? comparableVersion.toString() : label + ( unbounded ? "" : "@" + range);
|
||||
}
|
||||
|
||||
public VersionRange getRange()
|
||||
{
|
||||
return range;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -549,4 +549,15 @@ public class VersionRange
|
||||
hash = 31 * hash + ( restrictions == null ? 0 : restrictions.hashCode() );
|
||||
return hash;
|
||||
}
|
||||
|
||||
public boolean isUnboundedAbove()
|
||||
{
|
||||
return restrictions.size() == 1 && restrictions.get(0).getUpperBound() == null && !restrictions.get(0).isUpperBoundInclusive();
|
||||
}
|
||||
|
||||
public String getLowerBoundString()
|
||||
{
|
||||
return restrictions.size() == 1 ? restrictions.get(0).getLowerBound().getVersionString() : "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
public class ArgsWrapper
|
||||
{
|
||||
public ArgsWrapper(String[] args)
|
||||
{
|
||||
this.args=args;
|
||||
}
|
||||
|
||||
public String[] args;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
public class CoreFMLLibraries implements ILibrarySet
|
||||
{
|
||||
private static String[] libraries = { "argo-small-3.2.jar","guava-14.0-rc3.jar","asm-all-4.1.jar", "bcprov-jdk15on-148.jar", FMLInjectionData.debfuscationDataName(), "scala-library.jar" };
|
||||
private static String[] checksums = { "58912ea2858d168c50781f956fa5b59f0f7c6b51", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", "054986e962b88d8660ae4566475658469595ef58", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65", FMLInjectionData.deobfuscationDataHash, "458d046151ad179c85429ed7420ffb1eaf6ddf85" };
|
||||
|
||||
@Override
|
||||
public String[] getLibraries()
|
||||
{
|
||||
return libraries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHashes()
|
||||
{
|
||||
return checksums;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRootURL()
|
||||
{
|
||||
return System.getProperty("fml.core.libraries.mirror", "http://files.minecraftforge.net/fmllibs/%s");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,464 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.launcher.FMLTweaker;
|
||||
import cpw.mods.fml.common.toposort.TopologicalSort;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.DependsOn;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.Name;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
|
||||
|
||||
public class CoreModManager
|
||||
{
|
||||
private static final Attributes.Name COREMODCONTAINSFMLMOD = new Attributes.Name("FMLCorePluginContainsFMLMod");
|
||||
private static String[] rootPlugins = { "cpw.mods.fml.relauncher.FMLCorePlugin" , "net.minecraftforge.classloading.FMLForgePlugin" };
|
||||
private static List<String> loadedCoremods = Lists.newArrayList();
|
||||
private static List<FMLPluginWrapper> loadPlugins;
|
||||
private static boolean deobfuscatedEnvironment;
|
||||
private static FMLTweaker tweaker;
|
||||
private static File mcDir;
|
||||
private static List<String> reparsedCoremods = Lists.newArrayList();
|
||||
|
||||
private static class FMLPluginWrapper
|
||||
{
|
||||
public final String name;
|
||||
public final IFMLLoadingPlugin coreModInstance;
|
||||
public final List<String> predepends;
|
||||
public final File location;
|
||||
|
||||
public FMLPluginWrapper(String name, IFMLLoadingPlugin coreModInstance, File location, String... predepends)
|
||||
{
|
||||
super();
|
||||
this.name = name;
|
||||
this.coreModInstance = coreModInstance;
|
||||
this.location = location;
|
||||
this.predepends = Lists.newArrayList(predepends);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s {%s}", this.name, this.predepends);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleLaunch(File mcDir, LaunchClassLoader classLoader, FMLTweaker tweaker)
|
||||
{
|
||||
CoreModManager.mcDir = mcDir;
|
||||
CoreModManager.tweaker = tweaker;
|
||||
try
|
||||
{
|
||||
// Are we in a 'decompiled' environment?
|
||||
byte[] bs = classLoader.getClassBytes("net.minecraft.world.World");
|
||||
if (bs != null)
|
||||
{
|
||||
FMLRelaunchLog.info("Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation");
|
||||
deobfuscatedEnvironment = true;
|
||||
}
|
||||
}
|
||||
catch (IOException e1)
|
||||
{
|
||||
}
|
||||
|
||||
if (!deobfuscatedEnvironment)
|
||||
{
|
||||
FMLRelaunchLog.fine("Enabling runtime deobfuscation");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.PatchingTransformer");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, e, "The patch transformer failed to load! This is critical, loading cannot continue!");
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
|
||||
loadPlugins = new ArrayList<FMLPluginWrapper>();
|
||||
for (String rootPluginName : rootPlugins)
|
||||
{
|
||||
loadCoreMod(classLoader, rootPluginName, new File(FMLTweaker.getJarLocation()));
|
||||
}
|
||||
|
||||
if (loadPlugins.isEmpty())
|
||||
{
|
||||
throw new RuntimeException("A fatal error has occured - no valid fml load plugin was found - this is a completely corrupt FML installation.");
|
||||
}
|
||||
|
||||
FMLRelaunchLog.fine("All fundamental core mods are successfully located");
|
||||
// Now that we have the root plugins loaded - lets see what else might be around
|
||||
String commandLineCoremods = System.getProperty("fml.coreMods.load","");
|
||||
for (String coreModClassName : commandLineCoremods.split(","))
|
||||
{
|
||||
if (coreModClassName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
FMLRelaunchLog.info("Found a command line coremod : %s", coreModClassName);
|
||||
loadCoreMod(classLoader, coreModClassName, null);
|
||||
}
|
||||
discoverCoreMods(mcDir, classLoader);
|
||||
|
||||
}
|
||||
|
||||
private static void discoverCoreMods(File mcDir, LaunchClassLoader classLoader)
|
||||
{
|
||||
FMLRelaunchLog.fine("Discovering coremods");
|
||||
File coreMods = setupCoreModDir(mcDir);
|
||||
FilenameFilter ff = new FilenameFilter()
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File dir, String name)
|
||||
{
|
||||
return name.endsWith(".jar");
|
||||
}
|
||||
};
|
||||
File[] coreModList = coreMods.listFiles(ff);
|
||||
File versionedModDir = new File(coreMods,FMLInjectionData.mccversion);
|
||||
if (versionedModDir.isDirectory())
|
||||
{
|
||||
File[] versionedCoreMods = versionedModDir.listFiles(ff);
|
||||
coreModList = ObjectArrays.concat(coreModList,versionedCoreMods, File.class);
|
||||
}
|
||||
|
||||
Arrays.sort(coreModList);
|
||||
|
||||
for (File coreMod : coreModList)
|
||||
{
|
||||
FMLRelaunchLog.fine("Examining for coremod candidacy %s", coreMod.getName());
|
||||
JarFile jar = null;
|
||||
Attributes mfAttributes;
|
||||
try
|
||||
{
|
||||
jar = new JarFile(coreMod);
|
||||
if (jar.getManifest() == null)
|
||||
{
|
||||
// Not a coremod
|
||||
continue;
|
||||
}
|
||||
mfAttributes = jar.getManifest().getMainAttributes();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, ioe, "Unable to read the jar file %s - ignoring", coreMod.getName());
|
||||
continue;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (jar!=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
jar.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Noise
|
||||
}
|
||||
}
|
||||
}
|
||||
String cascadedTweaker = mfAttributes.getValue("TweakClass");
|
||||
if (cascadedTweaker != null)
|
||||
{
|
||||
FMLRelaunchLog.info("Loading tweaker %s from %s", cascadedTweaker, coreMod.getName());
|
||||
handleCascadingTweak(coreMod, jar, cascadedTweaker, classLoader);
|
||||
loadedCoremods.add(coreMod.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
String fmlCorePlugin = mfAttributes.getValue("FMLCorePlugin");
|
||||
if (fmlCorePlugin == null)
|
||||
{
|
||||
// Not a coremod
|
||||
FMLRelaunchLog.fine("Not found coremod data in %s", coreMod.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
classLoader.addURL(coreMod.toURI().toURL());
|
||||
if (!mfAttributes.containsKey(COREMODCONTAINSFMLMOD))
|
||||
{
|
||||
FMLRelaunchLog.finest("Adding %s to the list of known coremods, it will not be examined again", coreMod.getName());
|
||||
loadedCoremods.add(coreMod.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLRelaunchLog.finest("Found FMLCorePluginContainsFMLMod marker in %s, it will be examined later for regular @Mod instances", coreMod.getName());
|
||||
reparsedCoremods.add(coreMod.getName());
|
||||
}
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, e, "Unable to convert file into a URL. weird");
|
||||
continue;
|
||||
}
|
||||
loadCoreMod(classLoader, fmlCorePlugin, coreMod);
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleCascadingTweak(File coreMod, JarFile jar, String cascadedTweaker, LaunchClassLoader classLoader)
|
||||
{
|
||||
try
|
||||
{
|
||||
classLoader.addURL(coreMod.toURI().toURL());
|
||||
CoreModManager.tweaker.injectCascadingTweak(cascadedTweaker);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.INFO, e, "There was a problem trying to load the mod dir tweaker %s", coreMod.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mcDir the minecraft home directory
|
||||
* @return the coremod directory
|
||||
*/
|
||||
private static File setupCoreModDir(File mcDir)
|
||||
{
|
||||
File coreModDir = new File(mcDir,"mods");
|
||||
try
|
||||
{
|
||||
coreModDir = coreModDir.getCanonicalFile();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(String.format("Unable to canonicalize the coremod dir at %s", mcDir.getName()),e);
|
||||
}
|
||||
if (!coreModDir.exists())
|
||||
{
|
||||
coreModDir.mkdir();
|
||||
}
|
||||
else if (coreModDir.exists() && !coreModDir.isDirectory())
|
||||
{
|
||||
throw new RuntimeException(String.format("Found a coremod file in %s that's not a directory", mcDir.getName()));
|
||||
}
|
||||
return coreModDir;
|
||||
}
|
||||
|
||||
public static List<String> getLoadedCoremods()
|
||||
{
|
||||
return loadedCoremods;
|
||||
}
|
||||
|
||||
public static List<String> getReparseableCoremods()
|
||||
{
|
||||
return reparsedCoremods;
|
||||
}
|
||||
|
||||
private static FMLPluginWrapper loadCoreMod(LaunchClassLoader classLoader, String coreModClass, File location)
|
||||
{
|
||||
String coreModName = coreModClass.substring(coreModClass.lastIndexOf('.')+1);
|
||||
try
|
||||
{
|
||||
FMLRelaunchLog.fine("Instantiating coremod class %s", coreModName);
|
||||
classLoader.addTransformerExclusion(coreModClass);
|
||||
Class<?> coreModClazz = Class.forName(coreModClass, true, classLoader);
|
||||
Name coreModNameAnn = coreModClazz.getAnnotation(IFMLLoadingPlugin.Name.class);
|
||||
if (coreModNameAnn!=null && !Strings.isNullOrEmpty(coreModNameAnn.value()))
|
||||
{
|
||||
coreModName = coreModNameAnn.value();
|
||||
FMLRelaunchLog.finest("coremod named %s is loading", coreModName);
|
||||
}
|
||||
MCVersion requiredMCVersion = coreModClazz.getAnnotation(IFMLLoadingPlugin.MCVersion.class);
|
||||
if (!Arrays.asList(rootPlugins).contains(coreModClass) && (requiredMCVersion == null || Strings.isNullOrEmpty(requiredMCVersion.value())))
|
||||
{
|
||||
FMLRelaunchLog.log(Level.WARNING, "The coremod %s does not have a MCVersion annotation, it may cause issues with this version of Minecraft", coreModClass);
|
||||
}
|
||||
else if (requiredMCVersion!=null && !FMLInjectionData.mccversion.equals(requiredMCVersion.value()))
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, "The coremod %s is requesting minecraft version %s and minecraft is %s. It will be ignored.", coreModClass, requiredMCVersion.value(), FMLInjectionData.mccversion);
|
||||
return null;
|
||||
}
|
||||
else if (requiredMCVersion!=null)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.FINE, "The coremod %s requested minecraft version %s and minecraft is %s. It will be loaded.", coreModClass, requiredMCVersion.value(), FMLInjectionData.mccversion);
|
||||
}
|
||||
TransformerExclusions trExclusions = coreModClazz.getAnnotation(IFMLLoadingPlugin.TransformerExclusions.class);
|
||||
if (trExclusions!=null)
|
||||
{
|
||||
for (String st : trExclusions.value())
|
||||
{
|
||||
classLoader.addTransformerExclusion(st);
|
||||
}
|
||||
}
|
||||
DependsOn deplist = coreModClazz.getAnnotation(IFMLLoadingPlugin.DependsOn.class);
|
||||
String[] dependencies = new String[0];
|
||||
if (deplist != null)
|
||||
{
|
||||
dependencies = deplist.value();
|
||||
}
|
||||
IFMLLoadingPlugin plugin = (IFMLLoadingPlugin) coreModClazz.newInstance();
|
||||
FMLPluginWrapper wrap = new FMLPluginWrapper(coreModName, plugin, location, dependencies);
|
||||
|
||||
loadPlugins.add(wrap);
|
||||
FMLRelaunchLog.fine("Loaded coremod %s", coreModName);
|
||||
return wrap;
|
||||
}
|
||||
catch (ClassNotFoundException cnfe)
|
||||
{
|
||||
if (!Lists.newArrayList(rootPlugins).contains(coreModClass))
|
||||
FMLRelaunchLog.log(Level.SEVERE, cnfe, "Coremod %s: Unable to class load the plugin %s", coreModName, coreModClass);
|
||||
else
|
||||
FMLRelaunchLog.fine("Skipping root plugin %s", coreModClass);
|
||||
}
|
||||
catch (ClassCastException cce)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, cce, "Coremod %s: The plugin %s is not an implementor of IFMLLoadingPlugin", coreModName, coreModClass);
|
||||
}
|
||||
catch (InstantiationException ie)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, ie, "Coremod %s: The plugin class %s was not instantiable", coreModName, coreModClass);
|
||||
}
|
||||
catch (IllegalAccessException iae)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, iae, "Coremod %s: The plugin class %s was not accessible", coreModName, coreModClass);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void sortCoreMods()
|
||||
{
|
||||
TopologicalSort.DirectedGraph<FMLPluginWrapper> sortGraph = new TopologicalSort.DirectedGraph<FMLPluginWrapper>();
|
||||
Map<String, FMLPluginWrapper> pluginMap = Maps.newHashMap();
|
||||
for (FMLPluginWrapper plug : loadPlugins)
|
||||
{
|
||||
sortGraph.addNode(plug);
|
||||
pluginMap.put(plug.name, plug);
|
||||
}
|
||||
|
||||
for (FMLPluginWrapper plug : loadPlugins)
|
||||
{
|
||||
for (String dep : plug.predepends)
|
||||
{
|
||||
if (!pluginMap.containsKey(dep))
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, "Missing coremod dependency - the coremod %s depends on coremod %s which isn't present.", plug.name, dep);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
sortGraph.addEdge(plug, pluginMap.get(dep));
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
loadPlugins = TopologicalSort.topologicalSort(sortGraph);
|
||||
FMLRelaunchLog.fine("Sorted coremod list %s", loadPlugins);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, "There was a problem performing the coremod sort");
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
public static void injectTransformers(LaunchClassLoader classLoader)
|
||||
{
|
||||
|
||||
for (FMLPluginWrapper wrap : loadPlugins)
|
||||
{
|
||||
IFMLLoadingPlugin plug = wrap.coreModInstance;
|
||||
if (plug.getASMTransformerClass()!=null)
|
||||
{
|
||||
for (String xformClass : plug.getASMTransformerClass())
|
||||
{
|
||||
FMLRelaunchLog.finest("Registering transformer %s", xformClass);
|
||||
classLoader.registerTransformer(xformClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
FMLRelaunchLog.fine("Running coremod plugins");
|
||||
Map<String,Object> data = new HashMap<String,Object>();
|
||||
data.put("mcLocation", mcDir);
|
||||
data.put("coremodList", loadPlugins);
|
||||
data.put("runtimeDeobfuscationEnabled", !deobfuscatedEnvironment);
|
||||
for (FMLPluginWrapper pluginWrapper : loadPlugins)
|
||||
{
|
||||
IFMLLoadingPlugin plugin = pluginWrapper.coreModInstance;
|
||||
FMLRelaunchLog.fine("Running coremod plugin %s", pluginWrapper.name);
|
||||
data.put("coremodLocation", pluginWrapper.location);
|
||||
plugin.injectData(data);
|
||||
String setupClass = plugin.getSetupClass();
|
||||
if (setupClass != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
IFMLCallHook call = (IFMLCallHook) Class.forName(setupClass, true, classLoader).newInstance();
|
||||
Map<String,Object> callData = new HashMap<String, Object>();
|
||||
callData.put("mcLocation", mcDir);
|
||||
callData.put("classLoader", classLoader);
|
||||
callData.put("coremodLocation", pluginWrapper.location);
|
||||
callData.put("deobfuscationFileName", FMLInjectionData.debfuscationDataName());
|
||||
call.injectData(callData);
|
||||
call.call();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
FMLRelaunchLog.fine("Coremod plugin %s run successfully", plugin.getClass().getSimpleName());
|
||||
|
||||
String modContainer = plugin.getModContainerClass();
|
||||
if (modContainer != null)
|
||||
{
|
||||
FMLInjectionData.containers.add(modContainer);
|
||||
}
|
||||
}
|
||||
// Deobfuscation transformer, always last
|
||||
if (!deobfuscatedEnvironment)
|
||||
{
|
||||
classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer");
|
||||
}
|
||||
try
|
||||
{
|
||||
FMLRelaunchLog.fine("Validating minecraft");
|
||||
Class<?> loaderClazz = Class.forName("cpw.mods.fml.common.Loader", true, classLoader);
|
||||
Method m = loaderClazz.getMethod("injectData", Object[].class);
|
||||
m.invoke(null, (Object)FMLInjectionData.data());
|
||||
m = loaderClazz.getMethod("instance");
|
||||
m.invoke(null);
|
||||
FMLRelaunchLog.fine("Minecraft validated, launching...");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Load in the Loader, make sure he's ready to roll - this will initialize most of the rest of minecraft here
|
||||
System.out.println("A CRITICAL PROBLEM OCCURED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
import java.awt.Dialog.ModalityType;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JProgressBar;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
public class Downloader extends JOptionPane implements IDownloadDisplay
|
||||
{
|
||||
private JDialog container;
|
||||
private JLabel currentActivity;
|
||||
private JProgressBar progress;
|
||||
boolean stopIt;
|
||||
Thread pokeThread;
|
||||
|
||||
private Box makeProgressPanel()
|
||||
{
|
||||
Box box = Box.createVerticalBox();
|
||||
box.add(Box.createRigidArea(new Dimension(0,10)));
|
||||
JLabel welcomeLabel = new JLabel("<html><b><font size='+1'>FML is setting up your minecraft environment</font></b></html>");
|
||||
box.add(welcomeLabel);
|
||||
welcomeLabel.setAlignmentY(LEFT_ALIGNMENT);
|
||||
welcomeLabel = new JLabel("<html>Please wait, FML has some tasks to do before you can play</html>");
|
||||
welcomeLabel.setAlignmentY(LEFT_ALIGNMENT);
|
||||
box.add(welcomeLabel);
|
||||
box.add(Box.createRigidArea(new Dimension(0,10)));
|
||||
currentActivity = new JLabel("Currently doing ...");
|
||||
box.add(currentActivity);
|
||||
box.add(Box.createRigidArea(new Dimension(0,10)));
|
||||
progress = new JProgressBar(0, 100);
|
||||
progress.setStringPainted(true);
|
||||
box.add(progress);
|
||||
box.add(Box.createRigidArea(new Dimension(0,30)));
|
||||
return box;
|
||||
}
|
||||
|
||||
public JDialog makeDialog()
|
||||
{
|
||||
setMessageType(JOptionPane.INFORMATION_MESSAGE);
|
||||
setMessage(makeProgressPanel());
|
||||
setOptions(new Object[] { "Stop" });
|
||||
addPropertyChangeListener(new PropertyChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt)
|
||||
{
|
||||
if (evt.getSource() == Downloader.this && evt.getPropertyName()==VALUE_PROPERTY)
|
||||
{
|
||||
requestClose("This will stop minecraft from launching\nAre you sure you want to do this?");
|
||||
}
|
||||
}
|
||||
});
|
||||
container = new JDialog(null, "Hello", ModalityType.MODELESS);
|
||||
container.setResizable(false);
|
||||
container.setLocationRelativeTo(null);
|
||||
container.add(this);
|
||||
this.updateUI();
|
||||
container.pack();
|
||||
container.setMinimumSize(container.getPreferredSize());
|
||||
container.setVisible(true);
|
||||
container.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
container.addWindowListener(new WindowAdapter()
|
||||
{
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e)
|
||||
{
|
||||
requestClose("Closing this window will stop minecraft from launching\nAre you sure you wish to do this?");
|
||||
}
|
||||
});
|
||||
return container;
|
||||
}
|
||||
protected void requestClose(String message)
|
||||
{
|
||||
int shouldClose = JOptionPane.showConfirmDialog(container, message, "Are you sure you want to stop?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||
if (shouldClose == JOptionPane.YES_OPTION)
|
||||
{
|
||||
container.dispose();
|
||||
}
|
||||
stopIt = true;
|
||||
if (pokeThread != null)
|
||||
{
|
||||
pokeThread.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateProgressString(String progressUpdate, Object... data)
|
||||
{
|
||||
FMLLog.finest(progressUpdate, data);
|
||||
if (currentActivity!=null)
|
||||
{
|
||||
currentActivity.setText(String.format(progressUpdate,data));
|
||||
}
|
||||
}
|
||||
|
||||
public void resetProgress(int sizeGuess)
|
||||
{
|
||||
if (progress!=null)
|
||||
{
|
||||
progress.getModel().setRangeProperties(0, 0, 0, sizeGuess, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateProgress(int fullLength)
|
||||
{
|
||||
if (progress!=null)
|
||||
{
|
||||
progress.getModel().setValue(fullLength);
|
||||
}
|
||||
}
|
||||
|
||||
public void makeHeadless()
|
||||
{
|
||||
container = null;
|
||||
progress = null;
|
||||
currentActivity = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPokeThread(Thread currentThread)
|
||||
{
|
||||
this.pokeThread = currentThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldStopIt()
|
||||
{
|
||||
return stopIt;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
public class DummyDownloader implements IDownloadDisplay
|
||||
{
|
||||
|
||||
@Override
|
||||
public void resetProgress(int sizeGuess)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPokeThread(Thread currentThread)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(int fullLength)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldStopIt()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressString(String string, Object... data)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object makeDialog()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeHeadless()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -16,10 +16,11 @@ import java.util.Map;
|
||||
|
||||
public class FMLCorePlugin implements IFMLLoadingPlugin
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public String[] getLibraryRequestClass()
|
||||
{
|
||||
return new String[] {"cpw.mods.fml.relauncher.CoreFMLLibraries"};
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -20,6 +20,8 @@ import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
public class FMLInjectionData
|
||||
{
|
||||
static File minecraftHome;
|
||||
@@ -33,7 +35,7 @@ public class FMLInjectionData
|
||||
|
||||
public static List<String> containers = new ArrayList<String>();
|
||||
|
||||
static void build(File mcHome, RelaunchClassLoader classLoader)
|
||||
static void build(File mcHome, LaunchClassLoader classLoader)
|
||||
{
|
||||
minecraftHome = mcHome;
|
||||
InputStream stream = classLoader.getResourceAsStream("fmlversion.properties");
|
||||
@@ -62,7 +64,7 @@ public class FMLInjectionData
|
||||
|
||||
static String debfuscationDataName()
|
||||
{
|
||||
return "deobfuscation_data_"+mccversion+".zip";
|
||||
return "/deobfuscation_data-"+mccversion+".lzma";
|
||||
}
|
||||
public static Object[] data()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import cpw.mods.fml.common.launcher.FMLTweaker;
|
||||
|
||||
public class FMLLaunchHandler
|
||||
{
|
||||
private static FMLLaunchHandler INSTANCE;
|
||||
static Side side;
|
||||
private LaunchClassLoader classLoader;
|
||||
private FMLTweaker tweaker;
|
||||
private File minecraftHome;
|
||||
|
||||
public static void configureForClientLaunch(LaunchClassLoader loader, FMLTweaker tweaker)
|
||||
{
|
||||
instance(loader, tweaker).setupClient();
|
||||
}
|
||||
|
||||
public static void configureForServerLaunch(LaunchClassLoader loader, FMLTweaker tweaker)
|
||||
{
|
||||
instance(loader, tweaker).setupServer();
|
||||
}
|
||||
|
||||
private static FMLLaunchHandler instance(LaunchClassLoader launchLoader, FMLTweaker tweaker)
|
||||
{
|
||||
if (INSTANCE == null)
|
||||
{
|
||||
INSTANCE = new FMLLaunchHandler(launchLoader, tweaker);
|
||||
}
|
||||
return INSTANCE;
|
||||
|
||||
}
|
||||
|
||||
private FMLLaunchHandler(LaunchClassLoader launchLoader, FMLTweaker tweaker)
|
||||
{
|
||||
this.classLoader = launchLoader;
|
||||
this.tweaker = tweaker;
|
||||
this.minecraftHome = tweaker.getGameDir();
|
||||
this.classLoader.addClassLoaderExclusion("cpw.mods.fml.relauncher.");
|
||||
this.classLoader.addClassLoaderExclusion("net.minecraftforge.classloading.");
|
||||
this.classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers.deobf.");
|
||||
this.classLoader.addTransformerExclusion("cpw.mods.fml.common.patcher.");
|
||||
}
|
||||
|
||||
private void setupClient()
|
||||
{
|
||||
FMLRelaunchLog.logFileNamePattern = "ForgeModLoader-client-%g.log";
|
||||
side = Side.CLIENT;
|
||||
setupHome();
|
||||
}
|
||||
|
||||
private void setupServer()
|
||||
{
|
||||
FMLRelaunchLog.logFileNamePattern = "ForgeModLoader-server-%g.log";
|
||||
side = Side.SERVER;
|
||||
setupHome();
|
||||
|
||||
}
|
||||
|
||||
private void setupHome()
|
||||
{
|
||||
FMLInjectionData.build(minecraftHome, classLoader);
|
||||
FMLRelaunchLog.minecraftHome = minecraftHome;
|
||||
FMLRelaunchLog.info("Forge Mod Loader version %s.%s.%s.%s for Minecraft %s loading", FMLInjectionData.major, FMLInjectionData.minor,
|
||||
FMLInjectionData.rev, FMLInjectionData.build, FMLInjectionData.mccversion, FMLInjectionData.mcpversion);
|
||||
FMLRelaunchLog.info("Java is %s, version %s, running on %s:%s:%s, installed at %s", System.getProperty("java.vm.name"), System.getProperty("java.version"), System.getProperty("os.name"), System.getProperty("os.arch"), System.getProperty("os.version"), System.getProperty("java.home"));
|
||||
FMLRelaunchLog.fine("Java classpath at launch is %s", System.getProperty("java.class.path"));
|
||||
FMLRelaunchLog.fine("Java library path at launch is %s", System.getProperty("java.library.path"));
|
||||
|
||||
try
|
||||
{
|
||||
CoreModManager.handleLaunch(minecraftHome, classLoader, tweaker);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
FMLRelaunchLog.log(Level.SEVERE, t, "An error occurred trying to configure the minecraft home at %s for Forge Mod Loader", minecraftHome.getAbsolutePath());
|
||||
throw Throwables.propagate(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static Side side()
|
||||
{
|
||||
return side;
|
||||
}
|
||||
|
||||
|
||||
private void injectPostfixTransformers()
|
||||
{
|
||||
CoreModManager.injectTransformers(classLoader);
|
||||
}
|
||||
|
||||
public static void appendCoreMods()
|
||||
{
|
||||
INSTANCE.injectPostfixTransformers();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ final class FMLLogFormatter extends Formatter
|
||||
String name = lvl.getLocalizedName();
|
||||
if ( name == null )
|
||||
{
|
||||
name = lvl.getName();
|
||||
name = lvl.getName();
|
||||
}
|
||||
|
||||
if ( ( name != null ) && ( name.length() > 0 ) )
|
||||
@@ -57,7 +57,7 @@ final class FMLLogFormatter extends Formatter
|
||||
{
|
||||
msg.append("[] ");
|
||||
}
|
||||
msg.append(record.getMessage());
|
||||
msg.append(formatMessage(record));
|
||||
msg.append(LINE_SEPARATOR);
|
||||
Throwable thr = record.getThrown();
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@ import java.util.logging.LogManager;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.launchwrapper.LogWrapper;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
public class FMLRelaunchLog
|
||||
{
|
||||
|
||||
@@ -113,7 +117,7 @@ public class FMLRelaunchLog
|
||||
// Are we longer than just the line separator?
|
||||
int lastIdx = -1;
|
||||
int idx = currentMessage.indexOf("\n",lastIdx+1);
|
||||
while (idx > 0)
|
||||
while (idx >= 0)
|
||||
{
|
||||
log.log(Level.INFO, currentMessage.substring(lastIdx+1,idx));
|
||||
lastIdx = idx;
|
||||
@@ -121,7 +125,9 @@ public class FMLRelaunchLog
|
||||
}
|
||||
if (lastIdx >= 0)
|
||||
{
|
||||
String rem = currentMessage.substring(lastIdx+1);
|
||||
currentMessage.setLength(0);
|
||||
currentMessage.append(rem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,6 +150,8 @@ public class FMLRelaunchLog
|
||||
|
||||
private static FMLLogFormatter formatter;
|
||||
|
||||
static String logFileNamePattern;
|
||||
|
||||
private FMLRelaunchLog()
|
||||
{
|
||||
}
|
||||
@@ -157,6 +165,7 @@ public class FMLRelaunchLog
|
||||
globalLogger.setLevel(Level.OFF);
|
||||
|
||||
log.myLog = Logger.getLogger("ForgeModLoader");
|
||||
LogWrapper.retarget(log.myLog);
|
||||
|
||||
Logger stdOut = Logger.getLogger("STDOUT");
|
||||
stdOut.setParent(log.myLog);
|
||||
@@ -170,7 +179,7 @@ public class FMLRelaunchLog
|
||||
formatter = new FMLLogFormatter();
|
||||
try
|
||||
{
|
||||
File logPath = new File(minecraftHome, FMLRelauncher.logFileNamePattern);
|
||||
File logPath = new File(minecraftHome, logFileNamePattern);
|
||||
fileHandler = new FileHandler(logPath.getPath(), 0, 3)
|
||||
{
|
||||
public synchronized void close() throws SecurityException {
|
||||
@@ -178,8 +187,9 @@ public class FMLRelaunchLog
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw Throwables.propagate(t);
|
||||
}
|
||||
|
||||
resetLoggingHandlers();
|
||||
|
||||
@@ -1,335 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
import java.applet.Applet;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class FMLRelauncher
|
||||
{
|
||||
private static FMLRelauncher INSTANCE;
|
||||
public static String logFileNamePattern;
|
||||
private static String side;
|
||||
private RelaunchClassLoader classLoader;
|
||||
private Object newApplet;
|
||||
private Class<? super Object> appletClass;
|
||||
|
||||
JDialog popupWindow;
|
||||
|
||||
public static void handleClientRelaunch(ArgsWrapper wrap)
|
||||
{
|
||||
logFileNamePattern = "ForgeModLoader-client-%g.log";
|
||||
side = "CLIENT";
|
||||
instance().relaunchClient(wrap);
|
||||
}
|
||||
|
||||
public static void handleServerRelaunch(ArgsWrapper wrap)
|
||||
{
|
||||
logFileNamePattern = "ForgeModLoader-server-%g.log";
|
||||
side = "SERVER";
|
||||
instance().relaunchServer(wrap);
|
||||
}
|
||||
|
||||
static FMLRelauncher instance()
|
||||
{
|
||||
if (INSTANCE == null)
|
||||
{
|
||||
INSTANCE = new FMLRelauncher();
|
||||
}
|
||||
return INSTANCE;
|
||||
|
||||
}
|
||||
|
||||
private FMLRelauncher()
|
||||
{
|
||||
URLClassLoader ucl = (URLClassLoader) getClass().getClassLoader();
|
||||
|
||||
classLoader = new RelaunchClassLoader(ucl.getURLs());
|
||||
|
||||
}
|
||||
|
||||
private void showWindow(boolean showIt)
|
||||
{
|
||||
if (RelaunchLibraryManager.downloadMonitor != null) { return; }
|
||||
try
|
||||
{
|
||||
if (showIt)
|
||||
{
|
||||
RelaunchLibraryManager.downloadMonitor = new Downloader();
|
||||
popupWindow = (JDialog) RelaunchLibraryManager.downloadMonitor.makeDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
RelaunchLibraryManager.downloadMonitor = new DummyDownloader();
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
if (RelaunchLibraryManager.downloadMonitor == null)
|
||||
{
|
||||
RelaunchLibraryManager.downloadMonitor = new DummyDownloader();
|
||||
e.printStackTrace();
|
||||
}
|
||||
else
|
||||
{
|
||||
RelaunchLibraryManager.downloadMonitor.makeHeadless();
|
||||
}
|
||||
popupWindow = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void relaunchClient(ArgsWrapper wrap)
|
||||
{
|
||||
showWindow(true);
|
||||
// Now we re-inject the home into the "new" minecraft under our control
|
||||
Class<? super Object> client;
|
||||
try
|
||||
{
|
||||
File minecraftHome = computeExistingClientHome();
|
||||
setupHome(minecraftHome);
|
||||
|
||||
client = setupNewClientHome(minecraftHome);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (popupWindow != null)
|
||||
{
|
||||
popupWindow.setVisible(false);
|
||||
popupWindow.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
if (RelaunchLibraryManager.downloadMonitor.shouldStopIt())
|
||||
{
|
||||
System.exit(1);
|
||||
}
|
||||
try
|
||||
{
|
||||
ReflectionHelper.findMethod(client, null, new String[] { "fmlReentry" }, ArgsWrapper.class).invoke(null, wrap);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
// Hmmm
|
||||
}
|
||||
}
|
||||
|
||||
private Class<? super Object> setupNewClientHome(File minecraftHome)
|
||||
{
|
||||
Class<? super Object> client = ReflectionHelper.getClass(classLoader, "net.minecraft.client.Minecraft");
|
||||
ReflectionHelper.setPrivateValue(client, null, minecraftHome,
|
||||
"field_" + "71463_am" /*Separate that so that MCP's updatenames does not replace it*/,
|
||||
"an", "minecraftDir");
|
||||
return client;
|
||||
}
|
||||
|
||||
private void relaunchServer(ArgsWrapper wrap)
|
||||
{
|
||||
showWindow(false);
|
||||
// Now we re-inject the home into the "new" minecraft under our control
|
||||
Class<? super Object> server;
|
||||
File minecraftHome = new File(".");
|
||||
setupHome(minecraftHome);
|
||||
|
||||
server = ReflectionHelper.getClass(classLoader, "net.minecraft.server.MinecraftServer");
|
||||
try
|
||||
{
|
||||
ReflectionHelper.findMethod(server, null, new String[] { "fmlReentry" }, ArgsWrapper.class).invoke(null, wrap);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupHome(File minecraftHome)
|
||||
{
|
||||
FMLInjectionData.build(minecraftHome, classLoader);
|
||||
FMLRelaunchLog.minecraftHome = minecraftHome;
|
||||
FMLRelaunchLog.info("Forge Mod Loader version %s.%s.%s.%s for Minecraft %s loading", FMLInjectionData.major, FMLInjectionData.minor,
|
||||
FMLInjectionData.rev, FMLInjectionData.build, FMLInjectionData.mccversion, FMLInjectionData.mcpversion);
|
||||
FMLRelaunchLog.info("Java is %s, version %s, running on %s:%s:%s, installed at %s", System.getProperty("java.vm.name"), System.getProperty("java.version"), System.getProperty("os.name"), System.getProperty("os.arch"), System.getProperty("os.version"), System.getProperty("java.home"));
|
||||
FMLRelaunchLog.fine("Java classpath at launch is %s", System.getProperty("java.class.path"));
|
||||
FMLRelaunchLog.fine("Java library path at launch is %s", System.getProperty("java.library.path"));
|
||||
|
||||
try
|
||||
{
|
||||
RelaunchLibraryManager.handleLaunch(minecraftHome, classLoader);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
if (popupWindow != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
String logFile = new File(minecraftHome, "ForgeModLoader-client-0.log").getCanonicalPath();
|
||||
JOptionPane.showMessageDialog(popupWindow, String.format(
|
||||
"<html><div align=\"center\"><font size=\"+1\">There was a fatal error starting up minecraft and FML</font></div><br/>"
|
||||
+ "Minecraft cannot launch in it's current configuration<br/>"
|
||||
+ "Please consult the file <i><a href=\"file:///%s\">%s</a></i> for further information</html>", logFile, logFile),
|
||||
"Fatal FML error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// ah well, we tried
|
||||
}
|
||||
}
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the location of the client home
|
||||
*/
|
||||
private File computeExistingClientHome()
|
||||
{
|
||||
Class<? super Object> mcMaster = ReflectionHelper.getClass(getClass().getClassLoader(), "net.minecraft.client.Minecraft");
|
||||
// If we get the system property we inject into the old MC, setup the
|
||||
// dir, then pull the value
|
||||
String str = System.getProperty("minecraft.applet.TargetDirectory");
|
||||
if (str != null)
|
||||
{
|
||||
str = str.replace('/', File.separatorChar);
|
||||
ReflectionHelper.setPrivateValue(mcMaster, null, new File(str), "minecraftDir", "an", "minecraftDir");
|
||||
}
|
||||
// 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_71380_b", "getMinecraftDir", "b" });
|
||||
try
|
||||
{
|
||||
setupHome.invoke(null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Hmmm
|
||||
}
|
||||
File minecraftHome = ReflectionHelper.getPrivateValue(mcMaster, null, "field_71463_am", "an", "minecraftDir");
|
||||
return minecraftHome;
|
||||
}
|
||||
|
||||
public static void appletEntry(Applet minecraftApplet)
|
||||
{
|
||||
side = "CLIENT";
|
||||
logFileNamePattern = "ForgeModLoader-client-%g.log";
|
||||
instance().relaunchApplet(minecraftApplet);
|
||||
}
|
||||
|
||||
private void relaunchApplet(Applet minecraftApplet)
|
||||
{
|
||||
showWindow(true);
|
||||
|
||||
if (minecraftApplet.getClass().getClassLoader() == classLoader)
|
||||
{
|
||||
if (popupWindow != null)
|
||||
{
|
||||
popupWindow.setVisible(false);
|
||||
popupWindow.dispose();
|
||||
}
|
||||
try
|
||||
{
|
||||
newApplet = minecraftApplet;
|
||||
appletClass = ReflectionHelper.getClass(classLoader, "net.minecraft.client.MinecraftApplet");
|
||||
ReflectionHelper.findMethod(appletClass, newApplet, new String[] { "fmlInitReentry" }).invoke(newApplet);
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("FMLRelauncher.relaunchApplet");
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
File mcDir = computeExistingClientHome();
|
||||
setupHome(mcDir);
|
||||
setupNewClientHome(mcDir);
|
||||
|
||||
Class<? super Object> parentAppletClass = ReflectionHelper.getClass(getClass().getClassLoader(), "java.applet.Applet");
|
||||
|
||||
try
|
||||
{
|
||||
appletClass = ReflectionHelper.getClass(classLoader, "net.minecraft.client.MinecraftApplet");
|
||||
newApplet = appletClass.newInstance();
|
||||
Object appletContainer = ReflectionHelper.getPrivateValue(ReflectionHelper.getClass(getClass().getClassLoader(), "java.awt.Component"),
|
||||
minecraftApplet, "parent");
|
||||
|
||||
String launcherClassName = System.getProperty("minecraft.applet.WrapperClass", "net.minecraft.Launcher");
|
||||
Class<? super Object> launcherClass = ReflectionHelper.getClass(getClass().getClassLoader(), launcherClassName);
|
||||
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
|
||||
{
|
||||
FMLRelaunchLog.severe("Found unknown applet parent %s, unable to inject!\n", appletContainer.getClass().getName());
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (popupWindow != null)
|
||||
{
|
||||
popupWindow.setVisible(false);
|
||||
popupWindow.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void appletStart(Applet applet)
|
||||
{
|
||||
instance().startApplet(applet);
|
||||
}
|
||||
|
||||
private void startApplet(Applet applet)
|
||||
{
|
||||
if (applet.getClass().getClassLoader() == classLoader)
|
||||
{
|
||||
if (popupWindow != null)
|
||||
{
|
||||
popupWindow.setVisible(false);
|
||||
popupWindow.dispose();
|
||||
}
|
||||
if (RelaunchLibraryManager.downloadMonitor.shouldStopIt())
|
||||
{
|
||||
System.exit(1);
|
||||
}
|
||||
try
|
||||
{
|
||||
ReflectionHelper.findMethod(appletClass, newApplet, new String[] { "fmlStartReentry" }).invoke(newApplet);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("FMLRelauncher.startApplet");
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public static String side()
|
||||
{
|
||||
return side;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
public interface IClassNameTransformer {
|
||||
public String remapClassName(String name);
|
||||
|
||||
public String unmapClassName(String name);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
public interface IClassTransformer
|
||||
{
|
||||
public byte[] transform(String name, String transformedName, byte[] bytes);
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
import javax.swing.JDialog;
|
||||
|
||||
public interface IDownloadDisplay
|
||||
{
|
||||
|
||||
void resetProgress(int sizeGuess);
|
||||
|
||||
void setPokeThread(Thread currentThread);
|
||||
|
||||
void updateProgress(int fullLength);
|
||||
|
||||
boolean shouldStopIt();
|
||||
|
||||
void updateProgressString(String string, Object ... data);
|
||||
|
||||
Object makeDialog();
|
||||
|
||||
void makeHeadless();
|
||||
|
||||
}
|
||||
@@ -32,6 +32,7 @@ public interface IFMLLoadingPlugin
|
||||
*
|
||||
* @return a list of classes that implement the ILibrarySet interface
|
||||
*/
|
||||
@Deprecated
|
||||
String[] getLibraryRequestClass();
|
||||
/**
|
||||
* Return a list of classes that implements the IClassTransformer interface
|
||||
@@ -101,4 +102,24 @@ public interface IFMLLoadingPlugin
|
||||
{
|
||||
public String value() default "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Name this coremod something other than the "short class name"
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Name
|
||||
{
|
||||
public String value() default "";
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface DependsOn
|
||||
{
|
||||
public String[] value() default {};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -15,10 +15,12 @@ package cpw.mods.fml.relauncher;
|
||||
/**
|
||||
* Interface for certain core plugins to register libraries to
|
||||
* be loaded in by the FML class loader at launch time
|
||||
* Deprecated without replacement.
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ILibrarySet
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -1,411 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.JarURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.net.URLConnection;
|
||||
import java.security.CodeSigner;
|
||||
import java.security.CodeSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.jar.Attributes.Name;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
public class RelaunchClassLoader extends URLClassLoader
|
||||
{
|
||||
private List<URL> sources;
|
||||
private ClassLoader parent;
|
||||
|
||||
private List<IClassTransformer> transformers;
|
||||
private Map<String, Class> cachedClasses;
|
||||
private Set<String> invalidClasses;
|
||||
|
||||
private Set<String> classLoaderExceptions = new HashSet<String>();
|
||||
private Set<String> transformerExceptions = new HashSet<String>();
|
||||
private Map<Package,Manifest> packageManifests = new HashMap<Package,Manifest>();
|
||||
private IClassNameTransformer renameTransformer;
|
||||
|
||||
private static Manifest EMPTY = new Manifest();
|
||||
|
||||
private ThreadLocal<byte[]> loadBuffer = new ThreadLocal<byte[]>();
|
||||
|
||||
private static final String[] RESERVED = {"CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"};
|
||||
|
||||
private static final boolean DEBUG_CLASSLOADING = Boolean.parseBoolean(System.getProperty("fml.debugClassLoading", "false"));
|
||||
private static final boolean DEBUG_CLASSLOADING_FINER = DEBUG_CLASSLOADING && Boolean.parseBoolean(System.getProperty("fml.debugClassLoadingFiner", "false"));
|
||||
|
||||
public RelaunchClassLoader(URL[] sources)
|
||||
{
|
||||
super(sources, null);
|
||||
this.sources = new ArrayList<URL>(Arrays.asList(sources));
|
||||
this.parent = getClass().getClassLoader();
|
||||
this.cachedClasses = new HashMap<String,Class>(1000);
|
||||
this.invalidClasses = new HashSet<String>(1000);
|
||||
this.transformers = new ArrayList<IClassTransformer>(2);
|
||||
// ReflectionHelper.setPrivateValue(ClassLoader.class, null, this, "scl");
|
||||
Thread.currentThread().setContextClassLoader(this);
|
||||
|
||||
// standard classloader exclusions
|
||||
addClassLoaderExclusion("java.");
|
||||
addClassLoaderExclusion("sun.");
|
||||
addClassLoaderExclusion("org.lwjgl.");
|
||||
addClassLoaderExclusion("cpw.mods.fml.relauncher.");
|
||||
addClassLoaderExclusion("net.minecraftforge.classloading.");
|
||||
|
||||
// standard transformer exclusions
|
||||
addTransformerExclusion("javax.");
|
||||
addTransformerExclusion("argo.");
|
||||
addTransformerExclusion("org.objectweb.asm.");
|
||||
addTransformerExclusion("com.google.common.");
|
||||
addTransformerExclusion("org.bouncycastle.");
|
||||
addTransformerExclusion("cpw.mods.fml.common.asm.transformers.deobf.");
|
||||
}
|
||||
|
||||
public void registerTransformer(String transformerClassName)
|
||||
{
|
||||
try
|
||||
{
|
||||
IClassTransformer transformer = (IClassTransformer) loadClass(transformerClassName).newInstance();
|
||||
transformers.add(transformer);
|
||||
if (transformer instanceof IClassNameTransformer && renameTransformer == null)
|
||||
{
|
||||
renameTransformer = (IClassNameTransformer) transformer;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, e, "A critical problem occured registering the ASM transformer class %s", transformerClassName);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Class<?> findClass(String name) throws ClassNotFoundException
|
||||
{
|
||||
if (invalidClasses.contains(name))
|
||||
{
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
for (String st : classLoaderExceptions)
|
||||
{
|
||||
if (name.startsWith(st))
|
||||
{
|
||||
return parent.loadClass(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (cachedClasses.containsKey(name))
|
||||
{
|
||||
return cachedClasses.get(name);
|
||||
}
|
||||
|
||||
for (String st : transformerExceptions)
|
||||
{
|
||||
if (name.startsWith(st))
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> cl = super.findClass(name);
|
||||
cachedClasses.put(name, cl);
|
||||
return cl;
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
invalidClasses.add(name);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CodeSigner[] signers = null;
|
||||
String transformedName = transformName(name);
|
||||
String untransformedName = untransformName(name);
|
||||
int lastDot = untransformedName.lastIndexOf('.');
|
||||
String pkgname = lastDot == -1 ? "" : untransformedName.substring(0, lastDot);
|
||||
String fName = untransformedName.replace('.', '/').concat(".class");
|
||||
String pkgPath = pkgname.replace('.', '/');
|
||||
URLConnection urlConnection = findCodeSourceConnectionFor(fName);
|
||||
if (urlConnection instanceof JarURLConnection && lastDot > -1 && !untransformedName.startsWith("net.minecraft."))
|
||||
{
|
||||
JarURLConnection jarUrlConn = (JarURLConnection)urlConnection;
|
||||
JarFile jf = jarUrlConn.getJarFile();
|
||||
if (jf != null && jf.getManifest() != null)
|
||||
{
|
||||
Manifest mf = jf.getManifest();
|
||||
JarEntry ent = jf.getJarEntry(fName);
|
||||
Package pkg = getPackage(pkgname);
|
||||
getClassBytes(untransformedName);
|
||||
signers = ent.getCodeSigners();
|
||||
if (pkg == null)
|
||||
{
|
||||
pkg = definePackage(pkgname, mf, jarUrlConn.getJarFileURL());
|
||||
packageManifests.put(pkg, mf);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pkg.isSealed() && !pkg.isSealed(jarUrlConn.getJarFileURL()))
|
||||
{
|
||||
FMLLog.severe("The jar file %s is trying to seal already secured path %s", jf.getName(), pkgname);
|
||||
}
|
||||
else if (isSealed(pkgname, mf))
|
||||
{
|
||||
FMLLog.severe("The jar file %s has a security seal for path %s, but that path is defined and not secure", jf.getName(), pkgname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (lastDot > -1 && !untransformedName.startsWith("net.minecraft."))
|
||||
{
|
||||
Package pkg = getPackage(pkgname);
|
||||
if (pkg == null)
|
||||
{
|
||||
pkg = definePackage(pkgname, null, null, null, null, null, null, null);
|
||||
packageManifests.put(pkg, EMPTY);
|
||||
}
|
||||
else if (pkg.isSealed())
|
||||
{
|
||||
FMLLog.severe("The URL %s is defining elements for sealed path %s", urlConnection.getURL(), pkgname);
|
||||
}
|
||||
}
|
||||
byte[] basicClass = getClassBytes(untransformedName);
|
||||
byte[] transformedClass = runTransformers(untransformedName, transformedName, basicClass);
|
||||
Class<?> cl = defineClass(transformedName, transformedClass, 0, transformedClass.length, (urlConnection == null ? null : new CodeSource(urlConnection.getURL(), signers)));
|
||||
cachedClasses.put(transformedName, cl);
|
||||
return cl;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
invalidClasses.add(name);
|
||||
if (DEBUG_CLASSLOADING)
|
||||
{
|
||||
FMLLog.log(Level.FINEST, e, "Exception encountered attempting classloading of %s", name);
|
||||
}
|
||||
throw new ClassNotFoundException(name, e);
|
||||
}
|
||||
}
|
||||
|
||||
private String untransformName(String name)
|
||||
{
|
||||
if (renameTransformer != null)
|
||||
{
|
||||
return renameTransformer.unmapClassName(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
private String transformName(String name)
|
||||
{
|
||||
if (renameTransformer != null)
|
||||
{
|
||||
return renameTransformer.remapClassName(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSealed(String path, Manifest man)
|
||||
{
|
||||
Attributes attr = man.getAttributes(path);
|
||||
String sealed = null;
|
||||
if (attr != null) {
|
||||
sealed = attr.getValue(Name.SEALED);
|
||||
}
|
||||
if (sealed == null) {
|
||||
if ((attr = man.getMainAttributes()) != null) {
|
||||
sealed = attr.getValue(Name.SEALED);
|
||||
}
|
||||
}
|
||||
return "true".equalsIgnoreCase(sealed);
|
||||
}
|
||||
|
||||
private URLConnection findCodeSourceConnectionFor(String name)
|
||||
{
|
||||
URL res = findResource(name);
|
||||
if (res != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return res.openConnection();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] runTransformers(String name, String transformedName, byte[] basicClass)
|
||||
{
|
||||
if (DEBUG_CLASSLOADING_FINER)
|
||||
{
|
||||
FMLRelaunchLog.finest("Beginning transform of %s (%s) Start Length: %d", name, transformedName, (basicClass == null ? 0 : basicClass.length));
|
||||
for (IClassTransformer transformer : transformers)
|
||||
{
|
||||
String transName = transformer.getClass().getName();
|
||||
FMLRelaunchLog.finest("Before Transformer %s: %d", transName, (basicClass == null ? 0 : basicClass.length));
|
||||
basicClass = transformer.transform(name, transformedName, basicClass);
|
||||
FMLRelaunchLog.finest("After Transformer %s: %d", transName, (basicClass == null ? 0 : basicClass.length));
|
||||
}
|
||||
FMLRelaunchLog.finest("Ending transform of %s (%s) Start Length: %d", name, transformedName, (basicClass == null ? 0 : basicClass.length));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (IClassTransformer transformer : transformers)
|
||||
{
|
||||
basicClass = transformer.transform(name, transformedName, basicClass);
|
||||
}
|
||||
}
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addURL(URL url)
|
||||
{
|
||||
super.addURL(url);
|
||||
sources.add(url);
|
||||
}
|
||||
|
||||
public List<URL> getSources()
|
||||
{
|
||||
return sources;
|
||||
}
|
||||
|
||||
|
||||
private byte[] readFully(InputStream stream)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] buf = loadBuffer.get();
|
||||
if (buf == null)
|
||||
{
|
||||
loadBuffer.set(new byte[1 << 12]);
|
||||
buf = loadBuffer.get();
|
||||
}
|
||||
|
||||
int r, totalLength = 0;
|
||||
while ((r = stream.read(buf, totalLength, buf.length - totalLength)) != -1)
|
||||
{
|
||||
totalLength += r;
|
||||
if (totalLength >= buf.length - 1)
|
||||
{
|
||||
byte[] oldbuf = buf;
|
||||
buf = new byte[ oldbuf.length + (1 << 12 )];
|
||||
System.arraycopy(oldbuf, 0, buf, 0, oldbuf.length);
|
||||
}
|
||||
}
|
||||
|
||||
byte[] result = new byte[totalLength];
|
||||
System.arraycopy(buf, 0, result, 0, totalLength);
|
||||
return result;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.WARNING, t, "Problem loading class");
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
public List<IClassTransformer> getTransformers()
|
||||
{
|
||||
return Collections.unmodifiableList(transformers);
|
||||
}
|
||||
|
||||
private void addClassLoaderExclusion(String toExclude)
|
||||
{
|
||||
classLoaderExceptions.add(toExclude);
|
||||
}
|
||||
|
||||
void addTransformerExclusion(String toExclude)
|
||||
{
|
||||
transformerExceptions.add(toExclude);
|
||||
}
|
||||
|
||||
public byte[] getClassBytes(String name) throws IOException
|
||||
{
|
||||
if (name.indexOf('.') == -1)
|
||||
{
|
||||
for (String res : RESERVED)
|
||||
{
|
||||
if (name.toUpperCase(Locale.ENGLISH).startsWith(res))
|
||||
{
|
||||
byte[] data = getClassBytes("_" + name);
|
||||
if (data != null)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InputStream classStream = null;
|
||||
try
|
||||
{
|
||||
URL classResource = findResource(name.replace('.', '/').concat(".class"));
|
||||
if (classResource == null)
|
||||
{
|
||||
if (DEBUG_CLASSLOADING)
|
||||
{
|
||||
FMLLog.finest("Failed to find class resource %s", name.replace('.', '/').concat(".class"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
classStream = classResource.openStream();
|
||||
if (DEBUG_CLASSLOADING)
|
||||
{
|
||||
FMLLog.finest("Loading class %s from resource %s", name, classResource.toString());
|
||||
}
|
||||
return readFully(classStream);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (classStream != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
classStream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Swallow the close exception
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,630 +0,0 @@
|
||||
/*
|
||||
* Forge Mod Loader
|
||||
* Copyright (c) 2012-2013 cpw.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.FileChannel.MapMode;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import cpw.mods.fml.common.CertificateHelper;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
|
||||
|
||||
public class RelaunchLibraryManager
|
||||
{
|
||||
private static String[] rootPlugins = { "cpw.mods.fml.relauncher.FMLCorePlugin" , "net.minecraftforge.classloading.FMLForgePlugin" };
|
||||
private static List<String> loadedLibraries = new ArrayList<String>();
|
||||
private static Map<IFMLLoadingPlugin, File> pluginLocations;
|
||||
private static List<IFMLLoadingPlugin> loadPlugins;
|
||||
private static List<ILibrarySet> libraries;
|
||||
private static boolean deobfuscatedEnvironment;
|
||||
|
||||
public static void handleLaunch(File mcDir, RelaunchClassLoader actualClassLoader)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Are we in a 'decompiled' environment?
|
||||
byte[] bs = actualClassLoader.getClassBytes("net.minecraft.world.World");
|
||||
if (bs != null)
|
||||
{
|
||||
FMLRelaunchLog.info("Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation");
|
||||
deobfuscatedEnvironment = true;
|
||||
}
|
||||
}
|
||||
catch (IOException e1)
|
||||
{
|
||||
}
|
||||
|
||||
if (!deobfuscatedEnvironment)
|
||||
{
|
||||
FMLRelaunchLog.fine("Enabling runtime deobfuscation");
|
||||
}
|
||||
pluginLocations = new HashMap<IFMLLoadingPlugin, File>();
|
||||
loadPlugins = new ArrayList<IFMLLoadingPlugin>();
|
||||
libraries = new ArrayList<ILibrarySet>();
|
||||
for (String s : rootPlugins)
|
||||
{
|
||||
try
|
||||
{
|
||||
IFMLLoadingPlugin plugin = (IFMLLoadingPlugin) Class.forName(s, true, actualClassLoader).newInstance();
|
||||
loadPlugins.add(plugin);
|
||||
for (String libName : plugin.getLibraryRequestClass())
|
||||
{
|
||||
libraries.add((ILibrarySet) Class.forName(libName, true, actualClassLoader).newInstance());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// HMMM
|
||||
}
|
||||
}
|
||||
|
||||
if (loadPlugins.isEmpty())
|
||||
{
|
||||
throw new RuntimeException("A fatal error has occured - no valid fml load plugin was found - this is a completely corrupt FML installation.");
|
||||
}
|
||||
|
||||
downloadMonitor.updateProgressString("All core mods are successfully located");
|
||||
// Now that we have the root plugins loaded - lets see what else might be around
|
||||
String commandLineCoremods = System.getProperty("fml.coreMods.load","");
|
||||
for (String s : commandLineCoremods.split(","))
|
||||
{
|
||||
if (s.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
FMLRelaunchLog.info("Found a command line coremod : %s", s);
|
||||
try
|
||||
{
|
||||
actualClassLoader.addTransformerExclusion(s);
|
||||
Class<?> coreModClass = Class.forName(s, true, actualClassLoader);
|
||||
TransformerExclusions trExclusions = coreModClass.getAnnotation(IFMLLoadingPlugin.TransformerExclusions.class);
|
||||
if (trExclusions!=null)
|
||||
{
|
||||
for (String st : trExclusions.value())
|
||||
{
|
||||
actualClassLoader.addTransformerExclusion(st);
|
||||
}
|
||||
}
|
||||
IFMLLoadingPlugin plugin = (IFMLLoadingPlugin) coreModClass.newInstance();
|
||||
loadPlugins.add(plugin);
|
||||
if (plugin.getLibraryRequestClass()!=null)
|
||||
{
|
||||
for (String libName : plugin.getLibraryRequestClass())
|
||||
{
|
||||
libraries.add((ILibrarySet) Class.forName(libName, true, actualClassLoader).newInstance());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE,e,"Exception occured trying to load coremod %s",s);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
discoverCoreMods(mcDir, actualClassLoader, loadPlugins, libraries);
|
||||
|
||||
List<Throwable> caughtErrors = new ArrayList<Throwable>();
|
||||
try
|
||||
{
|
||||
File libDir;
|
||||
try
|
||||
{
|
||||
libDir = setupLibDir(mcDir);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
caughtErrors.add(e);
|
||||
return;
|
||||
}
|
||||
|
||||
for (ILibrarySet lib : libraries)
|
||||
{
|
||||
for (int i=0; i<lib.getLibraries().length; i++)
|
||||
{
|
||||
boolean download = false;
|
||||
String libName = lib.getLibraries()[i];
|
||||
String targFileName = libName.lastIndexOf('/')>=0 ? libName.substring(libName.lastIndexOf('/')) : libName;
|
||||
String checksum = lib.getHashes()[i];
|
||||
File libFile = new File(libDir, targFileName);
|
||||
if (!libFile.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
downloadFile(libFile, lib.getRootURL(), libName, checksum);
|
||||
download = true;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
caughtErrors.add(e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (libFile.exists() && !libFile.isFile())
|
||||
{
|
||||
caughtErrors.add(new RuntimeException(String.format("Found a file %s that is not a normal file - you should clear this out of the way", libName)));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!download)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileInputStream fis = new FileInputStream(libFile);
|
||||
FileChannel chan = fis.getChannel();
|
||||
MappedByteBuffer mappedFile = chan.map(MapMode.READ_ONLY, 0, libFile.length());
|
||||
String fileChecksum = generateChecksum(mappedFile);
|
||||
fis.close();
|
||||
// bad checksum and I did not download this file
|
||||
if (!checksum.equals(fileChecksum))
|
||||
{
|
||||
caughtErrors.add(new RuntimeException(String.format("The file %s was found in your lib directory and has an invalid checksum %s (expecting %s) - it is unlikely to be the correct download, please move it out of the way and try again.", libName, fileChecksum, checksum)));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, e, "The library file %s could not be validated", libFile.getName());
|
||||
caughtErrors.add(new RuntimeException(String.format("The library file %s could not be validated", libFile.getName()),e));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!download)
|
||||
{
|
||||
downloadMonitor.updateProgressString("Found library file %s present and correct in lib dir", libName);
|
||||
}
|
||||
else
|
||||
{
|
||||
downloadMonitor.updateProgressString("Library file %s was downloaded and verified successfully", libName);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
actualClassLoader.addURL(libFile.toURI().toURL());
|
||||
loadedLibraries.add(libName);
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
caughtErrors.add(new RuntimeException(String.format("Should never happen - %s is broken - probably a somehow corrupted download. Delete it and try again.", libFile.getName()), e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (downloadMonitor.shouldStopIt())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!caughtErrors.isEmpty())
|
||||
{
|
||||
FMLRelaunchLog.severe("There were errors during initial FML setup. " +
|
||||
"Some files failed to download or were otherwise corrupted. " +
|
||||
"You will need to manually obtain the following files from " +
|
||||
"these download links and ensure your lib directory is clean. ");
|
||||
for (ILibrarySet set : libraries)
|
||||
{
|
||||
for (String file : set.getLibraries())
|
||||
{
|
||||
FMLRelaunchLog.severe("*** Download "+set.getRootURL(), file);
|
||||
}
|
||||
}
|
||||
FMLRelaunchLog.severe("<===========>");
|
||||
FMLRelaunchLog.severe("The following is the errors that caused the setup to fail. " +
|
||||
"They may help you diagnose and resolve the issue");
|
||||
for (Throwable t : caughtErrors)
|
||||
{
|
||||
if (t.getMessage()!=null)
|
||||
{
|
||||
FMLRelaunchLog.severe(t.getMessage());
|
||||
}
|
||||
}
|
||||
FMLRelaunchLog.severe("<<< ==== >>>");
|
||||
FMLRelaunchLog.severe("The following is diagnostic information for developers to review.");
|
||||
for (Throwable t : caughtErrors)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, t, "Error details");
|
||||
}
|
||||
throw new RuntimeException("A fatal error occured and FML cannot continue");
|
||||
}
|
||||
}
|
||||
|
||||
for (IFMLLoadingPlugin plug : loadPlugins)
|
||||
{
|
||||
if (plug.getASMTransformerClass()!=null)
|
||||
{
|
||||
for (String xformClass : plug.getASMTransformerClass())
|
||||
{
|
||||
actualClassLoader.registerTransformer(xformClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Deobfuscation transformer, always last
|
||||
if (!deobfuscatedEnvironment)
|
||||
{
|
||||
actualClassLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer");
|
||||
}
|
||||
downloadMonitor.updateProgressString("Running coremod plugins");
|
||||
Map<String,Object> data = new HashMap<String,Object>();
|
||||
data.put("mcLocation", mcDir);
|
||||
data.put("coremodList", loadPlugins);
|
||||
data.put("runtimeDeobfuscationEnabled", !deobfuscatedEnvironment);
|
||||
for (IFMLLoadingPlugin plugin : loadPlugins)
|
||||
{
|
||||
downloadMonitor.updateProgressString("Running coremod plugin %s", plugin.getClass().getSimpleName());
|
||||
data.put("coremodLocation", pluginLocations.get(plugin));
|
||||
plugin.injectData(data);
|
||||
String setupClass = plugin.getSetupClass();
|
||||
if (setupClass != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
IFMLCallHook call = (IFMLCallHook) Class.forName(setupClass, true, actualClassLoader).newInstance();
|
||||
Map<String,Object> callData = new HashMap<String, Object>();
|
||||
callData.put("mcLocation", mcDir);
|
||||
callData.put("classLoader", actualClassLoader);
|
||||
callData.put("coremodLocation", pluginLocations.get(plugin));
|
||||
callData.put("deobfuscationFileName", FMLInjectionData.debfuscationDataName());
|
||||
call.injectData(callData);
|
||||
call.call();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
downloadMonitor.updateProgressString("Coremod plugin %s run successfully", plugin.getClass().getSimpleName());
|
||||
|
||||
String modContainer = plugin.getModContainerClass();
|
||||
if (modContainer != null)
|
||||
{
|
||||
FMLInjectionData.containers.add(modContainer);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
downloadMonitor.updateProgressString("Validating minecraft");
|
||||
Class<?> loaderClazz = Class.forName("cpw.mods.fml.common.Loader", true, actualClassLoader);
|
||||
Method m = loaderClazz.getMethod("injectData", Object[].class);
|
||||
m.invoke(null, (Object)FMLInjectionData.data());
|
||||
m = loaderClazz.getMethod("instance");
|
||||
m.invoke(null);
|
||||
downloadMonitor.updateProgressString("Minecraft validated, launching...");
|
||||
downloadBuffer = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Load in the Loader, make sure he's ready to roll - this will initialize most of the rest of minecraft here
|
||||
System.out.println("A CRITICAL PROBLEM OCCURED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void discoverCoreMods(File mcDir, RelaunchClassLoader classLoader, List<IFMLLoadingPlugin> loadPlugins, List<ILibrarySet> libraries)
|
||||
{
|
||||
downloadMonitor.updateProgressString("Discovering coremods");
|
||||
File coreMods = setupCoreModDir(mcDir);
|
||||
FilenameFilter ff = new FilenameFilter()
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File dir, String name)
|
||||
{
|
||||
return name.endsWith(".jar");
|
||||
}
|
||||
};
|
||||
File[] coreModList = coreMods.listFiles(ff);
|
||||
Arrays.sort(coreModList);
|
||||
|
||||
for (File coreMod : coreModList)
|
||||
{
|
||||
downloadMonitor.updateProgressString("Found a candidate coremod %s", coreMod.getName());
|
||||
JarFile jar;
|
||||
Attributes mfAttributes;
|
||||
try
|
||||
{
|
||||
jar = new JarFile(coreMod);
|
||||
if (jar.getManifest() == null)
|
||||
{
|
||||
FMLRelaunchLog.warning("Found an un-manifested jar file in the coremods folder : %s, it will be ignored.", coreMod.getName());
|
||||
continue;
|
||||
}
|
||||
mfAttributes = jar.getManifest().getMainAttributes();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, ioe, "Unable to read the coremod jar file %s - ignoring", coreMod.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
String fmlCorePlugin = mfAttributes.getValue("FMLCorePlugin");
|
||||
if (fmlCorePlugin == null)
|
||||
{
|
||||
FMLRelaunchLog.severe("The coremod %s does not contain a valid jar manifest- it will be ignored", coreMod.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
// String className = fmlCorePlugin.replace('.', '/').concat(".class");
|
||||
// JarEntry ent = jar.getJarEntry(className);
|
||||
// if (ent ==null)
|
||||
// {
|
||||
// FMLLog.severe("The coremod %s specified %s as it's loading class but it does not include it - it will be ignored", coreMod.getName(), fmlCorePlugin);
|
||||
// continue;
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// Class<?> coreModClass = Class.forName(fmlCorePlugin, false, classLoader);
|
||||
// FMLLog.severe("The coremods %s specified a class %s that is already present in the classpath - it will be ignored", coreMod.getName(), fmlCorePlugin);
|
||||
// continue;
|
||||
// }
|
||||
// catch (ClassNotFoundException cnfe)
|
||||
// {
|
||||
// // didn't find it, good
|
||||
// }
|
||||
try
|
||||
{
|
||||
classLoader.addURL(coreMod.toURI().toURL());
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, e, "Unable to convert file into a URL. weird");
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
downloadMonitor.updateProgressString("Loading coremod %s", coreMod.getName());
|
||||
classLoader.addTransformerExclusion(fmlCorePlugin);
|
||||
Class<?> coreModClass = Class.forName(fmlCorePlugin, true, classLoader);
|
||||
MCVersion requiredMCVersion = coreModClass.getAnnotation(IFMLLoadingPlugin.MCVersion.class);
|
||||
String version = "";
|
||||
if (requiredMCVersion == null)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.WARNING, "The coremod %s does not have a MCVersion annotation, it may cause issues with this version of Minecraft", fmlCorePlugin);
|
||||
}
|
||||
else
|
||||
{
|
||||
version = requiredMCVersion.value();
|
||||
}
|
||||
if (!"".equals(version) && !FMLInjectionData.mccversion.equals(version))
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, "The coremod %s is requesting minecraft version %s and minecraft is %s. It will be ignored.", fmlCorePlugin, version, FMLInjectionData.mccversion);
|
||||
continue;
|
||||
}
|
||||
else if (!"".equals(version))
|
||||
{
|
||||
FMLRelaunchLog.log(Level.FINE, "The coremod %s requested minecraft version %s and minecraft is %s. It will be loaded.", fmlCorePlugin, version, FMLInjectionData.mccversion);
|
||||
}
|
||||
TransformerExclusions trExclusions = coreModClass.getAnnotation(IFMLLoadingPlugin.TransformerExclusions.class);
|
||||
if (trExclusions!=null)
|
||||
{
|
||||
for (String st : trExclusions.value())
|
||||
{
|
||||
classLoader.addTransformerExclusion(st);
|
||||
}
|
||||
}
|
||||
IFMLLoadingPlugin plugin = (IFMLLoadingPlugin) coreModClass.newInstance();
|
||||
loadPlugins.add(plugin);
|
||||
pluginLocations .put(plugin, coreMod);
|
||||
if (plugin.getLibraryRequestClass()!=null)
|
||||
{
|
||||
for (String libName : plugin.getLibraryRequestClass())
|
||||
{
|
||||
libraries.add((ILibrarySet) Class.forName(libName, true, classLoader).newInstance());
|
||||
}
|
||||
}
|
||||
downloadMonitor.updateProgressString("Loaded coremod %s", coreMod.getName());
|
||||
}
|
||||
catch (ClassNotFoundException cnfe)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, cnfe, "Coremod %s: Unable to class load the plugin %s", coreMod.getName(), fmlCorePlugin);
|
||||
}
|
||||
catch (ClassCastException cce)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, cce, "Coremod %s: The plugin %s is not an implementor of IFMLLoadingPlugin", coreMod.getName(), fmlCorePlugin);
|
||||
}
|
||||
catch (InstantiationException ie)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, ie, "Coremod %s: The plugin class %s was not instantiable", coreMod.getName(), fmlCorePlugin);
|
||||
}
|
||||
catch (IllegalAccessException iae)
|
||||
{
|
||||
FMLRelaunchLog.log(Level.SEVERE, iae, "Coremod %s: The plugin class %s was not accessible", coreMod.getName(), fmlCorePlugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mcDir the minecraft home directory
|
||||
* @return the lib directory
|
||||
*/
|
||||
private static File setupLibDir(File mcDir)
|
||||
{
|
||||
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()));
|
||||
}
|
||||
return libDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mcDir the minecraft home directory
|
||||
* @return the coremod directory
|
||||
*/
|
||||
private static File setupCoreModDir(File mcDir)
|
||||
{
|
||||
File coreModDir = new File(mcDir,"coremods");
|
||||
try
|
||||
{
|
||||
coreModDir = coreModDir.getCanonicalFile();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(String.format("Unable to canonicalize the coremod dir at %s", mcDir.getName()),e);
|
||||
}
|
||||
if (!coreModDir.exists())
|
||||
{
|
||||
coreModDir.mkdir();
|
||||
}
|
||||
else if (coreModDir.exists() && !coreModDir.isDirectory())
|
||||
{
|
||||
throw new RuntimeException(String.format("Found a coremod file in %s that's not a directory", mcDir.getName()));
|
||||
}
|
||||
return coreModDir;
|
||||
}
|
||||
|
||||
private static void downloadFile(File libFile, String rootUrl,String realFilePath, String hash)
|
||||
{
|
||||
try
|
||||
{
|
||||
URL libDownload = new URL(String.format(rootUrl,realFilePath));
|
||||
downloadMonitor.updateProgressString("Downloading file %s", libDownload.toString());
|
||||
FMLRelaunchLog.info("Downloading file %s", libDownload.toString());
|
||||
URLConnection connection = libDownload.openConnection();
|
||||
connection.setConnectTimeout(5000);
|
||||
connection.setReadTimeout(5000);
|
||||
connection.setRequestProperty("User-Agent", "FML Relaunch Downloader");
|
||||
int sizeGuess = connection.getContentLength();
|
||||
performDownload(connection.getInputStream(), sizeGuess, hash, libFile);
|
||||
downloadMonitor.updateProgressString("Download complete");
|
||||
FMLRelaunchLog.info("Download complete");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (downloadMonitor.shouldStopIt())
|
||||
{
|
||||
FMLRelaunchLog.warning("You have stopped the downloading operation before it could complete");
|
||||
return;
|
||||
}
|
||||
if (e instanceof RuntimeException) throw (RuntimeException)e;
|
||||
FMLRelaunchLog.severe("There was a problem downloading the file %s automatically. Perhaps you " +
|
||||
"have an environment without internet access. You will need to download " +
|
||||
"the file manually or restart and let it try again\n", libFile.getName());
|
||||
libFile.delete();
|
||||
throw new RuntimeException("A download error occured", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getLibraries()
|
||||
{
|
||||
return loadedLibraries;
|
||||
}
|
||||
|
||||
private static ByteBuffer downloadBuffer = ByteBuffer.allocateDirect(1 << 23);
|
||||
static IDownloadDisplay downloadMonitor;
|
||||
|
||||
private static void performDownload(InputStream is, int sizeGuess, String validationHash, File target)
|
||||
{
|
||||
if (sizeGuess > downloadBuffer.capacity())
|
||||
{
|
||||
throw new RuntimeException(String.format("The file %s is too large to be downloaded by FML - the coremod is invalid", target.getName()));
|
||||
}
|
||||
downloadBuffer.clear();
|
||||
|
||||
int bytesRead, fullLength = 0;
|
||||
|
||||
downloadMonitor.resetProgress(sizeGuess);
|
||||
try
|
||||
{
|
||||
downloadMonitor.setPokeThread(Thread.currentThread());
|
||||
byte[] smallBuffer = new byte[1024];
|
||||
while ((bytesRead = is.read(smallBuffer)) >= 0) {
|
||||
downloadBuffer.put(smallBuffer, 0, bytesRead);
|
||||
fullLength += bytesRead;
|
||||
if (downloadMonitor.shouldStopIt())
|
||||
{
|
||||
break;
|
||||
}
|
||||
downloadMonitor.updateProgress(fullLength);
|
||||
}
|
||||
is.close();
|
||||
downloadMonitor.setPokeThread(null);
|
||||
downloadBuffer.limit(fullLength);
|
||||
downloadBuffer.position(0);
|
||||
}
|
||||
catch (InterruptedIOException e)
|
||||
{
|
||||
// We were interrupted by the stop button. We're stopping now.. clear interruption flag.
|
||||
Thread.interrupted();
|
||||
return;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
String cksum = generateChecksum(downloadBuffer);
|
||||
if (cksum.equals(validationHash))
|
||||
{
|
||||
downloadBuffer.position(0);
|
||||
FileOutputStream fos = new FileOutputStream(target);
|
||||
fos.getChannel().write(downloadBuffer);
|
||||
fos.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException(String.format("The downloaded file %s has an invalid checksum %s (expecting %s). The download did not succeed correctly and the file has been deleted. Please try launching again.", target.getName(), cksum, validationHash));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e instanceof RuntimeException) throw (RuntimeException)e;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static String generateChecksum(ByteBuffer buffer)
|
||||
{
|
||||
return CertificateHelper.getFingerprint(buffer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
public class ServerLaunchWrapper {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new ServerLaunchWrapper().run(args);
|
||||
}
|
||||
|
||||
private ServerLaunchWrapper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void run(String[] args)
|
||||
{
|
||||
Class<?> launchwrapper = null;
|
||||
try
|
||||
{
|
||||
launchwrapper = Class.forName("net.minecraft.launchwrapper.Launch",true,getClass().getClassLoader());
|
||||
Class.forName("org.objectweb.asm.Type",true,getClass().getClassLoader());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.printf("We appear to be missing one or more essential library files.\n" +
|
||||
"You will need to add them to your server before FML and Forge will run successfully.");
|
||||
e.printStackTrace(System.err);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Method main = launchwrapper.getMethod("main", String[].class);
|
||||
String[] allArgs = new String[args.length + 2];
|
||||
allArgs[0] = "--tweakClass";
|
||||
allArgs[1] = "cpw.mods.fml.common.launcher.FMLServerTweaker";
|
||||
System.arraycopy(args, 0, allArgs, 2, args.length);
|
||||
main.invoke(null,(Object)allArgs);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.printf("A problem occurred running the Server launcher.");
|
||||
e.printStackTrace(System.err);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -13,7 +13,17 @@
|
||||
package cpw.mods.fml.relauncher;
|
||||
|
||||
public enum Side {
|
||||
CLIENT, SERVER, BUKKIT;
|
||||
|
||||
/**
|
||||
* The client side. Specifically, an environment where rendering capability exists.
|
||||
* Usually in the game client.
|
||||
*/
|
||||
CLIENT,
|
||||
/**
|
||||
* The server side. Specifically, an environment where NO rendering capability exists.
|
||||
* Usually on the dedicated server.
|
||||
*/
|
||||
SERVER;
|
||||
|
||||
/**
|
||||
* @return If this is the server environment
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -17,7 +17,22 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
|
||||
|
||||
/**
|
||||
* Marks the associated element as being only available on a certain {@link Side}. This is
|
||||
* generally meant for internal Forge and FML use only and should only be used on mod classes
|
||||
* when other more common mechanisms, such as using a {@link SidedProxy} fail to work.
|
||||
*
|
||||
* Note, this will <em>only</em> apply to the direct element marked. This code:
|
||||
* <code> @SideOnly public MyField field = new MyField();</code> will <strong>not</strong> work, as the initializer
|
||||
* is a separate piece of code to the actual field declaration, and will not be able to find
|
||||
* it's field on the wrong side.
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
|
||||
public @interface SideOnly
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* ByteArraySeekableSource.java
|
||||
*
|
||||
* Created on May 17, 2006, 12:41 PM
|
||||
* Copyright (c) 2006 Heiko Klein
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.repackage.com.nothome.delta;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* Wraps a byte buffer as a source
|
||||
*/
|
||||
public class ByteBufferSeekableSource implements SeekableSource {
|
||||
|
||||
private ByteBuffer bb;
|
||||
private ByteBuffer cur;
|
||||
|
||||
/**
|
||||
* Constructs a new ByteArraySeekableSource.
|
||||
*/
|
||||
public ByteBufferSeekableSource(byte[] source) {
|
||||
this(ByteBuffer.wrap(source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ByteArraySeekableSource.
|
||||
*/
|
||||
public ByteBufferSeekableSource(ByteBuffer bb) {
|
||||
if (bb == null)
|
||||
throw new NullPointerException("bb");
|
||||
this.bb = bb;
|
||||
bb.rewind();
|
||||
try {
|
||||
seek(0);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void seek(long pos) throws IOException {
|
||||
cur = bb.slice();
|
||||
if (pos > cur.limit())
|
||||
throw new IOException("pos " + pos + " cannot seek " + cur.limit());
|
||||
cur.position((int) pos);
|
||||
}
|
||||
|
||||
public int read(ByteBuffer dest) throws IOException {
|
||||
if (!cur.hasRemaining())
|
||||
return -1;
|
||||
int c = 0;
|
||||
while (cur.hasRemaining() && dest.hasRemaining()) {
|
||||
dest.put(cur.get());
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
bb = null;
|
||||
cur = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a debug <code>String</code>.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "BBSeekable" +
|
||||
" bb=" + this.bb.position() + "-" + bb.limit() +
|
||||
" cur=" + this.cur.position() + "-" + cur.limit() +
|
||||
"";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2001 Torgeir Veimo
|
||||
* Copyright (c) 2002 Nicolas PERIDONT
|
||||
* Copyright (c) 2006 Heiko Klein
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.repackage.com.nothome.delta;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* Checksum computation class.
|
||||
*/
|
||||
public class Checksum {
|
||||
|
||||
static final boolean debug = false;
|
||||
|
||||
private Map<Long,Integer> checksums = Maps.newHashMap();
|
||||
|
||||
private static final char single_hash[] = {
|
||||
/* Random numbers generated using SLIB's pseudo-random number generator. */
|
||||
0xbcd1, 0xbb65, 0x42c2, 0xdffe, 0x9666, 0x431b, 0x8504, 0xeb46,
|
||||
0x6379, 0xd460, 0xcf14, 0x53cf, 0xdb51, 0xdb08, 0x12c8, 0xf602,
|
||||
0xe766, 0x2394, 0x250d, 0xdcbb, 0xa678, 0x02af, 0xa5c6, 0x7ea6,
|
||||
0xb645, 0xcb4d, 0xc44b, 0xe5dc, 0x9fe6, 0x5b5c, 0x35f5, 0x701a,
|
||||
0x220f, 0x6c38, 0x1a56, 0x4ca3, 0xffc6, 0xb152, 0x8d61, 0x7a58,
|
||||
0x9025, 0x8b3d, 0xbf0f, 0x95a3, 0xe5f4, 0xc127, 0x3bed, 0x320b,
|
||||
0xb7f3, 0x6054, 0x333c, 0xd383, 0x8154, 0x5242, 0x4e0d, 0x0a94,
|
||||
0x7028, 0x8689, 0x3a22, 0x0980, 0x1847, 0xb0f1, 0x9b5c, 0x4176,
|
||||
0xb858, 0xd542, 0x1f6c, 0x2497, 0x6a5a, 0x9fa9, 0x8c5a, 0x7743,
|
||||
0xa8a9, 0x9a02, 0x4918, 0x438c, 0xc388, 0x9e2b, 0x4cad, 0x01b6,
|
||||
0xab19, 0xf777, 0x365f, 0x1eb2, 0x091e, 0x7bf8, 0x7a8e, 0x5227,
|
||||
0xeab1, 0x2074, 0x4523, 0xe781, 0x01a3, 0x163d, 0x3b2e, 0x287d,
|
||||
0x5e7f, 0xa063, 0xb134, 0x8fae, 0x5e8e, 0xb7b7, 0x4548, 0x1f5a,
|
||||
0xfa56, 0x7a24, 0x900f, 0x42dc, 0xcc69, 0x02a0, 0x0b22, 0xdb31,
|
||||
0x71fe, 0x0c7d, 0x1732, 0x1159, 0xcb09, 0xe1d2, 0x1351, 0x52e9,
|
||||
0xf536, 0x5a4f, 0xc316, 0x6bf9, 0x8994, 0xb774, 0x5f3e, 0xf6d6,
|
||||
0x3a61, 0xf82c, 0xcc22, 0x9d06, 0x299c, 0x09e5, 0x1eec, 0x514f,
|
||||
0x8d53, 0xa650, 0x5c6e, 0xc577, 0x7958, 0x71ac, 0x8916, 0x9b4f,
|
||||
0x2c09, 0x5211, 0xf6d8, 0xcaaa, 0xf7ef, 0x287f, 0x7a94, 0xab49,
|
||||
0xfa2c, 0x7222, 0xe457, 0xd71a, 0x00c3, 0x1a76, 0xe98c, 0xc037,
|
||||
0x8208, 0x5c2d, 0xdfda, 0xe5f5, 0x0b45, 0x15ce, 0x8a7e, 0xfcad,
|
||||
0xaa2d, 0x4b5c, 0xd42e, 0xb251, 0x907e, 0x9a47, 0xc9a6, 0xd93f,
|
||||
0x085e, 0x35ce, 0xa153, 0x7e7b, 0x9f0b, 0x25aa, 0x5d9f, 0xc04d,
|
||||
0x8a0e, 0x2875, 0x4a1c, 0x295f, 0x1393, 0xf760, 0x9178, 0x0f5b,
|
||||
0xfa7d, 0x83b4, 0x2082, 0x721d, 0x6462, 0x0368, 0x67e2, 0x8624,
|
||||
0x194d, 0x22f6, 0x78fb, 0x6791, 0xb238, 0xb332, 0x7276, 0xf272,
|
||||
0x47ec, 0x4504, 0xa961, 0x9fc8, 0x3fdc, 0xb413, 0x007a, 0x0806,
|
||||
0x7458, 0x95c6, 0xccaa, 0x18d6, 0xe2ae, 0x1b06, 0xf3f6, 0x5050,
|
||||
0xc8e8, 0xf4ac, 0xc04c, 0xf41c, 0x992f, 0xae44, 0x5f1b, 0x1113,
|
||||
0x1738, 0xd9a8, 0x19ea, 0x2d33, 0x9698, 0x2fe9, 0x323f, 0xcde2,
|
||||
0x6d71, 0xe37d, 0xb697, 0x2c4f, 0x4373, 0x9102, 0x075d, 0x8e25,
|
||||
0x1672, 0xec28, 0x6acb, 0x86cc, 0x186e, 0x9414, 0xd674, 0xd1a5
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize checksums for source. The checksum for the <code>chunkSize</code> bytes at offset
|
||||
* <code>chunkSize</code> * i is inserted into a hash map.
|
||||
*/
|
||||
public Checksum(SeekableSource source, int chunkSize) throws IOException {
|
||||
ByteBuffer bb = ByteBuffer.allocate(chunkSize * 2);
|
||||
int count = 0;
|
||||
while (true) {
|
||||
source.read(bb);
|
||||
bb.flip();
|
||||
if (bb.remaining() < chunkSize)
|
||||
break;
|
||||
while (bb.remaining() >= chunkSize) {
|
||||
long queryChecksum = queryChecksum0(bb, chunkSize);
|
||||
checksums.put(queryChecksum, count++);
|
||||
}
|
||||
bb.compact();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the checksum computed from the buffer.
|
||||
* Marks, gets, then resets the buffer.
|
||||
*/
|
||||
public static long queryChecksum(ByteBuffer bb, int len) {
|
||||
bb.mark();
|
||||
long sum = queryChecksum0(bb, len);
|
||||
bb.reset();
|
||||
return sum;
|
||||
}
|
||||
|
||||
private static long queryChecksum0(ByteBuffer bb, int len) {
|
||||
int high = 0; int low = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
low += single_hash[bb.get()+128];
|
||||
high += low;
|
||||
}
|
||||
return ((high & 0xffff) << 16) | (low & 0xffff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments a checksum.
|
||||
* @param checksum initial checksum
|
||||
* @param out byte leaving view
|
||||
* @param in byte entering view
|
||||
* @param chunkSize size of chunks
|
||||
* @return new checksum
|
||||
*/
|
||||
public static long incrementChecksum(long checksum, byte out, byte in, int chunkSize) {
|
||||
char old_c = single_hash[out+128];
|
||||
char new_c = single_hash[in+128];
|
||||
int low = ((int)((checksum) & 0xffff) - old_c + new_c) & 0xffff;
|
||||
int high = ((int)((checksum) >> 16) - (old_c * chunkSize) + low) & 0xffff;
|
||||
return (high << 16) | (low & 0xffff);
|
||||
}
|
||||
|
||||
/**
|
||||
* 256 random hash values.
|
||||
*/
|
||||
public static char[] getSingleHash() {
|
||||
return single_hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the index of a checksum.
|
||||
*/
|
||||
public int findChecksumIndex(long hashf) {
|
||||
if (!checksums.containsKey(hashf))
|
||||
return -1;
|
||||
return checksums.get(hashf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a debug <code>String</code>.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return super.toString() +
|
||||
" checksums=" + this.checksums;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2001 Torgeir Veimo
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.repackage.com.nothome.delta;
|
||||
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* For debugging patch generation.
|
||||
*/
|
||||
public class DebugDiffWriter implements DiffWriter {
|
||||
|
||||
private ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
|
||||
/**
|
||||
* Constructs a new DebugDiffWriter.
|
||||
*/
|
||||
public DebugDiffWriter() {}
|
||||
|
||||
public void addCopy(long offset, int length) throws IOException {
|
||||
if (os.size() > 0)
|
||||
writeBuf();
|
||||
System.err.println("COPY off: " + offset + ", len: " + length);
|
||||
}
|
||||
|
||||
public void addData(byte b) throws IOException {
|
||||
os.write(b);
|
||||
writeBuf();
|
||||
}
|
||||
private void writeBuf() {
|
||||
System.err.print("DATA: ");
|
||||
byte[] ba = os.toByteArray();
|
||||
for (int ix = 0; ix < ba.length; ix++) {
|
||||
if (ba[ix] == '\n')
|
||||
System.err.print("\\n");
|
||||
else
|
||||
System.err.print(String.valueOf((char)((char) ba[ix])));
|
||||
//System.err.print("0x" + Integer.toHexString(buf[ix]) + " "); // hex output
|
||||
}
|
||||
System.err.println("");
|
||||
os.reset();
|
||||
}
|
||||
|
||||
public void flush() throws IOException {
|
||||
System.err.println("FLUSH");
|
||||
}
|
||||
public void close() throws IOException {
|
||||
System.err.println("CLOSE");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,447 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2001 Torgeir Veimo
|
||||
* Copyright (c) 2002 Nicolas PERIDONT
|
||||
* Bug Fixes: Daniel Morrione dan@morrione.net
|
||||
* Copyright (c) 2006 Heiko Klein
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*
|
||||
* Change Log:
|
||||
* iiimmddyyn nnnnn Description
|
||||
* ---------- ----- -------------------------------------------------------
|
||||
* gls100603a Fixes from Torgeir Veimo and Dan Morrione
|
||||
* gls110603a Stream not being closed thus preventing a file from
|
||||
* being subsequently deleted.
|
||||
* gls031504a Error being written to stderr rather than throwing exception
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.repackage.com.nothome.delta;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
|
||||
/**
|
||||
* Class for computing deltas against a source.
|
||||
* The source file is read by blocks and a hash is computed per block.
|
||||
* Then the target is scanned for matching blocks.
|
||||
* <p/>
|
||||
* This class is not thread safe. Use one instance per thread.
|
||||
* <p/>
|
||||
* This class should support files over 4GB in length, although you must
|
||||
* use a larger checksum size, such as 1K, as all checksums use "int" indexing.
|
||||
* Newer versions may eventually support paging in/out of checksums.
|
||||
*/
|
||||
public class Delta {
|
||||
|
||||
/**
|
||||
* Debug flag.
|
||||
*/
|
||||
final static boolean debug = false;
|
||||
|
||||
/**
|
||||
* Default size of 16.
|
||||
* For "Lorem ipsum" text files (see the tests) the ideal size is about 14.
|
||||
* Any smaller and the patch size becomes actually be larger.
|
||||
* <p>
|
||||
* Use a size like 64 or 128 for large files.
|
||||
*/
|
||||
public static final int DEFAULT_CHUNK_SIZE = 1<<4;
|
||||
|
||||
/**
|
||||
* Chunk Size.
|
||||
*/
|
||||
private int S;
|
||||
|
||||
private SourceState source;
|
||||
private TargetState target;
|
||||
private DiffWriter output;
|
||||
|
||||
/**
|
||||
* Constructs a new Delta.
|
||||
* In the future, additional constructor arguments will set the algorithm details.
|
||||
*/
|
||||
public Delta() {
|
||||
setChunkSize(DEFAULT_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the chunk size used.
|
||||
* Larger chunks are faster and use less memory, but create larger patches
|
||||
* as well.
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
public void setChunkSize(int size) {
|
||||
if (size <= 0)
|
||||
throw new IllegalArgumentException("Invalid size");
|
||||
S = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the source bytes with target bytes, writing to output.
|
||||
*/
|
||||
public void compute(byte source[], byte target[], OutputStream output)
|
||||
throws IOException {
|
||||
compute(new ByteBufferSeekableSource(source),
|
||||
new ByteArrayInputStream(target),
|
||||
new GDiffWriter(output));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the source bytes with target bytes, returning output.
|
||||
*/
|
||||
public byte[] compute(byte source[], byte target[])
|
||||
throws IOException {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
compute(source, target, os);
|
||||
return os.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the source bytes with target input, writing to output.
|
||||
*/
|
||||
public void compute(byte[] sourceBytes, InputStream inputStream,
|
||||
DiffWriter diffWriter) throws IOException
|
||||
{
|
||||
compute(new ByteBufferSeekableSource(sourceBytes),
|
||||
inputStream, diffWriter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the source file with a target file, writing to output.
|
||||
*
|
||||
* @param output will be closed
|
||||
*/
|
||||
public void compute(File sourceFile, File targetFile, DiffWriter output)
|
||||
throws IOException {
|
||||
RandomAccessFileSeekableSource source = new RandomAccessFileSeekableSource(new RandomAccessFile(sourceFile, "r"));
|
||||
InputStream is = new BufferedInputStream(new FileInputStream(targetFile));
|
||||
try {
|
||||
compute(source, is, output);
|
||||
} finally {
|
||||
source.close();
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the source with a target, writing to output.
|
||||
*
|
||||
* @param output will be closed
|
||||
*/
|
||||
public void compute(SeekableSource seekSource, InputStream targetIS, DiffWriter output)
|
||||
throws IOException {
|
||||
|
||||
if (debug) {
|
||||
debug("using match length S = " + S);
|
||||
}
|
||||
|
||||
source = new SourceState(seekSource);
|
||||
target = new TargetState(targetIS);
|
||||
this.output = output;
|
||||
if (debug)
|
||||
debug("checksums " + source.checksum);
|
||||
|
||||
while (!target.eof()) {
|
||||
debug("!target.eof()");
|
||||
int index = target.find(source);
|
||||
if (index != -1) {
|
||||
if (debug)
|
||||
debug("found hash " + index);
|
||||
long offset = (long)index * S;
|
||||
source.seek(offset);
|
||||
int match = target.longestMatch(source);
|
||||
if (match >= S) {
|
||||
if (debug)
|
||||
debug("output.addCopy("+offset+","+match+")");
|
||||
output.addCopy(offset, match);
|
||||
} else {
|
||||
// move the position back according to how much we can't copy
|
||||
target.tbuf.position(target.tbuf.position() - match);
|
||||
addData();
|
||||
}
|
||||
} else {
|
||||
addData();
|
||||
}
|
||||
}
|
||||
output.close();
|
||||
}
|
||||
|
||||
private void addData() throws IOException {
|
||||
int i = target.read();
|
||||
if (debug)
|
||||
debug("addData " + Integer.toHexString(i));
|
||||
if (i == -1)
|
||||
return;
|
||||
output.addData((byte)i);
|
||||
}
|
||||
|
||||
class SourceState {
|
||||
|
||||
private Checksum checksum;
|
||||
private SeekableSource source;
|
||||
|
||||
public SourceState(SeekableSource source) throws IOException {
|
||||
checksum = new Checksum(source, S);
|
||||
this.source = source;
|
||||
source.seek(0);
|
||||
}
|
||||
|
||||
public void seek(long index) throws IOException {
|
||||
source.seek(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a debug <code>String</code>.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Source"+
|
||||
" checksum=" + this.checksum +
|
||||
" source=" + this.source +
|
||||
"";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TargetState {
|
||||
|
||||
private ReadableByteChannel c;
|
||||
private ByteBuffer tbuf = ByteBuffer.allocate(blocksize());
|
||||
private ByteBuffer sbuf = ByteBuffer.allocate(blocksize());
|
||||
private long hash;
|
||||
private boolean hashReset = true;
|
||||
private boolean eof;
|
||||
|
||||
TargetState(InputStream targetIS) throws IOException {
|
||||
c = Channels.newChannel(targetIS);
|
||||
tbuf.limit(0);
|
||||
}
|
||||
|
||||
private int blocksize() {
|
||||
return Math.min(1024 * 16, S * 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the next N bytes of the stream.
|
||||
*/
|
||||
public int find(SourceState source) throws IOException {
|
||||
if (eof)
|
||||
return -1;
|
||||
sbuf.clear();
|
||||
sbuf.limit(0);
|
||||
if (hashReset) {
|
||||
debug("hashReset");
|
||||
while (tbuf.remaining() < S) {
|
||||
tbuf.compact();
|
||||
int read = c.read(tbuf);
|
||||
tbuf.flip();
|
||||
if (read == -1) {
|
||||
debug("target ending");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
hash = Checksum.queryChecksum(tbuf, S);
|
||||
hashReset = false;
|
||||
}
|
||||
if (debug)
|
||||
debug("hash " + hash + " " + dump());
|
||||
return source.checksum.findChecksumIndex(hash);
|
||||
}
|
||||
|
||||
public boolean eof() {
|
||||
return eof;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a byte.
|
||||
* @throws IOException
|
||||
*/
|
||||
public int read() throws IOException {
|
||||
if (tbuf.remaining() <= S) {
|
||||
readMore();
|
||||
if (!tbuf.hasRemaining()) {
|
||||
eof = true;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
byte b = tbuf.get();
|
||||
if (tbuf.remaining() >= S) {
|
||||
byte nchar = tbuf.get( tbuf.position() + S -1 );
|
||||
hash = Checksum.incrementChecksum(hash, b, nchar, S);
|
||||
} else {
|
||||
debug("out of char");
|
||||
}
|
||||
return b & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the longest match length at the source location.
|
||||
*/
|
||||
public int longestMatch(SourceState source) throws IOException {
|
||||
debug("longestMatch");
|
||||
int match = 0;
|
||||
hashReset = true;
|
||||
while (true) {
|
||||
if (!sbuf.hasRemaining()) {
|
||||
sbuf.clear();
|
||||
int read = source.source.read(sbuf);
|
||||
sbuf.flip();
|
||||
if (read == -1)
|
||||
return match;
|
||||
}
|
||||
if (!tbuf.hasRemaining()) {
|
||||
readMore();
|
||||
if (!tbuf.hasRemaining()) {
|
||||
debug("target ending");
|
||||
eof = true;
|
||||
return match;
|
||||
}
|
||||
}
|
||||
if (sbuf.get() != tbuf.get()) {
|
||||
tbuf.position(tbuf.position() - 1);
|
||||
return match;
|
||||
}
|
||||
match++;
|
||||
}
|
||||
}
|
||||
|
||||
private void readMore() throws IOException {
|
||||
if (debug)
|
||||
debug("readMore " + tbuf);
|
||||
tbuf.compact();
|
||||
c.read(tbuf);
|
||||
tbuf.flip();
|
||||
}
|
||||
|
||||
void hash() {
|
||||
hash = Checksum.queryChecksum(tbuf, S);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a debug <code>String</code>.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Target[" +
|
||||
" targetBuff=" + dump() + // this.tbuf +
|
||||
" sourceBuff=" + this.sbuf +
|
||||
" hashf=" + this.hash +
|
||||
" eof=" + this.eof +
|
||||
"]";
|
||||
}
|
||||
|
||||
private String dump() { return dump(tbuf); }
|
||||
|
||||
private String dump(ByteBuffer bb) {
|
||||
return getTextDump(bb);
|
||||
}
|
||||
|
||||
private void append(StringBuffer sb, int value) {
|
||||
char b1 = (char)((value >> 4) & 0x0F);
|
||||
char b2 = (char)((value) & 0x0F);
|
||||
sb.append( Character.forDigit(b1, 16) );
|
||||
sb.append( Character.forDigit(b2, 16) );
|
||||
}
|
||||
|
||||
public String getTextDump(ByteBuffer bb)
|
||||
{
|
||||
StringBuffer sb = new StringBuffer(bb.remaining() * 2);
|
||||
bb.mark();
|
||||
while (bb.hasRemaining()) {
|
||||
int val = bb.get();
|
||||
if (val > 32 && val < 127)
|
||||
sb.append(" ").append((char)val);
|
||||
else
|
||||
append(sb, val);
|
||||
}
|
||||
bb.reset();
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a patch using file names.
|
||||
*/
|
||||
public static void main(String argv[]) throws Exception {
|
||||
if (argv.length != 3) {
|
||||
System.err.println("usage Delta [-d] source target [output]");
|
||||
System.err.println("either -d or an output filename must be specified.");
|
||||
System.err.println("aborting..");
|
||||
return;
|
||||
}
|
||||
DiffWriter output = null;
|
||||
File sourceFile = null;
|
||||
File targetFile = null;
|
||||
if (argv[0].equals("-d")) {
|
||||
sourceFile = new File(argv[1]);
|
||||
targetFile = new File(argv[2]);
|
||||
output = new DebugDiffWriter();
|
||||
} else {
|
||||
sourceFile = new File(argv[0]);
|
||||
targetFile = new File(argv[1]);
|
||||
output =
|
||||
new GDiffWriter(
|
||||
new DataOutputStream(
|
||||
new BufferedOutputStream(
|
||||
new FileOutputStream(new File(argv[2])))));
|
||||
}
|
||||
|
||||
if (sourceFile.length() > Integer.MAX_VALUE
|
||||
|| targetFile.length() > Integer.MAX_VALUE) {
|
||||
System.err.println(
|
||||
"source or target is too large, max length is "
|
||||
+ Integer.MAX_VALUE);
|
||||
System.err.println("aborting..");
|
||||
output.close();
|
||||
return;
|
||||
}
|
||||
|
||||
Delta d = new Delta();
|
||||
d.compute(sourceFile, targetFile, output);
|
||||
|
||||
output.flush();
|
||||
output.close();
|
||||
if (debug) //gls031504a
|
||||
System.out.println("finished generating delta");
|
||||
}
|
||||
|
||||
private void debug(String s) {
|
||||
if (debug)
|
||||
System.err.println(s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2001 Torgeir Veimo
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.repackage.com.nothome.delta;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Interface for DIFF writers.
|
||||
*/
|
||||
public interface DiffWriter extends Closeable {
|
||||
|
||||
/**
|
||||
* Add a GDIFF copy instruction.
|
||||
*/
|
||||
public void addCopy(long offset, int length) throws IOException;
|
||||
|
||||
/**
|
||||
* Add a GDIFF data instruction.
|
||||
* Implementors should buffer the data.
|
||||
*/
|
||||
public void addData(byte b) throws IOException;
|
||||
|
||||
/**
|
||||
* Flushes to output, e.g. any data added.
|
||||
*/
|
||||
public void flush() throws IOException;
|
||||
|
||||
/**
|
||||
* Closes this stream.
|
||||
* Note that {@link DiffWriter} will invoke this method at the end.
|
||||
*/
|
||||
public void close() throws IOException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2001 Torgeir Veimo
|
||||
* Copyright (c) 2006 Heiko Klein
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.repackage.com.nothome.delta;
|
||||
|
||||
import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_INT_INT;
|
||||
import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_INT_UBYTE;
|
||||
import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_INT_USHORT;
|
||||
import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_LONG_INT;
|
||||
import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_USHORT_INT;
|
||||
import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_USHORT_UBYTE;
|
||||
import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_USHORT_USHORT;
|
||||
import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.DATA_INT;
|
||||
import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.DATA_MAX;
|
||||
import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.DATA_USHORT;
|
||||
import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.EOF;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* This class patches an input file with a GDIFF patch file.
|
||||
*
|
||||
* The patch file follows the GDIFF file specification available at
|
||||
*
|
||||
* <a href="http://www.w3.org/TR/NOTE-gdiff-19970901.html">http://www.w3.org/TR/NOTE-gdiff-19970901.html</a>.
|
||||
*/
|
||||
public class GDiffPatcher {
|
||||
|
||||
private ByteBuffer buf = ByteBuffer.allocate(1024);
|
||||
private byte buf2[] = buf.array();
|
||||
|
||||
/**
|
||||
* Constructs a new GDiffPatcher.
|
||||
*/
|
||||
public GDiffPatcher() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Patches to an output file.
|
||||
*/
|
||||
public void patch(File sourceFile, File patchFile, File outputFile)
|
||||
throws IOException
|
||||
{
|
||||
RandomAccessFileSeekableSource source =new RandomAccessFileSeekableSource(new RandomAccessFile(sourceFile, "r"));
|
||||
InputStream patch = new FileInputStream(patchFile);
|
||||
OutputStream output = new FileOutputStream(outputFile);
|
||||
try {
|
||||
patch(source, patch, output);
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
} finally {
|
||||
source.close();
|
||||
patch.close();
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Patches to an output stream.
|
||||
*/
|
||||
public void patch(byte[] source, InputStream patch, OutputStream output) throws IOException {
|
||||
patch(new ByteBufferSeekableSource(source), patch, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Patches in memory, returning the patch result.
|
||||
*/
|
||||
public byte[] patch(byte[] source, byte[] patch) throws IOException {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
patch(source, new ByteArrayInputStream(patch), os);
|
||||
return os.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Patches to an output stream.
|
||||
*/
|
||||
public void patch(SeekableSource source, InputStream patch, OutputStream out) throws IOException {
|
||||
|
||||
DataOutputStream outOS = new DataOutputStream(out);
|
||||
DataInputStream patchIS = new DataInputStream(patch);
|
||||
|
||||
// the magic string is 'd1 ff d1 ff' + the version number
|
||||
if (patchIS.readUnsignedByte() != 0xd1 ||
|
||||
patchIS.readUnsignedByte() != 0xff ||
|
||||
patchIS.readUnsignedByte() != 0xd1 ||
|
||||
patchIS.readUnsignedByte() != 0xff ||
|
||||
patchIS.readUnsignedByte() != 0x04) {
|
||||
|
||||
throw new PatchException("magic string not found, aborting!");
|
||||
}
|
||||
|
||||
while (true) {
|
||||
int command = patchIS.readUnsignedByte();
|
||||
if (command == EOF)
|
||||
break;
|
||||
int length;
|
||||
int offset;
|
||||
|
||||
if (command <= DATA_MAX) {
|
||||
append(command, patchIS, outOS);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (command) {
|
||||
case DATA_USHORT: // ushort, n bytes following; append
|
||||
length = patchIS.readUnsignedShort();
|
||||
append(length, patchIS, outOS);
|
||||
break;
|
||||
case DATA_INT: // int, n bytes following; append
|
||||
length = patchIS.readInt();
|
||||
append(length, patchIS, outOS);
|
||||
break;
|
||||
case COPY_USHORT_UBYTE:
|
||||
offset = patchIS.readUnsignedShort();
|
||||
length = patchIS.readUnsignedByte();
|
||||
copy(offset, length, source, outOS);
|
||||
break;
|
||||
case COPY_USHORT_USHORT:
|
||||
offset = patchIS.readUnsignedShort();
|
||||
length = patchIS.readUnsignedShort();
|
||||
copy(offset, length, source, outOS);
|
||||
break;
|
||||
case COPY_USHORT_INT:
|
||||
offset = patchIS.readUnsignedShort();
|
||||
length = patchIS.readInt();
|
||||
copy(offset, length, source, outOS);
|
||||
break;
|
||||
case COPY_INT_UBYTE:
|
||||
offset = patchIS.readInt();
|
||||
length = patchIS.readUnsignedByte();
|
||||
copy(offset, length, source, outOS);
|
||||
break;
|
||||
case COPY_INT_USHORT:
|
||||
offset = patchIS.readInt();
|
||||
length = patchIS.readUnsignedShort();
|
||||
copy(offset, length, source, outOS);
|
||||
break;
|
||||
case COPY_INT_INT:
|
||||
offset = patchIS.readInt();
|
||||
length = patchIS.readInt();
|
||||
copy(offset, length, source, outOS);
|
||||
break;
|
||||
case COPY_LONG_INT:
|
||||
long loffset = patchIS.readLong();
|
||||
length = patchIS.readInt();
|
||||
copy(loffset, length, source, outOS);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("command " + command);
|
||||
}
|
||||
}
|
||||
outOS.flush();
|
||||
}
|
||||
|
||||
private void copy(long offset, int length, SeekableSource source, OutputStream output)
|
||||
throws IOException
|
||||
{
|
||||
source.seek(offset);
|
||||
while (length > 0) {
|
||||
int len = Math.min(buf.capacity(), length);
|
||||
buf.clear().limit(len);
|
||||
int res = source.read(buf);
|
||||
if (res == -1)
|
||||
throw new EOFException("in copy " + offset + " " + length);
|
||||
output.write(buf.array(), 0, res);
|
||||
length -= res;
|
||||
}
|
||||
}
|
||||
|
||||
private void append(int length, InputStream patch, OutputStream output) throws IOException {
|
||||
while (length > 0) {
|
||||
int len = Math.min(buf2.length, length);
|
||||
int res = patch.read(buf2, 0, len);
|
||||
if (res == -1)
|
||||
throw new EOFException("cannot read " + length);
|
||||
output.write(buf2, 0, res);
|
||||
length -= res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple command line tool to patch a file.
|
||||
*/
|
||||
public static void main(String argv[]) {
|
||||
|
||||
if (argv.length != 3) {
|
||||
System.err.println("usage GDiffPatch source patch output");
|
||||
System.err.println("aborting..");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
File sourceFile = new File(argv[0]);
|
||||
File patchFile = new File(argv[1]);
|
||||
File outputFile = new File(argv[2]);
|
||||
|
||||
if (sourceFile.length() > Integer.MAX_VALUE ||
|
||||
patchFile.length() > Integer.MAX_VALUE) {
|
||||
System.err.println("source or patch is too large, max length is " + Integer.MAX_VALUE);
|
||||
System.err.println("aborting..");
|
||||
return;
|
||||
}
|
||||
GDiffPatcher patcher = new GDiffPatcher();
|
||||
patcher.patch(sourceFile, patchFile, outputFile);
|
||||
|
||||
System.out.println("finished patching file");
|
||||
|
||||
} catch (Exception ioe) { //gls031504a
|
||||
System.err.println("error while patching: " + ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2001 Torgeir Veimo
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.repackage.com.nothome.delta;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Outputs a diff following the GDIFF file specification available at
|
||||
* http://www.w3.org/TR/NOTE-gdiff-19970901.html.
|
||||
*/
|
||||
public class GDiffWriter implements DiffWriter {
|
||||
|
||||
/**
|
||||
* Max length of a chunk.
|
||||
*/
|
||||
public static final int CHUNK_SIZE = Short.MAX_VALUE;
|
||||
|
||||
public static final byte EOF = 0;
|
||||
|
||||
/**
|
||||
* Max length for single length data encode.
|
||||
*/
|
||||
public static final int DATA_MAX = 246;
|
||||
|
||||
public static final int DATA_USHORT = 247;
|
||||
public static final int DATA_INT = 248;
|
||||
public static final int COPY_USHORT_UBYTE = 249;
|
||||
public static final int COPY_USHORT_USHORT = 250;
|
||||
public static final int COPY_USHORT_INT = 251;
|
||||
public static final int COPY_INT_UBYTE = 252;
|
||||
public static final int COPY_INT_USHORT = 253;
|
||||
public static final int COPY_INT_INT = 254;
|
||||
public static final int COPY_LONG_INT = 255;
|
||||
|
||||
private ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
|
||||
private boolean debug = false;
|
||||
|
||||
private DataOutputStream output = null;
|
||||
|
||||
/**
|
||||
* Constructs a new GDiffWriter.
|
||||
*/
|
||||
public GDiffWriter(DataOutputStream os) throws IOException {
|
||||
this.output = os;
|
||||
// write magic string "d1 ff d1 ff 04"
|
||||
output.writeByte(0xd1);
|
||||
output.writeByte(0xff);
|
||||
output.writeByte(0xd1);
|
||||
output.writeByte(0xff);
|
||||
output.writeByte(0x04);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new GDiffWriter.
|
||||
*/
|
||||
public GDiffWriter(OutputStream output) throws IOException {
|
||||
this(new DataOutputStream(output));
|
||||
}
|
||||
|
||||
public void addCopy(long offset, int length) throws IOException {
|
||||
writeBuf();
|
||||
|
||||
//output debug data
|
||||
if (debug)
|
||||
System.err.println("COPY off: " + offset + ", len: " + length);
|
||||
|
||||
// output real data
|
||||
if (offset > Integer.MAX_VALUE) {
|
||||
// Actually, we don't support longer files than int.MAX_VALUE at the moment..
|
||||
output.writeByte(COPY_LONG_INT);
|
||||
output.writeLong(offset);
|
||||
output.writeInt(length);
|
||||
} else if (offset < 65536) {
|
||||
if (length < 256) {
|
||||
output.writeByte(COPY_USHORT_UBYTE);
|
||||
output.writeShort((int)offset);
|
||||
output.writeByte(length);
|
||||
} else if (length > 65535) {
|
||||
output.writeByte(COPY_USHORT_INT);
|
||||
output.writeShort((int)offset);
|
||||
output.writeInt(length);
|
||||
} else {
|
||||
output.writeByte(COPY_USHORT_USHORT);
|
||||
output.writeShort((int)offset);
|
||||
output.writeShort(length);
|
||||
}
|
||||
} else {
|
||||
if (length < 256) {
|
||||
output.writeByte(COPY_INT_UBYTE);
|
||||
output.writeInt((int)offset);
|
||||
output.writeByte(length);
|
||||
} else if (length > 65535) {
|
||||
output.writeByte(COPY_INT_INT);
|
||||
output.writeInt((int)offset);
|
||||
output.writeInt(length);
|
||||
} else {
|
||||
output.writeByte(COPY_INT_USHORT);
|
||||
output.writeInt((int)offset);
|
||||
output.writeShort(length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a data byte.
|
||||
*/
|
||||
public void addData(byte b) throws IOException {
|
||||
buf.write(b);
|
||||
if (buf.size() >= CHUNK_SIZE)
|
||||
writeBuf();
|
||||
}
|
||||
|
||||
private void writeBuf() throws IOException {
|
||||
if (buf.size() > 0) {
|
||||
if (buf.size() <= DATA_MAX) {
|
||||
output.writeByte(buf.size());
|
||||
} else if (buf.size() <= 65535) {
|
||||
output.writeByte(DATA_USHORT);
|
||||
output.writeShort(buf.size());
|
||||
} else {
|
||||
output.writeByte(DATA_INT);
|
||||
output.writeInt(buf.size());
|
||||
}
|
||||
buf.writeTo(output);
|
||||
buf.reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes accumulated data bytes, if any.
|
||||
*/
|
||||
public void flush() throws IOException
|
||||
{
|
||||
writeBuf();
|
||||
output.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the final EOF byte, closes the underlying stream.
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
this.flush();
|
||||
output.write((byte)EOF);
|
||||
output.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* PatchException.java
|
||||
*
|
||||
* Created on June 6, 2006, 9:34 PM
|
||||
* Copyright (c) 2006 Heiko Klein
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.repackage.com.nothome.delta;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Thrown when a patch is invalid.
|
||||
*/
|
||||
public class PatchException extends IOException {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>PatchException</code> without detail message.
|
||||
*/
|
||||
public PatchException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>PatchException</code> with the specified detail message.
|
||||
* @param msg the detail message.
|
||||
*/
|
||||
public PatchException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 196 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user