use of org.bukkit.entity.ZombieVillager in project Denizen-For-Bukkit by DenizenScript.
the class EntityInfected method setInfected.
public void setInfected(boolean bool) {
if (bool) {
if (infected.isCitizensNPC()) {
NPC infected_npc = infected.getDenizenNPC().getCitizen();
infected_npc.setBukkitEntityType(EntityType.ZOMBIE_VILLAGER);
} else // TODO: Improve upon.
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_11_R1)) {
LivingEntity entity = infected.getLivingEntity();
// Make a new entity
ZombieVillager infect = (ZombieVillager) entity.getLocation().getWorld().spawnEntity(infected.getLocation(), EntityType.ZOMBIE_VILLAGER);
// Set health
infect.setHealth(entity.getHealth());
// Set equipment
infect.getEquipment().setArmorContents(entity.getEquipment().getArmorContents());
// Remove the Villager
entity.remove();
// Set the dEntity to the new entity
infected.setEntity(infect);
} else // TODO: Improve upon.
if (infected.getBukkitEntity() instanceof Villager) {
Villager villager = (Villager) infected.getBukkitEntity();
// Make a new entity
Zombie infect = (Zombie) villager.getLocation().getWorld().spawnEntity(infected.getLocation(), EntityType.ZOMBIE);
infect.setVillager(true);
// Set health
infect.setHealth(villager.getHealth());
// Set equipment
infect.getEquipment().setArmorContents(villager.getEquipment().getArmorContents());
// Remove the Villager
villager.remove();
// Set the dEntity to the new entity
infected.setEntity(infect);
} else // Much much easier
if (infected.getBukkitEntity() instanceof Zombie) {
((Zombie) infected).setVillager(true);
}
}
}
Aggregations