Minecraft 1.14.3, unable to stop items despawning using command blocks

minecraft-commandsminecraft-java-edition

I am making a puzzle adventure map which involves dropping items onto pressure plates to keep doors open. Of course, an item despawning would break the map, so I've been trying to find ways to prevent this.

At the moment, I'm running two repeating command blocks both set to 'Unconditional' and 'Always active' with these commands:

/tag @e[type=minecraft:item] add Remain

/execute as @e[tag=Remain] run data merge entity @s {Age:0}

The first command gives the 'Remain' tag to all items, and the second command continuously sets their age to 0. Unfortunately, items are still despawning. Any help would be greatly appreciated.

Best Answer

You can execute a command for all items just by using "/execute as @e[type=item]", there's no need on adding a tag.

Also to make the item not despawn, you can simply modify it's "Age" tag to '-32768s', that will make the item never despawn.

/execute as @e[type=item] run data modify entity @s Age set value -32768s

If you want to make this for all items, just put the command on a repeat commandblock, and it'll work for every item that is dropped.