Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 71 lines 2.0 kB view raw
1package net.minecraft.server; 2 3// CraftBukkit start 4 5import org.bukkit.Location; 6import org.bukkit.craftbukkit.event.CraftEventFactory; 7import org.bukkit.craftbukkit.inventory.CraftItemStack; 8import org.bukkit.event.player.PlayerBucketFillEvent; 9// CraftBukkit end 10 11public class EntityCow extends EntityAnimal { 12 13 public EntityCow(World world) { 14 super(world); 15 this.texture = "/mob/cow.png"; 16 this.b(0.9F, 1.3F); 17 } 18 19 public void b(NBTTagCompound nbttagcompound) { 20 super.b(nbttagcompound); 21 } 22 23 public void a(NBTTagCompound nbttagcompound) { 24 super.a(nbttagcompound); 25 } 26 27 protected String g() { 28 return "mob.cow"; 29 } 30 31 protected String h() { 32 return "mob.cowhurt"; 33 } 34 35 protected String i() { 36 return "mob.cowhurt"; 37 } 38 39 protected float k() { 40 return 0.4F; 41 } 42 43 protected int j() { 44 return Item.LEATHER.id; 45 } 46 47 public boolean a(EntityHuman entityhuman) { 48 ItemStack itemstack = entityhuman.inventory.getItemInHand(); 49 50 if (itemstack != null && itemstack.id == Item.BUCKET.id) { 51 // CraftBukkit start - got milk? 52 Location loc = this.getBukkitEntity().getLocation(); 53 PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Item.MILK_BUCKET); 54 55 if (event.isCancelled()) { 56 return false; 57 } 58 59 CraftItemStack itemInHand = (CraftItemStack) event.getItemStack(); 60 byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData(); 61 itemstack = new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data); 62 63 entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, itemstack); 64 // CraftBukkit end 65 66 return true; 67 } else { 68 return false; 69 } 70 } 71}