MOAR PATCHES
This commit is contained in:
parent
27a8d6da9a
commit
f55b6e04b1
34 changed files with 623 additions and 967 deletions
|
@ -0,0 +1,81 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 29 Mar 2020 18:26:14 -0400
|
||||
Subject: [PATCH] Ensure Entity is never double registered
|
||||
|
||||
If something calls register twice, and the world is ticking, it could be
|
||||
enqueued to add twice.
|
||||
|
||||
Vs behavior of non ticking of just overwriting state.
|
||||
|
||||
We will now simply log a warning when this happens instead of crashing the server.
|
||||
|
||||
1.17: Probably not needed?
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 9da0d98bc2ed7876a00a734690ed42f01b9a9a9b..9898d5c8fab63c576831bd416ccf1854ed077b0d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -643,6 +643,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||
Entity entity2;
|
||||
|
||||
while ((entity2 = (Entity) this.toAddAfterTick.poll()) != null) {
|
||||
+ if (!entity2.isQueuedForRegister) continue; // Paper - ignore cancelled registers
|
||||
this.add(entity2);
|
||||
}
|
||||
|
||||
@@ -1400,6 +1401,19 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||
|
||||
public void onEntityRemoved(Entity entity) {
|
||||
org.spigotmc.AsyncCatcher.catchOp("entity unregister"); // Spigot
|
||||
+ // Paper start - fix entity registration issues
|
||||
+ if (entity instanceof EnderDragonPart) {
|
||||
+ // Usually this is a no-op for complex parts, and ID's should be removed, but go ahead and remove it anyways
|
||||
+ // Dragon parts are handled special in register. they don't receive a valid = true or register by UUID etc.
|
||||
+ this.entitiesById.remove(entity.getId(), entity);
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!entity.valid) {
|
||||
+ // Someone called remove before we ever got added, cancel the add.
|
||||
+ entity.isQueuedForRegister = false;
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
// Spigot start
|
||||
if ( entity instanceof Player )
|
||||
{
|
||||
@@ -1466,9 +1480,21 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||
|
||||
private void add(Entity entity) {
|
||||
org.spigotmc.AsyncCatcher.catchOp("entity register"); // Spigot
|
||||
+ // Paper start - don't double enqueue entity registration
|
||||
+ //noinspection ObjectEquality
|
||||
+ if (this.entitiesById.get(entity.getId()) == entity) {
|
||||
+ LOGGER.error(entity + " was already registered!");
|
||||
+ new Throwable().printStackTrace();
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (this.tickingEntities) {
|
||||
- this.toAddAfterTick.add(entity);
|
||||
+ if (!entity.isQueuedForRegister) { // Paper
|
||||
+ this.toAddAfterTick.add(entity);
|
||||
+ entity.isQueuedForRegister = true; // Paper
|
||||
+ }
|
||||
} else {
|
||||
+ entity.isQueuedForRegister = false; // Paper
|
||||
this.entitiesById.put(entity.getId(), entity);
|
||||
if (entity instanceof EnderDragon) {
|
||||
EnderDragonPart[] aentitycomplexpart = ((EnderDragon) entity).getSubEntities();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 43f77d01fceab107d3502d282205aa579d64cc4b..7e198b94f349d4c4d61502f5ad8c60686800d88f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -147,6 +147,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
|
||||
}
|
||||
|
||||
// Paper start
|
||||
+ public boolean isQueuedForRegister = false;
|
||||
public static Random SHARED_RANDOM = new Random() {
|
||||
private boolean locked = false;
|
||||
@Override
|
|
@ -0,0 +1,34 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 31 Mar 2020 03:01:45 -0400
|
||||
Subject: [PATCH] Fix unregistering entities from unloading chunks
|
||||
|
||||
CraftBukkit caused a regression here by making unloading chunks not
|
||||
have a ticket added and returning unloaded future.
|
||||
|
||||
This caused entities who were killed in same tick their chunk is unloading
|
||||
to not be able to be removed from the chunk.
|
||||
|
||||
This then results in dead entities lingering in the Chunk.
|
||||
|
||||
Combine that with a buggy detail of the previous implementation of
|
||||
the Dupe UUID patch, then this was the likely source of the "Ghost entities"
|
||||
|
||||
1.17: Probably not needed?
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 9898d5c8fab63c576831bd416ccf1854ed077b0d..c5dc41a3cf499038bd33451a189913cd3978b230 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1559,9 +1559,9 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||||
}
|
||||
|
||||
private void removeFromChunk(Entity entity) {
|
||||
- ChunkAccess ichunkaccess = chunkSource.getChunkUnchecked(entity.xChunk, entity.zChunk); // CraftBukkit - SPIGOT-5228: getChunkAt won't find the entity's chunk if it has already been unloaded (i.e. if it switched to state INACCESSIBLE).
|
||||
+ LevelChunk ichunkaccess = entity.getCurrentChunk(); // Paper - getChunkAt(x,z,full,false) is broken by CraftBukkit as it won't return an unloading chunk. Use our current chunk reference as this points to what chunk they need to be removed from anyways
|
||||
|
||||
- if (ichunkaccess instanceof LevelChunk) {
|
||||
+ if (ichunkaccess != null) { // Paper
|
||||
((LevelChunk) ichunkaccess).removeEntity(entity);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue