mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
c953e51dd7
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing CraftBukkit Changes: 221aed6cf SPIGOT-6413: Server Corruption Changing Blocks in Piston Events 721c4966b SPIGOT-6411: The PlayerEditBookEvent is not called when the player edits a book in the off-hand. be0e94581 Add mc-dev imports Spigot Changes: a25e8ed2 Remove mc-dev imports
49 lines
3.0 KiB
Diff
49 lines
3.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Thu, 2 Apr 2020 01:42:39 -0400
|
|
Subject: [PATCH] Prevent Double PlayerChunkMap adds crashing server
|
|
|
|
Suspected case would be around the technique used in .stopRiding
|
|
Stack will identify any causer of this and warn instead of crashing.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
index 4be5f3be285b1944eee66684c1a565ac1eceb024..12cfe9f3c89316557e94c8b944b4f82277fb8877 100644
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerChunkMap.java
|
|
@@ -1495,6 +1495,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
|
|
|
protected void addEntity(Entity entity) {
|
|
org.spigotmc.AsyncCatcher.catchOp("entity track"); // Spigot
|
|
+ // Paper start - ignore and warn about illegal addEntity calls instead of crashing server
|
|
+ if (!entity.valid || entity.world != this.world || this.trackedEntities.containsKey(entity.getId())) {
|
|
+ new Throwable("[ERROR] Illegal PlayerChunkMap::addEntity for world " + this.world.getWorld().getName()
|
|
+ + ": " + entity + (this.trackedEntities.containsKey(entity.getId()) ? " ALREADY CONTAINED (This would have crashed your server)" : ""))
|
|
+ .printStackTrace();
|
|
+ return;
|
|
+ }
|
|
+ // Paper end
|
|
if (!(entity instanceof EntityComplexPart)) {
|
|
EntityTypes<?> entitytypes = entity.getEntityType();
|
|
int i = entitytypes.getChunkRange() * 16;
|
|
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
index 49a4c2ab35e00cc30bcfad7c702f9278db7b1155..5d085321414134043e52d8012e12a8891529097c 100644
|
|
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
@@ -1531,7 +1531,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
}
|
|
}
|
|
|
|
- this.getChunkProvider().addEntity(entity);
|
|
+ // this.getChunkProvider().addEntity(entity); // Paper - moved down below valid=true
|
|
// CraftBukkit start - SPIGOT-5278
|
|
if (entity instanceof EntityDrowned) {
|
|
this.navigators.add(((EntityDrowned) entity).navigationWater);
|
|
@@ -1542,6 +1542,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
this.navigators.add(((EntityInsentient) entity).getNavigation());
|
|
}
|
|
entity.valid = true; // CraftBukkit
|
|
+ this.getChunkProvider().addEntity(entity); // Paper - from above to be below valid=true
|
|
// Paper start - Set origin location when the entity is being added to the world
|
|
if (entity.origin == null) {
|
|
entity.origin = entity.getBukkitEntity().getLocation();
|