mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-12 10:45:50 -07:00
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:
@@ -20,6 +20,7 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.util.UnsafeList;
|
||||
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
@@ -40,7 +41,7 @@ public class World implements IBlockAccess {
|
||||
private List J = new ArrayList();
|
||||
private List K = new ArrayList();
|
||||
public List players = new ArrayList();
|
||||
public List e = new ArrayList();
|
||||
public UnsafeList e = new UnsafeList(); // CraftBukkit - use UnsafeList
|
||||
private long L = 16777215L;
|
||||
public int f = 0;
|
||||
protected int g = (new Random()).nextInt();
|
||||
@@ -1104,7 +1105,7 @@ public class World implements IBlockAccess {
|
||||
Entity entity;
|
||||
|
||||
for (i = 0; i < this.e.size(); ++i) {
|
||||
entity = (Entity) this.e.get(i);
|
||||
entity = (Entity) this.e.unsafeGet(i); // CraftBukkit - use unsafeGet
|
||||
// CraftBukkit start - fixed an NPE
|
||||
if (entity == null) {
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user