From 33bfb9d928c6a7d57065af741b300b898f6a10a2 Mon Sep 17 00:00:00 2001 From: Boblet Date: Wed, 26 Jan 2022 16:58:24 +0100 Subject: [PATCH] variable protection yield ranges for FSB armor --- src/main/java/com/hbm/items/ModItems.java | 2 + .../java/com/hbm/items/armor/ArmorFSB.java | 64 +++++++++++-------- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index ed0ce8337..4f53e24bf 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -4834,6 +4834,7 @@ public class ModItems { .addEffect(new PotionEffect(Potion.field_76443_y.id, 20, 0)) .addEffect(new PotionEffect(HbmPotion.radx.id, 20, 0)) .setBlastProtection(0.5F) + .setProtectionLevel(500F) //.setGravity(0.02D) .setStep("hbm:step.metal") .setJump("hbm:step.iron_jump") @@ -4875,6 +4876,7 @@ public class ModItems { .setStep("hbm:step.metal") .setJump("hbm:step.iron_jump") .setFall("hbm:step.iron_land") + .setProtectionLevel(1000F) .addResistance("fall", 0F) .addResistance("monoxide", 0F) .setFireproof(true).setUnlocalizedName("fau_helmet").setTextureName(RefStrings.MODID + ":fau_helmet"); diff --git a/src/main/java/com/hbm/items/armor/ArmorFSB.java b/src/main/java/com/hbm/items/armor/ArmorFSB.java index 8c43bfe8f..94a6ba88d 100644 --- a/src/main/java/com/hbm/items/armor/ArmorFSB.java +++ b/src/main/java/com/hbm/items/armor/ArmorFSB.java @@ -51,6 +51,7 @@ public class ArmorFSB extends ItemArmor { public float damageCap = -1; public float damageMod = -1; public float damageThreshold = 0; + public float protectionYield = 100F; public boolean fireproof = false; public boolean noHelmet = false; public boolean vats = false; @@ -93,6 +94,11 @@ public class ArmorFSB extends ItemArmor { return this; } + public ArmorFSB setProtectionLevel(float damageYield) { + this.protectionYield = damageYield; + return this; + } + public ArmorFSB setBlastProtection(float blastProtection) { this.blastProtection = blastProtection; return this; @@ -171,6 +177,7 @@ public class ArmorFSB extends ItemArmor { this.damageCap = original.damageCap; this.damageMod = original.damageMod; this.damageThreshold = original.damageThreshold; + this.protectionYield = original.protectionYield; this.blastProtection = original.blastProtection; this.projectileProtection = original.projectileProtection; this.fireproof = original.fireproof; @@ -217,12 +224,10 @@ public class ArmorFSB extends ItemArmor { } if(blastProtection != -1) { - list.add(EnumChatFormatting.YELLOW + " " + I18nUtil.resolveKey("armor.blastProtection", blastProtection)); } if(projectileProtection != -1) { - list.add(EnumChatFormatting.YELLOW + " " + I18nUtil.resolveKey("armor.projectileProtection", projectileProtection)); } @@ -265,6 +270,10 @@ public class ArmorFSB extends ItemArmor { if(gravity != 0) { list.add(EnumChatFormatting.BLUE + " " + I18nUtil.resolveKey("armor.gravity", gravity)); } + + if(protectionYield != 100F) { + list.add(EnumChatFormatting.BLUE + " Protection applies to damage <" + protectionYield); + } } public static boolean hasFSBArmor(EntityPlayer player) { @@ -361,32 +370,37 @@ public class ArmorFSB extends ItemArmor { if(ArmorFSB.hasFSBArmor(player)) { ArmorFSB chestplate = (ArmorFSB) player.inventory.armorInventory[2].getItem(); + + //store any damage above the yield + float overFlow = Math.max(0, event.ammount - chestplate.protectionYield); + //reduce the damage to the yield cap if it exceeds the yield + event.ammount = Math.min(event.ammount, chestplate.protectionYield); - if(event.ammount < 100) { + if(!event.source.isUnblockable()) + event.ammount -= chestplate.damageThreshold; - if(!event.source.isUnblockable()) - event.ammount -= chestplate.damageThreshold; - - if(chestplate.damageMod != -1) { - event.ammount *= chestplate.damageMod; - } - - if(chestplate.resistance.get(event.source.getDamageType()) != null) { - event.ammount *= chestplate.resistance.get(event.source.getDamageType()); - } - - if(chestplate.blastProtection != -1 && event.source.isExplosion()) { - event.ammount *= chestplate.blastProtection; - } - - if(chestplate.projectileProtection != -1 && event.source.isProjectile()) { - event.ammount *= chestplate.projectileProtection; - } - - if(chestplate.damageCap != -1) { - event.ammount = Math.min(event.ammount, chestplate.damageCap); - } + if(chestplate.damageMod != -1) { + event.ammount *= chestplate.damageMod; } + + if(chestplate.resistance.get(event.source.getDamageType()) != null) { + event.ammount *= chestplate.resistance.get(event.source.getDamageType()); + } + + if(chestplate.blastProtection != -1 && event.source.isExplosion()) { + event.ammount *= chestplate.blastProtection; + } + + if(chestplate.projectileProtection != -1 && event.source.isProjectile()) { + event.ammount *= chestplate.projectileProtection; + } + + if(chestplate.damageCap != -1) { + event.ammount = Math.min(event.ammount, chestplate.damageCap); + } + + //add back anything that was above the protection yield before + event.ammount += overFlow; } } }