Minecraft – Why does kill @e[type=!minecraft:bat] kill every mob

minecraft-commandsminecraft-java-edition

I was tired of the sheer mass of bats I had in my intentionally dimly lit tunnel, so I typed in that command. Then I died. Then I saw that all my pets and animals were also gone. I'm playing in 1.14.2, is there a bug I do not know of or am I doing it wrong?

Best Answer

Your selector, @e[type=!minecraft:bat] includes a !, which inverts the selection. In this case, the kill command killed every entity that was not a bat, when you really wanted @e[type=minecraft:bat]. Unfortunately, unless you have a backup, there's no real way to recover from this as far as I know.