public static void spawnGuildVender(Location location) {
   Villager villager = (Villager) Bukkit.getWorld("world").spawn(location, (Class) Villager.class);
   villager.setCustomName("§aGuild Vender");
   villager.setCustomNameVisible(true);
   villager.setProfession(Villager.Profession.LIBRARIAN);
   villager.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 999999, 20));
 }
 @Override
 public void setVillagerProfession(Villager villager, int profession) {
   try {
     Profession prof = Profession.getProfession(profession);
     if (prof != null) {
       villager.setProfession(prof);
     } else {
       villager.setProfession(Profession.FARMER);
     }
   } catch (Exception e) {
   }
 }
  public static void MoveVillagersBack() {
    if (EpicSystem.useCitizens()) return;

    Object[] villagerArray = entityList.keySet().toArray();
    for (Object entity : villagerArray) {
      if (!(entity instanceof Villager)) continue;
      Villager tempVil = (Villager) entity;
      QuestEntity qEntity = GetQuestEntity(tempVil);

      if (qEntity != null && qEntity.originalLocation != null)
        tempVil.teleport(qEntity.originalLocation);
    }
  }
  @Override
  public Hostage getHostage(Entity entity) {
    Hostage h;
    try {
      h = (Hostage) ((CraftEntity) entity).getHandle();
    } catch (ClassCastException ex) {
      // Caused by baby villager or a non-Hostage Villager.
      plugin
          .debug()
          .log(
              "onHostageInteract() ClassCastException: most likely "
                  + "caused by a baby villager or a Villager that is not a Hostage.");

      Villager v = (Villager) entity;
      World world = ((CraftWorld) v.getWorld()).getHandle();

      CraftHostage hostage = new CraftHostage(world, v.getProfession().getId());
      hostage.setLocation(v.getLocation());

      world.removeEntity(((CraftEntity) entity).getHandle());
      world.addEntity(hostage);

      hostage.setHealth((float) v.getHealth());
      hostage.setProfessionType(v.getProfession());
      hostage.setCustomName(v.getCustomName());

      return hostage;
    }
    return h;
  }
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  void onEntityInteract(PlayerInteractEntityEvent event) {
    if (!(event.getRightClicked() instanceof Villager)) return;
    Villager villager = (Villager) event.getRightClicked();

    if (plugin.isShopkeeper(villager)) return; // shopkeeper interaction is handled elsewhere
    Log.debug("Interaction with Non-shopkeeper villager ..");

    if (villager.hasMetadata("NPC")) {
      // ignore any interaction with citizens2 NPCs
      Log.debug("  ignoring (probably citizens2) NPC");
      return;
    }

    Player player = event.getPlayer();
    if (Settings.disableOtherVillagers) {
      // don't allow trading with other villagers
      event.setCancelled(true);
      if (Settings.hireOtherVillagers) {
        // allow hiring of other villagers
        Log.debug("  trade prevented, but possible hire ..");
        if (this.handleHireOtherVillager(player, villager)) {
          // hiring was successful -> prevent normal trading
          Log.debug("    ..success");
        } else {

        }
      } else {
        Log.debug("  trade prevented");
      }
    } else if (Settings.hireOtherVillagers) {
      // allow hiring of other villagers
      Log.debug("  possible hire ..");
      if (this.handleHireOtherVillager(player, villager)) {
        // hiring was successful -> prevent normal trading
        Log.debug("    ..success (normal trading prevented)");
        event.setCancelled(true);
      } else {
        // hiring was not successful -> no preventing of normal villager trading
        Log.debug("    ..failed");
      }
    }
  }
  /*
   * Villager specific methods
   */
  public static Villager SpawnVillager(World world, Location loc, String name) {
    if (EpicSystem.useCitizens()) return null;

    // Check if villager exists
    if (GetEntity(world, name) != null) {
      RemoveVillager(world, name);
    }

    // Set properties
    Villager villager = (Villager) world.spawnEntity(loc, EntityType.VILLAGER);
    villager.setCustomName(name);
    villager.setCustomNameVisible(true);
    villager.setAgeLock(true);
    villager.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000000000, 100000000));
    villager.setCanPickupItems(false);

    QuestEntity epicVillager = new QuestEntity(villager);
    epicVillager.originalLocation = loc;

    entityList.put(villager, epicVillager);

    return villager;
  }
