Skip to content

Commit 78199b9

Browse files
committed
RDI update
1 parent 6654e61 commit 78199b9

6 files changed

Lines changed: 40 additions & 13 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
asm_version=9.4
22
fernflower_version=27416e1ed8b6955a64c78bfc21351db5b2412edc
3-
rdi_version=669ba3a
3+
rdi_version=c4d6594
44
jansi_version=2.4.0
55
json_version=20220924
66
diffpatch_version=c639936cdbed7e28c7833316161dcb7fae80d0b6

src/main/java/org/mcphackers/mcp/tasks/TaskDecompile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public ClassStorage applyInjector() throws IOException {
176176
}
177177
}
178178
injector.addTransform(storage -> Transform.decomposeVars(storage));
179+
injector.addTransform(storage -> Transform.fixTryCatchRange(storage));
179180
injector.addTransform(storage -> Transform.replaceCommonConstants(storage));
180181
if(hasLWJGL) injector.addVisitor(new GLConstants(null));
181182
injector.restoreSourceFile();

src/main/java/org/mcphackers/mcp/tasks/TaskRecompile.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ protected Stage[] setStages() {
5757
if (!Files.exists(srcPath)) {
5858
throw new IOException(side.getName() + " sources not found!");
5959
}
60-
if(Files.list(srcPath).collect(Collectors.toList()).isEmpty()) {
61-
return;
60+
try(Stream<Path> paths = Files.list(srcPath)) {
61+
if(paths.collect(Collectors.toList()).isEmpty()) {
62+
return;
63+
}
6264
}
6365

6466
final List<File> src = collectSource();

src/main/java/org/mcphackers/mcp/tasks/TaskRun.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public TaskRun(Side side, MCP instance) {
3232
@Override
3333
public void doTask() throws Exception {
3434
Version currentVersion = mcp.getCurrentVersion();
35-
Side runSide = mcp.getOptions().side;
36-
if(runSide == Side.ANY) {
37-
runSide = side;
35+
Side mcpSide = mcp.getOptions().side;
36+
if(mcpSide == Side.ANY) {
37+
mcpSide = side;
3838
}
3939

4040
String main = getMain(mcp, currentVersion, side);
@@ -45,7 +45,7 @@ public void doTask() throws Exception {
4545

4646
boolean runBuild = mcp.getOptions().getBooleanParameter(TaskParameter.RUN_BUILD);
4747
String[] runArgs = mcp.getOptions().getStringArrayParameter(TaskParameter.RUN_ARGS);
48-
List<Path> cpList = getClasspath(mcp, currentVersion, runSide, runBuild);
48+
List<Path> cpList = getClasspath(mcp, currentVersion, mcpSide, side, runBuild);
4949

5050
List<String> classPath = new ArrayList<>();
5151
cpList.forEach(p -> classPath.add(p.toAbsolutePath().toString()));
@@ -170,7 +170,7 @@ public static Path getOriginalMCDir() {
170170
}
171171
}
172172

173-
private static List<Path> getClasspath(MCP mcp, Version version, Side side, boolean runBuild) {
173+
private static List<Path> getClasspath(MCP mcp, Version version, Side side, Side runSide, boolean runBuild) {
174174
List<Path> cpList = new ArrayList<>();
175175
if(runBuild) {
176176
cpList.add(MCPPaths.get(mcp, BUILD_ZIP, side));
@@ -182,11 +182,9 @@ private static List<Path> getClasspath(MCP mcp, Version version, Side side, bool
182182
cpList.add(MCPPaths.get(mcp, REMAPPED, side));
183183
}
184184
else {
185-
cpList.add(MCPPaths.get(mcp, JAR_ORIGINAL, side));
186-
}
187-
if(side == Side.CLIENT || side == Side.MERGED) {
188-
cpList.addAll(mcp.getLibraries());
185+
cpList.add(MCPPaths.get(mcp, JAR_ORIGINAL, runSide));
189186
}
187+
cpList.addAll(mcp.getLibraries());
190188
return cpList;
191189
}
192190
}

src/main/java/org/mcphackers/mcp/tasks/mode/TaskParameter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public enum TaskParameter {
1818
OBFUSCATION("obf", Boolean.class, false),
1919
FULL_BUILD("fullbuild", Boolean.class, false),
2020
RUN_BUILD("runbuild", Boolean.class, false),
21-
RUN_ARGS("runargs", String[].class, new String[] {"-Xms1024M", "-Xmx1024M", "-Djava.util.Arrays.useLegacyMergeSort=true"}),
21+
RUN_ARGS("runargs", String[].class, new String[] {"-Xms1024M", "-Xmx1024M"}),
2222
SETUP_VERSION("setup", String.class, null),
2323
SOURCE_VERSION("source", Integer.class, -1),
2424
TARGET_VERSION("target", Integer.class, -1),
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.mcphackers.mcp.tools.injector;
2+
3+
import org.mcphackers.rdi.injector.data.ClassStorage;
4+
import org.objectweb.asm.Opcodes;
5+
import org.objectweb.asm.tree.AbstractInsnNode;
6+
import org.objectweb.asm.tree.ClassNode;
7+
import org.objectweb.asm.tree.MethodNode;
8+
import org.objectweb.asm.tree.TryCatchBlockNode;
9+
10+
public class TransformUtil {
11+
12+
public static final void fixTryCatchRange(ClassStorage storage) {
13+
for(ClassNode node : storage) {
14+
for(MethodNode m : node.methods) {
15+
for(TryCatchBlockNode tryCatch : m.tryCatchBlocks) {
16+
AbstractInsnNode endNode = tryCatch.handler.getPrevious();
17+
if(endNode.getOpcode() == Opcodes.RETURN || endNode.getOpcode() == Opcodes.GOTO) {
18+
if(endNode.getPrevious() != tryCatch.end) {
19+
System.out.println("Found a bad try catch in " + m.name + m.desc + " at index " + m.tryCatchBlocks.indexOf(tryCatch));
20+
}
21+
}
22+
}
23+
}
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)