TransWikia.com

Is there a way to target only undead mobs in a command?

Arqade Asked by SonicBoom2o on May 8, 2021

I want to give undead mobs in a certain radius instant health potions, but I don’t know how to only target undead mobs.

effect give @e[distance=1..7, type=undead] minecraft:instant_health 7 10

But there is no "undead" mob type. At least in this context.

Any help would be appreciated.

One Answer

Assuming you're using a data pack, which you should be doing if this is a big project. Create an entity tag named minecraft:undead with the following contents:

{
  "values": [
    "minecraft:drowned",
    "minecraft:husk",
    "minecraft:phantom",
    "minecraft:skeleton",
    "minecraft:skeleton_horse",
    "minecraft:stray",
    "minecraft:wither",
    "minecraft:wither_skeleton",
    "minecraft:zoglin",
    "minecraft:zombie",
    "minecraft:zombie_horse",
    "minecraft:zombie_villager",
    "minecraft:zombified_piglin"
  ]
}

Then target those entities with the following target selector:

@e[type=#minecraft:undead]

If you're not using a data pack, then have one command per possible entity type, or switch to using a data pack (highly recommended)

Correct answer by ExpertCoder14 on May 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP