Skip to content

Commit

Permalink
Make visitor an inner class
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Dec 10, 2024
1 parent 9ec10cd commit b3f80d4
Showing 1 changed file with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,37 @@ public void exec() throws IOException {
new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(classList),
StandardCharsets.UTF_8);
}
}

class Visitor extends ClassVisitor {
final Set<String> matchedClasses = new TreeSet<>();
String currentClass = null;

protected Visitor() {
super(Opcodes.ASM9);
}
static class Visitor extends ClassVisitor {
final Set<String> matchedClasses = new TreeSet<>();
String currentClass = null;

@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
currentClass = name;
}
protected Visitor() {
super(Opcodes.ASM9);
}

@Override
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
// Ignore this class as we special case it
if (currentClass.equals("net/minecraft/world/level/BaseSpawner")) {
return null;
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
currentClass = name;
}

return new MethodVisitor(api) {
@Override
public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) {
if (opcode == Opcodes.INVOKEVIRTUAL
&& name.equals("finalizeSpawn")
&& descriptor.equals("(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;")) {
matchedClasses.add(currentClass);
}
@Override
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
// Ignore this class as we special case it
if (currentClass.equals("net/minecraft/world/level/BaseSpawner")) {
return null;
}
};

return new MethodVisitor(api) {
@Override
public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) {
if (opcode == Opcodes.INVOKEVIRTUAL
&& name.equals("finalizeSpawn")
&& descriptor.equals("(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;")) {
matchedClasses.add(currentClass);
}
}
};
}
}
}

0 comments on commit b3f80d4

Please sign in to comment.