How do you spawn ONLY zombies in Singleplayer?

Solution 1:

Here are the brief steps to ensure only zombies and players live.

(Thanks Unionhawk for pointing out my mistake in the first answer and providing suggestions on this answer!)

  1. Make a redstone clock.

  2. Connect 4 command blocks into the redstone clock.

  3. Insert these commands into the command blocks:

    kill @e[type=Skeleton]
    
    kill @e[type=Creeper]
    
    kill @e[type=Enderman]
    
    kill @e[type=Spider]
    

    3.5 If you are in a superflat world you may want to add a kill Slime command.

  4. Remember to activate these command blocks at the same time.

  5. Activate the redstone clock.

  6. Done.

You can also make the super fast command block clock but you have to change the doTileDrops gamerule to false.


Here are the brief steps to spawn a zombie.

  1. Place a command block on the ground.

  2. set the following command:

    summon Zombie ~ ~2 ~
    
  3. Activate it.

This will make the zombie spawn 2 blocks on top of the command block.

Solution 2:

To spawn a zombie with a command block, type in the command:

/summon Zombie X Y Z

Replace X Y Z with the coordinates of where you want to spawn the zombie.

Solution 3:

Setup:

/scoreboard objectives add selector dummy

Clock(20tps)

/scoreboard players set @e selector 1
/scoreboard players set @e[type=<Type>] selector 0//One of these per entity type, in this case one for zombie and one for players
/tp @e[x=<X>,y=<Y>,z=<Z>,r=<Range>,score_selector_min=1] ~ ~-600 ~

First it marks all entites, then unmarks the selected entite(s), and finally teleports the marked entites down into the void so there is no dying animation and no items drop.

Solution 4:

Use a command block to set certain gamerules. If you program one with this command,

/gamerule doMobSpawning false

then mobs can only spawn if you spawn them in with /summon, a spawn egg, a dispenser, etc.