aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0147-Fix-Double-World-Add-issues.patch
blob: 0e3dda835af5b4a3a1073a633745274bac2ad21e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From 8ed79f772341407250572ea3a08b13d46bafab63 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 21 Jun 2016 22:54:34 -0400
Subject: [PATCH] Fix Double World Add issues

Vanilla will double add Spider Jockeys to the world, so ignore already added.

Also add debug if something else tries to, and abort before world gets bad state

diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index 310ab96ab..19411212a 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -525,7 +525,7 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
     }
 
     public static void a(Entity entity, World world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
-        if (world.addEntity(entity, reason) && entity.isVehicle()) {
+        if (!entity.valid && world.addEntity(entity, reason) && entity.isVehicle()) { // Paper
             // CraftBukkit end
             Iterator iterator = entity.bx().iterator();
 
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 7ed3a0677..7900fca57 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1098,6 +1098,7 @@ public abstract class World implements IBlockAccess {
     public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
         org.spigotmc.AsyncCatcher.catchOp( "entity add"); // Spigot
         if (entity == null) return false;
+        if (entity.valid) { MinecraftServer.LOGGER.error("Attempted Double World add on " + entity, new Throwable()); return true; } // Paper
         // CraftBukkit end
         int i = MathHelper.floor(entity.locX / 16.0D);
         int j = MathHelper.floor(entity.locZ / 16.0D);
-- 
2.12.2