Skip to content

Commit

Permalink
Fix compatibility with ResourceLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
albus12138 committed Jan 31, 2021
1 parent 527d103 commit 9c8358e
Showing 1 changed file with 0 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
Expand All @@ -27,8 +26,6 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
return transformMinecraft(basicClass);
if (name.equals("com.mumfrey.liteloader.client.api.ObjectFactoryClient"))
return transformObjectFactoryClient(basicClass);
if (name.equals("lumien.resourceloader.ResourceLoader"))
return transformResourceLoader(basicClass);
}
catch (Throwable t) {
System.out.println("An issue occoured while transforming " + transformedName);
Expand Down Expand Up @@ -119,27 +116,4 @@ private byte[] transformMinecraft(byte[] before) {
System.out.println("Transformed Minecraft");
return cw.toByteArray();
}

private byte[] transformResourceLoader(byte[] before) {
ClassNode classNode = new ClassNode();
ClassReader reader = new ClassReader(before);
reader.accept(classNode, 0);

for (MethodNode m : classNode.methods) {
if (m.name.equals("preInit")) {
m.visibleAnnotations.remove(0);// Remove @Mod.EventHandler
}
}

for (FieldNode f : classNode.fields) {
if (f.name.equals("INSTANCE"))
f.visibleAnnotations.remove(0);// Remove @Mod.Instance("ResourceLoader")
}

ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(cw);
byte[] arr = cw.toByteArray();
System.out.println("Transformed ResourceLoader!");
return arr;
}
}

0 comments on commit 9c8358e

Please sign in to comment.