summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntityWolf.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityWolf.java')
-rw-r--r--src/main/java/net/minecraft/server/EntityWolf.java201
1 files changed, 116 insertions, 85 deletions
diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java
index 132b55f9..d3593bc0 100644
--- a/src/main/java/net/minecraft/server/EntityWolf.java
+++ b/src/main/java/net/minecraft/server/EntityWolf.java
@@ -1,60 +1,84 @@
package net.minecraft.server;
+import java.util.Iterator;
+import java.util.List;
+
public class EntityWolf extends EntityTameableAnimal {
- private float e;
- private float f;
- private boolean g;
- private boolean h;
- private float i;
- private float j;
+ private float bq;
+ private float br;
+ private boolean bs;
+ private boolean bt;
+ private float bu;
+ private float bv;
public EntityWolf(World world) {
super(world);
- this.texture = "/mob/wolf.png";
this.a(0.6F, 0.8F);
- this.bI = 0.3F;
this.getNavigation().a(true);
this.goalSelector.a(1, new PathfinderGoalFloat(this));
- this.goalSelector.a(2, this.d);
+ this.goalSelector.a(2, this.bp);
this.goalSelector.a(3, new PathfinderGoalLeapAtTarget(this, 0.4F));
- this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, this.bI, true));
- this.goalSelector.a(5, new PathfinderGoalFollowOwner(this, this.bI, 10.0F, 2.0F));
- this.goalSelector.a(6, new PathfinderGoalBreed(this, this.bI));
- this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, this.bI));
+ this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, 1.0D, true));
+ this.goalSelector.a(5, new PathfinderGoalFollowOwner(this, 1.0D, 10.0F, 2.0F));
+ this.goalSelector.a(6, new PathfinderGoalBreed(this, 1.0D));
+ this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D));
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));
+ this.targetSelector.a(4, new PathfinderGoalRandomTargetNonTamed(this, EntitySheep.class, 200, false));
+ this.setTamed(false);
}
- public boolean bh() {
+ protected void ax() {
+ super.ax();
+ this.a(GenericAttributes.d).a(0.30000001192092896D);
+ if (this.isTamed()) {
+ this.a(GenericAttributes.a).a(20.0D);
+ } else {
+ this.a(GenericAttributes.a).a(8.0D);
+ }
+ }
+
+ public boolean bb() {
return true;
}
public void setGoalTarget(EntityLiving entityliving) {
super.setGoalTarget(entityliving);
- if (entityliving instanceof EntityHuman) {
+ if (entityliving == null) {
+ if (!this.isAngry()) {
+ return;
+ }
+
+ this.setAngry(false);
+ List list = this.world.a(this.getClass(), AxisAlignedBB.a().a(this.locX, this.locY, this.locZ, this.locX + 1.0D, this.locY + 1.0D, this.locZ + 1.0D).grow(16.0D, 10.0D, 16.0D));
+ Iterator iterator = list.iterator();
+
+ while (iterator.hasNext()) {
+ EntityWolf entitywolf = (EntityWolf) iterator.next();
+
+ if (this != entitywolf) {
+ entitywolf.setAngry(false);
+ }
+ }
+ } else {
this.setAngry(true);
}
}
- protected void bp() {
- this.datawatcher.watch(18, Integer.valueOf(this.getScaledHealth())); // CraftBukkit - this.getHealth() -> this.getScaledHealth()
- }
-
- public int getMaxHealth() {
- return this.isTamed() ? 20 : 8;
+ protected void bg() {
+ this.datawatcher.watch(18, Float.valueOf(this.getScaledHealth())); // CraftBukkit - this.getHealth() -> this.getScaledHealth()
}
protected void a() {
super.a();
- this.datawatcher.a(18, new Integer(this.getHealth()));
+ this.datawatcher.a(18, new Float(this.getHealth()));
this.datawatcher.a(19, new Byte((byte) 0));
- this.datawatcher.a(20, new Byte((byte) BlockCloth.g_(1)));
+ this.datawatcher.a(20, new Byte((byte) BlockCloth.j_(1)));
}
protected void a(int i, int j, int k, int l) {
@@ -75,24 +99,20 @@ public class EntityWolf extends EntityTameableAnimal {
}
}
- protected boolean isTypeNotPersistent() {
- return this.isAngry() && !this.isTamed();
- }
-
- protected String bb() {
+ protected String r() {
// CraftBukkit - getInt(18) < 10 -> < this.maxHealth / 2
- return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getInt(18) < this.maxHealth / 2 ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
+ return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getFloat(18) < this.maxHealth / 2 ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
}
- protected String bc() {
+ protected String aK() {
return "mob.wolf.hurt";
}
- protected String bd() {
+ protected String aL() {
return "mob.wolf.death";
}
- protected float ba() {
+ protected float aW() {
return 0.4F;
}
@@ -102,49 +122,49 @@ public class EntityWolf extends EntityTameableAnimal {
public void c() {
super.c();
- if (!this.world.isStatic && this.g && !this.h && !this.k() && this.onGround) {
- this.h = true;
- this.i = 0.0F;
- this.j = 0.0F;
+ if (!this.world.isStatic && this.bs && !this.bt && !this.bI() && this.onGround) {
+ this.bt = true;
+ this.bu = 0.0F;
+ this.bv = 0.0F;
this.world.broadcastEntityEffect(this, (byte) 8);
}
}
public void l_() {
super.l_();
- this.f = this.e;
- if (this.bY()) {
- this.e += (1.0F - this.e) * 0.4F;
+ this.br = this.bq;
+ if (this.ca()) {
+ this.bq += (1.0F - this.bq) * 0.4F;
} else {
- this.e += (0.0F - this.e) * 0.4F;
+ this.bq += (0.0F - this.bq) * 0.4F;
}
- if (this.bY()) {
- this.bJ = 10;
+ if (this.ca()) {
+ this.g = 10;
}
if (this.F()) {
- this.g = true;
- this.h = false;
- this.i = 0.0F;
- this.j = 0.0F;
- } else if ((this.g || this.h) && this.h) {
- if (this.i == 0.0F) {
- this.makeSound("mob.wolf.shake", this.ba(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ this.bs = true;
+ this.bt = false;
+ this.bu = 0.0F;
+ this.bv = 0.0F;
+ } else if ((this.bs || this.bt) && this.bt) {
+ if (this.bu == 0.0F) {
+ this.makeSound("mob.wolf.shake", this.aW(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
}
- this.j = this.i;
- this.i += 0.05F;
- if (this.j >= 2.0F) {
- this.g = false;
- this.h = false;
- this.j = 0.0F;
- this.i = 0.0F;
+ this.bv = this.bu;
+ this.bu += 0.05F;
+ if (this.bv >= 2.0F) {
+ this.bs = false;
+ this.bt = false;
+ this.bv = 0.0F;
+ this.bu = 0.0F;
}
- if (this.i > 0.4F) {
+ if (this.bu > 0.4F) {
float f = (float) this.boundingBox.b;
- int i = (int) (MathHelper.sin((this.i - 0.4F) * 3.1415927F) * 7.0F);
+ int i = (int) (MathHelper.sin((this.bu - 0.4F) * 3.1415927F) * 7.0F);
for (int j = 0; j < i; ++j) {
float f1 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
@@ -160,32 +180,41 @@ public class EntityWolf extends EntityTameableAnimal {
return this.length * 0.8F;
}
- public int bs() {
- return this.isSitting() ? 20 : super.bs();
+ public int bl() {
+ return this.isSitting() ? 20 : super.bl();
}
- public boolean damageEntity(DamageSource damagesource, int i) {
+ public boolean damageEntity(DamageSource damagesource, float f) {
if (this.isInvulnerable()) {
return false;
} else {
Entity entity = damagesource.getEntity();
- this.d.setSitting(false);
+ this.bp.setSitting(false);
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
- i = (i + 1) / 2;
+ f = (f + 1.0F) / 2.0F;
}
- return super.damageEntity(damagesource, i);
+ return super.damageEntity(damagesource, f);
}
}
public boolean m(Entity entity) {
int i = this.isTamed() ? 4 : 2;
- return entity.damageEntity(DamageSource.mobAttack(this), i);
+ return entity.damageEntity(DamageSource.mobAttack(this), (float) i);
}
- public boolean a_(EntityHuman entityhuman) {
+ public void setTamed(boolean flag) {
+ super.setTamed(flag);
+ if (flag) {
+ this.a(GenericAttributes.a).a(20.0D);
+ } else {
+ this.a(GenericAttributes.a).a(8.0D);
+ }
+ }
+
+ public boolean a(EntityHuman entityhuman) {
ItemStack itemstack = entityhuman.inventory.getItemInHand();
if (this.isTamed()) {
@@ -193,12 +222,12 @@ public class EntityWolf extends EntityTameableAnimal {
if (Item.byId[itemstack.id] instanceof ItemFood) {
ItemFood itemfood = (ItemFood) Item.byId[itemstack.id];
- if (itemfood.i() && this.datawatcher.getInt(18) < 20) {
+ if (itemfood.j() && this.datawatcher.getFloat(18) < 20.0F) {
if (!entityhuman.abilities.canInstantlyBuild) {
--itemstack.count;
}
- this.heal(itemfood.getNutrition());
+ this.heal((float) itemfood.getNutrition());
if (itemstack.count <= 0) {
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
}
@@ -206,7 +235,7 @@ public class EntityWolf extends EntityTameableAnimal {
return true;
}
} else if (itemstack.id == Item.INK_SACK.id) {
- int i = BlockCloth.g_(itemstack.getData());
+ int i = BlockCloth.j_(itemstack.getData());
if (i != this.getCollarColor()) {
this.setCollarColor(i);
@@ -219,9 +248,9 @@ public class EntityWolf extends EntityTameableAnimal {
}
}
- if (entityhuman.name.equalsIgnoreCase(this.getOwnerName()) && !this.world.isStatic && !this.c(itemstack)) {
- this.d.setSitting(!this.isSitting());
- this.bG = false;
+ if (entityhuman.getName().equalsIgnoreCase(this.getOwnerName()) && !this.world.isStatic && !this.c(itemstack)) {
+ this.bp.setSitting(!this.isSitting());
+ this.bd = false;
this.setPathEntity((PathEntity) null);
}
} else if (itemstack != null && itemstack.id == Item.BONE.id && !this.isAngry()) {
@@ -240,18 +269,18 @@ public class EntityWolf extends EntityTameableAnimal {
this.setTamed(true);
this.setPathEntity((PathEntity) null);
this.setGoalTarget((EntityLiving) null);
- this.d.setSitting(true);
+ this.bp.setSitting(true);
// CraftBukkit start
if (updateMaxHealth) {
this.maxHealth = this.getMaxHealth();
}
this.setHealth(this.maxHealth);
// CraftBukkit end
- this.setOwnerName(entityhuman.name);
- this.i(true);
+ this.setOwnerName(entityhuman.getName());
+ this.j(true);
this.world.broadcastEntityEffect(this, (byte) 7);
} else {
- this.i(false);
+ this.j(false);
this.world.broadcastEntityEffect(this, (byte) 6);
}
}
@@ -259,14 +288,14 @@ public class EntityWolf extends EntityTameableAnimal {
return true;
}
- return super.a_(entityhuman);
+ return super.a(entityhuman);
}
public boolean c(ItemStack itemstack) {
- return itemstack == null ? false : (!(Item.byId[itemstack.id] instanceof ItemFood) ? false : ((ItemFood) Item.byId[itemstack.id]).i());
+ return itemstack == null ? false : (!(Item.byId[itemstack.id] instanceof ItemFood) ? false : ((ItemFood) Item.byId[itemstack.id]).j());
}
- public int by() {
+ public int br() {
return 8;
}
@@ -304,9 +333,7 @@ public class EntityWolf extends EntityTameableAnimal {
return entitywolf;
}
- public void m(boolean flag) {
- byte b0 = this.datawatcher.getByte(19);
-
+ public void n(boolean flag) {
if (flag) {
this.datawatcher.watch(19, Byte.valueOf((byte) 1));
} else {
@@ -324,14 +351,18 @@ public class EntityWolf extends EntityTameableAnimal {
} else {
EntityWolf entitywolf = (EntityWolf) entityanimal;
- return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.r() && entitywolf.r());
+ return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.bU() && entitywolf.bU());
}
}
- public boolean bY() {
+ public boolean ca() {
return this.datawatcher.getByte(19) == 1;
}
+ protected boolean isTypeNotPersistent() {
+ return !this.isTamed() && this.ticksLived > 2400;
+ }
+
public EntityAgeable createChild(EntityAgeable entityageable) {
return this.b(entityageable);
}