2012-03-10 03:52:32 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
public class EntityWolf extends EntityTameableAnimal {
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private float e;
|
|
|
|
private float f;
|
|
|
|
private boolean g;
|
2012-03-10 03:52:32 +01:00
|
|
|
private boolean h;
|
2012-07-29 09:33:13 +02:00
|
|
|
private float i;
|
2012-03-10 03:52:32 +01:00
|
|
|
private float j;
|
|
|
|
|
|
|
|
public EntityWolf(World world) {
|
|
|
|
super(world);
|
|
|
|
this.texture = "/mob/wolf.png";
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(0.6F, 0.8F);
|
|
|
|
this.bw = 0.3F;
|
|
|
|
this.getNavigation().a(true);
|
2012-03-10 03:52:32 +01:00
|
|
|
this.goalSelector.a(1, new PathfinderGoalFloat(this));
|
2012-07-29 09:33:13 +02:00
|
|
|
this.goalSelector.a(2, this.d);
|
2012-03-10 03:52:32 +01:00
|
|
|
this.goalSelector.a(3, new PathfinderGoalLeapAtTarget(this, 0.4F));
|
2012-07-29 09:33:13 +02:00
|
|
|
this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, this.bw, true));
|
|
|
|
this.goalSelector.a(5, new PathfinderGoalFollowOwner(this, this.bw, 10.0F, 2.0F));
|
|
|
|
this.goalSelector.a(6, new PathfinderGoalBreed(this, this.bw));
|
|
|
|
this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, this.bw));
|
2012-03-10 03:52:32 +01:00
|
|
|
this.goalSelector.a(8, new PathfinderGoalBeg(this, 8.0F));
|
|
|
|
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
|
|
|
|
this.goalSelector.a(9, new PathfinderGoalRandomLookaround(this));
|
|
|
|
this.targetSelector.a(1, new PathfinderGoalOwnerHurtByTarget(this));
|
|
|
|
this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this));
|
|
|
|
this.targetSelector.a(3, new PathfinderGoalHurtByTarget(this, true));
|
|
|
|
this.targetSelector.a(4, new PathfinderGoalRandomTargetNonTamed(this, EntitySheep.class, 16.0F, 200, false));
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean aV() {
|
2012-03-10 03:52:32 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(EntityLiving entityliving) {
|
|
|
|
super.b(entityliving);
|
|
|
|
if (entityliving instanceof EntityHuman) {
|
|
|
|
this.setAngry(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void bd() {
|
2012-03-10 03:52:32 +01:00
|
|
|
this.datawatcher.watch(18, Integer.valueOf(this.getHealth()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getMaxHealth() {
|
|
|
|
return this.isTamed() ? 20 : 8;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a() {
|
|
|
|
super.a();
|
2012-03-10 03:52:32 +01:00
|
|
|
this.datawatcher.a(18, new Integer(this.getHealth()));
|
2012-07-29 09:33:13 +02:00
|
|
|
this.datawatcher.a(19, new Byte((byte) 0));
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected boolean e_() {
|
2012-03-10 03:52:32 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(NBTTagCompound nbttagcompound) {
|
|
|
|
super.b(nbttagcompound);
|
|
|
|
nbttagcompound.setBoolean("Angry", this.isAngry());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
super.a(nbttagcompound);
|
|
|
|
this.setAngry(nbttagcompound.getBoolean("Angry"));
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected boolean ba() {
|
2012-03-10 03:52:32 +01:00
|
|
|
return this.isAngry();
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected String aQ() {
|
2012-03-10 03:52:32 +01:00
|
|
|
return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getInt(18) < 10 ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected String aR() {
|
2012-03-10 03:52:32 +01:00
|
|
|
return "mob.wolf.hurt";
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected String aS() {
|
2012-03-10 03:52:32 +01:00
|
|
|
return "mob.wolf.death";
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected float aP() {
|
2012-03-10 03:52:32 +01:00
|
|
|
return 0.4F;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int getLootId() {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void d() {
|
|
|
|
super.d();
|
|
|
|
if (!this.world.isStatic && this.g && !this.h && !this.l() && this.onGround) {
|
|
|
|
this.h = true;
|
|
|
|
this.i = 0.0F;
|
2012-03-10 03:52:32 +01:00
|
|
|
this.j = 0.0F;
|
|
|
|
this.world.broadcastEntityEffect(this, (byte) 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void h_() {
|
|
|
|
super.h_();
|
|
|
|
this.f = this.e;
|
|
|
|
if (this.bv()) {
|
|
|
|
this.e += (1.0F - this.e) * 0.4F;
|
2012-03-10 03:52:32 +01:00
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.e += (0.0F - this.e) * 0.4F;
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.bv()) {
|
|
|
|
this.bx = 10;
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.G()) {
|
|
|
|
this.g = true;
|
|
|
|
this.h = false;
|
|
|
|
this.i = 0.0F;
|
2012-03-10 03:52:32 +01:00
|
|
|
this.j = 0.0F;
|
2012-07-29 09:33:13 +02:00
|
|
|
} else if ((this.g || this.h) && this.h) {
|
|
|
|
if (this.i == 0.0F) {
|
|
|
|
this.world.makeSound(this, "mob.wolf.shake", this.aP(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.j = this.i;
|
|
|
|
this.i += 0.05F;
|
|
|
|
if (this.j >= 2.0F) {
|
|
|
|
this.g = false;
|
2012-03-10 03:52:32 +01:00
|
|
|
this.h = false;
|
|
|
|
this.j = 0.0F;
|
2012-07-29 09:33:13 +02:00
|
|
|
this.i = 0.0F;
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.i > 0.4F) {
|
2012-03-10 03:52:32 +01:00
|
|
|
float f = (float) this.boundingBox.b;
|
2012-07-29 09:33:13 +02:00
|
|
|
int i = (int) (MathHelper.sin((this.i - 0.4F) * 3.1415927F) * 7.0F);
|
2012-03-10 03:52:32 +01:00
|
|
|
|
|
|
|
for (int j = 0; j < i; ++j) {
|
|
|
|
float f1 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
|
|
|
|
float f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
|
|
|
|
|
|
|
|
this.world.a("splash", this.locX + (double) f1, (double) (f + 0.8F), this.locZ + (double) f2, this.motX, this.motY, this.motZ);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getHeadHeight() {
|
|
|
|
return this.length * 0.8F;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int bf() {
|
|
|
|
return this.isSitting() ? 20 : super.bf();
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean damageEntity(DamageSource damagesource, int i) {
|
|
|
|
Entity entity = damagesource.getEntity();
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.d.a(false);
|
2012-03-10 03:52:32 +01:00
|
|
|
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
|
|
|
|
i = (i + 1) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.damageEntity(damagesource, i);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean k(Entity entity) {
|
2012-03-10 03:52:32 +01:00
|
|
|
int i = this.isTamed() ? 4 : 2;
|
|
|
|
|
|
|
|
return entity.damageEntity(DamageSource.mobAttack(this), i);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean c(EntityHuman entityhuman) {
|
2012-03-10 03:52:32 +01:00
|
|
|
ItemStack itemstack = entityhuman.inventory.getItemInHand();
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.isTamed()) {
|
2012-03-10 03:52:32 +01:00
|
|
|
if (itemstack != null && Item.byId[itemstack.id] instanceof ItemFood) {
|
|
|
|
ItemFood itemfood = (ItemFood) Item.byId[itemstack.id];
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (itemfood.h() && this.datawatcher.getInt(18) < 20) {
|
2012-03-30 23:33:51 +02:00
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
--itemstack.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.heal(itemfood.getNutrition());
|
2012-03-10 03:52:32 +01:00
|
|
|
if (itemstack.count <= 0) {
|
|
|
|
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (entityhuman.name.equalsIgnoreCase(this.getOwnerName()) && !this.world.isStatic && !this.b(itemstack)) {
|
|
|
|
this.d.a(!this.isSitting());
|
|
|
|
this.bu = false;
|
2012-03-10 03:52:32 +01:00
|
|
|
this.setPathEntity((PathEntity) null);
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
} else if (itemstack != null && itemstack.id == Item.BONE.id && !this.isAngry()) {
|
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
--itemstack.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itemstack.count <= 0) {
|
|
|
|
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.world.isStatic) {
|
|
|
|
// CraftBukkit - added event call and isCancelled check.
|
|
|
|
if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
|
|
|
|
this.setTamed(true);
|
|
|
|
this.setPathEntity((PathEntity) null);
|
|
|
|
this.b((EntityLiving) null);
|
|
|
|
this.d.a(true);
|
|
|
|
this.setHealth(20);
|
|
|
|
this.setOwnerName(entityhuman.name);
|
|
|
|
this.e(true);
|
|
|
|
this.world.broadcastEntityEffect(this, (byte) 7);
|
|
|
|
} else {
|
|
|
|
this.e(false);
|
|
|
|
this.world.broadcastEntityEffect(this, (byte) 6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
return super.c(entityhuman);
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean b(ItemStack itemstack) {
|
|
|
|
return itemstack == null ? false : (!(Item.byId[itemstack.id] instanceof ItemFood) ? false : ((ItemFood) Item.byId[itemstack.id]).h());
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int bl() {
|
2012-03-10 03:52:32 +01:00
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAngry() {
|
|
|
|
return (this.datawatcher.getByte(16) & 2) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAngry(boolean flag) {
|
|
|
|
byte b0 = this.datawatcher.getByte(16);
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 2)));
|
|
|
|
} else {
|
|
|
|
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -3)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityAnimal createChild(EntityAnimal entityanimal) {
|
|
|
|
EntityWolf entitywolf = new EntityWolf(this.world);
|
|
|
|
|
|
|
|
entitywolf.setOwnerName(this.getOwnerName());
|
|
|
|
entitywolf.setTamed(true);
|
|
|
|
return entitywolf;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void i(boolean flag) {
|
|
|
|
byte b0 = this.datawatcher.getByte(19);
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
this.datawatcher.watch(19, Byte.valueOf((byte) 1));
|
|
|
|
} else {
|
|
|
|
this.datawatcher.watch(19, Byte.valueOf((byte) 0));
|
|
|
|
}
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean mate(EntityAnimal entityanimal) {
|
|
|
|
if (entityanimal == this) {
|
|
|
|
return false;
|
|
|
|
} else if (!this.isTamed()) {
|
|
|
|
return false;
|
|
|
|
} else if (!(entityanimal instanceof EntityWolf)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
EntityWolf entitywolf = (EntityWolf) entityanimal;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.s() && entitywolf.s());
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
|
|
|
public boolean bv() {
|
|
|
|
return this.datawatcher.getByte(19) == 1;
|
|
|
|
}
|
2012-03-10 03:52:32 +01:00
|
|
|
}
|