Skip to content

Commit

Permalink
Fix for OptiFine G8
Browse files Browse the repository at this point in the history
  • Loading branch information
fr1kin committed May 18, 2021
1 parent f69482a commit 0392274
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ public void compileOptiFine(MethodNode node,
// jump to skip rendering in this layer
LabelNode defaultLayerCheck = new LabelNode();

int blockstateId = ASMHelper.getLocalVariable(node, "blockstate", null)
.map(lv -> lv.index)
.orElseThrow(() -> new Error("Could not find index for \"blockstate\" local variable"));
int rendertypeId = ASMHelper.getLocalVariable(node, "rendertype1", null)
.map(lv -> lv.index)
.orElseThrow(() -> new Error("Could not find index for \"rendertype1\" local variable"));

// aloads for canRenderInLayer call

InsnList pre = new InsnList();
Expand All @@ -106,8 +113,8 @@ public void compileOptiFine(MethodNode node,
// if we are not then jump over this code
pre.add(new JumpInsnNode(IFEQ, defaultLayerCheck));
// call override method
pre.add(new VarInsnNode(ALOAD, 18));
pre.add(new VarInsnNode(ALOAD, 24));
pre.add(new VarInsnNode(ALOAD, blockstateId));
pre.add(new VarInsnNode(ALOAD, rendertypeId));
pre.add(ASMHelper.call(INVOKESTATIC, canRenderInLayerOverride));
// goto return
pre.add(new JumpInsnNode(IFNE, jumpToRenderLayer.label));
Expand Down

0 comments on commit 0392274

Please sign in to comment.