Current Chunk for Entity and Block Entities, counts by entity type

This enables us a fast reference to the entities current chunk instead
of having to look it up by hashmap lookups.

We also store counts by type to further enable other performance optimizations in later patches.
This commit is contained in:
Aikar
2018-07-04 03:55:24 -04:00
parent 58a2e2dc04
commit 8778a2ef97
157 changed files with 666 additions and 294 deletions

View File

@@ -18,7 +18,7 @@ index 0c82c6f5b..9659a45ef 100644
private float b;
private final float c;
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index f76be4da0..3cd37f28d 100644
index dda6219a7..9e864864d 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity {
@@ -96,7 +96,7 @@ index e5b5e9887..e3781f3a8 100644
}
}
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 47865c027..b08564618 100644
index b79bf70f0..b1536e1c5 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -0,0 +0,0 @@ import net.minecraft.server.EntityFireball;
@@ -140,4 +140,13 @@ index 47865c027..b08564618 100644
if ( entity instanceof EntityAnimal )
{
EntityAnimal animal = (EntityAnimal) entity;
@@ -0,0 +0,0 @@ public class ActivationRange
int x = MathHelper.floor( entity.locX );
int z = MathHelper.floor( entity.locZ );
// Make sure not on edge of unloaded chunk
- Chunk chunk = entity.world.getChunkIfLoaded( x >> 4, z >> 4 );
+ Chunk chunk = entity.getCurrentChunk(); // Paper
if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) )
{
isActive = false;
--