I want to make something in Minecraft with security doors but I can’t find out how to locate a specific item in a players inventory shulker box, ender chest, or hand. I need assistance to find the correct command for pocket edition.
2 Answers
You are unable to locate an item in a shulker box or enderchest - this will require game file editing.
Using commands, you are able to clear their inventory of tnt, or link any other command.
First, custom command if tnt is found:
execute at @a[nbt={Inventory:[{id:"minecraft:tnt"}]}] run <Your command here>
If you would like for no player to have tnt in their inventory, run
clear @a tnt
every tick (using a repeating command block)
-
@MarcoGeertsma Hi Marco - /toggleitem is not a vanilla minecraft command. If I am mistaken, please link a reputable source. Thanks– JaydenCommented Jan 8, 2019 at 9:43
-
@MarcoGeertsma Hi again Marco - /recipe is only for the Java edition of the game. -Detailed here: minecraft.gamepedia.com/Commands#recipe– JaydenCommented Jan 8, 2019 at 9:45
-
Your entirely right, my source seems to provide wrong information. Ill remove my comments to prevent discussion. Your answer covers it then Commented Jan 8, 2019 at 9:48
-
Remark: The
/clear
command does not remove items from shulker boxes or the ender chest, at least that's how it works in Java Minecraft. Commented Jan 8, 2019 at 17:54 -
1Sure, but not in this case. Your answer is pretty much as good as it gets, since what the asker wants is impossible in MCPE. Commented Jan 9, 2019 at 6:57
You can run this command:
clear @p tnt
When this returns true, have it do whatever you want. Note that that will take away the TNT, although you could hook it up to a system that gives it back once it is taken.
Note that the other answer provided above is for Java edition, and the command won't work. This command will work.