Horses will drop now their inventory when caught.

This commit is contained in:
shansen 2013-12-19 00:43:51 +00:00
parent 370304f1fa
commit 7aaadba6e3

View File

@ -31,6 +31,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
@ -269,6 +270,23 @@ public class EggCatcherEntityListener implements Listener {
}
}
if(entity instanceof Horse) {
if(((Horse) entity).isCarryingChest()){
entity.getWorld().dropItemNaturally(entity.getLocation(), new ItemStack(Material.CHEST));
}
}
if(entity instanceof InventoryHolder){
ItemStack[] items = ((InventoryHolder) entity).getInventory().getContents();
for(ItemStack itemStack : items) {
if(itemStack!=null){
entity.getWorld().dropItemNaturally(entity.getLocation(), itemStack);
}
}
}
entity.getWorld().dropItem(entity.getLocation(), eggStack);
if (!this.spawnChickenOnSuccess) {