Mission 1: Stage 1: Decompile Minecraft - mverteuil/alminac GitHub Wiki

2015/03/28

Trying to decompile the versions I have unsuccessfully:

1.8.3

$ ./decompile.sh                                                                                                                                                                          
== MCP 9.10 (data: 9.10, client: 1.8.3, server: 1.8.3) ==
# found ff, ff patches, srgs, name csvs, doc csvs, param csvs, astyle, astyle config, scalac, rg, ss
!! Modified jar detected. Unpredictable results !!
== Decompiling client using fernflower ==
> Creating SRGs
> Applying SpecialSource
'"java" -cp "runtime/bin/specialsource.jar:jars/versions/1.8.3/1.8.3.jar:lib:lib/*:lib:lib/*:jars/bin/minecraft.jar:jars/bin/jinput.jar:jars/bin/lwjgl.jar:jars/bin/lwjgl_util.jar:jars/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar:jars/libraries/org/lwjgl/lwjgl/lwjgl-platform/2.9.2-nightly-20140822/lwjgl-platform-2.9.2-nightly-20140822-natives-osx.jar:jars/libraries/com/ibm/icu/icu4j-core-mojang/51.2/icu4j-core-mojang-51.2.jar:jars/libraries/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar:jars/libraries/org/apache/logging/log4j/log4j-api/2.0-beta9/log4j-api-2.0-beta9.jar:jars/libraries/org/apache/commons/commons-lang3/3.3.2/commons-lang3-3.3.2.jar:jars/libraries/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar:jars/libraries/net/java/dev/jna/jna/3.4.0/jna-3.4.0.jar:jars/libraries/com/paulscode/libraryjavasound/20101123/libraryjavasound-20101123.jar:jars/libraries/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar:jars/libraries/com/google/guava/guava/17.0/guava-17.0.jar:jars/libraries/oshi-project/oshi-core/1.1/oshi-core-1.1.jar:jars/libraries/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:jars/libraries/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar:jars/libraries/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar:jars/libraries/com/paulscode/codecjorbis/20101023/codecjorbis-20101023.jar:jars/libraries/com/paulscode/soundsystem/20120107/soundsystem-20120107.jar:jars/libraries/com/paulscode/librarylwjglopenal/20100824/librarylwjglopenal-20100824.jar:jars/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.2-nightly-20140822/lwjgl_util-2.9.2-nightly-20140822.jar:jars/libraries/commons-codec/commons-codec/1.9/commons-codec-1.9.jar:jars/libraries/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar:jars/libraries/org/lwjgl/lwjgl/lwjgl/2.9.2-nightly-20140822/lwjgl-2.9.2-nightly-20140822.jar:jars/libraries/commons-io/commons-io/2.4/commons-io-2.4.jar:jars/libraries/com/mojang/realms/1.7.13/realms-1.7.13.jar:jars/libraries/com/mojang/authlib/1.5.17/authlib-1.5.17.jar:jars/libraries/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar:jars/libraries/tv/twitch/twitch/6.5/twitch-6.5.jar:jars/libraries/com/paulscode/codecwav/20101023/codecwav-20101023.jar:jars/libraries/tv/twitch/twitch-platform/6.5/twitch-platform-6.5-natives-osx.jar:jars/libraries/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-osx.jar:jars/libraries/org/apache/logging/log4j/log4j-core/2.0-beta9/log4j-core-2.0-beta9.jar:jars/libraries/io/netty/netty-all/4.0.23.Final/netty-all-4.0.23.Final.jar" -jar runtime/bin/specialsource.jar -i jars/versions/1.8.3/1.8.3.jar -o temp/minecraft_rg.jar -m temp/client_rg.srg --kill-source --kill-lvt --kill-generics' failed : 1

== ERRORS FOUND ==

Loading mappings
7 packages, 2532 classes, 8788 fields, 16210 methods
Remapping final jar
Exception in thread "main" java.util.zip.ZipException: duplicate entry: net/minecraft/block/state/BlockState$1.class
	at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:215)
	at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
	at net.md_5.specialsource.JarRemapper.remapJar(JarRemapper.java:214)
	at net.md_5.specialsource.SpecialSource.main(SpecialSource.java:259)
