1.16.5 Health declines

Discussion in 'Spigot Plugin Development' started by Bosternike, Jun 16, 2021.

Thread Status:
Not open for further replies.
  1. I have a problem with setting max health for player.

    For example: if I set player health to 24, his health will decline to 20.
     
  2. How are you settings the player's max hp?

    Setting the health of the player above their max amount will do nothing.
     
  3. Not quite sure what you mean, but I know that when you set a larger max health you still keep the same health value. So if you already have the default (20) health and set it to 24 you'll still only have 20 health (10 hearts/12 hearts) until the other health regenerates. If you want the user to have the full 24 health after setting that to the max health you have to set their health right after setting that maximum.
     
  4. I used Attribute.GENERIC_MAX_HEALTH to set player Max Health.
     
  5. Did you try what I said and set the actual health?

    How could the player health decline to 20 if that is where it defaults to?
     
    #5 S1ant, Jun 16, 2021
    Last edited: Jun 16, 2021
  6. Assuming your code looks similar to the one I've provided and it still doesn't work, please provide some more information and/or a video of what's occurring.

    Code (Java):
    player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(40); // Sets the player's attributes to allow 40 max health.
    player.setHealth(40); // Forces the player's health to be set to 40.
     
  7. It does work! I appeared to do something wrong...
     
Thread Status:
Not open for further replies.