
net.minecraft.server.EntityChicken Maven / Gradle / Ivy
package net.minecraft.server;
import org.bukkit.entity.Chicken;
import org.jetbrains.annotations.NotNull;
public class EntityChicken extends EntityAnimal {
public float bm;
public float bo;
public float bp;
public float bq;
public float br = 1.0F;
public int bs;
public boolean bt;
public EntityChicken(World world) {
super(world);
this.setSize(0.4F, 0.7F);
this.bs = this.random.nextInt(6000) + 6000;
this.goalSelector.addTask(0, new PathfinderGoalFloat(this));
this.goalSelector.addTask(1, new PathfinderGoalPanic(this, 1.4D));
this.goalSelector.addTask(2, new PathfinderGoalBreed(this, 1.0D));
this.goalSelector.addTask(3, new PathfinderGoalTempt(this, 1.0D, Items.WHEAT_SEEDS, false));
this.goalSelector.addTask(4, new PathfinderGoalFollowParent(this, 1.1D));
this.goalSelector.addTask(5, new PathfinderGoalRandomStroll(this, 1.0D));
this.goalSelector.addTask(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
this.goalSelector.addTask(7, new PathfinderGoalRandomLookaround(this));
}
public float getHeadHeight() {
return this.length;
}
@NotNull
@Override
public Chicken getEntityBukkit() {
return (Chicken) super.getEntityBukkit();
}
protected void initAttributes() {
super.initAttributes();
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(4.0D);
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.25D);
}
public void onLivingUpdate() {
// CraftBukkit start
if (this.isChickenJockey()) {
this.persistent = !this.isTypeNotPersistent();
}
// CraftBukkit end
super.onLivingUpdate();
this.bq = this.bm;
this.bp = this.bo;
this.bo = (float) ((double) this.bo + (double) (this.onGround ? -1 : 4) * 0.3D);
this.bo = MathHelper.a(this.bo, 0.0F, 1.0F);
if (!this.onGround && this.br < 1.0F) {
this.br = 1.0F;
}
this.br = (float) ((double) this.br * 0.9D);
if (!this.onGround && this.motY < 0.0D) {
this.motY *= 0.6D;
}
this.bm += this.br * 2.0F;
if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bs <= 0) {
this.playSound("mob.chicken.plop", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
this.dropItem(Items.EGG, 1);
this.bs = this.random.nextInt(6000) + 6000;
}
}
public void fall(float f, float f1) {
}
protected String getLivingSound() {
return "mob.chicken.say";
}
protected String getHurtSound() {
return "mob.chicken.hurt";
}
protected String getDeathSound() {
return "mob.chicken.hurt";
}
protected void playStepSound(BlockPosition pos, Block block) {
this.playSound("mob.chicken.step", 0.15F, 1.0F);
}
protected Item getLoot() {
return Items.FEATHER;
}
protected void dropDeathLoot(boolean wasRecentlyHit, int lootingModifier) {
int j = this.random.nextInt(3) + this.random.nextInt(1 + lootingModifier);
for (int k = 0; k < j; ++k) {
this.dropItem(Items.FEATHER, 1);
}
if (this.isBurning()) {
this.dropItem(Items.COOKED_CHICKEN, 1);
} else {
this.dropItem(Items.CHICKEN, 1);
}
}
public EntityChicken b(EntityAgeable entityageable) {
return new EntityChicken(this.world);
}
public boolean d(ItemStack itemstack) {
return itemstack != null && itemstack.getItem() == Items.WHEAT_SEEDS;
}
public void loadEntityData(NBTTagCompound tag) {
super.loadEntityData(tag);
this.bt = tag.getBoolean("IsChickenJockey");
if (tag.hasKey("EggLayTime")) {
this.bs = tag.getInt("EggLayTime");
}
}
protected int getExpValue(EntityHuman player) {
return this.isChickenJockey() ? 10 : super.getExpValue(player);
}
public void saveEntityData(NBTTagCompound tag) {
super.saveEntityData(tag);
tag.setBoolean("IsChickenJockey", this.bt);
tag.setInt("EggLayTime", this.bs);
}
protected boolean isTypeNotPersistent() {
return this.isChickenJockey() && this.passenger == null;
}
public void updateRiderPosition() {
super.updateRiderPosition();
float f = MathHelper.sin(this.renderYawOffset * 3.1415927F / 180.0F);
float f1 = MathHelper.cos(this.renderYawOffset * 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.getYOffset() + (double) f3, this.locZ - (double) (f2 * f1));
if (this.passenger instanceof EntityLiving) {
((EntityLiving) this.passenger).renderYawOffset = this.renderYawOffset;
}
}
public boolean isChickenJockey() {
return this.bt;
}
public void l(boolean flag) {
this.bt = flag;
}
public EntityAgeable createChild(EntityAgeable entityageable) {
return this.b(entityageable);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy