Unfortunately, you'll have to have one command for each different mob you want to modify. It is not possible to target a group of mobs in one target selector.
Or is it?
If you just go to your chat and begin typing /effect give @e[type=
, you'll notice that in addition to all the different mob listings, there are also entries that begin with a #
, and if you try those, you'll notice that they do function as group entries, allowing you to specify a set of entity types contained within that group.
So these are some preset group entries, but they aren't much use to us unless we have one that contains the exact listings of entity types we need. If only there was some way to create our own group entries, hmm…
Well, guess what? With a data pack, you can! In data pack lingo, these #
group entries are called entity type tags, and you can create one as part of a data pack. Creating the data pack itself is outside the scope of this post, but once it is created, you can create a file at /data/<namespace>/tags/entity_types/<tag_name>.json
, replacing <namespace>
and <tag_name>
with appropriate values.
The contents of said file are quite simple:
{
"values": [
"first_entry",
"second_entry",
…
]
}
where each set of " "
contains the ID of one entity type.
Load your data pack into your world, and you should be able to target your new tag file with @e[type=#<namespace>:<tag name>]
.