==================

Decompile failed

1.8.2

== MCP 9.10 (data: 9.10, client: 1.8.2, server: 1.8.2) ==
# found ff, ff patches, srgs, name csvs, doc csvs, param csvs, astyle, astyle config, scalac, rg, ss
Looking in /Users/mverteuil/Library/Application Support/minecraft/versions for mc installs... OK
Copying assets... OK
Parsing JSON file... OK
Looking for minecraft main jar... OK
> Checking libraries...
	Copying library realms... Error copying library com.mojang:realms:1.7.9

1.8.1

 ❯ ./decompile.sh                                                                                                                                                                          [7:47:59 pm]
== MCP 9.10 (data: 9.10, client: 1.8.1, server: 1.8.1) ==
# found ff, ff patches, srgs, name csvs, doc csvs, param csvs, astyle, astyle config, scalac, rg, ss
Looking in /Users/mverteuil/Library/Application Support/minecraft/versions for mc installs... OK
Copying assets... OK
Parsing JSON file... OK
Looking for minecraft main jar... OK
> Checking libraries...
	Copying library realms... Error copying library com.mojang:realms:1.7.8

1.8.1 w/o com.mojang:realms:1.7.8

I read somewhere that I just needed to remove the line that mentions the realms jar file in the 1.8.1.json catalog. Also Searge says on Twitter that 1.8.2/3 are 'just bug fix releases' or something to that effect. This seems promising, but fails nonetheless:

$ ./decompile.sh                                                                                                                                                                          
== MCP 9.10 (data: 9.10, client: 1.8.1, server: 1.8.1) ==
# found ff, ff patches, srgs, name csvs, doc csvs, param csvs, astyle, astyle config, scalac, rg, ss
Looking in /Users/mverteuil/Library/Application Support/minecraft/versions for mc installs... OK
Copying assets... OK
Parsing JSON file... OK
Looking for minecraft main jar... OK
> Checking libraries...
> Checking Natives...
!! Modified jar detected. Unpredictable results !!
== Decompiling client using fernflower ==
> Creating SRGs
> Applying SpecialSource
> Applying MCInjector
> Creating renamed srg
> Filtering classes
> Decompiling
> Unpacking jar
FATAL ERROR
Traceback (most recent call last):
  File "runtime/decompile.py", line 136, in decompile
    keep_lvt=keep_lvt, keep_generics=keep_generics, force_rg=force_rg)
  File "/Users/mverteuil/Documents/Codebase/alminac/parts/mcp910/runtime/mcp.py", line 43, in decompile_side
    commands.applyff(side)
  File "/Users/mverteuil/Documents/Codebase/alminac/parts/mcp910/runtime/commands.py", line 1335, in applyff
    with closing(zipfile.ZipFile(jarout)) as zipjar:
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 756, in __init__
    self.fp = open(file, modeDict[mode])
IOError: [Errno 2] No such file or directory: 'temp/src/minecraft/minecraft_ff_in.jar'

2015/03/29

I've tracked down 1.8.json and 1.8.jar from a friend, and am attempting to decompile with these now. This is the version it is designed to work with, so I imagine this should work.

1.8

Wrong. Now investigating...

== MCP 9.10 (data: 9.10, client: 1.8, server: 1.8) ==
# found ff, ff patches, srgs, name csvs, doc csvs, param csvs, astyle, astyle config, scalac, rg, ss
Looking in /Users/mverteuil/Library/Application Support/minecraft/versions for mc installs... OK
Copying assets... OK
Parsing JSON file... OK
Looking for minecraft main jar... Not found
Copying minecraft main jar... OK
> Checking libraries...
	Copying library trove4j... Error copying library net.sf.trove4j:trove4j:3.0.3

1.8 ... attempts #2, #3, #4, #5

I suspected that it could be like the realms issue from before, so I tried several more attempts. Each time, I removed another offending record. At the time of writing, fingers crossed, I've been sitting at > Decompiling for an encouraging length of time.

