mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Fix placement of chunk tracking - Fixes #1199
Spigot had code that returned early in chunk add/remove methods. This was causing our code added to set current chunks and counts to be skipped over if the entity was default not persistent but made persistent. This was the source of many issues Fixes #1208
This commit is contained in:
parent
fe9d5b5570
commit
9a22d2fdec
12 changed files with 41 additions and 44 deletions
|
@ -50,7 +50,7 @@ index 000000000..93397188b
|
|||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index a5db14343..0788f7712 100644
|
||||
index 08d6ef09a..d5ef4ed0e 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -0,0 +0,0 @@
|
||||
|
|
|
@ -64,7 +64,7 @@ index 1b9eb7f45..ce848d63e 100644
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index cc9c8b2e0..a59f5b190 100644
|
||||
index 62767a383..798522fa7 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 {
|
||||
|
|
|
@ -10,7 +10,7 @@ to the object directly on the Entity/TileEntity object we can directly grab.
|
|||
Use that local value instead to reduce lookups in many hot places.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 3e80825f7..4a94fd5a6 100644
|
||||
index 81bf60efa..04adf4e3c 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 {
|
||||
|
|
|
@ -14,7 +14,7 @@ And since minecart hoppers are used _very_ rarely near we can avoid alot of sear
|
|||
Combined, this adds up a lot.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index aaf253c89..a5db14343 100644
|
||||
index d6f6cfef2..08d6ef09a 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 {
|
||||
|
@ -32,33 +32,29 @@ index aaf253c89..a5db14343 100644
|
|||
private int neighbors = 0x1 << 12;
|
||||
public long chunkKey;
|
||||
@@ -0,0 +0,0 @@ public class Chunk {
|
||||
entity.ac = k;
|
||||
entity.ad = this.locZ;
|
||||
this.entitySlices[k].add(entity);
|
||||
+ // Paper start - update count
|
||||
// Paper start
|
||||
entity.setCurrentChunk(this);
|
||||
entityCounts.increment(entity.entityKeyString);
|
||||
+ if (entity instanceof EntityItem) {
|
||||
+ itemCounts[k]++;
|
||||
+ } else if (entity instanceof IInventory) {
|
||||
+ inventoryEntityCounts[k]++;
|
||||
+ }
|
||||
+ // Paper end
|
||||
// Paper end
|
||||
// Spigot start - increment creature type count
|
||||
// Keep this synced up with World.a(Class)
|
||||
if (entity instanceof EntityInsentient) {
|
||||
@@ -0,0 +0,0 @@ public class Chunk {
|
||||
}
|
||||
|
||||
this.entitySlices[i].remove(entity);
|
||||
+ // Paper start - update counts
|
||||
// Paper start
|
||||
entity.setCurrentChunk(null);
|
||||
entityCounts.decrement(entity.entityKeyString);
|
||||
+ if (entity instanceof EntityItem) {
|
||||
+ itemCounts[i]--;
|
||||
+ } else if (entity instanceof IInventory) {
|
||||
+ inventoryEntityCounts[i]--;
|
||||
+ }
|
||||
+ // Paper end
|
||||
// Paper end
|
||||
// Spigot start - decrement creature type count
|
||||
// Keep this synced up with World.a(Class)
|
||||
if (entity instanceof EntityInsentient) {
|
||||
@@ -0,0 +0,0 @@ public class Chunk {
|
||||
if (!this.entitySlices[k].isEmpty()) {
|
||||
Iterator iterator = this.entitySlices[k].iterator();
|
||||
|
|
|
@ -23,7 +23,7 @@ index e634c3afd..54f23ea75 100644
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index bf3b64e37..6b13e1d7d 100644
|
||||
index d84cc9843..da7b59434 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 {
|
||||
|
|
|
@ -6,7 +6,7 @@ Subject: [PATCH] Do not mark chunks as active for neighbor updates
|
|||
Fixes chunk unload issues
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 1e78fc625..ba3ee64f8 100644
|
||||
index 1157bc7eb..f3f4b7fe5 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 {
|
||||
|
|
|
@ -18,7 +18,7 @@ only send chunks which are actually ready to be sent, otherwise, we
|
|||
will always send chunks.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index cb33cf902..87d0d426f 100644
|
||||
index 9c88effef..51e7a4ad8 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 {
|
||||
|
|
|
@ -14,7 +14,7 @@ Specially with servers using smaller mob spawn ranges than view distance, as wel
|
|||
This patch returns mob counting to use all loaded chunks, and 17x17 division.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index e07ef14ed..aca1457b0 100644
|
||||
index da7b59434..1157bc7eb 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 {
|
||||
|
@ -22,10 +22,11 @@ index e07ef14ed..aca1457b0 100644
|
|||
}
|
||||
|
||||
- this.entitySlices[i].remove(entity);
|
||||
+ if (!this.entitySlices[i].remove(entity)) { return; } // Paper
|
||||
// Paper start - update counts
|
||||
// Paper start
|
||||
+ if (!this.entitySlices[i].remove(entity)) { return; }
|
||||
entity.setCurrentChunk(null);
|
||||
entityCounts.decrement(entity.entityKeyString);
|
||||
if (entity instanceof EntityItem) {
|
||||
itemCounts[i]--;
|
||||
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
index 45a83ae99..ed22607d9 100644
|
||||
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
|
|
|
@ -7,7 +7,7 @@ Allows you to determine why an inventory was closed, enabling plugin developers
|
|||
to "confirm" things based on if it was player triggered close or not.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 8c96e7318..3e80825f7 100644
|
||||
index 51e7a4ad8..81bf60efa 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 {
|
||||
|
|
|
@ -19,7 +19,7 @@ index ce848d63e..93b0af036 100644
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index a59f5b190..27a36b2b0 100644
|
||||
index 798522fa7..ee6c6af94 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 {
|
||||
|
|
|
@ -6,7 +6,7 @@ Subject: [PATCH] Store counts for each Entity/Block Entity Type
|
|||
Opens door for future patches to optimize performance
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index b40e60942..952c96c0c 100644
|
||||
index ea167a17b..77fdb3c4a 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 {
|
||||
|
@ -38,19 +38,19 @@ index b40e60942..952c96c0c 100644
|
|||
return removed;
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class Chunk {
|
||||
}
|
||||
this.entitySlices[k].add(entity);
|
||||
// Paper start
|
||||
entity.setCurrentChunk(this);
|
||||
+ entityCounts.increment(entity.entityKeyString);
|
||||
// Paper end
|
||||
// Spigot end
|
||||
}
|
||||
// Spigot start - increment creature type count
|
||||
// Keep this synced up with World.a(Class)
|
||||
@@ -0,0 +0,0 @@ public class Chunk {
|
||||
}
|
||||
this.entitySlices[i].remove(entity);
|
||||
// Paper start
|
||||
entity.setCurrentChunk(null);
|
||||
+ entityCounts.decrement(entity.entityKeyString);
|
||||
// Paper end
|
||||
// Spigot end
|
||||
}
|
||||
// Spigot start - decrement creature type count
|
||||
// Keep this synced up with World.a(Class)
|
||||
--
|
|
@ -8,7 +8,7 @@ This enables us a fast reference to the entities current chunk instead
|
|||
of having to look it up by hashmap lookups.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 4bbebb25a..68008fe6a 100644
|
||||
index 4bbebb25a..ea167a17b 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 {
|
||||
|
@ -61,25 +61,25 @@ index 4bbebb25a..68008fe6a 100644
|
|||
this.y = Queues.newConcurrentLinkedQueue();
|
||||
this.entitySlices = (List[]) (new List[16]); // Spigot
|
||||
@@ -0,0 +0,0 @@ public class Chunk {
|
||||
this.entityCount.adjustOrPutValue( creatureType.a(), 1, 1 );
|
||||
}
|
||||
}
|
||||
entity.ac = k;
|
||||
entity.ad = this.locZ;
|
||||
this.entitySlices[k].add(entity);
|
||||
+ // Paper start
|
||||
+ entity.setCurrentChunk(this);
|
||||
+ // Paper end
|
||||
// Spigot end
|
||||
// Spigot start - increment creature type count
|
||||
// Keep this synced up with World.a(Class)
|
||||
if (entity instanceof EntityInsentient) {
|
||||
@@ -0,0 +0,0 @@ public class Chunk {
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class Chunk {
|
||||
this.entityCount.adjustValue( creatureType.a(), -1 );
|
||||
}
|
||||
}
|
||||
this.entitySlices[i].remove(entity);
|
||||
+ // Paper start
|
||||
+ entity.setCurrentChunk(null);
|
||||
+ // Paper end
|
||||
// Spigot end
|
||||
}
|
||||
|
||||
// Spigot start - decrement creature type count
|
||||
// Keep this synced up with World.a(Class)
|
||||
if (entity instanceof EntityInsentient) {
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 3a8902bf1..4af566b36 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
|
|
Loading…
Reference in a new issue