Optimize entity AI goal selector
Remove redundant ArrayList to avoid excessive object creation and CPU overhead, the entries are added to the list then immediately iterated through to run so just run them directly. Swap order of some conditionals to perform the more efficient check first as if it fails the list lookup will not be executed. Remove profiling hooks including some rather expensive calls to getSimpleName.
Dieser Commit ist enthalten in:
Ursprung
858d36efc9
Commit
d628c886d2
@ -470,7 +470,7 @@ public abstract class EntityLiving extends Entity {
|
||||
}
|
||||
|
||||
this.av += (f3 - this.av) * 0.3F;
|
||||
this.world.methodProfiler.a("headTurn");
|
||||
// this.world.methodProfiler.a("headTurn"); // CraftBukkit - not in production code
|
||||
if (this.aV()) {
|
||||
this.senses.a();
|
||||
} else {
|
||||
@ -498,8 +498,8 @@ public abstract class EntityLiving extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
this.world.methodProfiler.b();
|
||||
this.world.methodProfiler.a("rangeChecks");
|
||||
// this.world.methodProfiler.b(); // CraftBukkit - not in production code
|
||||
// this.world.methodProfiler.a("rangeChecks"); // CraftBukkit - not in production code
|
||||
|
||||
while (this.yaw - this.lastYaw < -180.0F) {
|
||||
this.lastYaw -= 360.0F;
|
||||
@ -533,7 +533,7 @@ public abstract class EntityLiving extends Entity {
|
||||
this.at += 360.0F;
|
||||
}
|
||||
|
||||
this.world.methodProfiler.b();
|
||||
// this.world.methodProfiler.b(); // CraftBukkit - not in production code
|
||||
this.aw += f2;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class PathfinderGoalSelector {
|
||||
}
|
||||
|
||||
public void a() {
|
||||
UnsafeList arraylist = new UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList
|
||||
// ArrayList arraylist = new ArrayList(); // CraftBukkit - remove usage
|
||||
Iterator iterator;
|
||||
PathfinderGoalSelectorItem pathfindergoalselectoritem;
|
||||
|
||||
@ -46,7 +46,10 @@ public class PathfinderGoalSelector {
|
||||
}
|
||||
|
||||
if (this.b(pathfindergoalselectoritem) && pathfindergoalselectoritem.a.a()) {
|
||||
arraylist.add(pathfindergoalselectoritem);
|
||||
// CraftBukkit start - call method now instead of queueing
|
||||
// arraylist.add(pathfindergoalselectoritem);
|
||||
pathfindergoalselectoritem.a.e();
|
||||
// CraftBukkit end
|
||||
this.b.add(pathfindergoalselectoritem);
|
||||
}
|
||||
}
|
||||
@ -62,40 +65,42 @@ public class PathfinderGoalSelector {
|
||||
}
|
||||
}
|
||||
|
||||
this.c.a("goalStart");
|
||||
iterator = arraylist.iterator();
|
||||
// this.c.a("goalStart"); // CraftBukkit - not in production code
|
||||
// CraftBukkit start - removed usage of arraylist
|
||||
/*iterator = arraylist.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next();
|
||||
this.c.a(pathfindergoalselectoritem.a.getClass().getSimpleName());
|
||||
// this.c.a(pathfindergoalselectoritem.a.getClass().getSimpleName()); // CraftBukkit - not in production code
|
||||
pathfindergoalselectoritem.a.e();
|
||||
this.c.b();
|
||||
}
|
||||
// this.c.b(); // CraftBukkit - not in production code
|
||||
}*/
|
||||
// CraftBukkit end
|
||||
|
||||
this.c.b();
|
||||
this.c.a("goalTick");
|
||||
// this.c.b(); // CraftBukkit - not in production code
|
||||
// this.c.a("goalTick"); // CraftBukkit - not in production code
|
||||
iterator = this.b.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next();
|
||||
this.c.a(pathfindergoalselectoritem.a.getClass().getSimpleName());
|
||||
// this.c.a(pathfindergoalselectoritem.a.getClass().getSimpleName()); // CraftBukkit - not in production code
|
||||
pathfindergoalselectoritem.a.d();
|
||||
this.c.b();
|
||||
// this.c.b(); // CraftBukkit - not in production code
|
||||
}
|
||||
|
||||
this.c.b();
|
||||
// this.c.b(); // CraftBukkit - not in production code
|
||||
}
|
||||
|
||||
private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem) {
|
||||
this.c.a("canContinue");
|
||||
// this.c.a("canContinue"); // CraftBukkit - not in production code
|
||||
boolean flag = pathfindergoalselectoritem.a.b();
|
||||
|
||||
this.c.b();
|
||||
// this.c.b(); // CraftBukkit - not in production code
|
||||
return flag;
|
||||
}
|
||||
|
||||
private boolean b(PathfinderGoalSelectorItem pathfindergoalselectoritem) {
|
||||
this.c.a("canUse");
|
||||
// this.c.a("canUse"); // CraftBukkit - not in production code
|
||||
Iterator iterator = this.a.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@ -103,18 +108,20 @@ public class PathfinderGoalSelector {
|
||||
|
||||
if (pathfindergoalselectoritem1 != pathfindergoalselectoritem) {
|
||||
if (pathfindergoalselectoritem.b >= pathfindergoalselectoritem1.b) {
|
||||
if (this.b.contains(pathfindergoalselectoritem1) && !this.a(pathfindergoalselectoritem, pathfindergoalselectoritem1)) {
|
||||
this.c.b();
|
||||
// CraftBukkit - switch order
|
||||
if (!this.a(pathfindergoalselectoritem, pathfindergoalselectoritem1) && this.b.contains(pathfindergoalselectoritem1)) {
|
||||
// this.c.b(); // CraftBukkit - not in production code
|
||||
return false;
|
||||
}
|
||||
} else if (this.b.contains(pathfindergoalselectoritem1) && !pathfindergoalselectoritem1.a.g()) {
|
||||
this.c.b();
|
||||
// CraftBukkit - switch order
|
||||
} else if (!pathfindergoalselectoritem1.a.g() && this.b.contains(pathfindergoalselectoritem1)) {
|
||||
// this.c.b(); // CraftBukkit - not in production code
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.c.b();
|
||||
// this.c.b(); // CraftBukkit - not in production code
|
||||
return true;
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren