Madis0 / OneBar

A Minecraft HUD mod for Fabric Loader
Other
8 stars 2 forks source link

Natural regeneration estimate #8

Closed Madis0 closed 3 years ago

Madis0 commented 3 years ago

https://minecraft.gamepedia.com/Hunger#Mechanics

Should be colored the same as saturation effect by default (or maybe light brown?)

Madis0 commented 3 years ago

Made a mixin to foodTickTimer (foodStarvationTimer on Fabric mappings), returns just zero... Perhaps it is server-side?

Madis0 commented 3 years ago

Exhaustion is server-side, so this probably is too (hence protected int and all) 😢

Madis0 commented 3 years ago

Added an arrow to show when regen is happening, despite not knowing exact value

Madis0 commented 3 years ago

Although maybe saturation could be shown as the regen value?

Madis0 commented 3 years ago

Formula to approximate foodTickTimer behaviour:

naturalRegenerationHealth = 0;
        if(health < maxHealth && hunger < 3 ){
            int regenerationAddition = 0;
            // Approximate formula for calculating regeneration addition health: saturation * exhaustion max / 6 exhaustion per healed heart
            regenerationAddition = MathHelper.ceil((float)saturation * (float)4 / (float)6);

            naturalRegenerationHealth = Math.min(health + regenerationAddition, maxHealth);
        }

It works the first time hunger is in the correct value, but it shouldn't re-estimate until the health has that value... Or I guess the formula is just wrong.