PT-BR EN ES
Channel Icon

Crazy Ozz

Official Channel Website

Command Block

How to Detect Item Category in Hand in Minecraft (Tags)

Minecraft Java Edition 1.21+ and 26+ – Detect Swords, Boats, Armor and More

Want to run different commands depending on what item a player is holding? In this tutorial you will learn how to detect item categories in Minecraft using item tags such as #minecraft:swords, #minecraft:boats and many others. This is perfect for creating custom abilities, kits, minigames and advanced Command Block systems in Minecraft Java Edition 1.21+ and 26+.

Let's detect the sword that the nearest player is holding in their hand

Place 1 Repeat command block set to Always Active with the following command:

execute if items entity @p weapon.* #minecraft:swords run

If any sword is being held in either hand, the command after run will be executed

Just add any command you want

There are other examples below, such as boats, armor, etc...

execute if items entity @p weapon.* #minecraft:boats run

execute if items entity @p weapon.* #minecraft:head_armor run

execute if items entity @p weapon.* #minecraft:logs run

Want cheap and lag-free Minecraft hosting?

I recommend Sparked Host: affordable plans, great performance, easy panel and fast support.

🚀 Start your Minecraft Server

Still have questions? Watch the video below