How do I summon an item that despawns after a custom period of time?
How can I summon an item that will despawn after a specified number of minutes, as opposed to the default 5?
I tried
/summon Item ~ ~1 ~ {Item:{id:minecraft:planks,Count:1,Age:1}}
but the item always despawns after 5 min no matter what number I specify for the Age
.
Solution 1:
You can set the Age
to a negative number to make it last longer. The age will always increase once per tick until it gets to 6000, at which point the item will despawn. The Age
is a tag of the item entity itself, not of the contained item, so it should be outside the Item:{}
tag:
/summon Item ~ ~-2 ~ {Item:{id:minecraft:planks,Count:1},Age:-5000}
There is also a special case for Age:-32768, the lowest possible value for a short, for which the item will never despawn. E.G:
/summon Item ~ ~-2 ~ {Item:{id:minecraft:planks,Count:1},Age:-32768}