0

I'm creating a game for my school on Minecraft Education Edition, which is Bedrock based. At a point in the game, the players will collect items I rename on an anvil that will give special abilities, e.g. a book that summons lightning, a book that replenishes health of nearby players, a book that makes the holder invulnerable, a helmet that allows night vision, and a few others I am working out.

How do I code command blocks to tag a player either wearing item or holding in off-hand and allow the tagged player to have the effect happen?

1 Answer 1

1

In bedrock / edu edition you are able to use the hasitem selector to select entites / players based on their items. However, it is a bit limited as it cannot select specifically named items, only types of items and their integer data (and at the time of writing that is also bugged).

So, for those things that you want to happen if they have it equipped / in their hand, you'll need to rely on using a different item instead of detecting its name.
Sidenote: For things like this I would recommend making an add-on, as it allows you to make your own custom items, but that is a lot more work and a lot more complicated than doing it ingame.

Here are two examples:

  1. detecting someone wearing an iron helmet:
@a[hasitem={item=iron_helmet,location=slot.armor.head}]
  1. detecting someone holding an amethyst shard in their offhand:
@a[hasitem={item=amethyst_shard,location=slot.weapon.offhand}]

Now with that you can either tag (/tag @a[...] add resistance) someone or even apply the desired effects immediately (/effect @a[...] night_vision).

You must log in to answer this question.

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