diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-04-21 13:47:29 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-04-21 23:53:10 -0400 |
commit | e8459c1ff6a8e58f6d7578a99ea164deadc30884 (patch) | |
tree | 5e279538c8c5b3facf71314b69dc37427d6ef0c2 /src/main/java/net/minecraft/server/EntityLiving.java | |
parent | 343f39b2b3750036f3749a16cf06ae39d65e87db (diff) | |
download | craftbukkit-e8459c1ff6a8e58f6d7578a99ea164deadc30884.tar craftbukkit-e8459c1ff6a8e58f6d7578a99ea164deadc30884.tar.gz craftbukkit-e8459c1ff6a8e58f6d7578a99ea164deadc30884.tar.lz craftbukkit-e8459c1ff6a8e58f6d7578a99ea164deadc30884.tar.xz craftbukkit-e8459c1ff6a8e58f6d7578a99ea164deadc30884.zip |
Optimize AI and EntityLiving ticking
Reduce usage of getCubes as it is an expensive call.
Remove iterator usage and object creation from PathfinderGoalSelector
methods as these are called very often.
Update EntityLiving goal selectors less often as this is still quite an
expensive task.
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityLiving.java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityLiving.java | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index 8c279ec7..1f192275 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -1090,22 +1090,28 @@ public abstract class EntityLiving extends Entity { --this.aN; this.setPosition(d0, d1, d2); this.c(this.yaw, this.pitch); - List list = this.world.getCubes(this, this.boundingBox.shrink(0.03125D, 0.0D, 0.03125D)); + // CraftBukkit start - getCubes is expensive, use an approximation + if (this.world.getTypeId(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2)) != 0) { + d1 += 1.0D; + this.setPosition(d0, d1, d2); + } + //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 } // MethodProfiler.a("ai"); // CraftBukkit - not in production code @@ -1116,13 +1122,13 @@ public abstract class EntityLiving extends Entity { this.aY = 0.0F; } else if (this.aF()) { if (this.c_()) { - MethodProfiler.a("newAi"); + // MethodProfiler.a("newAi"); // CraftBukkit - not in production code this.z_(); - MethodProfiler.a(); + // MethodProfiler.a(); // CraftBukkit - not in production code } else { - MethodProfiler.a("oldAi"); + // MethodProfiler.a("oldAi"); // CraftBukkit - not in production code this.d_(); - MethodProfiler.a(); + // MethodProfiler.a(); // CraftBukkit - not in production code this.X = this.yaw; } } @@ -1234,10 +1240,14 @@ public abstract class EntityLiving extends Entity { this.m.a(); //MethodProfiler.a(); // CraftBukkit - not in production code //MethodProfiler.a("targetSelector"); // CraftBukkit - not in production code - this.targetSelector.a(); + // CraftBukkit start - run goal selectors every other tick + if ((this.aV & 1) == 0) { + this.targetSelector.a(); //MethodProfiler.a(); // CraftBukkit - not in production code //MethodProfiler.a("goalSelector"); // CraftBukkit - not in production code - this.goalSelector.a(); + this.goalSelector.a(); + } + // CraftBukkit end //MethodProfiler.a(); // CraftBukkit - not in production code //MethodProfiler.a("navigation"); // CraftBukkit - not in production code this.navigation.d(); |