How to change the player's Max Health?

Started by Hamburger_Patty on

Topic category: Help with modding (Java Edition)

Last seen on 11:09, 1. May 2024
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to change the player's Max Health?

I would like to change the player's max health, for example, from max 20 to max 1, but I'm having trouble doing it successfully. What should I do?

I'm a beginner who has just started making mods, so I would appreciate it if you could explain things in as much detail as possible :)

Last seen on 14:21, 9. May 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
For limiting the hearts, you…
Fri, 12/08/2023 - 11:50

For limiting the hearts, you would want to create a player-persistent number variable, (you can do this in the 'variables' tab of the workspace), and then run a procedure with the 'on player update tick' global trigger that checks if the player's health is greater than the variable, and, if it is, sets it to the current limit. You could then change the variable to change the limit on the player's hearts.

Adding more health is a bit trickier. Depending on how you want this to work, you could just give the player absorption with varying levels. (Every level of absorption grants the player an additional two hearts.) If you want it to better resemble normal hearts though, you might have to design your own system, or do something with custom code. (I know whatever mod they're using on Secret Life allows this, so it might be worth looking into that.) 

Last seen on 11:09, 1. May 2024
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm not sure if I can do it,…
Fri, 12/08/2023 - 12:02

I'm not sure if I can do it, but I'll give it a try as a reference. Thank you!