mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-12 18:55:51 -07:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user