5

I am making a mine craft bed-wars mini-game designed for 1v1v1v1. In your base there is an item spawner that occasionally spawns iron and gold. To limit the amount that spawns I am going to use the nbt: Health. I am going to have a clock going into a command block that decreases the heath of all gold and iron by 1. They will eventually go from 5 to 0 and DE-spawn. I have this command started but I don't know what to put next.

/execute as @e[type=minecraft:item,nbt={Item:{id:"minecraft:gold_ingot",Count:1}}] run data merge entity @s {}

I just need something to make the health decrease.

7

There's unfortunately no way of decreasing NBT tags with commands. You can only set them.

You can however do this:

The NBT tag {Health:Xs} acts just like hearts, and the item dies just like a normal player does when it hits 0. You can spawn the items on fire and set the health value to the amount of seconds you want the items to last.

Example:

summon item ~ ~ ~ {Item:{id:"stone",Count:1b},Fire:1200s,Health:60s}

The item I just summoned with this command will last for 60 seconds total. The NBT tag {Fire:Xs} works with ticks. And fire takes 1 value off the Health NBT tag per second. Meaning the item will die in 60 seconds. (1 second = 20 ticks)

Hope this helps!

  • 1
    Dude @thaccoman10285 You are an absolute legend. Not only do the items disappear, THEY LOOK SICK AS FLIP!!! I have been trying so long to limit the number that spawn. I've tried scoreboards I've tried aging them up so they DE-spawn faster. (But they just clump up and it messes with their age.) Thanks for putting in the time to answer me. Means a lot. EDIT: they still do clump up, I don't know what to do about that. Still works though, it just kill a lot then they build back up and it kills a lot of them again. Thanks again though. – tanner Sep 24 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.