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.
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:
Hope that helps you. :)
In a repeating, always active command block type:
This will kill any entity that is not a player,skeleton or an item if you need to keep other entity's e.g. an ArmorStand add another comma and write the name of the entity you want to preserve so in this case you would add ,[type=!ArmorStand]
Hope this helps.