Minecraft Java Edition Commands – How to Set a Damage Value on a Slot

minecraft-commandsminecraft-java-edition

So I was just asking if it was possible that items on the ground got random damage values or that when you pick them up your items gets a value. My goal is that I want the player to only be able to have 1 item per slot. I think this is possible by changing the damage value on the items so that they can't stack. But they all need to be random or not the same number for that to happen. I tried with taging every slot in my inventory to a seperate tag name and then the tag name would give it a damage value but I could not find a to get the command blocks to give the items a damage value. There is a way and it's to give each and every item in every slot a diffrent tag but that would take a very verrry long time. So any ideas?

Best Answer

This command prevents items from stacking. If you put it into a repeating command block, then items should no longer stack, as soon as they were dropped at least once (it will not break stacks that already exist as stacks)

/execute as @e[type=item] run data modify entity @s Item.tag.PreventStacking set from entity @s UUIDMost

Note: I use Minecraft 1.14.2 and this command may not work in older versions