Minecraft – How to stop Zombie Villagers from spawning or Zombies

minecraft-commandsminecraft-java-edition

I am making a flat adventure/Survival map which is meant to be played for maybe a year or two and is made to make the game harder.

In the map when you spawn you have a big shop which is setted up with custom villagers using a online generator. There are 2 types of villagers one that sells items and one that buys items. Keep in mind the currency is emeralds.

But the problem is that zombie villagers are able to spawn within the world and I have only intended that the only way to achieve emeralds is by trading with the villagers within the shop.

I want some way to make them despawn or teleporting them to the void.

Keep in mind im not able to remove normal zombies due to that an important item within the shop is zombie flesh.

Best Answer

You will have to label zombies based on their IsVillager byte tag and then run commands based on the label.

1.8

Objective to use.

/scoreboard objectives add ZombieVillager dummy

Commands to run in numerical order.

  1. Set the "ZombieVillager" score to 1 for zombies with IsVillager set to 1.

    /scoreboard players set @e[type=Zombie] ZombieVillager 1 {IsVillager:1b}
    
  2. Teleport those zombies to the void.

    /tp @e[type=Zombie,score_ZombieVillager_min=1] ~ -64 ~
    

1.9

Commands to run in numerical order.

  1. Apply "ZombieVillager" label for zombies with IsVillager set to 1.

    /scoreboard players tag @e[type=Zombie,tag=!ZombieVillager] add ZombieVillager {IsVillager:1b}
    
  2. Teleport those zombies to the void.

    /tp @e[type=Zombie,tag=ZombieVillager] ~ -64 ~