summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntityCreature.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityCreature.java')
-rw-r--r--src/main/java/net/minecraft/server/EntityCreature.java144
1 files changed, 110 insertions, 34 deletions
diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java
index 4d91a461..052f2338 100644
--- a/src/main/java/net/minecraft/server/EntityCreature.java
+++ b/src/main/java/net/minecraft/server/EntityCreature.java
@@ -1,33 +1,43 @@
package net.minecraft.server;
+import java.util.UUID;
+
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.event.entity.EntityTargetEvent;
// CraftBukkit end
-public abstract class EntityCreature extends EntityLiving {
+public abstract class EntityCreature extends EntityInsentient {
+ public static final UUID h = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A");
+ public static final AttributeModifier i = (new AttributeModifier(h, "Fleeing speed bonus", 2.0D, 2)).a(false);
public PathEntity pathEntity; // CraftBukkit - private -> public
public Entity target; // CraftBukkit - protected -> public
- protected boolean b = false;
- protected int c = 0;
+ protected boolean bn;
+ protected int bo;
+ private ChunkCoordinates bq = new ChunkCoordinates(0, 0, 0);
+ private float br = -1.0F;
+ private PathfinderGoal bs = new PathfinderGoalMoveTowardsRestriction(this, 1.0D);
+ private boolean bt;
public EntityCreature(World world) {
super(world);
}
- protected boolean h() {
+ protected boolean bF() {
return false;
}
- protected void bq() {
+ protected void bh() {
this.world.methodProfiler.a("ai");
- if (this.c > 0) {
- --this.c;
+ if (this.bo > 0 && --this.bo == 0) {
+ AttributeInstance attributeinstance = this.a(GenericAttributes.d);
+
+ attributeinstance.b(i);
}
- this.b = this.h();
- float f = 16.0F;
+ this.bn = this.bF();
+ float f11 = 16.0F;
if (this.target == null) {
// CraftBukkit start
@@ -47,12 +57,12 @@ public abstract class EntityCreature extends EntityLiving {
// CraftBukkit end
if (this.target != null) {
- this.pathEntity = this.world.findPath(this, this.target, f, true, false, false, true);
+ this.pathEntity = this.world.findPath(this, this.target, f11, true, false, false, true);
}
} else if (this.target.isAlive()) {
float f1 = this.target.d((Entity) this);
- if (this.n(this.target)) {
+ if (this.o(this.target)) {
this.a(this.target, f1);
}
} else {
@@ -71,10 +81,10 @@ public abstract class EntityCreature extends EntityLiving {
}
this.world.methodProfiler.b();
- if (!this.b && this.target != null && (this.pathEntity == null || this.random.nextInt(20) == 0)) {
- this.pathEntity = this.world.findPath(this, this.target, f, true, false, false, true);
- } else if (!this.b && (this.pathEntity == null && this.random.nextInt(180) == 0 || this.random.nextInt(120) == 0 || this.c > 0) && this.bC < 100) {
- this.i();
+ if (!this.bn && this.target != null && (this.pathEntity == null || this.random.nextInt(20) == 0)) {
+ this.pathEntity = this.world.findPath(this, this.target, f11, true, false, false, true);
+ } else if (!this.bn && (this.pathEntity == null && this.random.nextInt(180) == 0 || this.random.nextInt(120) == 0 || this.bo > 0) && this.aV < 100) {
+ this.bG();
}
int i = MathHelper.floor(this.boundingBox.b + 0.5D);
@@ -97,7 +107,7 @@ public abstract class EntityCreature extends EntityLiving {
}
}
- this.bG = false;
+ this.bd = false;
if (vec3d != null) {
double d1 = vec3d.c - this.locX;
double d2 = vec3d.e - this.locZ;
@@ -106,7 +116,7 @@ public abstract class EntityCreature extends EntityLiving {
float f2 = (float) (org.bukkit.craftbukkit.TrigMath.atan2(d2, d1) * 180.0D / 3.1415927410125732D) - 90.0F;
float f3 = MathHelper.g(f2 - this.yaw);
- this.bE = this.bI;
+ this.bf = (float) this.a(GenericAttributes.d).e();
if (f3 > 30.0F) {
f3 = 30.0F;
}
@@ -116,19 +126,19 @@ public abstract class EntityCreature extends EntityLiving {
}
this.yaw += f3;
- if (this.b && this.target != null) {
+ if (this.bn && this.target != null) {
double d4 = this.target.locX - this.locX;
double d5 = this.target.locZ - this.locZ;
float f4 = this.yaw;
this.yaw = (float) (Math.atan2(d5, d4) * 180.0D / 3.1415927410125732D) - 90.0F;
f3 = (f4 - this.yaw + 90.0F) * 3.1415927F / 180.0F;
- this.bD = -MathHelper.sin(f3) * this.bE * 1.0F;
- this.bE = MathHelper.cos(f3) * this.bE * 1.0F;
+ this.be = -MathHelper.sin(f3) * this.bf * 1.0F;
+ this.bf = MathHelper.cos(f3) * this.bf * 1.0F;
}
if (d3 > 0.0D) {
- this.bG = true;
+ this.bd = true;
}
}
@@ -136,22 +146,22 @@ public abstract class EntityCreature extends EntityLiving {
this.a(this.target, 30.0F, 30.0F);
}
- if (this.positionChanged && !this.k()) {
- this.bG = true;
+ if (this.positionChanged && !this.bI()) {
+ this.bd = true;
}
if (this.random.nextFloat() < 0.8F && (flag || flag1)) {
- this.bG = true;
+ this.bd = true;
}
this.world.methodProfiler.b();
} else {
- super.bq();
+ super.bh();
this.pathEntity = null;
}
}
- protected void i() {
+ protected void bG() {
this.world.methodProfiler.a("stroll");
boolean flag = false;
int i = -1;
@@ -199,7 +209,7 @@ public abstract class EntityCreature extends EntityLiving {
return super.canSpawn() && this.a(i, j, k) >= 0.0F;
}
- public boolean k() {
+ public boolean bI() {
return this.pathEntity != null;
}
@@ -207,7 +217,7 @@ public abstract class EntityCreature extends EntityLiving {
this.pathEntity = pathentity;
}
- public Entity l() {
+ public Entity bJ() {
return this.target;
}
@@ -215,13 +225,79 @@ public abstract class EntityCreature extends EntityLiving {
this.target = entity;
}
- public float bE() {
- float f = super.bE();
+ public boolean bK() {
+ return this.b(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ));
+ }
- if (this.c > 0 && !this.bh()) {
- f *= 2.0F;
- }
+ public boolean b(int i, int j, int k) {
+ return this.br == -1.0F ? true : this.bq.e(i, j, k) < this.br * this.br;
+ }
+
+ public void b(int i, int j, int k, int l) {
+ this.bq.b(i, j, k);
+ this.br = (float) l;
+ }
+
+ public ChunkCoordinates bL() {
+ return this.bq;
+ }
+
+ public float bM() {
+ return this.br;
+ }
+
+ public void bN() {
+ this.br = -1.0F;
+ }
+
+ public boolean bO() {
+ return this.br != -1.0F;
+ }
- return f;
+ protected void bB() {
+ super.bB();
+ if (this.bD() && this.bE() != null && this.bE().world == this.world) {
+ Entity entity = this.bE();
+
+ this.b((int) entity.locX, (int) entity.locY, (int) entity.locZ, 5);
+ float f = this.d(entity);
+
+ if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) {
+ if (f > 10.0F) {
+ this.i(true);
+ }
+
+ return;
+ }
+
+ if (!this.bt) {
+ this.goalSelector.a(2, this.bs);
+ this.getNavigation().a(false);
+ this.bt = true;
+ }
+
+ if (f > 4.0F) {
+ this.getNavigation().a(entity, 1.0D);
+ }
+
+ if (f > 6.0F) {
+ double d0 = (entity.locX - this.locX) / (double) f;
+ double d1 = (entity.locY - this.locY) / (double) f;
+ double d2 = (entity.locZ - this.locZ) / (double) f;
+
+ this.motX += d0 * Math.abs(d0) * 0.4D;
+ this.motY += d1 * Math.abs(d1) * 0.4D;
+ this.motZ += d2 * Math.abs(d2) * 0.4D;
+ }
+
+ if (f > 10.0F) {
+ this.i(true);
+ }
+ } else if (!this.bD() && this.bt) {
+ this.bt = false;
+ this.goalSelector.a(this.bs);
+ this.getNavigation().a(true);
+ this.bN();
+ }
}
}