Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 03:20:07 +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
Dieser Commit ist enthalten in:
Ursprung
230bf934b5
Commit
5d8b3d4969
@ -1,4 +1,4 @@
|
||||
From 8613a4e2ae9a4bb6faef75b90d69728a88692dc1 Mon Sep 17 00:00:00 2001
|
||||
From ada548d469ddfd07d7ee05b4473b46eafbe104e0 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 4 Jul 2018 02:10:36 -0400
|
||||
Subject: [PATCH] Store reference to current Chunk for Entity and Block
|
||||
@ -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
|
||||
@@ -25,7 +25,7 @@ public class Chunk {
|
||||
@ -60,26 +60,26 @@ index 4bbebb25a..68008fe6a 100644
|
||||
this.x = 4096;
|
||||
this.y = Queues.newConcurrentLinkedQueue();
|
||||
this.entitySlices = (List[]) (new List[16]); // Spigot
|
||||
@@ -624,6 +648,9 @@ public class Chunk {
|
||||
this.entityCount.adjustOrPutValue( creatureType.a(), 1, 1 );
|
||||
}
|
||||
}
|
||||
@@ -609,6 +633,9 @@ public class Chunk {
|
||||
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) {
|
||||
@@ -641,6 +668,9 @@ public class Chunk {
|
||||
}
|
||||
|
||||
@@ -656,6 +683,9 @@ 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 9638089fa0dcff84f21fc77d17a984b430eb3423 Mon Sep 17 00:00:00 2001
|
||||
From 20c6d16a7db36e57bde2a9bac4e5bb99d606239a Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 4 Jul 2018 02:13:59 -0400
|
||||
Subject: [PATCH] Store counts for each Entity/Block Entity Type
|
||||
@ -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
|
||||
@@ -34,15 +34,19 @@ public class Chunk {
|
||||
@ -37,22 +37,22 @@ index b40e60942..952c96c0c 100644
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
@@ -650,6 +655,7 @@ public class Chunk {
|
||||
}
|
||||
@@ -635,6 +640,7 @@ public class Chunk {
|
||||
this.entitySlices[k].add(entity);
|
||||
// Paper start
|
||||
entity.setCurrentChunk(this);
|
||||
+ entityCounts.increment(entity.entityKeyString);
|
||||
// Paper end
|
||||
// Spigot end
|
||||
}
|
||||
@@ -685,6 +691,7 @@ public class Chunk {
|
||||
}
|
||||
// Spigot start - increment creature type count
|
||||
// Keep this synced up with World.a(Class)
|
||||
@@ -670,6 +676,7 @@ 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)
|
||||
--
|
||||
2.18.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 04eb0a217ec431985499b59ceb505a2047a3173c Mon Sep 17 00:00:00 2001
|
||||
From 8878c3563aa9f2217bd4ea486aa52ee394b69f01 Mon Sep 17 00:00:00 2001
|
||||
From: CullanP <cullanpage@gmail.com>
|
||||
Date: Thu, 3 Mar 2016 02:13:38 -0600
|
||||
Subject: [PATCH] Avoid hopper searches if there are no items
|
||||
@ -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
|
||||
@@ -76,6 +76,13 @@ public class Chunk {
|
||||
@ -31,35 +31,31 @@ index aaf253c89..a5db14343 100644
|
||||
// CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
|
||||
private int neighbors = 0x1 << 12;
|
||||
public long chunkKey;
|
||||
@@ -648,6 +655,13 @@ public class Chunk {
|
||||
entity.ac = k;
|
||||
entity.ad = this.locZ;
|
||||
this.entitySlices[k].add(entity);
|
||||
+ // Paper start - update count
|
||||
@@ -651,6 +658,11 @@ public class Chunk {
|
||||
// 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) {
|
||||
@@ -684,6 +698,13 @@ public class Chunk {
|
||||
}
|
||||
|
||||
this.entitySlices[i].remove(entity);
|
||||
+ // Paper start - update counts
|
||||
@@ -687,6 +699,11 @@ public class Chunk {
|
||||
// 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) {
|
||||
@@ -879,6 +900,15 @@ public class Chunk {
|
||||
@@ -879,6 +896,15 @@ public class Chunk {
|
||||
if (!this.entitySlices[k].isEmpty()) {
|
||||
Iterator iterator = this.entitySlices[k].iterator();
|
||||
|
||||
@ -75,7 +71,7 @@ index aaf253c89..a5db14343 100644
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity1 = (Entity) iterator.next();
|
||||
|
||||
@@ -915,7 +945,18 @@ public class Chunk {
|
||||
@@ -915,7 +941,18 @@ public class Chunk {
|
||||
i = MathHelper.clamp(i, 0, this.entitySlices.length - 1);
|
||||
j = MathHelper.clamp(j, 0, this.entitySlices.length - 1);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From fa5787eee0ee62491653acc9fd911e0e3f9134c0 Mon Sep 17 00:00:00 2001
|
||||
From 6ceadeb266a7fc9a4a41c7819ce49ec3e034b39c Mon Sep 17 00:00:00 2001
|
||||
From: Joseph Hirschfeld <joe@ibj.io>
|
||||
Date: Thu, 3 Mar 2016 03:15:41 -0600
|
||||
Subject: [PATCH] Add exception reporting event
|
||||
@ -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
|
||||
@@ -1,5 +1,6 @@
|
||||
@ -68,7 +68,7 @@ index a5db14343..0788f7712 100644
|
||||
|
||||
public class Chunk {
|
||||
|
||||
@@ -795,10 +797,15 @@ public class Chunk {
|
||||
@@ -791,10 +793,15 @@ public class Chunk {
|
||||
this.tileEntities.remove(blockposition);
|
||||
// Paper end
|
||||
} else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
From e2eb0375f3b5fa6b9d074ee6d8551732eb8e37a7 Mon Sep 17 00:00:00 2001
|
||||
From b0b7b1aef28c4017f37927c00042e87384f5a9bc Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 28 Mar 2016 20:46:14 -0400
|
||||
Subject: [PATCH] Configurable Chunk Inhabited Timer
|
||||
@ -23,10 +23,10 @@ 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
|
||||
@@ -1445,7 +1445,7 @@ public class Chunk {
|
||||
@@ -1441,7 +1441,7 @@ public class Chunk {
|
||||
}
|
||||
|
||||
public long x() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 868e6d9441457ad084678875f8c583f27d306916 Mon Sep 17 00:00:00 2001
|
||||
From f7b327727e2ac3ad221592ae2b97c64d9297c702 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 14 Apr 2016 21:01:39 -0400
|
||||
Subject: [PATCH] Fix Bugs with Spigot Mob Spawn Logic
|
||||
@ -14,18 +14,19 @@ 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
|
||||
@@ -716,7 +716,7 @@ public class Chunk {
|
||||
@@ -714,8 +714,8 @@ public class Chunk {
|
||||
i = this.entitySlices.length - 1;
|
||||
}
|
||||
|
||||
- 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
From b61b569f426f29ca36a9b769f868e62d552645ec Mon Sep 17 00:00:00 2001
|
||||
From 6a04d822bcaed5049e8c100649a084511ddf364b Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 12 May 2016 01:55:17 -0400
|
||||
Subject: [PATCH] Do not mark chunks as active for neighbor updates
|
||||
@ -6,10 +6,10 @@ 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
|
||||
@@ -1044,25 +1044,25 @@ public class Chunk {
|
||||
@@ -1040,25 +1040,25 @@ public class Chunk {
|
||||
// CraftBukkit end
|
||||
world.timings.syncChunkLoadPostTimer.stopTiming(); // Paper
|
||||
world.timings.syncChunkLoadPopulateNeighbors.startTiming(); // Paper
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 3116c6b8cd13ddce911fcb81a43a7a8b6696bd67 Mon Sep 17 00:00:00 2001
|
||||
From d8b347ac8d0edf9680b00ec72d12945dea811afb Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 19 Sep 2016 23:16:39 -0400
|
||||
Subject: [PATCH] Auto Save Improvements
|
||||
@ -64,10 +64,10 @@ 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
|
||||
@@ -1000,11 +1000,9 @@ public class Chunk {
|
||||
@@ -996,11 +996,9 @@ public class Chunk {
|
||||
if (this.t && this.world.getTime() != this.lastSaved || this.s) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 5b908630761c4e62419ce38535eaa3b715c34675 Mon Sep 17 00:00:00 2001
|
||||
From da23bbc651183f13e725c4a1c85043f06b3164c1 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Wed, 5 Oct 2016 16:27:36 -0500
|
||||
Subject: [PATCH] Option to remove corrupt tile entities
|
||||
@ -19,10 +19,10 @@ 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
|
||||
@@ -823,11 +823,18 @@ public class Chunk {
|
||||
@@ -819,11 +819,18 @@ public class Chunk {
|
||||
"Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16));
|
||||
e.printStackTrace();
|
||||
ServerInternalException.reportInternalException(e);
|
||||
|
@ -1,4 +1,4 @@
|
||||
From dd48bbfe6038596192469c818bb31f0a29d71646 Mon Sep 17 00:00:00 2001
|
||||
From 308db0274f868def0d98c712102ba50e26a35685 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Mon, 18 Dec 2017 07:26:56 +0000
|
||||
Subject: [PATCH] Don't blindly send unlit chunks when lighting updates are
|
||||
@ -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
|
||||
@@ -68,7 +68,7 @@ public class Chunk {
|
||||
@ -30,7 +30,7 @@ index cb33cf902..87d0d426f 100644
|
||||
private boolean s;
|
||||
private boolean t;
|
||||
private long lastSaved;
|
||||
@@ -1174,7 +1174,11 @@ public class Chunk {
|
||||
@@ -1170,7 +1170,11 @@ public class Chunk {
|
||||
* We cannot unfortunately do this lighting stage during chunk gen as it appears to put a lot more noticeable load on the server, than when it is done at play time.
|
||||
* For now at least we will simply send all chunks, in accordance with pre 1.7 behaviour.
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
From c5d1182aa2daec8a3627d2295b105756845013b7 Mon Sep 17 00:00:00 2001
|
||||
From 7a60efbad7a444b9c728712d98b5d628c0c3206f Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 3 Jul 2018 21:56:23 -0400
|
||||
Subject: [PATCH] InventoryCloseEvent Reason API
|
||||
@ -7,10 +7,10 @@ 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
|
||||
@@ -873,7 +873,7 @@ public class Chunk {
|
||||
@@ -869,7 +869,7 @@ public class Chunk {
|
||||
{
|
||||
if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity )
|
||||
{
|
||||
@ -19,7 +19,7 @@ index 8c96e7318..3e80825f7 100644
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -898,7 +898,7 @@ public class Chunk {
|
||||
@@ -894,7 +894,7 @@ public class Chunk {
|
||||
{
|
||||
if ( h instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity )
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 855c50b43725ac1167d2735d0d0b0b60de73499f Mon Sep 17 00:00:00 2001
|
||||
From dbe49167504d8c10b0dd8fbd271f186cf752057e Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 4 Jul 2018 03:39:51 -0400
|
||||
Subject: [PATCH] Avoid Chunk Lookups for Entity/TileEntity Current Chunk
|
||||
@ -10,10 +10,10 @@ 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
|
||||
@@ -704,6 +704,7 @@ public class Chunk {
|
||||
@@ -702,6 +702,7 @@ public class Chunk {
|
||||
// Spigot end
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren