Search in sources :

Example 1 with Chicken

use of org.bukkit.entity.Chicken in project EliteMobs by MagmaGuy.

the class ChickenHandler method superEggs.

public static void superEggs(Entity entity, int passiveStackAmount) {
    List<Chicken> tempChickenList = new ArrayList<>();
    if (entity instanceof Chicken && entity.hasMetadata(MetadataHandler.PASSIVE_ELITE_MOB_MD)) {
        tempChickenList.add((Chicken) entity);
    }
    if (tempChickenList.size() > 0) {
        Random random = new Random();
        int eggChance = random.nextInt(12000 / passiveStackAmount);
        //should spawn 1 by 1 but the odds of it spawning are scaled to fit config passivemob stack size
        if (eggChance == 1) {
            for (Chicken chicken : tempChickenList) {
                ItemStack eggStack = new ItemStack(EGG, 1);
                chicken.getWorld().dropItem(chicken.getLocation(), eggStack).setVelocity(ItemDropVelocity.ItemDropVelocity());
            }
        }
    }
}
Also used : Random(java.util.Random) ArrayList(java.util.ArrayList) Chicken(org.bukkit.entity.Chicken) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 Chicken (org.bukkit.entity.Chicken)1 ItemStack (org.bukkit.inventory.ItemStack)1