Beispiel #7
0
  protected SpellResult alterEntity(Entity entity) {
    EntityType entityType = entity.getType();
    switch (entityType) {
      case PAINTING:
        registerModified(entity);
        Painting painting = (Painting) entity;
        Art[] artValues = Art.values();
        Art oldArt = painting.getArt();
        Art newArt = oldArt;
        int ordinal = (oldArt.ordinal() + 1);
        for (int i = 0; i < artValues.length; i++) {
          newArt = artValues[ordinal++ % artValues.length];
          painting.setArt(newArt);
          newArt = painting.getArt();
          if (oldArt != newArt) {
            break;
          }
        }
        if (oldArt == newArt) {
          return SpellResult.FAIL;
        }
        mage.sendDebugMessage("Altering art from " + oldArt + " to " + newArt);
        break;
      case ITEM_FRAME:
        ItemFrame itemFrame = (ItemFrame) entity;
        ItemStack frameItem = itemFrame.getItem();
        if (frameItem == null || frameItem.getType() != Material.MAP) {
          return SpellResult.NO_TARGET;
        }
        short data = frameItem.getDurability();
        data++;
        MapView mapView = DeprecatedUtils.getMap(data);
        if (mapView == null) {
          data = 0;
          mapView = DeprecatedUtils.getMap(data);
          if (mapView == null) {
            return SpellResult.NO_TARGET;
          }
        }
        registerModified(entity);
        frameItem.setDurability(data);
        itemFrame.setItem(frameItem);
        break;
      case HORSE:
        registerModified(entity);
        Horse horse = (Horse) entity;

        Color color = horse.getColor();
        Color[] colorValues = Color.values();
        color = colorValues[(color.ordinal() + 1) % colorValues.length];

        Variant variant = horse.getVariant();
        Variant[] variantValues = Variant.values();
        variant = variantValues[(variant.ordinal() + 1) % variantValues.length];

        Style horseStyle = horse.getStyle();
        Style[] styleValues = Style.values();
        horseStyle = styleValues[(horseStyle.ordinal() + 1) % styleValues.length];

        horse.setStyle(horseStyle);
        horse.setColor(color);
        horse.setVariant(variant);
        break;
      case OCELOT:
        registerModified(entity);
        Ocelot ocelot = (Ocelot) entity;
        Type catType = ocelot.getCatType();
        Type[] typeValues = Type.values();
        catType = typeValues[(catType.ordinal() + 1) % typeValues.length];
        ocelot.setCatType(catType);
        break;
      case VILLAGER:
        registerModified(entity);
        Villager villager = (Villager) entity;
        Profession profession = villager.getProfession();
        Profession[] professionValues = Profession.values();
        profession = professionValues[(profession.ordinal() + 1) % professionValues.length];
        villager.setProfession(profession);
        break;
      case WOLF:
        registerModified(entity);
        Wolf wolf = (Wolf) entity;
        DyeColor wolfColor = wolf.getCollarColor();
        DyeColor[] wolfColorValues = DyeColor.values();
        wolfColor = wolfColorValues[(wolfColor.ordinal() + 1) % wolfColorValues.length];
        wolf.setCollarColor(wolfColor);
        break;
      case SHEEP:
        registerModified(entity);
        Sheep sheep = (Sheep) entity;
        DyeColor dyeColor = sheep.getColor();
        DyeColor[] dyeColorValues = DyeColor.values();
        dyeColor = dyeColorValues[(dyeColor.ordinal() + 1) % dyeColorValues.length];
        sheep.setColor(dyeColor);
        break;
      case SKELETON:
        registerModified(entity);
        Skeleton skeleton = (Skeleton) entity;
        SkeletonType skeletonType = skeleton.getSkeletonType();
        SkeletonType[] skeletonTypeValues = SkeletonType.values();
        skeletonType = skeletonTypeValues[(skeletonType.ordinal() + 1) % skeletonTypeValues.length];
        skeleton.setSkeletonType(skeletonType);
        break;
      default:
        return SpellResult.NO_TARGET;
    }
    ;
    registerForUndo();
    return SpellResult.CAST;
  }
  // returns false, if the player wasn't able to hire this villager
  @SuppressWarnings("deprecation")
  // because of player.updateInventory()
  private boolean handleHireOtherVillager(Player player, Villager villager) {
    // hire him if holding his hiring item
    ItemStack inHand = player.getItemInHand();
    if (Settings.isHireItem(inHand)) {
      Inventory inventory = player.getInventory();
      // check if the player has enough of those hiring items
      int costs = Settings.hireOtherVillagersCosts;
      if (costs > 0) {
        if (Utils.hasInventoryItemsAtLeast(
            inventory, Settings.hireItem, (short) Settings.hireItemData, costs)) {
          Log.debug("  Villager hiring: the player has the needed amount of hiring items");
          int inHandAmount = inHand.getAmount();
          int remaining = inHandAmount - costs;
          Log.debug(
              "  Villager hiring: in hand="
                  + inHandAmount
                  + " costs="
                  + costs
                  + " remaining="
                  + remaining);
          if (remaining > 0) {
            inHand.setAmount(remaining);
          } else { // remaining <= 0
            player.setItemInHand(null); // remove item in hand
            if (remaining < 0) {
              // remove remaining costs from inventory
              Utils.removeItemsFromInventory(
                  inventory, Settings.hireItem, (short) Settings.hireItemData, -remaining);
            }
          }
        } else {
          Utils.sendMessage(player, Settings.msgCantHire);
          return false;
        }
      }

      // give player the creation item
      ItemStack creationItem = Settings.createCreationItem();
      Map<Integer, ItemStack> remaining = inventory.addItem(creationItem);
      if (!remaining.isEmpty()) {
        villager.getWorld().dropItem(villager.getLocation(), creationItem);
      }

      // remove the entity:
      villager.remove();

      // update client's inventory
      player.updateInventory();

      Utils.sendMessage(player, Settings.msgHired);
      return true;
    } else {
      Utils.sendMessage(
          player,
          Settings.msgVillagerForHire,
          "{costs}",
          String.valueOf(Settings.hireOtherVillagersCosts),
          "{hire-item}",
          Settings.hireItem.toString());
    }
    return false;
  }
