How can I decrease the maximum health of a player using commands in Minecraft 1.8?
2 Answers
This is possible using item attributes with a command like this:
replaceitem entity @p slot.armor.feet chainmail_boots 1 0 {AttributeModifiers:[{AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Amount:-10,Operation:0,UUIDMost:12272,UUIDLeast:110438}]}
What the above command does is replace one of a selected entity's armor slots (in this case their feet) with a piece of armor that has a negative maxHealth
attribute, causing their maximum health to lower.
You can change the number after Amount:
to change how much their health drops by; 1 unit is half a heart.
Note that their health will go back up if they take the armor piece off, so you will probably want to have the command on a clock.
and for a button and only 1 heart, use this: replaceitem entity @p slot.armor.head stone_button 1 0 {AttributeModifiers:[{AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Amount:-18,Operation:0,UUIDMost:12272,UUIDLeast:110438}]}
-
1This adds nothing new and is essentially just a copy/paste of the accepted answer. Commented Aug 26, 2016 at 22:06