1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-02-17 18:47:40 +01:00

Make loaded entity list logic more consistent ()

When adding/removing to a chunk, we need to also look at
editing the loaded entity list.

Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
This commit is contained in:
Spottedleaf 2020-05-06 07:57:18 -07:00
parent d2a300598c
commit f1b980c22f

View file

@ -10,6 +10,30 @@ diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/m
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
entity.chunkZ = this.loc.z;
this.entities.add(entity); // Paper - per chunk entity list
this.entitySlices[k].add(entity); if (entity.hardCollides()) this.hardCollidingEntities[k].add(entity); // Paper - optimise hard colliding entities
+ // Paper start - world loaded entity list
+ if (this.loadedTicketLevel) {
+ ((WorldServer)this.world).loadedEntities.add(entity);
+ } else {
+ ((WorldServer)this.world).loadedEntities.remove(entity);
+ }
+ // Paper end - world loaded entity list
// Paper start
if (entity instanceof EntityItem) {
itemCounts[k]++;
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
if (entity.hardCollides()) this.hardCollidingEntities[i].remove(entity); if (!this.entitySlices[i].remove(entity)) { // Paper - optimise hard colliding entities
return;
}
+ // Paper start - world loaded entity list
+ ((WorldServer)this.world).loadedEntities.remove(entity);
+ // Paper end - world loaded entity list
if (entity instanceof EntityItem) {
itemCounts[i]--;
} else if (entity instanceof IInventory) {
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
this.setNeighbourLoaded(0, 0, this);
this.loadedTicketLevel = true;