0

Is there any way to test if a player's inventory is not full (eg. atleast 1 empty slot anywhere in the inventory, not counting Armor Slots) with command blocks and whatnot?

Update 2: I found /testfor @p {Inventory:[{Slot:0b}]}, which outputs a 1 block signal if there's an item there, and no signal if that slot is empty. THis would require 36 command blocks, to check every slot (including the hotbar; 27 to just check the inventory).

  • I think it would be possible by checking each individual slot with command blocks and using lots of comparators + AND gates, but that would take forever. – angussidney Jun 7 '15 at 0:05
  • Well, good to know that it might atleast be possible. Any clue how I would check the slots themselves (ie. what command I would need for each command block?) – MCCG Jun 7 '15 at 0:34
  • 3
    If you solved your own question, please post it as an answer rather than editing the question. – angussidney Jun 7 '15 at 7:42
1

I found /testfor @p {Inventory:[{Slot:0b}]}, which outputs a 1 block signal if there's an item there, and no signal if that slot is empty. This would require 36 command blocks, to check every slot (including the hotbar; 27 to just check the inventory, 40 if you wanted to check armor slots)

  • Major flaw with straight up using test for: NOT multiplayer friendly. Also this is very labourous to do. – ModDL Jun 8 '15 at 6:05
  • Looks like you can also check all slots in one single command, since as you see, the Inventory tag accepts an array. I'd assume you can stuff all slots into that array. Not sure if that checks for non-empty or full, though. – Egor Hans Aug 16 '17 at 15:57
1

This solution works for 1.14 for sure, I have not tested for 1.13. It can be elaborated on to check the entire inventory in one command; however, in this example I am only checking the hotbar.

/execute if entity @p[nbt={Inventory:[{Slot:0b},{Slot:1b},{Slot:2b},{Slot:3b},{Slot:4b},{Slot:5b},{Slot:6b},{Slot:7b},{Slot:8b}]}] run say Hotbar is not full.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.