2011-03-16 16:13:42 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
// CraftBukkit start
|
2011-09-21 02:40:22 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2011-03-16 16:13:42 +01:00
|
|
|
import org.bukkit.Location;
|
2011-09-21 02:40:22 +02:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
2011-03-16 16:13:42 +01:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
2011-09-21 02:40:22 +02:00
|
|
|
import org.bukkit.event.entity.EntityDeathEvent;
|
2011-03-16 16:13:42 +01:00
|
|
|
import org.bukkit.event.player.PlayerBucketFillEvent;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
public class EntityCow extends EntityAnimal {
|
|
|
|
|
|
|
|
public EntityCow(World world) {
|
|
|
|
super(world);
|
|
|
|
this.texture = "/mob/cow.png";
|
2011-03-31 22:40:00 +02:00
|
|
|
this.b(0.9F, 1.3F);
|
2011-03-16 16:13:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
protected String h() {
|
2011-03-16 16:13:42 +01:00
|
|
|
return "mob.cow";
|
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
protected String i() {
|
2011-03-16 16:13:42 +01:00
|
|
|
return "mob.cowhurt";
|
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
protected String j() {
|
2011-03-16 16:13:42 +01:00
|
|
|
return "mob.cowhurt";
|
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
protected float l() {
|
2011-03-16 16:13:42 +01:00
|
|
|
return 0.4F;
|
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
protected int k() {
|
2011-03-16 16:13:42 +01:00
|
|
|
return Item.LEATHER.id;
|
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
protected void a(boolean flag) {
|
2011-09-21 02:40:22 +02:00
|
|
|
// CraftBukkit start - whole method
|
|
|
|
List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
|
|
|
int count = this.random.nextInt(3);
|
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(Item.LEATHER.id, count));
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-09-21 02:40:22 +02:00
|
|
|
count = this.random.nextInt(3) + 1;
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-09-21 02:40:22 +02:00
|
|
|
if (count > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(this.fireTicks > 0 ? Item.COOKED_BEEF.id : Item.RAW_BEEF.id, count));
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-09-21 16:41:24 +02:00
|
|
|
CraftEventFactory.callEntityDeathEvent(this, loot);
|
2011-09-21 02:40:22 +02:00
|
|
|
// CraftBukkit end
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b(EntityHuman entityhuman) {
|
2011-04-20 19:05:14 +02:00
|
|
|
ItemStack itemstack = entityhuman.inventory.getItemInHand();
|
2011-03-16 16:13:42 +01:00
|
|
|
|
|
|
|
if (itemstack != null && itemstack.id == Item.BUCKET.id) {
|
|
|
|
// CraftBukkit start - got milk?
|
|
|
|
Location loc = this.getBukkitEntity().getLocation();
|
|
|
|
PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Item.MILK_BUCKET);
|
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CraftItemStack itemInHand = (CraftItemStack) event.getItemStack();
|
|
|
|
byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
|
2011-05-14 16:29:42 +02:00
|
|
|
itemstack = new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data);
|
2011-03-16 16:13:42 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, itemstack);
|
2011-03-16 16:13:42 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|