Is there any way to tell if a player has a full inventory? /give {player} item 1 always succeeds even if the player has a full inventory. I would like something that fails when the player is not given an item successfully. This is to go with a minigame where players pay for items with points and I need a way to stop the points from being deducted if they are not receiving items.
And similarly, is there any way to tell if a player has one empty inventory slot (any slot other than armor.) Preferably in 1 or 2 command blocks and not checking each and every slot individually.
You can label players that have a full inventory by checking their "Inventory" tag for every slot possible:
/scoreboard players tag @a[tag=full] remove full
/scoreboard players tag @a add full {Inventory:[{Slot:0b},{Slot:1b},{Slot:2b},{Slot:3b},{Slot:4b},{Slot:5b},{Slot:6b},{Slot:7b},{Slot:8b},{Slot:9b},{Slot:10b},{Slot:11b},{Slot:12b},{Slot:13b},{Slot:14b},{Slot:15b},{Slot:16b},{Slot:17b},{Slot:18b},{Slot:19b},{Slot:20b},{Slot:21b},{Slot:22b},{Slot:23b},{Slot:24b},{Slot:25b},{Slot:26b},{Slot:27b},{Slot:28b},{Slot:29b},{Slot:30b},{Slot:31b},{Slot:32b},{Slot:33b},{Slot:34b},{Slot:35b},{Slot:100b},{Slot:101b},{Slot:102b},{Slot:103b},{Slot:-106b}]}
And can then target the player based on that label:
/say Players with an item in every slot: @a[tag=full]
However, that does not consider stack size, just if there's an item in every slot. The player could technically receive a new item if one of the slots that has items isn't at a full stack. If that doesn't work for you, then unfortunately there's not much else you can do if players can receive items that don't stack to 64.
And you can use the same label negated for your second question (though you would need to remove the armor slots from the NBT):
/say Players with an inventory slot available: @a[tag=!full]
You can label players that have a full inventory by checking their "Inventory" tag for every slot possible:
Thank you, this seems to work, but how can I remove the armor and weapon slots? Which numbers are they?
Also, can you recommend a good json tutorial for minecraft? The googles is not very helpful for what I have searched for. i am looking for a full list of all NBT references that can be used and a simple description of how to use them.
Thank you, this seems to work, but how can I remove the armor and weapon slots? Which numbers are they?
Also, can you recommend a good json tutorial for minecraft? The googles is not very helpful for what I have searched for. i am looking for a full list of all NBT references that can be used and a simple description of how to use them.
Thanks!
Slots 100, 101, 102, and 103 will be armor slots. I should mention that I had included slot "-106", which is the offhand slot. Revised command:
/scoreboard players tag @a add full {Inventory:[{Slot:0b},{Slot:1b},{Slot:2b},{Slot:3b},{Slot:4b},{Slot:5b},{Slot:6b},{Slot:7b},{Slot:8b},{Slot:9b},{Slot:10b},{Slot:11b},{Slot:12b},{Slot:13b},{Slot:14b},{Slot:15b},{Slot:16b},{Slot:17b},{Slot:18b},{Slot:19b},{Slot:20b},{Slot:21b},{Slot:22b},{Slot:23b},{Slot:24b},{Slot:25b},{Slot:26b},{Slot:27b},{Slot:28b},{Slot:29b},{Slot:30b},{Slot:31b},{Slot:32b},{Slot:33b},{Slot:34b},{Slot:35b},{Slot:-106b}]}
2 linked questions:
Is there any way to tell if a player has a full inventory? /give {player} item 1 always succeeds even if the player has a full inventory. I would like something that fails when the player is not given an item successfully. This is to go with a minigame where players pay for items with points and I need a way to stop the points from being deducted if they are not receiving items.
And similarly, is there any way to tell if a player has one empty inventory slot (any slot other than armor.) Preferably in 1 or 2 command blocks and not checking each and every slot individually.
Thanks
You can label players that have a full inventory by checking their "Inventory" tag for every slot possible:
And can then target the player based on that label:
However, that does not consider stack size, just if there's an item in every slot. The player could technically receive a new item if one of the slots that has items isn't at a full stack. If that doesn't work for you, then unfortunately there's not much else you can do if players can receive items that don't stack to 64.And you can use the same label negated for your second question (though you would need to remove the armor slots from the NBT):
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
Thank you, this seems to work, but how can I remove the armor and weapon slots? Which numbers are they?
Also, can you recommend a good json tutorial for minecraft? The googles is not very helpful for what I have searched for. i am looking for a full list of all NBT references that can be used and a simple description of how to use them.
Thanks!
Slots 100, 101, 102, and 103 will be armor slots. I should mention that I had included slot "-106", which is the offhand slot. Revised command:
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/