2

I am aware this has been asked and answered before, but I can't find a solution that works for me, somehow. Aside from giving the mobs health_boost, that is. But that works per 4 health, so this isn't exactly my prefered choice.

I am currently using a /data merge on a chicken with:

Health:10,Attributes:[{Name:"generic.maxHealth",Base:10}]

Which doesn't work. I thought it might just not regenerate the health above the value it had before merging the data, but healing it doesn't change it, since it still has 4 health.

For the full data merge command:

execute as @e[type=chicken,scores={empowered=1..,lifetime=1..2}] run data merge entity @s {CustomName:"\"Floating Chicken\"",CustomNameVisible:1,Health:10,Attributes:[{Name:"generic.maxHealth",Base:10}],HandDropChances:[0.33F,2F],HandItems:[{id:"minecraft:leather_boots",tag:{Tags:"Airflow",Unbreakable:1,display:{color:16448250,Name:'[{"text":"Airflow","italic":false}]',Lore:['[{"text":"Slows down falling speed while worn","italic":false}]']},AttributeModifiers:[{AttributeName:"generic.armor",Amount:1,Slot:feet,Name:"generic.armor",UUID:[I;-1211110,25079,235157,-50158]},{AttributeName:"generic.max_health",Amount:1,Slot:feet,Name:"generic.max_health",UUID:[I;-1211110,25179,235157,-50358]},{AttributeName:"generic.movement_speed",Amount:0.01,Slot:feet,Operation:1,Name:"generic.movement_speed",UUID:[I;-1211110,25279,235157,-50558]}]},Count:1},{}]}

I am making a simple datapack that causes every mob to sometimes spawn as an empowered mob with higher stats, effects and sometimes special abilities, while also having special drops. This includes almost every mob, except a few such as villagers.

Lifetime is a score that gets increased by 1 per tick to keep track of how long something has been alive. Right now it's only used to change the empowered mobs once instead of constantly, but later I'm planning on using it for things like slimes that regrow in size after being alive for a while.

3
  • You need to change maxHealth to max_health. Commented Dec 12, 2021 at 9:35
  • I tried it, but it also didn't seem to work. You do mean the generic.maxHealth in the attributes, right? Commented Dec 12, 2021 at 15:53
  • Yes. I thought that was the issue. Commented Dec 12, 2021 at 16:58

1 Answer 1

0

I just realised this has a pretty obvious answer. It isn't NBT as I asked but works perfrectly fine as well. The attribute command allows exactly what I want. I can even reduce health of mobs if I want to. Example:

/attribute <entity> minecraft:generic.max_health base set <value>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .