4

I searched up how to do this several times and I could only find ways to spawn items that cannot be picked up, and if it was a tutorial about stopping item despawning, it would still despawn after being picked up and dropped on the ground again.

I'm working on a game, fully with command blocks, and I have absolutely no idea how to stop items from despawning.

Could NBT tags be put on item entities too? So that when they get dropped, they still have the NBT tag?

Does anyone know how to stop them from despawning?

2
  • Are you trying to stop all items from despawning, or only some items from despawning?
    – pppery
    Jul 28, 2020 at 14:18
  • only specific items, is what I'm trying to do Jul 28, 2020 at 14:19

1 Answer 1

2

First, you can stop a specific item from despawning unless it is picked up and then dropped again by setting it's Age to -32768 with a command block.

Second, you can add arbitrary custom NBT data to an item, which will be preserved across drop-and-pickup cycles.

You can combine these two techniques to make specific items never despawn by running the command:

/execute as @e[type=item,nbt={Item:{tag:{noDespawn:1b}}}] run data merge entity @s {Age:-32768}

This would make any item given with a noDespawn:1b NBT tag (/give <player> <item>{noDespawn:1b}) never despawn, even if it is picked up and dropped again.

You must log in to answer this question.

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