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

161 Zeilen
4.9 KiB
Java

package net.minecraft.server;
2013-11-04 14:07:38 +01:00
import org.bukkit.craftbukkit.util.CraftMagicNumbers; // CraftBukkit
public class EntityChicken extends EntityAnimal {
2013-07-01 13:03:00 +02:00
public float bp;
public float bq;
public float br;
public float bs;
public float bt = 1.0F;
public int bu;
2014-03-21 05:26:30 +01:00
public boolean bv;
public EntityChicken(World world) {
super(world);
2012-07-29 09:33:13 +02:00
this.a(0.3F, 0.7F);
2013-07-01 13:03:00 +02:00
this.bu = this.random.nextInt(6000) + 6000;
2012-03-01 11:49:23 +01:00
this.goalSelector.a(0, new PathfinderGoalFloat(this));
2013-07-01 13:03:00 +02:00
this.goalSelector.a(1, new PathfinderGoalPanic(this, 1.4D));
this.goalSelector.a(2, new PathfinderGoalBreed(this, 1.0D));
2013-11-04 14:07:38 +01:00
this.goalSelector.a(3, new PathfinderGoalTempt(this, 1.0D, Items.SEEDS, false));
2013-07-01 13:03:00 +02:00
this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 1.1D));
this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, 1.0D));
2012-03-01 11:49:23 +01:00
this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this));
}
2014-03-21 05:26:30 +01:00
public boolean bj() {
2012-03-01 11:49:23 +01:00
return true;
}
2014-03-21 05:26:30 +01:00
protected void aC() {
super.aC();
2013-07-09 01:43:37 +02:00
this.getAttributeInstance(GenericAttributes.a).setValue(4.0D);
this.getAttributeInstance(GenericAttributes.d).setValue(0.25D);
2011-11-20 09:01:14 +01:00
}
2013-11-04 14:07:38 +01:00
public void e() {
super.e();
2013-07-01 13:03:00 +02:00
this.bs = this.bp;
this.br = this.bq;
this.bq = (float) ((double) this.bq + (double) (this.onGround ? -1 : 4) * 0.3D);
if (this.bq < 0.0F) {
this.bq = 0.0F;
}
2013-07-01 13:03:00 +02:00
if (this.bq > 1.0F) {
this.bq = 1.0F;
}
2013-07-01 13:03:00 +02:00
if (!this.onGround && this.bt < 1.0F) {
this.bt = 1.0F;
}
2013-07-01 13:03:00 +02:00
this.bt = (float) ((double) this.bt * 0.9D);
if (!this.onGround && this.motY < 0.0D) {
this.motY *= 0.6D;
}
2013-07-01 13:03:00 +02:00
this.bp += this.bt * 2.0F;
2014-04-11 03:04:38 +02:00
if (!this.world.isStatic && !this.isBaby() && !this.bZ() && --this.bu <= 0) {
2012-11-06 13:05:28 +01:00
this.makeSound("mob.chicken.plop", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
2013-11-04 14:07:38 +01:00
this.a(Items.EGG, 1);
2013-07-01 13:03:00 +02:00
this.bu = this.random.nextInt(6000) + 6000;
}
}
2013-07-01 13:03:00 +02:00
protected void b(float f) {}
2013-11-04 14:07:38 +01:00
protected String t() {
return "mob.chicken.say";
}
2014-03-21 05:26:30 +01:00
protected String aS() {
return "mob.chicken.hurt";
}
2014-03-21 05:26:30 +01:00
protected String aT() {
return "mob.chicken.hurt";
}
2013-11-04 14:07:38 +01:00
protected void a(int i, int j, int k, Block block) {
2012-11-06 13:05:28 +01:00
this.makeSound("mob.chicken.step", 0.15F, 1.0F);
}
2013-11-04 14:07:38 +01:00
protected Item getLoot() {
return Items.FEATHER;
}
protected void dropDeathLoot(boolean flag, int i) {
2013-03-25 05:22:32 +01:00
// 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);
if (j > 0) {
2013-11-04 14:07:38 +01:00
loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.FEATHER), j));
2011-11-20 09:01:14 +01:00
}
if (this.isBurning()) {
2013-11-04 14:07:38 +01:00
loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.COOKED_CHICKEN), 1));
2011-11-20 09:01:14 +01:00
} else {
2013-11-04 14:07:38 +01:00
loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.RAW_CHICKEN), 1));
}
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
2011-11-20 09:01:14 +01:00
2012-11-06 13:05:28 +01:00
public EntityChicken b(EntityAgeable entityageable) {
2011-11-20 09:01:14 +01:00
return new EntityChicken(this.world);
}
public boolean c(ItemStack itemstack) {
return itemstack != null && itemstack.getItem() instanceof ItemSeeds;
}
2012-11-06 13:05:28 +01:00
2014-03-21 05:26:30 +01:00
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
this.bv = nbttagcompound.getBoolean("IsChickenJockey");
}
protected int getExpValue(EntityHuman entityhuman) {
return this.bZ() ? 10 : super.getExpValue(entityhuman);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setBoolean("IsChickenJockey", this.bv);
}
protected boolean isTypeNotPersistent() {
return this.bZ() && this.passenger == null;
}
public void ab() {
super.ab();
float f = MathHelper.sin(this.aM * 3.1415927F / 180.0F);
float f1 = MathHelper.cos(this.aM * 3.1415927F / 180.0F);
float f2 = 0.1F;
float f3 = 0.0F;
this.passenger.setPosition(this.locX + (double) (f2 * f), this.locY + (double) (this.length * 0.5F) + this.passenger.ac() + (double) f3, this.locZ - (double) (f2 * f1));
if (this.passenger instanceof EntityLiving) {
((EntityLiving) this.passenger).aM = this.aM;
}
}
public boolean bZ() {
return this.bv;
}
public void i(boolean flag) {
this.bv = flag;
}
2012-11-06 13:05:28 +01:00
public EntityAgeable createChild(EntityAgeable entityageable) {
return this.b(entityageable);
}
}