/** * Begins Tree Feller * * @param player Player using Shake Mob * @param mob Targeted entity * @param skillLevel Fishing level of the player */ public static void process(Player player, LivingEntity mob, int skillLevel) { int activationChance = Misc.calculateActivationChance(Permissions.luckyFishing(player)); if (getShakeProbability(skillLevel) <= Misc.getRandom().nextInt(activationChance)) { return; } Map<ItemStack, Integer> possibleDrops = new HashMap<ItemStack, Integer>(); findPossibleDrops(mob, possibleDrops); if (possibleDrops.isEmpty()) { return; } ItemStack drop = chooseDrop(possibleDrops); // It's possible that chooseDrop returns null if the sum of probability in possibleDrops is // inferior than 100 if (drop == null) { return; } // Extra processing depending on the mob and drop type switch (mob.getType()) { case SHEEP: Sheep sheep = (Sheep) mob; if (drop.getType() == Material.WOOL) { if (sheep.isSheared()) { return; } // TODO: Find a cleaner way to do this, maybe by using Sheep.getColor().getWoolData() // (available since 1.4.7-R0.1) Wool wool = (Wool) drop.getData(); wool.setColor(sheep.getColor()); drop.setDurability(wool.getData()); sheep.setSheared(true); } break; case SKELETON: Skeleton skeleton = (Skeleton) mob; if (skeleton.getSkeletonType() == SkeletonType.WITHER) { switch (drop.getType()) { case SKULL_ITEM: drop.setDurability((short) 1); break; case ARROW: drop.setType(Material.COAL); break; default: break; } } default: break; } Misc.dropItem(mob.getLocation(), drop); CombatTools.dealDamage(mob, 1); // We may want to base the damage on the entity max health }