How can I solve a problem caused by altering player's maximum health?

Started by Sacron1143 on Tue, 08/13/2019 - 16:16

Topic category: Help with MCreator modding

Last seen on 11:32, 14. Sep 2019
Joined Aug 2019
User points:


  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
How can I solve a problem caused by altering player's maximum health?
Tue, 08/13/2019 - 16:16

Tl;Dr : By changing the player's maximum health, hunger makes it stop regenerating

As the title suggests, I want to have the player start with a certain amount of health, and by using a certain item your maximum amount changes. So far I've been able to do so, but I have encountered a problem: Hunger

The way I changed it is that there is procedure that verifies how much health you currently have and, if it is higher then the variable that stores how much is your maximum, it puts you back at that amount. However, by doing so the player's health is constantly regenerating in vain, resulting in you almost always having 1.5 of hunger missing (Aka, how much is needed to stop regeneration).

That makes battles a lot tougher in the beginning, as by the time you encounter a enemy your already low health will not regenerate unless you eat something. And those enemies are everywhere, so you can expect to fight them a lot.

How can I solve this issue? I imagine it would have to be by changing the actual maximum health value or something with the hunger