[1.12.2] Focus Sash only accounts for the original damage taken. It also doesn't take into account for any Damage Reduction or Absorption.
SonicX8000 opened this issue ยท 23 comments
Minecraft: 1.12.2
Forge: 14.23.5.2795
Mods: 1
DarkUtils-1.12.2-1.8.219
Was originally a comment before... but been leaning towards it being a bug. Anyway... to quote my comment about the Focus Sash...
There's an object that deals 48 damage via magic, or rather... /effect instant damage 3. With my health at 20... due to the way the sash works. I take 19 damage, leaving me with 1 health. Now... if you have armor on & such, you can reduce the damage value that the sash sets, so using the same setup but wearing Diamond Armor with Protection IV x4, that damage from the sash gets cut down from 19 to 6 but only because my health is full. Magic bypasses armor so I went with the Protection IV way.
Without the sash I take 17 damage which... isn't enough to kill me as I'll be left with 3 health. My guess is that it's taking into account of the full 43 damage rather than the reduced damage which without any form of damage reductions I'll be taking the full 43 damage.
Now say I have 20 Absorb due to a powerful potion effect or a mod that grants you some sort of shield, using the same setup at full health + the diamond armor with the protection + sash... 6 of that damage is dealt to my absorb. Because I have 20 Absorb... I can survive 4 instant kills as the 4th hit will affect my health, then I will take the 17 damage on the 5th hit.
I'm just wondering if the Focus Sash is suppose to be doing this with ignoring damage reductions & absorb leading to surviving multiple instant kills. It tends to be more noticeable with mods that allow you to scale your health/absorb alongside damage sources being scaled. Like one can run with 20 Health + 100 Absorb and they'll be able to survive many instant-kills from something that deals 10000 magic damage but it'll be reduced to 19 due to max health being at 20 and further reduced due to armor/protection/other, if 6 damage that's 17 instant-kill hits blocked with the 18th hit being fatal.
To add onto this...
Using a few mods such as Scaling Health & Cyclic which allows me to altar max health... I can lower my maximum health from 20 to just 2 and with a good Absorption Potion Effect or using a mod called Natural Absorption which grants you a rechargeable absorption shield... I am pretty much invincible if I have a high enough Absorption as the Focus Sash will reduce all damage to 2 due to my max health and further reduce it if I have Protection IV & other defense factors. Heck, even damage sources that should outright kill you will only at most deal 2-3 damage due to the Sash and if having like 100+ absorption... that's quite a number of instant kills that I'm saved from.
EDIT
Apparently with Scaling Health & Cyclic, I can have exactly 1 or less Max Health... which means that as long as I have the Focus Sash I cannot die as the damage dealt will always be 0. Not even /kill can do anything.
I read the Focus Sash code and tried to fix that using native functions applyArmorCalculations
, applyPotionDamageCalculations
and getAbsorptionAmount
.
If everything is cool, it applies armor and potion effect to the damage, check if it's more than (maxHealth+absorption) and if so applies a (maxHealth-1) damage.
Would that account for the Protection enchantments? The Focus Sash shouldn't work if the player somehow got a Max Heath of 1 as they pretty much become invincible since maxHealth-1 would be 0 damage at 1/1 Health as long as they have it.
Doing some messing around in a test world, you can have 0/0 Health but anything that damages you is an instant kill... unless you have the Sash, then you can't be killed by anything.
Would that account for the Protection enchantments?
I don't know and I can't find the right informations right now (I'm not in my dev env...). I'll check this ASAP.
EDIT : looking at MC source code, looks like no.
EDIT2 : the applyPotionDamageCalculations
takes Enchantments in count. It's fine.
The Focus Sash shouldn't work if the player somehow got a Max Heath of 1 as they pretty much become invincible since maxHealth-1 would be 0 damage at 1/1 Health as long as they have it.
Well, a maxHealth (including absorption) of 1 is pretty uncommon XD
I'll add a condition
Meh. I keep trying but applyArmorCalculations
and applyPotionDamageCalculations
are protected float. I haven't deal with those for a while :'D
The armor and potion issues are definitely a bug, and I am surprised that Forge doesn't already account for those. As for the half a heart max health issue, I don't see that as a bug. While that's definitely a very powerful combination, it's not possible to obtain under standard conditions, and once the above fixes have been applied it actually leaves the player in a very vulnerable state. You would have to have half a heart while wearing no armor and having no potion effects, which leaves you vulnerable to many of the weapons in other mods. To help make this less of an issue, I plan to make the half a heart thing configurable (enabled by default), along with adding durability to the sash, and an exception to allow void damage to kill the player.
@Z-Tunic As your testing environement looks more advanced than mine, could you test this build? I experimented a little but I can't do more atm.
https://www.dropbox.com/s/ch1alx1cpvgpx03/DarkUtils-1.12.2-1.8.0.jar?dl=0
The armor and potion issues are definitely a bug, and I am surprised that Forge doesn't already account for those.
Forge has a applyArmor
method that recreate the protected float applyArmorCalculations
method from EntityLivingBase
, but there's no protected float applyPotionDamageCalculations
(calculation from Potions and Enchantment // magic) alternative :(
Testing Build...
The Player now dies with 1/1 Health + Sash & 0/0 Health + Sash, which is good as they're no longer immortal. Absorption is accountable even with 1/1 Health or 0/0 Health as well as Armor, Protection & Resistance. Void damage ignores the Sash so falling out of the world & /kill works as intended.
@Darkhax
While you can't get it by standard means, with mods that allows you to lower your max health to 0 or 1 from the default 20 would make those wearing the Sash become immortal. The current fixes in the test build prevents that now.
EDIT
Just wondering... but is it intended for the Sash's set damage value to be reduced by defense factors like Armor, Protection, etc.?
@Z-Tunic
Just wondering... but is it intended for the Sash's set damage value to be reduced by defense factors like Armor, Protection, etc.?
Are you talking about my patch (where I [tried to] made damage absolute) or the current official build?
@Sewef
It happens in the official build as well as the test build.
@Z-Tunic
Ahem.
It looks like Absolute damages can bypass Enchantment and Potion effects, but not armor.
Grmbl.
I set the damageBypassesArmor
flag. New test build after work c:
@Z-Tunic
TAKE THAT.
https://www.dropbox.com/s/ch1alx1cpvgpx03/DarkUtils-1.12.2-1.8.0.jar?dl=0
@Sewef
OBJECTION.
Looks all good now. I guess Terrasteel/Flux Armor had a high armor value than what it visually shows on the armor bar which is perhaps why I was seeing such a massive damage reduction with the Absolute Damage in my survival world. By massive... Scaling Health is added on that world and I have damage sources scaled depending on it's difficulty.
The reduction was still there with Diamond Armor but not as much compared to those two armors. There's some modded damage reductions that affects the Absolute damage but I'm not sure how that will be handled. To name a few... RPG Inventory's Emerald Gloves which reduces damage taken by 20%, and Angel of Vengeance's 'Faith' Spell that reduces damage taken by 50%. At least by vanilla standards it works.
@Z-Tunic
https://github.com/ArtixAllMighty/Rpg-Inventory-2016/blob/master/src/main/java/subaraki/rpginventory/handler/JeweleryEffectsHandler.java#L115
RPG Inventory's Emerald Gloves doesn't care about AbsoluteDamage.
https://github.com/Tamaized/AoV/blob/1.12/src/main/java/tamaized/aov/common/events/AttackHandler.java#L72
Angel of Vengeance's ShieldOfFaith too.
I don't know if it would be better to ask mod authors to add the Absolute behavior or find a way to bypass this in the Focus Sash code.
Hey, let's be smart.
LivingDamageEvent is fired just before damage is applied to entity.
At this point armor, potion and absorption modifiers have already been applied to damage - this is FINAL value.
Also note that appropriate resources (like armor durability and absorption extra hearths) have already been consumed.
This event is fired whenever an Entity is damaged in EntityLivingBase.damageEntity(DamageSource, float) and EntityPlayer.damageEntity(DamageSource, float).
I trashed everything and added a @SubscribeEvent
on onLivingDamage
.
@Z-Tunic
Mgrabblblblbl
https://www.dropbox.com/s/ch1alx1cpvgpx03/DarkUtils-1.12.2-1.8.0.jar?dl=0
Totally untested.
Testing build...
Focus Sash now accounts for modded damage reductions so if enough damage was blocked it won't proc the Sash as before the Sash could proc on a non-KO blow with the modded damage reductions. If a KO blow occurs I'll be left with exactly 1 HP meaning the Absolute Damage value isn't reduced by anything anymore.
I had modded damage reductions from...
Level Up! Reloaded - Iron Skin Ability
+5% Damage reduction per level, up to +50% at level 10 which is the max.
RPG Inventory - Emerald Gloves & Cloak with Emerald Defense Incrustation II
Gloves is a +20% Damage Reduction but I dunno how much for the Cloak.
Angel of Vengeance - Shield of Faith
+50% Damage Reduction when spell is in effect.
With the above listed as well as Protection & such with Max Health at 226... I took damage from something that dealt 1875? 1880? damage... my health dropped to 112, 112.23268 to be exact. Without the Shield of Faith... that procs the Sash and puts my health to 1.
Looks like everything is good now.
Yeay \o/
@Darkhax Can you merge my PR please? ^_^