Avoid doing unnecessary range checks when we're looping from start to end.

Make EntityLiving call AI logic every tick again.
Rework PathfinderGoalSelector logic.

Adds UnsafeList for use in places where we use ArrayList and know we won't
get index out of range errors. Added usage to World's tickEntities, Chunk's
entitySlices to speed up searching for entities, and to PathfinderGoalSelector
to speed up dealing with AI goals.

Reworked logic in PathfinderGoalSelector with help from fullwall. This code
no longer uses an extra ArrayList for setting up goals and only updates which
goals should be run every other time it is called.

Removed only calling PathfinderGoalSelector every other tick from EntityLiving
as we now only setup new goals every other tick. This ensures existing goals
run every tick to properly update mob movement.
This commit is contained in:
Travis Watkins
2012-04-23 09:47:05 -05:00
committed by EvilSeph
parent e8459c1ff6
commit b7376e0865
5 changed files with 207 additions and 44 deletions

View File

@@ -1095,22 +1095,22 @@ public abstract class EntityLiving extends Entity {
d1 += 1.0D;
this.setPosition(d0, d1, d2);
}
//List list = this.world.getCubes(this, this.boundingBox.shrink(0.03125D, 0.0D, 0.03125D));
/*List list = this.world.getCubes(this, this.boundingBox.shrink(0.03125D, 0.0D, 0.03125D));
//if (list.size() > 0) {
// double d4 = 0.0D;
if (list.size() > 0) {
double d4 = 0.0D;
// for (int i = 0; i < list.size(); ++i) {
// AxisAlignedBB axisalignedbb = (AxisAlignedBB) list.get(i);
for (int i = 0; i < list.size(); ++i) {
AxisAlignedBB axisalignedbb = (AxisAlignedBB) list.get(i);
// if (axisalignedbb.e > d4) {
// d4 = axisalignedbb.e;
// }
// }
if (axisalignedbb.e > d4) {
d4 = axisalignedbb.e;
}
}
// d1 += d4 - this.boundingBox.b;
// this.setPosition(d0, d1, d2);
//}
d1 += d4 - this.boundingBox.b;
this.setPosition(d0, d1, d2);
}*/
// CraftBukkit end
}
@@ -1240,14 +1240,10 @@ public abstract class EntityLiving extends Entity {
this.m.a();
//MethodProfiler.a(); // CraftBukkit - not in production code
//MethodProfiler.a("targetSelector"); // CraftBukkit - not in production code
// CraftBukkit start - run goal selectors every other tick
if ((this.aV & 1) == 0) {
this.targetSelector.a();
this.targetSelector.a();
//MethodProfiler.a(); // CraftBukkit - not in production code
//MethodProfiler.a("goalSelector"); // CraftBukkit - not in production code
this.goalSelector.a();
}
// CraftBukkit end
this.goalSelector.a();
//MethodProfiler.a(); // CraftBukkit - not in production code
//MethodProfiler.a("navigation"); // CraftBukkit - not in production code
this.navigation.d();