2011-03-16 16:13:42 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
|
|
// CraftBukkit end
|
2011-03-16 16:13:42 +01:00
|
|
|
|
|
|
|
public class EntityCow extends EntityAnimal {
|
|
|
|
|
|
|
|
public EntityCow(World world) {
|
|
|
|
super(world);
|
|
|
|
this.texture = "/mob/cow.png";
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(0.9F, 1.3F);
|
|
|
|
this.getNavigation().a(true);
|
2012-03-01 11:49:23 +01:00
|
|
|
this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
|
|
|
this.goalSelector.a(1, new PathfinderGoalPanic(this, 0.38F));
|
|
|
|
this.goalSelector.a(2, new PathfinderGoalBreed(this, 0.2F));
|
|
|
|
this.goalSelector.a(3, new PathfinderGoalTempt(this, 0.25F, Item.WHEAT.id, false));
|
|
|
|
this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 0.25F));
|
|
|
|
this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, 0.2F));
|
|
|
|
this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
|
|
|
|
this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this));
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public boolean be() {
|
2012-03-01 11:49:23 +01:00
|
|
|
return true;
|
2011-03-16 16:13:42 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public int getMaxHealth() {
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
protected String aY() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.cow.say";
|
2011-03-16 16:13:42 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
protected String aZ() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.cow.hurt";
|
2011-03-16 16:13:42 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
protected String ba() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return "mob.cow.hurt";
|
2011-03-16 16:13:42 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
protected void a(int i, int j, int k, int l) {
|
2012-11-06 13:05:28 +01:00
|
|
|
this.makeSound("mob.cow.step", 0.15F, 1.0F);
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
protected float aX() {
|
2011-03-16 16:13:42 +01:00
|
|
|
return 0.4F;
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
protected int getLootId() {
|
2011-03-16 16:13:42 +01:00
|
|
|
return Item.LEATHER.id;
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
protected void dropDeathLoot(boolean flag, int i) {
|
2011-09-21 02:40:22 +02:00
|
|
|
// CraftBukkit start - whole method
|
2012-07-22 08:18:00 +02:00
|
|
|
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
2011-11-20 09:01:14 +01:00
|
|
|
int j = this.random.nextInt(3) + this.random.nextInt(1 + i);
|
2011-09-21 02:40:22 +02:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
int k;
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (j > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(Item.LEATHER.id, j));
|
2011-09-21 02:40:22 +02:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
j = this.random.nextInt(3) + 1 + this.random.nextInt(1 + i);
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (j > 0) {
|
2012-01-14 21:03:48 +01:00
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(this.isBurning() ? Item.COOKED_BEEF.id : Item.RAW_BEEF.id, j));
|
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
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public boolean a(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?
|
2012-07-22 08:18:00 +02:00
|
|
|
org.bukkit.Location loc = this.getBukkitEntity().getLocation();
|
|
|
|
org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Item.MILK_BUCKET);
|
2011-03-16 16:13:42 +01:00
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (--itemstack.count <= 0) {
|
2012-12-17 08:31:41 +01:00
|
|
|
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, CraftItemStack.asNMSCopy(event.getItemStack()));
|
2012-07-29 09:33:13 +02:00
|
|
|
} else if (!entityhuman.inventory.pickup(new ItemStack(Item.MILK_BUCKET))) {
|
2012-12-17 08:31:41 +01:00
|
|
|
entityhuman.drop(CraftItemStack.asNMSCopy(event.getItemStack()));
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2011-03-16 16:13:42 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
2012-11-06 13:05:28 +01:00
|
|
|
return super.a(entityhuman);
|
2011-03-16 16:13:42 +01:00
|
|
|
}
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public EntityCow b(EntityAgeable entityageable) {
|
2011-11-20 09:01:14 +01:00
|
|
|
return new EntityCow(this.world);
|
|
|
|
}
|
2012-11-06 13:05:28 +01:00
|
|
|
|
|
|
|
public EntityAgeable createChild(EntityAgeable entityageable) {
|
|
|
|
return this.b(entityageable);
|
|
|
|
}
|
2011-03-16 16:13:42 +01:00
|
|
|
}
|