使用 MCP 反编译 Minecraft 时分配更多 RAM(Mod Coder Pack)

Allocating more RAM while decompiling Minecraft with MCP (Mod Coder Pack)

我正在尝试创建自定义 Minecraft 客户端,但首先我需要使用 MCP 反编译源文件,但它失败了。它失败并显示 JavaOutOfMemoryError。这是错误:

18:31:41 - Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
18:31:41 -  at java.util.Arrays.copyOfRange(Arrays.java:3664)
18:31:41 -  at java.lang.String.<init>(String.java:207)
18:31:41 -  at java.io.DataInputStream.readUTF(DataInputStream.java:661)
18:31:41 -  at java.io.DataInputStream.readUTF(DataInputStream.java:564)
18:31:41 -  at org.jetbrains.java.decompiler.struct.consts.ConstantPool.<init>(ConstantPool.java:54)
18:31:41 -  at org.jetbrains.java.decompiler.struct.StructClass.<init>(StructClass.java:87)
18:31:41 -  at org.jetbrains.java.decompiler.struct.StructClass.<init>(StructClass.java:75)
18:31:41 -  at org.jetbrains.java.decompiler.struct.StructContext.addArchive(StructContext.java:167)
18:31:41 -  at org.jetbrains.java.decompiler.struct.StructContext.addSpace(StructContext.java:100)
18:31:41 -  at org.jetbrains.java.decompiler.struct.StructContext.addSpace(StructContext.java:78)
18:31:41 -  at org.jetbrains.java.decompiler.main.Fernflower.addAllClasspath(Fernflower.java:120)
18:31:41 -  at org.jetbrains.java.decompiler.main.Fernflower.<init>(Fernflower.java:49)
18:31:41 -  at org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.<init>(ConsoleDecompiler.java:126)
18:31:41 -  at org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(ConsoleDecompiler.java:87)
18:31:41 - '"C:\Program Files\Java\jdk1.8.0_261\bin\java" -jar runtime\bin\fernflower.jar -din=1 -rbr=1 -dgs=1 -asc=1 -rsy=1 -iec=1 -jvn=1 -log=WARN "-e=jars\libraries\net/java/jinput\jinput.0.5\jinput-2.0.5.jar" "-e=jars\libraries\org/lwjgl/lwjgl\lwjgl-platform.9.4-nightly-20150209\lwjgl-platform-2.9.4-nightly-20150209-natives-windows.jar" "-e=jars\libraries\com/ibm/icu\icu4j-core-mojang.2\icu4j-core-mojang-51.2.jar" "-e=jars\libraries\tv/twitch\twitch-external-platform.5\twitch-external-platform-4.5-natives-windows-32.jar" "-e=jars\libraries\org/apache/httpcomponents\httpcore.3.2\httpcore-4.3.2.jar" "-e=jars\libraries\org/apache/logging/log4j\log4j-api.0-beta9\log4j-api-2.0-beta9.jar" "-e=jars\libraries\org/apache/commons\commons-lang3.3.2\commons-lang3-3.3.2.jar" "-e=jars\libraries\net/java/dev/jna\jna.4.0\jna-3.4.0.jar" "-e=jars\libraries\com/paulscode\libraryjavasound101123\libraryjavasound-20101123.jar" "-e=jars\libraries\net/sf/jopt-simple\jopt-simple.6\jopt-simple-4.6.jar" "-e=jars\libraries\com/google/guava\guava.0\guava-17.0.jar" "-e=jars\libraries\oshi-project\oshi-core.1\oshi-core-1.1.jar" "-e=jars\libraries\org/apache/httpcomponents\httpclient.3.3\httpclient-4.3.3.jar" "-e=jars\libraries\org/apache/commons\commons-compress.8.1\commons-compress-1.8.1.jar" "-e=jars\libraries\net/java/dev/jna\platform.4.0\platform-3.4.0.jar" "-e=jars\libraries\com/paulscode\codecjorbis101023\codecjorbis-20101023.jar" "-e=jars\libraries\com/paulscode\soundsystem120107\soundsystem-20120107.jar" "-e=jars\libraries\com/paulscode\librarylwjglopenal100824\librarylwjglopenal-20100824.jar" "-e=jars\libraries\org/lwjgl/lwjgl\lwjgl_util.9.4-nightly-20150209\lwjgl_util-2.9.4-nightly-20150209.jar" "-e=jars\libraries\commons-codec\commons-codec.9\commons-codec-1.9.jar" "-e=jars\libraries\net/java/jutils\jutils.0.0\jutils-1.0.0.jar" "-e=jars\libraries\commons-logging\commons-logging.1.3\commons-logging-1.1.3.jar" "-e=jars\libraries\org/lwjgl/lwjgl\lwjgl.9.4-nightly-20150209\lwjgl-2.9.4-nightly-20150209.jar" "-e=jars\libraries\commons-io\commons-io.4\commons-io-2.4.jar" "-e=jars\libraries\com/mojang\realms.7.39\realms-1.7.39.jar" "-e=jars\libraries\com/mojang\authlib.5.21\authlib-1.5.21.jar" "-e=jars\libraries\com/google/code/gson\gson.2.4\gson-2.2.4.jar" "-e=jars\libraries\com/mojang\netty.7.7\netty-1.7.7.jar" "-e=jars\libraries\tv/twitch\twitch.5\twitch-6.5.jar" "-e=jars\libraries\com/paulscode\codecwav101023\codecwav-20101023.jar" "-e=jars\libraries\tv/twitch\twitch-platform.5\twitch-platform-6.5-natives-windows-32.jar" "-e=jars\libraries\net/java/jinput\jinput-platform.0.5\jinput-platform-2.0.5-natives-windows.jar" "-e=jars\libraries\org/apache/logging/log4j\log4j-core.0-beta9\log4j-core-2.0-beta9.jar" "-e=jars\libraries\io/netty\netty-all.0.23.Final\netty-all-4.0.23.Final.jar" temp/minecraft_ff_in.jar temp\src\minecraft' failed : 1
18:31:41 - Decompile failed

