From 207eaef07de2d5fa4a22063818f139945100648b Mon Sep 17 00:00:00 2001 From: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Date: Sun, 10 Aug 2025 15:24:25 +0200 Subject: [PATCH] Fix ASMUtil with multiple class loaders (#165) --- .../java/com/gtnewhorizon/gtnhlib/asm/ASMUtil.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gtnewhorizon/gtnhlib/asm/ASMUtil.java b/src/main/java/com/gtnewhorizon/gtnhlib/asm/ASMUtil.java index a0dde177..4f78bd11 100644 --- a/src/main/java/com/gtnewhorizon/gtnhlib/asm/ASMUtil.java +++ b/src/main/java/com/gtnewhorizon/gtnhlib/asm/ASMUtil.java @@ -23,7 +23,9 @@ public class ASMUtil { private static File outputDir = null; private static void emptyClassOutputFolder() { - outputDir = new File(Launch.minecraftHome, "ASM_GTNH"); + outputDir = new File( + Launch.minecraftHome, + "ASM_GTNH" + File.separatorChar + stripClassName(ASMUtil.class.getClassLoader().getClass().getName())); try { FileUtils.deleteDirectory(outputDir); } catch (IOException ignored) {} @@ -79,7 +81,7 @@ public class ASMUtil { } } - private static String stripClassName(String classname) { + public static String stripClassName(String classname) { final String[] split = classname.split("\\."); return split[split.length - 1]; } @@ -147,6 +149,8 @@ public class ASMUtil { if (outputDir == null) { emptyClassOutputFolder(); } + // Replace $->. because otherwise the files are invisible in IntelliJ + fileName = fileName.replace('$', '.'); final File classFile = new File(outputDir, fileName + ".class"); final File outDir = classFile.getParentFile(); if (!outDir.exists()) { @@ -201,6 +205,8 @@ public class ASMUtil { if (outputDir == null) { emptyClassOutputFolder(); } + // Replace $->. because otherwise the files are invisible in IntelliJ + fileName = fileName.replace('$', '.'); final File bytecodeFile = new File(outputDir, fileName + "_BYTECODE.txt"); final File outDir = bytecodeFile.getParentFile(); if (!outDir.exists()) { @@ -256,6 +262,8 @@ public class ASMUtil { if (outputDir == null) { emptyClassOutputFolder(); } + // Replace $->. because otherwise the files are invisible in IntelliJ + fileName = fileName.replace('$', '.'); final File asmifiedFile = new File(outputDir, fileName + "_ASM.txt"); final File outDir = asmifiedFile.getParentFile(); if (!outDir.exists()) {