Paper/src/main/java/net/minecraft/server/EntityCow.java

107 Zeilen
3.4 KiB
Java

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));
}
public boolean bb() {
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;
}
protected String aW() {
return "mob.cow.say";
2011-03-16 16:13:42 +01:00
}
protected String aX() {
return "mob.cow.hurt";
2011-03-16 16:13:42 +01:00
}
protected String aY() {
return "mob.cow.hurt";
2011-03-16 16:13:42 +01:00
}
protected void a(int i, int j, int k, int l) {
this.world.makeSound(this, "mob.cow.step", 0.15F, 1.0F);
}
protected float aV() {
2011-03-16 16:13:42 +01:00
return 0.4F;
}
protected int getLootId() {
2011-03-16 16:13:42 +01:00
return Item.LEATHER.id;
}
protected void dropDeathLoot(boolean flag, int i) {
// CraftBukkit start - whole method
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);
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-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) {
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
}
CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
2011-09-15 02:23:52 +02:00
}
2012-07-29 09:33:13 +02:00
public boolean c(EntityHuman entityhuman) {
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?
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) {
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, CraftItemStack.createNMSItemStack(event.getItemStack()));
} else if (!entityhuman.inventory.pickup(new ItemStack(Item.MILK_BUCKET))) {
entityhuman.drop(CraftItemStack.createNMSItemStack(event.getItemStack()));
}
2011-03-16 16:13:42 +01:00
// CraftBukkit end
return true;
} else {
2012-07-29 09:33:13 +02:00
return super.c(entityhuman);
2011-03-16 16:13:42 +01:00
}
}
2011-11-20 09:01:14 +01:00
2012-03-01 11:49:23 +01:00
public EntityAnimal createChild(EntityAnimal entityanimal) {
2011-11-20 09:01:14 +01:00
return new EntityCow(this.world);
}
2011-03-16 16:13:42 +01:00
}