I am creating a server where a certain item is banned. How do I get to know if a player has it in their inventory, and, if so, how can I delete all instances of it using command blocks?

  • I'm pretty this has been asked many times before but I can't find a post.
    – Timmy Jim
    Dec 3, 2022 at 15:02

2 Answers 2


You can use the clear command.


/clear @a minecraft:flint_and_steel

@a is a target selector which selects all players. You can supply any item ID instead of minecraft:flint_and_steel. The Minecraft wiki should tell you the ID of any item on it's page. For example, see the Sword page for all the different sword IDs.

Because you need this to execute every tick, make sure this Command Block is set to "repeating" mode. Otherwise, it will only clear the items once.


No need to detect; if an item is outright banned from the server, you just need to run the clear command on a command block in repeating mode. The command is /clear @a [item].

  • This adds not very much to the previous answer.
    – pinckerman
    Dec 3, 2022 at 13:06
  • @pinckerman It doesn't have to. Just because an answer is there doesn't mean I can't post another one. Dec 26, 2022 at 17:21
  • You are encouraged to post new answers if they add something new, or if they reorganize information into a more readable format. You are essentially saying the same things already written. So what's the point?
    – pinckerman
    Dec 26, 2022 at 17:50
  • @pinckerman This is in a more readable format, as it is a simplified version. Feb 24, 2023 at 10:39

You must log in to answer this question.

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