Beispiel #9
0
  public static void setEntityTypeData(final Entity entity, final String data) {
    if (data == "") return;

    final String parts[] = data.split(",");
    if (entity instanceof LivingEntity) {
      ((LivingEntity) entity).setMaxHealth(Double.parseDouble(parts[1]));
      ((LivingEntity) entity).setHealth(Double.parseDouble(parts[0]));
      if (!parts[2].equals("null")) ((LivingEntity) entity).setCustomName(parts[2]);
      if (entity instanceof Animals) {
        ((Animals) entity).setAge(Integer.parseInt(parts[3]));
        if (entity instanceof Sheep) {
          ((Sheep) entity).setSheared(Boolean.parseBoolean(parts[4]));
          ((Sheep) entity).setColor(sheepColors.get(parts[5]));
        } else if (entity instanceof Wolf) {
          if (Boolean.parseBoolean(parts[4])) {
            ((Wolf) entity).setAngry(Boolean.parseBoolean(parts[4]));
          } else if (parts.length > 5) {
            ((Tameable) entity).setTamed(true);
            ((Tameable) entity).setOwner(getPlayer(parts[5]));
            ((Wolf) entity).setCollarColor(DyeColor.valueOf(parts[6]));
          }
        } else if (entity instanceof Ocelot) {
          if (parts.length > 4) {
            ((Tameable) entity).setTamed(true);
            ((Tameable) entity).setOwner(getPlayer(parts[4]));
            ((Ocelot) entity).setCatType(catTypes.get(parts[5]));
          }
        } else if (entity instanceof Pig) {
          ((Pig) entity).setSaddle(Boolean.parseBoolean(parts[4]));
        } else if (entity instanceof Horse) {
          ((Horse) entity).setVariant(horseVariants.get(parts[4]));
          ((Horse) entity).setStyle(horseStyles.get(parts[5]));
          ((Horse) entity).setColor(horseColors.get(parts[6]));
          ((Horse) entity).setDomestication(Integer.parseInt(parts[7]));
          ((Horse) entity).setMaxDomestication(Integer.parseInt(parts[8]));
          ((Horse) entity).setJumpStrength(Double.parseDouble(parts[9]));
          if (parts.length > 10) {
            ((Tameable) entity).setTamed(true);
            if (!parts[10].equals("null")) ((Tameable) entity).setOwner(getPlayer(parts[10]));
            ((Horse) entity)
                .getInventory()
                .setSaddle(ItemStackUtil.stringToItemStack(parts[11])[0]);
            ((Horse) entity).getInventory().setArmor(ItemStackUtil.stringToItemStack(parts[12])[0]);
            if (parts.length > 13) {
              ((Horse) entity).setCarryingChest(true);
              ((Horse) entity)
                  .getInventory()
                  .setContents(ItemStackUtil.stringToItemStack(parts[13]));
            }
          }
        }
      } else if (entity instanceof Villager) {
        ((Villager) entity).setProfession(villagerProfessions.get(parts[3]));
        ((Villager) entity).setAge(Integer.parseInt(parts[4]));
      } else if (entity instanceof Creeper) {
        ((Creeper) entity).setPowered(Boolean.parseBoolean(parts[3]));
      } else if (entity instanceof Slime) {
        ((Slime) entity).setSize(Integer.parseInt(parts[3]));
      } else if (entity instanceof Skeleton) {
        ((Skeleton) entity).setSkeletonType(skeletonTypes.get(parts[3]));
        if (parts[3].equals("0")) {
          ((Skeleton) entity).getEquipment().setItemInHand(new ItemStack(Material.BOW));
        } else {
          ((Skeleton) entity).getEquipment().setItemInHand(new ItemStack(Material.BOW));
        }
      } else if (entity instanceof PigZombie) {
        ((LivingEntity) entity).getEquipment().setItemInHand(new ItemStack(Material.GOLD_SWORD));
      }
    }
  }
  @SuppressWarnings("deprecation")
  public void assignMobProps(Entity baseEntity, ISpawnableEntity data) {

    // This needs to be before everything else!
    if (data.getRider() != null) {
      addRider(baseEntity, data.getRider());
    }

    Vector v1 = data.getVelocity(baseEntity);
    Vector v2 = data.getVelocity2(baseEntity);
    if (v2.getX() == 0 && v2.getY() == 0 && v2.getZ() == 0) {
      baseEntity.setVelocity(data.getVelocity(baseEntity).clone());
    } else {
      Vector v3 = randomVector(v1, v2);
      baseEntity.setVelocity(v3.clone());
    }
    baseEntity.setFireTicks(data.getFireTicks(baseEntity));

    if (baseEntity instanceof LivingEntity) {
      LivingEntity entity = (LivingEntity) baseEntity;
      setBasicProps(entity, data);

      if (data.showCustomName()) {
        setCustomName(entity, data);
      }

      if (entity instanceof Ageable) {
        Ageable a = (Ageable) entity;
        setAgeProps(a, data);
      }

      if (entity instanceof Animals) {
        Animals animal = (Animals) entity;

        // Setting animal specific properties
        if (animal instanceof Pig) {
          Pig p = (Pig) animal;
          p.setSaddle(data.isSaddled());
        } else if (animal instanceof Sheep) {
          Sheep s = (Sheep) animal;
          DyeColor color = DyeColor.valueOf(data.getColor());
          s.setColor(color);
        } else if (animal instanceof Wolf) {
          Wolf w = (Wolf) animal;
          w.setAngry(data.isAngry());
          w.setTamed(data.isTamed());
          if (data.isTamed()) {

            ArrayList<Player> nearPlayers = getNearbyPlayers(w.getLocation(), 16);
            int index = (int) Math.round(Math.rint(nearPlayers.size() - 1));
            if (nearPlayers != null) {
              w.setOwner(nearPlayers.get(index));
            }

            w.setSitting(data.isSitting());
          }
        } else if (animal instanceof Ocelot) {
          Ocelot o = (Ocelot) animal;
          o.setTamed(data.isTamed());
          if (data.isTamed()) {
            Ocelot.Type catType = Ocelot.Type.valueOf(data.getCatType());
            o.setCatType(catType);

            ArrayList<Player> nearPlayers = getNearbyPlayers(o.getLocation(), 16);
            int index = (int) Math.round(Math.rint(nearPlayers.size() - 1));
            if (nearPlayers != null) {
              o.setOwner(nearPlayers.get(index));
            }

            o.setSitting(data.isSitting());
          }
        }
      } else if (entity instanceof Villager) {
        Villager v = (Villager) entity;
        v.setAge(data.getAge(baseEntity));
        v.setProfession(data.getProfession());
      } else if (entity instanceof Monster) {
        Monster monster = (Monster) entity;

        // Setting monster specific properties.
        if (monster instanceof Enderman) {
          Enderman e = (Enderman) monster;
          e.setCarriedMaterial(data.getEndermanBlock());
        } else if (monster instanceof Creeper) {
          Creeper c = (Creeper) monster;
          c.setPowered(data.isCharged());
        } else if (monster instanceof PigZombie) {
          PigZombie p = (PigZombie) monster;
          if (data.isAngry()) {
            p.setAngry(true);
          }
          p.setBaby((data.getAge(baseEntity) < -1) ? true : false);
        } else if (monster instanceof Spider) {
          Spider s = (Spider) monster;
          if (data.isJockey()) {
            makeJockey(s, data);
          }
        } else if (monster instanceof Zombie) {
          Zombie z = (Zombie) monster;
          boolean isVillager = false;
          if (data.hasProp("zombie")) {
            isVillager = (Boolean) (data.getProp("zombie"));
          }
          z.setBaby((data.getAge(baseEntity) < -1) ? true : false);
          z.setVillager(isVillager);
        } else if (monster instanceof Skeleton) {
          Skeleton sk = (Skeleton) monster;
          SkeletonType skType = SkeletonType.NORMAL;

          if (data.hasProp("wither")) {
            skType =
                ((Boolean) (data.getProp("wither")) == true)
                    ? SkeletonType.WITHER
                    : SkeletonType.NORMAL;
          }

          sk.setSkeletonType(skType);
        }
      } else if (entity instanceof Golem) {
        Golem golem = (Golem) entity;

        if (golem instanceof IronGolem) {
          IronGolem i = (IronGolem) golem;
          if (data.isAngry()) {
            ArrayList<Player> nearPlayers = getNearbyPlayers(i.getLocation(), 16);
            int index = (int) Math.round(Math.rint(nearPlayers.size() - 1));
            if (nearPlayers != null) {
              i.setPlayerCreated(false);
              i.damage(0, nearPlayers.get(index));
              i.setTarget(nearPlayers.get(index));
            }
          }
        }
        // Some are not classified as animals or monsters
      } else if (entity instanceof Slime) {
        Slime s = (Slime) entity;
        s.setSize(data.getSlimeSize());
      } else if (entity instanceof MagmaCube) {
        MagmaCube m = (MagmaCube) entity;
        m.setSize(data.getSlimeSize());
      }

    } else if (baseEntity instanceof Projectile) {
      Projectile pro = (Projectile) baseEntity;

      // Eventually add explosive arrows and such :D

      if (pro instanceof Fireball) {
        Fireball f = (Fireball) pro;
        setExplosiveProps(f, data);
        f.setVelocity(new Vector(0, 0, 0));
        f.setDirection(data.getVelocity(baseEntity));
      } else if (pro instanceof SmallFireball) {
        SmallFireball f = (SmallFireball) pro;
        setExplosiveProps(f, data);
        f.setVelocity(new Vector(0, 0, 0));
        f.setDirection(data.getVelocity(baseEntity));
      }

    } else if (baseEntity instanceof Explosive) {

      Explosive ex = (Explosive) baseEntity;

      if (ex instanceof TNTPrimed) {
        TNTPrimed tnt = (TNTPrimed) ex;
        setExplosiveProps(tnt, data);
        tnt.setFuseTicks(data.getFuseTicks(baseEntity));
      }

    } else if (baseEntity instanceof Firework) {

      Firework f = (Firework) baseEntity;
      ItemMeta meta = data.getItemType().getItemMeta();
      if (meta != null) {
        if (meta instanceof FireworkMeta) {
          FireworkMeta fMeta = (FireworkMeta) meta;
          if (fMeta != null) {
            f.setFireworkMeta(fMeta);
          }
        }
      }

    } else if (baseEntity instanceof Minecart) {

      Minecart m = (Minecart) baseEntity;
      if (data.hasProp("minecartSpeed")) {
        m.setMaxSpeed((Double) data.getProp("minecartSpeed"));
      }

    } else if (baseEntity instanceof ExperienceOrb) {
      ExperienceOrb o = (ExperienceOrb) baseEntity;
      o.setExperience(data.getDroppedExp(baseEntity));
    }

    setNBT(baseEntity, data);
  }
