Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 19:10:09 +01:00
Make loaded entity list logic more consistent (#3301)
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>
Dieser Commit ist enthalten in:
Ursprung
36f34f01c0
Commit
841c7d1879
@ -7,10 +7,34 @@ Subject: [PATCH] Optimize entity list iteration requiring entities be in
|
||||
We retain a list of loaded entities specifically for this usage
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 750fb07756f7e40b21f8ab0925f2e842aae50f7b..69bfece7d43bc9e0c4cf7f71bffec9a44c2b9a67 100644
|
||||
index 750fb07756f7e40b21f8ab0925f2e842aae50f7b..21918ab101b423eadff5c00530f7a7c8e40cde9a 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -801,6 +801,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -588,6 +588,13 @@ 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]++;
|
||||
@@ -627,6 +634,9 @@ 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) {
|
||||
@@ -801,6 +811,7 @@ public class Chunk implements IChunkAccess {
|
||||
this.setNeighbourLoaded(0, 0, this);
|
||||
this.loadedTicketLevel = true;
|
||||
// Paper end - neighbour cache
|
||||
@ -18,7 +42,7 @@ index 750fb07756f7e40b21f8ab0925f2e842aae50f7b..69bfece7d43bc9e0c4cf7f71bffec9a4
|
||||
org.bukkit.Server server = this.world.getServer();
|
||||
((WorldServer)this.world).getChunkProvider().addLoadedChunk(this); // Paper
|
||||
if (server != null) {
|
||||
@@ -859,6 +860,7 @@ public class Chunk implements IChunkAccess {
|
||||
@@ -859,6 +870,7 @@ public class Chunk implements IChunkAccess {
|
||||
this.loadedTicketLevel = false;
|
||||
this.resetNeighbours();
|
||||
// Paper end
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren