hasitem command bedrock

How To Use The HasItem Command In Minecraft

Guide on how to use the hasitem command as part of the effect command in Minecraft bedrock edition.

What Is The HasItem Command Used For?

You can use this command to detect whether a player or entity has an item in their inventory. It does however go further than that, giving you the options to check by quantity and also by where the item is places within a players inventory.

It is used as part of the effect command which can be started by typing /effect @a [

So let’s go through the uses of the hastier command in Minecraft.

HasItem Command Guide

HasItem Item Command

Let’s get started with a simple command which can simply detect whether a player has an item anywhere in their inventory. For example the player will be called bob123 and we will give this player an effect of slowness for 10 seconds with a power of 10.

/effect bob123 [hasitem={item=command_block}] slowness 10 10

Hasitem Quantity Command

Now lets do the same as the above, bu this time lets see if the player has a certain quantity of the item were searching for. There are some variations but for the first example lets search for an exact quantity.

/effect bob123 [hasitem={item=command_block,quantity=2}] slowness 10 10

You can also use other variations such as less than a number, you can do this by adding two fullstops before the number like the example below.

/effect bob123 [hasitem={item=command_block,quantity=..2}] slowness 10 10

To look for more than a certain number add two fullstops after the number like the example below, this one means its looking for anyone with over 2 command blocks in their inventory.

/effect bob123 [hasitem={item=command_block,quantity=2..}] slowness 10 10

Alternatively you can see if a player has an amount between a range, such as seeing if they have between 5 and 10 quantity of that item. You do this by adding the first range, then two full stops then finishing with the last number in the range to look for.

/effect bob123 [hasitem={item=command_block,quantity=5..10}] slowness 10 10

HasItem Location Command

You can also look for this item in a location of the player. You can search all slots of a player or entity to make your search more specific. In the example below we will be looking for 2 command blocks, in the players hotbar.

/effect bob123 [hasitem={item=command_block,quantity=2,location=slot.hotbar}] slowness 10 10

Locations On A Player

  • slot.hotbar
  • slot.inventory
  • slot.armour
  • Head
  • Chest
  • Feet
  • Legs
  • slot.weapon.offhand
  • slot.weapon.mainhand

This will search the entire area which you have selected. You can also search over slot like the example below.

HasItem Location Slot Command

You can look specifically within a location by adding a slot part to your command. So lets try and find something in the 2nd slot of the players hotbar for example. And don’t forget that slots start at 0 in Minecraft so the furthest on the left is slot 0 the second is slot 1 etc.

/effect bob123 [hasitem={item=command_block,quantity=2,location=slot.hotbar,slot=1}] slowness 10 10

HasItem Data Command

You can specify different blocks if they are similar but with a different data value using the data argument to the command. This is best used if the command of 2 different blocks has the same name but a different data value.

/effect bob123 [hasitem={item=command_block,quantity=2,location=slot.hotbar,slot=1,data=2}] slowness 10 10

Different Uses For The HasItem Command In Minecraft

I can see this being used in a great way to stop grievers or players that should have an item. For example you can detect if anyone has a tnt block with a repeating command block (in a tick area) and then give them instant blindness, making it impossible to start a grief as they can’t see.

Perhaps set one up and if it detects anyone with illegal items such as bedrock it slows them to a crawl, making it not fun in anyway to have these banned items.

Another use is to give players boosts in mini games. For example if a player gets a specific item, it may give them jump boost for a few seconds, or potentially get a bit speedier.

Conclusion

I love playing around with bedrock commands and this one is certainly one to be exited about due to its huge variety of uses. I can see this one being a firm favourite amongst the bedrock command block engineers!

You may also like...

Leave a Reply

Your email address will not be published.

error

Enjoy this blog? Please spread the word :)

error: Content is protected !!