if (entity instanceof Cow || entity instanceof Sheep) {
if(InventoryUtil.doesInventoryContain(inv.getInventory(), false, new ItemStack(Material.WHEAT, 2))) {
if(InventoryUtil.removeItemsFromInventory(inv, new ItemStack(Material.WHEAT, 2))) {
Ageable animal = (Ageable) entity.getWorld().spawnEntity(entity.getLocation(), entity.getType());
animal.setBaby();
((Ageable) entity).setBreed(false);
if(entity instanceof Sheep && animal instanceof Sheep)
((Sheep) animal).setColor(((Sheep) entity).getColor());
return true;
}
}
} else if (entity instanceof Pig) {
if(InventoryUtil.doesInventoryContain(inv.getInventory(), false, new ItemStack(Material.CARROT, 2))) {
if(InventoryUtil.removeItemsFromInventory(inv, new ItemStack(Material.CARROT, 2))) {
Ageable animal = (Ageable) entity.getWorld().spawnEntity(entity.getLocation(), entity.getType());
animal.setBaby();
((Ageable) entity).setBreed(false);
return true;
}
}
} else if (entity instanceof Chicken) {
if(InventoryUtil.doesInventoryContain(inv.getInventory(), false, new ItemStack(Material.SEEDS, 2))) {
if(InventoryUtil.removeItemsFromInventory(inv, new ItemStack(Material.SEEDS, 2))) {
Ageable animal = (Ageable) entity.getWorld().spawnEntity(entity.getLocation(), entity.getType());
animal.setBaby();
((Ageable) entity).setBreed(false);
return true;
}
}
} else if (entity instanceof Wolf) {
Material[] validItems = new Material[]{Material.RAW_CHICKEN, Material.COOKED_CHICKEN, Material.RAW_BEEF, Material.COOKED_BEEF, Material.PORK, Material.GRILLED_PORK, Material.ROTTEN_FLESH};
for(Material item : validItems) {
if(InventoryUtil.doesInventoryContain(inv.getInventory(), false, new ItemStack(item, 2))) {
if(InventoryUtil.removeItemsFromInventory(inv, new ItemStack(item, 2))) {
Ageable animal = (Ageable) entity.getWorld().spawnEntity(entity.getLocation(), entity.getType());
animal.setBaby();
((Ageable) entity).setBreed(false);
return true;
}
}
}