Skip to content

Commit

Permalink
Patch yet another broken hook in smoothfont
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Apr 3, 2024
1 parent 751c012 commit 7c54bb5
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ public byte[] transform(byte[] bytes) {
}
}
});

classNode.methods.stream().filter(methodNode -> methodNode.name.equals("func_78263_a")).findFirst().ifPresent(m4 ->
m4.instructions.forEach(n -> {
if (n.getOpcode() == Opcodes.INVOKEVIRTUAL && n instanceof MethodInsnNode methodInsnNode) {
if (methodInsnNode.owner.equals("java/lang/String") && methodInsnNode.name.equals("indexOf")) {
m4.instructions.insert(methodInsnNode, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "bre/smoothfont/FontRendererHook", "getCharWidthFloatGetCharIndexHook", "(C)I", false));
m4.instructions.remove(methodInsnNode);
}
}
}));
ClassWriter classWriter = new ClassWriter(0);

classNode.accept(classWriter);
Expand Down

0 comments on commit 7c54bb5

Please sign in to comment.