I'd like to create a Minecraft data pack to let a player see what he dropped/lost upon death (whatever he had in inventory+hotbar+offhand+armor+etc). I got the GUI part but i'm missing how to read a user inventory with a command so i can fill the new GUI with those items. I don't think /testfor is viable since i'd have to test for every single block present in the game and also i'd lose all the tags attached to an item (Edit: i've read that command is available only on BE, this is for JE). I tried to look at the documentation of /replaceitem but it doesn't seem useful either. Thanks in advance.

  • Upvote, even though I believe it to be impossible. To my understanding, yes, you would have to test for everything; every item ID, every enchantment type and level, every banner pattern, every leather armour colour code, etc. Some parts could probably be made easier, for example you would only need binary search and therefore 13 commands to check all 12326391 possible leather colours, but you would also have to set whatever you have as a display, so unless that's a scoreboard display (like the sidebar), you would have to have one command per value. Or you transfer the number from the... Aug 29, 2018 at 16:21
  • ...scoreboard back into some NBT value. But even if you solve all of this, there's still the problem of item names, which can have up to 35 characters, as far as I know pretty much all of Unicode (1114112 different characters) is allowed, which makes the number of combinations a few novemsexagintillion or more than 600 command blocks even if binary search is somehow possible (which I doubt). And even if you're insane enough to program all of that, there are also shulker boxes, which make the number of possibilities explode once again (to whatever your previous number was to the power of 27). Aug 29, 2018 at 16:30
  • So your real question becomes: How accurate do you want this display to be? Is just item type enough? Or also damage? Or also leather armour dye? Or... Aug 29, 2018 at 16:32
  • I want it to be as accurate as possible, ideally the new GUI being a clone of the player's inventory (without the player being able to take back the items). If that's impossible with commands I'm not fixed on that and i could learn how to program a mod that does that. The data pack was just a convenient way to distribute the new feature to friends who play on my server.
    – plumbe0
    Aug 29, 2018 at 16:59
  • 4
    Possible duplicate of How would you copy a player's inventory into a double chest?
    – pppery
    May 10, 2021 at 15:48

2 Answers 2


It seems that this is not possible. Maybe you could do something that detects if the player dies and teleports all the items on the ground or something along those lines. Perhaps using hoppers. You could also make sure that it doesn't teleport other items in the world by doing a radius. Although to my knowledge doing it any other way is impossible. You can use a scoreboard objective to test if the player has died.


You need a place to store the player data before the player dies. You can copy the player's inventory to another entity, perhaps an invisible armor stand at 0,0.

/execute as <player selector> run data modify entity <global armorstand selector> Items set from @s Items

Then, once the player is dead and whatnot, you need to copy the inventory from the armor stand to a chest/minecart chest for the player to be able to retrieve the items.

/execute as <chest selector> run data modify entity @s Items set from <global armorstand selector> Items

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