variable protection yield ranges for FSB armor

This commit is contained in:
Boblet 2022-01-26 16:58:24 +01:00
parent b17a1a9cd8
commit 33bfb9d928
2 changed files with 41 additions and 25 deletions

View File

@ -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");

View File

@ -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;
}
}
}