Beispiel #11
0
    public List<LivingEntity> spawn(Location location, Player player) {
      List<LivingEntity> entities = new ArrayList<LivingEntity>(this.num);
      World world = location.getWorld();

      for (int num = 0; num < this.num; num++) {
        if (spread > 0) {
          int minX = location.getBlockX() - spread / 2;
          int minY = location.getBlockY() - spread / 2;
          int minZ = location.getBlockZ() - spread / 2;
          int maxX = location.getBlockX() + spread / 2;
          int maxY = location.getBlockY() + spread / 2;
          int maxZ = location.getBlockZ() + spread / 2;

          int tries = spread * 10;
          boolean found = false;

          while (tries-- > 0) {
            int x = minX + RecipeManager.random.nextInt(maxX - minX);
            int z = minZ + RecipeManager.random.nextInt(maxZ - minZ);
            int y = 0;

            for (y = maxY; y >= minY; y--) {
              if (!Material.getMaterial(world.getBlockTypeIdAt(x, y, z)).isSolid()) {
                found = true;
                break;
              }
            }

            if (found) {
              location.setX(x);
              location.setY(y);
              location.setZ(z);
              break;
            }
          }

          if (!found) {
            Messages.debug(
                "Couldn't find suitable location after " + (spread * 10) + " tries, using center.");
          }

          location.add(0.5, 0, 0.5);
        }

        LivingEntity ent = (LivingEntity) world.spawnEntity(location, type);
        entities.add(ent);

        if (!noEffect) {
          world.playEffect(location, Effect.MOBSPAWNER_FLAMES, 20);
        }

        if (name != null) {
          ent.setCustomName(name);
          ent.setCustomNameVisible(noHideName);
        }

        if (onFire > 0.0f) {
          ent.setFireTicks((int) Math.ceil(onFire * 20.0));
        }

        if (pickup != null) {
          ent.setCanPickupItems(pickup);
        }

        if (pet && ent instanceof Tameable) {
          Tameable npc = (Tameable) ent;
          npc.setOwner(player);
          npc.setTamed(true);
        }

        if (ent instanceof Wolf) {
          Wolf npc = (Wolf) ent;

          if (pet) {
            if (noSit) {
              npc.setSitting(false);
            }

            if (color != null) {
              npc.setCollarColor(color);
            }
          } else if (angry) {
            npc.setAngry(true);
          }
        }

        if (ent instanceof Ocelot) {
          Ocelot npc = (Ocelot) ent;

          if (pet && noSit) {
            npc.setSitting(false);
          }

          if (cat != null) {
            npc.setCatType(cat);
          }
        }

        if (hp > 0) {
          ent.setHealth(hp);

          if (maxHp > 0) {
            ent.setMaxHealth(maxHp);
          }
        }

        if (ent instanceof Ageable) {
          Ageable npc = (Ageable) ent;

          if (baby) {
            npc.setBaby();
          }

          if (ageLock) {
            npc.setAgeLock(true);
          }

          if (noBreed) {
            npc.setBreed(false);
          }
        }

        if (saddle && ent instanceof Pig) {
          Pig npc = (Pig) ent;
          npc.setSaddle(true);

          if (mount) {
            npc.setPassenger(player);
          }
        }

        if (ent instanceof Zombie) {
          Zombie npc = (Zombie) ent;

          if (baby) {
            npc.setBaby(true);
          }

          if (zombieVillager) {
            npc.setVillager(true);
          }
        }

        if (villager != null && ent instanceof Villager) {
          Villager npc = (Villager) ent;
          npc.setProfession(villager);
        }

        if (poweredCreeper && ent instanceof Creeper) {
          Creeper npc = (Creeper) ent;
          npc.setPowered(true);
        }

        if (playerIronGolem && ent instanceof IronGolem) {
          IronGolem npc = (IronGolem) ent;
          npc.setPlayerCreated(true); // TODO what exacly does this do ?
        }

        if (shearedSheep && ent instanceof Sheep) {
          Sheep npc = (Sheep) ent;
          npc.setSheared(true);
        }

        if (color != null && ent instanceof Colorable) {
          Colorable npc = (Colorable) ent;
          npc.setColor(color);
        }

        if (skeleton != null && ent instanceof Skeleton) {
          Skeleton npc = (Skeleton) ent;
          npc.setSkeletonType(skeleton);
        }

        if (target && ent instanceof Creature) {
          Creature npc = (Creature) ent;
          npc.setTarget(player);
        }

        if (pigAnger > 0 && ent instanceof PigZombie) {
          PigZombie npc = (PigZombie) ent;
          npc.setAnger(pigAnger);
        }

        if (hit) {
          ent.damage(0, player);
          ent.setVelocity(new Vector());
        }

        if (!potions.isEmpty()) {
          for (PotionEffect effect : potions) {
            ent.addPotionEffect(effect, true);
          }
        }

        ent.setRemoveWhenFarAway(!noRemove);

        EntityEquipment eq = ent.getEquipment();

        for (int i = 0; i < equip.length; i++) {
          ItemStack item = equip[i];

          if (item == null) {
            continue;
          }

          switch (i) {
            case 0:
              eq.setHelmet(item);
              eq.setHelmetDropChance(drop[i]);
              break;

            case 1:
              eq.setChestplate(item);
              eq.setChestplateDropChance(drop[i]);
              break;

            case 2:
              eq.setLeggings(item);
              eq.setLeggingsDropChance(drop[i]);
              break;

            case 3:
              eq.setBoots(item);
              eq.setBootsDropChance(drop[i]);
              break;

            case 4:
              {
                if (ent instanceof Enderman) {
                  Enderman npc = (Enderman) ent;
                  npc.setCarriedMaterial(item.getData());
                } else {
                  eq.setItemInHand(item);
                  eq.setItemInHandDropChance(drop[i]);
                }

                break;
              }
          }
        }
      }

      return entities;
    }