ghen-git / Thirst-Mod

Other
13 stars 10 forks source link

Armor enchantments break thirst #43

Closed nickyprowse21 closed 10 months ago

nickyprowse21 commented 10 months ago

With The most recent update (was previously using Thirst Was Remade), due to the changes to fire protection affecting thirst, thirst is entirely broken by enchantments. The effect works as intended with one piece of armour enchanted with fire protection 1, but as soon as you equip 2 pieces of armour with fire protection 1, doing activities that would increase thirst actually drain it, which can be seen when using appleskin.

So rather than slowing the rate you get thirsty, it actually puts it into negative values, meaning it is impossible to lose any thirst if having one piece of armour with fire protection 2 or 2 separate pieces with fire protection 1. As this effect seems to stack, it gets to completely ridiculous levels when having 4 pieces of fire protection 4 armour as after running around for a few minutes, it puts the thirst rate into so far negative values that even after taking off the armour you can't get thirsty.

This same bug applies to protection, not fire protection, which means protection has the same thirst rate reducing effect as fire protection.

To replicate this issue, where any armour with protection/fire protection above level 1, or multiple pieces of level 1, and run around.

nickyprowse21 commented 10 months ago

Also noticed the fire resistance potion effect doesn't slow down the rate of thirst increasing but just stops you from getting thirstier at all while the potion effect is active, no matter what level the potion is

nickyprowse21 commented 10 months ago

Had a look at the source code, think I found where the errors come from:

public static float getExhaustionFireProtModifier(Player player)
{
    final float perLevelMultiplier = 0.625f;
    int totalLevels = EnchantmentHelper.getDamageProtection(player.getArmorSlots(), DamageSource.ON_FIRE) / 2;

    return 1.0f - (totalLevels * perLevelMultiplier);
}

As the protection enchantment also protects the player from fire damage, just not as much as fire protection, it is getting taken into account here when calculating totalLevels.

As for going into negative values with multiple levels, I believe it is because the value of totalLevels ends up above 1 when multiple levels of protection/fire protection are applied, therefore it returns a negative value decreasing thirst exhaustion rather than increasing it. perhaps normalising (totalLevels * perLevelMultiplier) fixes this issue, as it would never end up above 1

ghen-git commented 10 months ago

oh nope dont worry, i missed a zero in eh perLevelMultiplier, its supposed to be a number that when multiplied by 16 is equal to 1. Thats the case for 0.0625, and its a perfect float so it doesnt get fucked up like 0.1. Its fixed in the latest update, although i'd have to look into normal protection also influencing it