Skip to content

Commit

Permalink
SideTransformer logging improve
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Dec 20, 2024
1 parent 53dc8c0 commit 604ce23
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
Expand All @@ -42,7 +41,7 @@

public class SideTransformer implements IClassTransformer
{
private static String SIDE = FMLLaunchHandler.side().name();
private static final String SIDE = FMLLaunchHandler.side().name();
private static final boolean DEBUG = false;
@Override
public byte[] transform(String name, String transformedName, byte[] bytes)
Expand All @@ -57,9 +56,9 @@ public byte[] transform(String name, String transformedName, byte[] bytes)
{
if (DEBUG)
{
System.out.println(String.format("Attempted to load class %s for invalid side %s", classNode.name, SIDE));
System.out.printf("Attempted to load class %s/%s for invalid side %s%n", name, transformedName, SIDE);
}
throw new RuntimeException(String.format("Attempted to load class %s for invalid side %s", classNode.name, SIDE));
throw new RuntimeException(String.format("Attempted to load class %s/%s for invalid side %s", name, transformedName, SIDE));
}

Iterator<FieldNode> fields = classNode.fields.iterator();
Expand All @@ -70,7 +69,7 @@ public byte[] transform(String name, String transformedName, byte[] bytes)
{
if (DEBUG)
{
System.out.println(String.format("Removing Field: %s.%s", classNode.name, field.name));
System.out.printf("Removing Field: %s.%s%n", classNode.name, field.name);
}
fields.remove();
}
Expand All @@ -85,7 +84,7 @@ public byte[] transform(String name, String transformedName, byte[] bytes)
{
if (DEBUG)
{
System.out.println(String.format("Removing Method: %s.%s%s", classNode.name, method.name, method.desc));
System.out.printf("Removing Method: %s.%s%s%n", classNode.name, method.name, method.desc);
}
methods.remove();
lambdaGatherer.accept(method);
Expand Down Expand Up @@ -166,12 +165,8 @@ public LambdaGatherer() {
}

public void accept(MethodNode method) {
ListIterator<AbstractInsnNode> insnNodeIterator = method.instructions.iterator();
while (insnNodeIterator.hasNext())
{
AbstractInsnNode insnNode = insnNodeIterator.next();
if (insnNode.getType() == AbstractInsnNode.INVOKE_DYNAMIC_INSN)
{
for (AbstractInsnNode insnNode : method.instructions) {
if (insnNode.getType() == AbstractInsnNode.INVOKE_DYNAMIC_INSN) {
insnNode.accept(this);
}
}
Expand Down

0 comments on commit 604ce23

Please sign in to comment.