Minecraft – How to prevent all hostile mobs from spawning except for skeletons

minecraft-commandsminecraft-java-edition

I am trying to make a map where only skeletons and non-hostile mobs are able to spawn. Is there a command that can do this? I don't want a redstone clock because that will lag my game and spam the chat. I am using 1.10.2.

Best Answer

Try This

Enter this command in chat:

/scoreboard objectives add noKill dummy

Then run these commands on a repeating command block or clock:

/scoreboard players set @e noKill 1
/scoreboard players set @e[type=Player] noKill 0
/scoreboard players set @e[type=Skeleton] noKill 0

Keep adding entities that you don't want to be killed

Then this command will kill all entities that don't have a noKill score of 0:

/kill @e[score_noKill_min=1]

Hope that helps you. :)