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:
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import org.bukkit.Bukkit; // CraftBukkit
|
||||
import org.bukkit.craftbukkit.util.UnsafeList; // CraftBukkit
|
||||
|
||||
public class Chunk {
|
||||
|
||||
@@ -53,7 +54,7 @@ public class Chunk {
|
||||
this.heightMap = new int[256];
|
||||
|
||||
for (int k = 0; k < this.entitySlices.length; ++k) {
|
||||
this.entitySlices[k] = new ArrayList();
|
||||
this.entitySlices[k] = new UnsafeList(); // CraftBukkit - use UnsafeList
|
||||
}
|
||||
|
||||
Arrays.fill(this.b, -999);
|
||||
@@ -697,10 +698,10 @@ public class Chunk {
|
||||
}
|
||||
|
||||
for (int k = i; k <= j; ++k) {
|
||||
List list1 = this.entitySlices[k];
|
||||
UnsafeList list1 = (UnsafeList) this.entitySlices[k]; // CraftBukkit - use UnsafeList
|
||||
|
||||
for (int l = 0; l < list1.size(); ++l) {
|
||||
Entity entity1 = (Entity) list1.get(l);
|
||||
Entity entity1 = (Entity) list1.unsafeGet(l); // CraftBukkit - use unsafeGet
|
||||
|
||||
if (entity1 != entity && entity1.boundingBox.a(axisalignedbb)) {
|
||||
list.add(entity1);
|
||||
@@ -736,10 +737,10 @@ public class Chunk {
|
||||
}
|
||||
|
||||
for (int k = i; k <= j; ++k) {
|
||||
List list1 = this.entitySlices[k];
|
||||
UnsafeList list1 = (UnsafeList) this.entitySlices[k]; // CraftBukkit - use UnsafeList
|
||||
|
||||
for (int l = 0; l < list1.size(); ++l) {
|
||||
Entity entity = (Entity) list1.get(l);
|
||||
Entity entity = (Entity) list1.unsafeGet(l); // CraftBukkit - use unsafeGet
|
||||
|
||||
if (oclass.isAssignableFrom(entity.getClass()) && entity.boundingBox.a(axisalignedbb)) {
|
||||
list.add(entity);
|
||||
|
||||
Reference in New Issue
Block a user