Paper/Spigot-Server-Patches/0159-Fix-Double-World-Add-issues.patch
Zach Brown c02c01b2c5
Add rate limiting to PacketPlayInUseItem as well
Also removes our toggle for Spigot's option, I doubt anyone uses it.
2016-09-10 21:44:06 -05:00

38 lines
1.9 KiB
Diff

From 5ac6ef5ec3966a96a72feb81de1f03c8b4a049d4 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 eb36e1f..3a46a0a 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -523,7 +523,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 1d47a11..f7d9a7c 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1039,6 +1039,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.10.0.windows.1