1

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

3
  • 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. Commented Jun 7, 2015 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
    Commented Jun 7, 2015 at 0:34
  • 4
    If you solved your own question, please post it as an answer rather than editing the question. Commented Jun 7, 2015 at 7:42

2 Answers 2

2

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.
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, 40 if you wanted to check armor slots.

2
  • Major flaw with straight up using test for: NOT multiplayer friendly. Also this is very labourous to do.
    – Moddl
    Commented Jun 8, 2015 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
    Commented Aug 16, 2017 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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