How do I prevent a specific mob from being killed by players?
I'm making a map in Minecraft. No mods, no Bukkit, no anything; just command blocks. and I have this one mob that I don't want players to be able to kill.
Normally, I would simply give it a resistance potion so that it couldn't be hurt, but I want other mobs to be able to hurt it, just not players.
Is it possible to make this mob unkillable by players, but still able to die by other mobs?
Best Answer
You could give the player a really strong weakness status effect if they're within melee range of the mob. This isn't exactly what you're looking for, since the player won't be able to kill any mobs within that region, even ones that they normally would elsewhere. If you're fine with that, then go right ahead.
If you also want it to be immune to player-shot arrows you could add
execute at @e[tag=enemy] run kill @e[type=arrow,distance=..2,nbt={pickup:1b}]
This only affects arrows shot by someone in survival or adventure mode, and not in creative. It also ignores arrows from entities like skeletons or pillagers.
Pictures about "How do I prevent a specific mob from being killed by players?"



Can you disable certain mobs in Minecraft?
Java Edition players can type \u201c/gamerule doMobSpawning false\u201d into the chat bar to disable mobs. You'll need to be a server admin and have cheats enabled. Keep in mind using this setting will also disable friendly spawns as well, like animals.How do you make a command block kill a specific mob?
If you want to kill mobs all at once then this step is the best.Minecraft| How to get rid specific Mobs?
More answers regarding how do I prevent a specific mob from being killed by players?
Answer 2
/summon ExampleMob ~ ~ ~ {Invulnerable:1}
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Brett Sayles, Brett Sayles, Karolina Grabowska, Karolina Grabowska
