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

109 Zeilen
3.3 KiB
Java

2011-03-16 16:13:42 +01:00
package net.minecraft.server;
// CraftBukkit start
import java.util.List;
2011-03-16 16:13:42 +01:00
import org.bukkit.Location;
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
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);
this.al().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 c_() {
return true;
2011-03-16 16:13:42 +01:00
}
2011-11-20 09:01:14 +01:00
public int getMaxHealth() {
return 10;
}
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);
}
2012-03-01 11:49:23 +01:00
protected String i() {
2011-03-16 16:13:42 +01:00
return "mob.cow";
}
2012-03-01 11:49:23 +01:00
protected String j() {
2011-03-16 16:13:42 +01:00
return "mob.cowhurt";
}
2012-03-01 11:49:23 +01:00
protected String k() {
2011-03-16 16:13:42 +01:00
return "mob.cowhurt";
}
2012-03-01 11:49:23 +01:00
protected float p() {
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
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-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
}
public boolean b(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?
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;
}
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, CraftItemStack.createNMSItemStack(event.getItemStack()));
2011-03-16 16:13:42 +01:00
// CraftBukkit end
return true;
} else {
2011-11-20 09:01:14 +01:00
return super.b(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
}