Paper/Spigot-Server-Patches/0265-Properly-remove-entities-on-dimension-teleport.patch
Shane Freeder 3496f2d7e4
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Developers!: You will need to clean up your work/Minecraft/1.13.2 folder for this

Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
b850a822 SPIGOT-4526: Add conversion time API for Zombie & subclasses

CraftBukkit Changes:
38cf676e SPIGOT-4534: CreatureSpawnEvent not being called for CHUNK_GEN
b446cb5d SPIGOT-4527: Fix sponges with waterlogged blocks
6ec8ea5c SPIGOT-4526: Add conversion time API for Zombie & subclasses
c64fe508 Mappings Update
a3c2ec03 Fix missing ServerListPingEvent call for legacy pings

Spigot Changes:
1dc156ce Rebuild patches
140f654d Mappings Update
2018-12-17 05:19:39 +00:00

52 lines
2.4 KiB
Diff

From 50aa3a863c329e3f0fb655a6414d40eb6ed6845f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 10 Jun 2018 20:04:42 -0400
Subject: [PATCH] Properly remove entities on dimension teleport
To teleport an entity between dimensions, the server makes a copy
and puts the copy in the new location, and marks the old one dead.
If this method got called for the same world in the same tick,
the entity would not have been removed from the UUID map, and the
world readd would fail.
This can be triggered even with a plugin if the entity is teleported
twice in the same tick, from world A to B, then back from B to A.
The re-add to A will fail to add the entity to the world. It will
actually be there, but it will not be visible on the client until
the server is restarted to re-try the add to world process again.
This bug was unlikely to be seen by many due to the double teleport
requirement, but plugins (such as my own) use this method to
trigger a "reload" of the entity on the client.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 7c558c355..d033969cd 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -2594,7 +2594,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
// CraftBukkit end */
- this.world.kill(this);
+ this.world.removeEntity(this); // Paper - Fully remove entity, can't have dupes in the UUID map
this.dead = false;
this.world.methodProfiler.enter("reposition");
/* CraftBukkit start - Handled in calculateTarget
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 55e45dbb1..91850fded 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1021,6 +1021,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
}
protected void c(Entity entity) {
+ if (!this.entitiesByUUID.containsKey(entity.getUniqueID()) && !entity.valid) return; // Paper - Already removed, dont fire twice - this looks like it can happen even without our changes
super.c(entity);
this.entitiesById.d(entity.getId());
this.entitiesByUUID.remove(entity.getUniqueID());
--
2.20.0