Skip to content

Commit

Permalink
Fix renderbug (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
conker-rsc authored Dec 24, 2023
1 parent 9cd1d32 commit b8cf8dd
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/Client/JClassPatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -5072,6 +5072,53 @@ private void patchRendererHelper(ClassNode node) {
while (methodNodeList.hasNext()) {
MethodNode methodNode = methodNodeList.next();

// Renderbug fix
if (methodNode.name.equals("b") && methodNode.desc.equals("(IZ)V")) {
LabelNode skipLabel = new LabelNode();

AbstractInsnNode start = methodNode.instructions.getFirst();
while (start != null) {
if (start.getOpcode() == Opcodes.GETFIELD
&& ((FieldInsnNode) start).owner.equals("lb")
&& ((FieldInsnNode) start).name.equals("D")) {
AbstractInsnNode insnNode = start.getPrevious();

methodNode.instructions.insertBefore(
insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "k", "e", "J"));
methodNode.instructions.insertBefore(insnNode, new LdcInsnNode(1072741824L));
methodNode.instructions.insertBefore(insnNode, new InsnNode(Opcodes.LCMP));
methodNode.instructions.insertBefore(
insnNode, new JumpInsnNode(Opcodes.IFLE, skipLabel));
methodNode.instructions.insertBefore(insnNode, new InsnNode(Opcodes.LCONST_0));
methodNode.instructions.insertBefore(
insnNode, new FieldInsnNode(Opcodes.PUTSTATIC, "k", "e", "J"));
methodNode.instructions.insertBefore(insnNode, new VarInsnNode(Opcodes.ALOAD, 0));
methodNode.instructions.insertBefore(
insnNode, new FieldInsnNode(Opcodes.GETSTATIC, "jb", "o", "I"));
methodNode.instructions.insertBefore(
insnNode, new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_LONG));
methodNode.instructions.insertBefore(
insnNode, new FieldInsnNode(Opcodes.PUTFIELD, "lb", "D", "[J"));

methodNode.instructions.insertBefore(insnNode, new LdcInsnNode("RENDERBUG SQUASHED"));
methodNode.instructions.insertBefore(
insnNode,
new MethodInsnNode(
Opcodes.INVOKESTATIC,
"Client/Logger",
"Debug",
"(Ljava/lang/String;)V",
false));

methodNode.instructions.insertBefore(insnNode, skipLabel);

break;
}

start = start.getNext();
}
}

if (methodNode.name.equals("c") && methodNode.desc.equals("(I)V")) {
// Throwable crash patch - a condition of indexoutbounds was reported on this method
Iterator<AbstractInsnNode> insnNodeList = methodNode.instructions.iterator();
Expand Down

0 comments on commit b8cf8dd

Please sign in to comment.