Having a ton of trouble using attributes to modify player health.

Started by Rooftop on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Having a ton of trouble using attributes to modify player health.

Hi, I've been using Mcreator and one of the first things I wanted to try was to add a heart container like item to the game. The attribute command is perfect for this however adding only 1 heart at a time is almost impossible from what I can tell. I can only set the hearts to a certain value like this /attribute <target> <attribute> base set <value> or a better way I found is by adding hearts like this /attribute <target> <attribute> modifier add <uuid> <name> <value> add. The problem with the second one is I can only use 1 heart crystal ever because running the command a second time throws an error that the UUID is the same. I cannot for the life of me figure out how to change the UUID each time I run the command and I feel as though I've exhausted all the information I could find on google. Any help or pointers would be greatly appreciated! Thank you!

Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I might have no idea what I…
Wed, 01/12/2022 - 07:25

I might have no idea what I'm talking about, but I do know a little itty bit of programming. I would suggest making it a variable that is saved like "BonusHpValue" or something, and use math to add when you wanna increase or decrease it by a certain amount.

Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How would I import that…
Wed, 01/12/2022 - 07:34

How would I import that value into a command? Like I could do the /attribute <target> <attribute> base set <value>  but I can't seem to figure out how to import that "BonusHpValue" global variable into the command syntax. Like how would I make it attribute @p minecraft:generic.max_health base set "BonusHpValue"   ?