Skip to content

Commit

Permalink
Fix resistance overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
Meldexun committed Mar 3, 2023
1 parent f78c7e3 commit 843e091
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ public void patch(ClassNode clazzNode) {
"(Z)Lnet/minecraft/entity/ai/attributes/BaseAttribute;", 3);
target = target.getPrevious();

m_clinit.instructions.insertBefore(target, ASMUtil.listOf(new MethodInsnNode(Opcodes.INVOKESTATIC,
"com/charles445/rltweaker/hook/HookPotionCore", "resistance_createAttribute",
"(Lnet/minecraft/entity/ai/attributes/RangedAttribute;)Lnet/minecraft/entity/ai/attributes/RangedAttribute;",
false)));
m_clinit.instructions.insertBefore(target, ASMUtil.listOf(
new MethodInsnNode(Opcodes.INVOKESTATIC, "com/charles445/rltweaker/hook/HookPotionCore", "resistance_createAttribute", "(Lnet/minecraft/entity/ai/attributes/RangedAttribute;)Lnet/minecraft/entity/ai/attributes/RangedAttribute;", false)));
}
});

Expand Down Expand Up @@ -118,6 +116,24 @@ public void patch(ClassNode clazzNode) {
new VarInsnNode(Opcodes.FSTORE, 2)));
}
});

add(new Patch(this, "com.tmtravlr.potioncore.PotionCoreEventHandlerClient",
ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES) {
@Override
public void patch(ClassNode clazzNode) {
MethodNode m_renderOverlaysPre = this.findMethodWithDesc(clazzNode,
"(Lnet/minecraftforge/client/event/RenderGameOverlayEvent$Pre;)V", "renderOverlaysPre");

AbstractInsnNode target = ASMUtil.findMethodInsn(m_renderOverlaysPre, Opcodes.INVOKEVIRTUAL,
"net/minecraft/entity/ai/attributes/IAttributeInstance", "func_111126_e", "getAttributeValue",
"()D", 0);
target = target.getNext();
target = target.getNext();

insert(m_renderOverlaysPre, target, ASMUtil.listOf(
new MethodInsnNode(Opcodes.INVOKESTATIC, "com/charles445/rltweaker/hook/HookPotionCore", "getActualResistance", "(D)D", false)));
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,8 @@ public static float postResistancePotionCalculation(EntityLivingBase entity, flo
}
}

public static double getActualResistance(double resistance) {
return ModConfig.server.potioncore.alternativeResistanceMode ? -resistance : resistance;
}

}

0 comments on commit 843e091

Please sign in to comment.