The items removed were:

  • net.sf.trove4j:trove4j:3.0.3
  • java3d:vecmath:1.5.2
  • io.netty:netty-all:4.0.15.Final

An offensively long failure follows:

== MCP 9.10 (data: 9.10, client: 1.8, server: 1.8) ==
# found ff, ff patches, srgs, name csvs, doc csvs, param csvs, astyle, astyle config, scalac, rg, ss
Looking in /Users/mverteuil/Library/Application Support/minecraft/versions for mc installs... OK
Copying assets... OK
Parsing JSON file... OK
Looking for minecraft main jar... OK
> Checking libraries...
> Checking Natives...
	Extracting native libtwitchsdk.dylib... OK
	Extracting native liblwjgl.dylib... OK
	Extracting native libjinput-osx.jnilib... OK
	Extracting native openal.dylib... OK
== Decompiling client using fernflower ==
> Creating SRGs
> Applying SpecialSource
> Applying MCInjector
> Creating renamed srg
> Filtering classes
> Decompiling
> Unpacking jar
> Copying sources
> Applying fernflower fixes
> Applying patches
> Cleaning comments
- Done in 188.30 seconds
== Reformating client ==
> Cleaning sources
> Replacing OpenGL constants
> Reformating sources
- Done in 13.37 seconds
== Updating client ==
> Adding javadoc
> Renaming sources
- Done in 4.68 seconds
!! Missing server jar file. Aborting !!
== Recompiling client ==
> Cleaning bin
> Recompiling
'"javac" -Xlint:-options -deprecation -g -source 1.6 -target 1.6 -classpath ...

== ERRORS FOUND in JAVA CODE ==

src/minecraft/net/minecraft/entity/player/EntityPlayerMP.java:6: error: package io.netty.buffer does not exist
import io.netty.buffer.Unpooled;
                      ^
...

100 errors
==================

Initial client recompile failed, correct source then run updatemd5
>>> elapsed time 4m15s

Well, that seems obvious, because I've removed io.netty...whatever from the json catalog in order to make this run. So, perhaps the next step is to try and locate these classes, and then bust open the jar file and hope that placing them alongside the extracted jar is acceptable to the decompiler.

Perhaps I've done something stupid or missed an instruction somewhere.

1.8 attempt #6

Aha! I looked into the minecraft client settings and realized that they aren't actually trying to prevent you from using older versions. I was able to select 'Use client version 1.8' and on launch it downloaded the jars that the decompiler had complained about.

Again, a promising amount of time has elapsed...

Success!

 ❯ ./decompile.sh                                                                                                                                                                          [8:30:36 pm]
== MCP 9.10 (data: 9.10, client: 1.8, server: 1.8) ==
# found ff, ff patches, srgs, name csvs, doc csvs, param csvs, astyle, astyle config, scalac, rg, ss
== Decompiling client using fernflower ==
> Creating SRGs
> Applying SpecialSource
> Applying MCInjector
> Creating renamed srg
> Filtering classes
> Decompiling
> Unpacking jar
> Copying sources
> Applying fernflower fixes
> Applying patches
> Cleaning comments
- Done in 185.35 seconds
== Reformating client ==
> Cleaning sources
> Replacing OpenGL constants
> Reformating sources
- Done in 11.19 seconds
== Updating client ==
> Adding javadoc
> Renaming sources
- Done in 4.24 seconds
!! Missing server jar file. Aborting !!
== Recompiling client ==
> Cleaning bin
> Recompiling
- Done in 53.76 seconds
> Generating client md5s
>>> elapsed time 4m18s
 ❯ ./reformat.sh                                                                                                                                                                           [8:49:43 pm]
== MCP 9.10 (data: 9.10, client: 1.8, server: 1.8) ==
# found ff, ff patches, srgs, name csvs, doc csvs, param csvs, astyle, astyle config, scalac, rg, ss
== Reformating client ==
> Cleaning sources
> Replacing OpenGL constants
> Reformating sources
- Done in 15.68 seconds
>>> elapsed time 19s