Skip to content

Commit

Permalink
Add config options to modify vulnerable potion modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Meldexun committed Mar 8, 2023
1 parent a046785 commit 8ff0c1f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ public void patch(ClassNode clazzNode) {
}
});

add(new Patch(this, "com.tmtravlr.potioncore.potion.PotionVulnerable",
ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES) {
@Override
public void patch(ClassNode clazzNode) {
MethodNode m_registerPotionAttributeModifiers = this.findMethodWithDesc(clazzNode, "()V",
"registerPotionAttributeModifiers");

MethodInsnNode i_registerPotionAttributeModifier = ASMUtil.findMethodInsn(
m_registerPotionAttributeModifiers, Opcodes.INVOKEVIRTUAL,
"com/tmtravlr/potioncore/potion/PotionVulnerable", "func_111184_a",
"registerPotionAttributeModifier",
"(Lnet/minecraft/entity/ai/attributes/IAttribute;Ljava/lang/String;DI)Lnet/minecraft/potion/Potion;",
0);
MethodInsnNode redirect = new MethodInsnNode(Opcodes.INVOKESTATIC,
"com/charles445/rltweaker/hook/HookPotionCore", "vulnerable_registerPotionAttributeModifier",
"(Lnet/minecraft/potion/Potion;Lnet/minecraft/entity/ai/attributes/IAttribute;Ljava/lang/String;DI)Lnet/minecraft/potion/Potion;",
false);
m_registerPotionAttributeModifiers.instructions.set(i_registerPotionAttributeModifier, redirect);
}
});

add(new Patch(this, "com.tmtravlr.potioncore.PotionCoreEventHandler",
ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,20 @@ public class ConfigPotionCore
@RLConfig.RLCraftTwoNine("2")
public int resistanceOperation = 2;

@RequiresMcRestart
@Config.Comment("Requires patchPotionCoreResistance patch! Amount of the vulnerable potion attribute modifier.")
@Config.Name("Resistance Potion Modifier Amount")
@RLConfig.ImprovementsOnly("-0.5")
@RLConfig.RLCraftTwoEightTwo("-0.5")
@RLConfig.RLCraftTwoNine("-0.5")
public double vulnerableAmount = -0.5D;

@RequiresMcRestart
@Config.Comment("Requires patchPotionCoreResistance patch! Operation of the vulnerable potion attribute modifier.")
@Config.Name("Resistance Potion Modifier Operation")
@RLConfig.ImprovementsOnly("2")
@RLConfig.RLCraftTwoEightTwo("2")
@RLConfig.RLCraftTwoNine("2")
public int vulnerableOperation = 2;

}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ public static Potion resistance_registerPotionAttributeModifier(Potion potion, I
ModConfig.server.potioncore.resistanceOperation);
}

public static Potion vulnerable_registerPotionAttributeModifier(Potion potion, IAttribute attribute,
String uniqueId, double ammount, int operation) {
// override registration of attribute modifier
return potion.registerPotionAttributeModifier(attribute, uniqueId, ModConfig.server.potioncore.vulnerableAmount,
ModConfig.server.potioncore.vulnerableOperation);
}

public static double getAdjustedDamageResistanceAttribute(EntityLivingBase entity) {
// skip potion core damage resistance handler
return 0.0D;
Expand Down

0 comments on commit 8ff0c1f

Please sign in to comment.