Baby zombie

Discussion in 'Spigot Plugin Development' started by harveycat1, May 30, 2017.

  1. how can i check the world for baby zombies with a certain name
     
  2. for(Entity en : Bukkit.getWorld("worldname").getEntities()) {
    if(en instanceof Zombie) {
    if(((Zombie) en).isBaby()) {
    if(en.getCustomName().equalsIgnoreCase("the name")) {

    }
    }
    }
    }
     
  3. Get all the entities in the world. Check if is an instance of Zombie. Cast is as an Ageable and checks if it's baby. Check then if its name using getCustomName (i think). Anyway, you should avoid check mobs in this way (Using their name), instead use metadata

    EDIT: Dani_R explained in the same moment
     
  4. The Zombie interface doesn't implement Ageable. After casting it to an instance of Zombie, just use the method: Zombie#isBaby().