Topic category: Help with Minecraft modding (Java Edition)
So I'm porting a mod of mine to 1.16.5 and I always wanted to add a heart container-esque item, and since 1.16 added the /attribute command, I thought I could finally add it
with /attribute you can set a players health to a certain number, for example, you can add 1 more heart by doing /attribute @p minecraft:generic.max_health base set 22
however Since I was trying to make an item that increased health, I wanted to to make it so each use of the item stacked, I.E. if you used the item twice, it would get you
to a total of 24 health.
I'm not really good with commands, so I experimented with a few ideas and none of them worked. I tried using the following commands:
/attribute @p minecraft:generic.max_health base set (minecraft:generic.max_health + 2)
/attribute @p minecraft:generic.max_health base set {minecraft:generic.max_health + 2}
/attribute @p minecraft:generic.max_health base set [minecraft:generic.max_health + 2]
/attribute @p minecraft:generic.max_health base set {minecraft:generic.max_health+2}
After trying those out I was stumped and couldn't think of a way to get it working the way I wanted it to, so that's why I'm asking here if anyone knows a command that can do what I want it to.
Maybe I'm dumb but I don't know how I'm supposed to apply this to the /attribute command
/attribute isn't a custom command, so I don't know how exactly I'm supposed to get the CMD parameter of a vanilla command.
and from what I'm testing out I can't use the "command parameter with index with index" block with any of the math blocks, so I can't use it to get the player's health and add 2 to it.
again maybe I'm dumb or I'm just too tired to see the big picture, but I don't exactly know how this helps me, could you possibly elaborate more?
Sadly there's a problem with that.
Originally I had used the health boost effect in an older build,
but I didn't like how, if the player died, they would lose all their health because health boost is a potion effect. by using /attribute I can permanently increase the player's health, which is a much more desirable effect.
That worked! thanks!
How did you figure this out? I can't see the other replies in this thread and I am having the same exact issue!