我试过 运行 命令:

"C:\Program Files\Java\jdk1.8.0_261\bin\java" -jar runtime\bin\fernflower.jar -din=1 -rbr=1 -dgs=1 -asc=1 -rsy=1 -iec=1 -jvn=1 -log=WARN "-e=jars\libraries\net/java/jinput\jinput.0.5\jinput-2.0.5.jar" "-e=jars\libraries\org/lwjgl/lwjgl\lwjgl-platform.9.4-nightly-20150209\lwjgl-platform-2.9.4-nightly-20150209-natives-windows.jar" "-e=jars\libraries\com/ibm/icu\icu4j-core-mojang.2\icu4j-core-mojang-51.2.jar" "-e=jars\libraries\tv/twitch\twitch-external-platform.5\twitch-external-platform-4.5-natives-windows-32.jar" "-e=jars\libraries\org/apache/httpcomponents\httpcore.3.2\httpcore-4.3.2.jar" "-e=jars\libraries\org/apache/logging/log4j\log4j-api.0-beta9\log4j-api-2.0-beta9.jar" "-e=jars\libraries\org/apache/commons\commons-lang3.3.2\commons-lang3-3.3.2.jar" "-e=jars\libraries\net/java/dev/jna\jna.4.0\jna-3.4.0.jar" "-e=jars\libraries\com/paulscode\libraryjavasound101123\libraryjavasound-20101123.jar" "-e=jars\libraries\net/sf/jopt-simple\jopt-simple.6\jopt-simple-4.6.jar" "-e=jars\libraries\com/google/guava\guava.0\guava-17.0.jar" "-e=jars\libraries\oshi-project\oshi-core.1\oshi-core-1.1.jar" "-e=jars\libraries\org/apache/httpcomponents\httpclient.3.3\httpclient-4.3.3.jar" "-e=jars\libraries\org/apache/commons\commons-compress.8.1\commons-compress-1.8.1.jar" "-e=jars\libraries\net/java/dev/jna\platform.4.0\platform-3.4.0.jar" "-e=jars\libraries\com/paulscode\codecjorbis101023\codecjorbis-20101023.jar" "-e=jars\libraries\com/paulscode\soundsystem120107\soundsystem-20120107.jar" "-e=jars\libraries\com/paulscode\librarylwjglopenal100824\librarylwjglopenal-20100824.jar" "-e=jars\libraries\org/lwjgl/lwjgl\lwjgl_util.9.4-nightly-20150209\lwjgl_util-2.9.4-nightly-20150209.jar" "-e=jars\libraries\commons-codec\commons-codec.9\commons-codec-1.9.jar" "-e=jars\libraries\net/java/jutils\jutils.0.0\jutils-1.0.0.jar" "-e=jars\libraries\commons-logging\commons-logging.1.3\commons-logging-1.1.3.jar" "-e=jars\libraries\org/lwjgl/lwjgl\lwjgl.9.4-nightly-20150209\lwjgl-2.9.4-nightly-20150209.jar" "-e=jars\libraries\commons-io\commons-io.4\commons-io-2.4.jar" "-e=jars\libraries\com/mojang\realms.7.39\realms-1.7.39.jar" "-e=jars\libraries\com/mojang\authlib.5.21\authlib-1.5.21.jar" "-e=jars\libraries\com/google/code/gson\gson.2.4\gson-2.2.4.jar" "-e=jars\libraries\com/mojang\netty.7.7\netty-1.7.7.jar" "-e=jars\libraries\tv/twitch\twitch.5\twitch-6.5.jar" "-e=jars\libraries\com/paulscode\codecwav101023\codecwav-20101023.jar" "-e=jars\libraries\tv/twitch\twitch-platform.5\twitch-platform-6.5-natives-windows-32.jar" "-e=jars\libraries\net/java/jinput\jinput-platform.0.5\jinput-platform-2.0.5-natives-windows.jar" "-e=jars\libraries\org/apache/logging/log4j\log4j-core.0-beta9\log4j-core-2.0-beta9.jar" "-e=jars\libraries\io/netty\netty-all.0.23.Final\netty-all-4.0.23.Final.jar" temp/minecraft_ff_in.jar temp\src\minecraft

但添加了 -Xmx1124m 并且有效。

我不知道如何在 运行 decompile.bat 文件时重现相同的内容,因为该文件只是运行另一个 python 文件。

我正在使用 MCP 9.18 并尝试反编译 Minecraft 1.8.8。我的电脑有 2GB 内存,其中 1.9GB 可用。

转到 conf/mcp.cfg。找到这一行

CmdFernflower = %s -jar %s -din=1 -rbr=0 -dgs=1 -asc=1 -log=WARN {indir} {outdir}

然后改成这个

CmdFernflower = %s -Xmx1.7G -jar %s -din=1 -rbr=0 -dgs=1 -asc=1 -log=WARN {indir} {outdir}

反编译时应该给MCP 1.7gb ram。我真的建议获得更多的 ram,即使是 8gb 也会有很大的帮助