2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-04-02 05:45:33 +00:00
|
|
|
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/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
2020-07-14 10:58:55 +00:00
|
|
|
index 210e91c56197818b622a3ef12a644ea1b77584e0..2d3eeb3a87e345ceb3496ec60d684452c070d4b7 100644
|
2020-04-02 05:45:33 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
2020-06-27 04:57:36 +00:00
|
|
|
@@ -1443,6 +1443,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
2020-04-02 05:45:33 +00:00
|
|
|
|
|
|
|
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)) {
|
2020-06-25 23:38:24 +00:00
|
|
|
EntityTypes<?> entitytypes = entity.getEntityType();
|
|
|
|
int i = entitytypes.getChunkRange() * 16;
|
2020-04-02 05:45:33 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-07-14 10:58:55 +00:00
|
|
|
index e5f5efa00c69ca0a06b2f28313ef7163a0e5c208..9ae46983ce46f6e9f05869333474d7a3dac41658 100644
|
2020-04-02 05:45:33 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-07-14 10:58:55 +00:00
|
|
|
@@ -1351,7 +1351,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-04-02 05:45:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- 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);
|
2020-07-14 10:58:55 +00:00
|
|
|
@@ -1362,6 +1362,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-04-02 05:45:33 +00:00
|
|
|
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();
|