diff --git a/Spigot-Server-Patches/0247-Player.setPlayerProfile-API.patch b/Spigot-Server-Patches/0247-Player.setPlayerProfile-API.patch index 249a14d0cd..ac40b7d8a0 100644 --- a/Spigot-Server-Patches/0247-Player.setPlayerProfile-API.patch +++ b/Spigot-Server-Patches/0247-Player.setPlayerProfile-API.patch @@ -1,4 +1,4 @@ -From 4557d91dd4ca4ccd0d1ddbb66fdde9161dc25f47 Mon Sep 17 00:00:00 2001 +From 41b4ebc08ef0a4929b0564d18d68cc105280bf85 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 18 Mar 2018 12:29:48 -0400 Subject: [PATCH] Player.setPlayerProfile API @@ -6,7 +6,7 @@ Subject: [PATCH] Player.setPlayerProfile API This can be useful for changing name or skins after a player has logged in. diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java -index d04f9b380e..5015bd0710 100644 +index d04f9b380..5015bd071 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -67,7 +67,7 @@ public abstract class EntityHuman extends EntityLiving { @@ -19,7 +19,7 @@ index d04f9b380e..5015bd0710 100644 private final ItemCooldown ce; @Nullable diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java -index a721eb30e9..258bdfe66a 100644 +index a721eb30e..258bdfe66 100644 --- a/src/main/java/net/minecraft/server/LoginListener.java +++ b/src/main/java/net/minecraft/server/LoginListener.java @@ -38,7 +38,7 @@ public class LoginListener implements PacketLoginInListener, ITickable { @@ -48,7 +48,7 @@ index a721eb30e9..258bdfe66a 100644 uniqueId = i.getId(); // Paper end diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 9f69000cb2..3c85d6323b 100644 +index 9f69000cb..8313c5192 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1,6 +1,8 @@ @@ -91,7 +91,7 @@ index 9f69000cb2..3c85d6323b 100644 getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other)); -@@ -1191,6 +1204,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1191,6 +1204,46 @@ public class CraftPlayer extends CraftHumanEntity implements Player { entry.updatePlayer(getHandle()); } } @@ -109,10 +109,31 @@ index 9f69000cb2..3c85d6323b 100644 + for (EntityPlayer player : players) { + player.getBukkitEntity().reregisterPlayer(self); + } ++ refreshPlayer(); + } + public PlayerProfile getPlayerProfile() { + return new CraftPlayerProfile(this).clone(); + } ++ ++ private void refreshPlayer() { ++ EntityPlayer handle = getHandle(); ++ ++ Location loc = getLocation(); ++ ++ PlayerConnection connection = handle.playerConnection; ++ reregisterPlayer(handle); ++ ++ //Respawn the player then update their position and selected slot ++ connection.sendPacket(new net.minecraft.server.PacketPlayOutRespawn(handle.dimension, handle.world.getDifficulty(), handle.world.getWorldData().getType(), handle.playerInteractManager.getGameMode())); ++ handle.updateAbilities(); ++ connection.sendPacket(new net.minecraft.server.PacketPlayOutPosition(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), new HashSet<>(), 0)); ++ net.minecraft.server.MinecraftServer.getServer().getPlayerList().updateClient(handle); ++ ++ if (this.isOp()) { ++ this.setOp(false); ++ this.setOp(true); ++ } ++ } + // Paper end public void removeDisconnectingPlayer(Player player) { diff --git a/Spigot-Server-Patches/0253-Flag-to-disable-the-channel-limit.patch b/Spigot-Server-Patches/0253-Flag-to-disable-the-channel-limit.patch index 02c36b4567..fb5e686fa8 100644 --- a/Spigot-Server-Patches/0253-Flag-to-disable-the-channel-limit.patch +++ b/Spigot-Server-Patches/0253-Flag-to-disable-the-channel-limit.patch @@ -1,4 +1,4 @@ -From 5f354f6ae7a61b535e8d1a764b49675c944dd812 Mon Sep 17 00:00:00 2001 +From 397887e6789c73b3cee3d5fc35f7a1c5c5a4b19d Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sat, 31 Mar 2018 17:04:26 +0100 Subject: [PATCH] Flag to disable the channel limit @@ -9,7 +9,7 @@ e.g. servers which allow and support the usage of mod packs. provide an optional flag to disable this check, at your own risk. diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 3c85d6323b..ab9956fa24 100644 +index 8313c5192..8c1e49759 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -132,6 +132,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -20,7 +20,7 @@ index 3c85d6323b..ab9956fa24 100644 // Paper end public CraftPlayer(CraftServer server, EntityPlayer entity) { -@@ -1385,7 +1386,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1406,7 +1407,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public void addChannel(String channel) { diff --git a/Spigot-Server-Patches/0299-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch b/Spigot-Server-Patches/0299-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch index 84a4dd6bc3..4d07bb8119 100644 --- a/Spigot-Server-Patches/0299-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch +++ b/Spigot-Server-Patches/0299-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch @@ -1,12 +1,31 @@ -From 73e6428814b5eb1135bb45d9d3c2f30695c052e6 Mon Sep 17 00:00:00 2001 +From 50bd6c799a35435682d288098ad5a3999f888f42 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 21 Jul 2018 08:25:40 -0400 Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues Add -Ddebug.entities=true to your JVM flags to gain more information +diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java +index ea8684747..5fd0c0cf5 100644 +--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java ++++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java +@@ -566,6 +566,14 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); ++ // Paper start ++ if (entity.getChunkX() != chunk.locX || entity.getChunkZ() != chunk.locZ) { ++ LogManager.getLogger().error(entity + " is not actually in this chunk! Report this to https://github.com/PaperMC/Paper/issues/1223", new Throwable()); ++ } ++ if ((int)Math.floor(entity.locX) >> 4 != chunk.locX || (int)Math.floor(entity.locZ) >> 4 != chunk.locZ) { ++ LogManager.getLogger().error(entity + " will be leaving this chunk but saved to it. Report this to https://github.com/PaperMC/Paper/issues/1223", new Throwable()); ++ } ++ // Paper end + + if (entity.d(nbttagcompound1)) { + chunk.f(true); diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index 47ce5cda76..b308f44168 100644 +index 47ce5cda7..b308f4416 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -71,6 +71,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -18,7 +37,7 @@ index 47ce5cda76..b308f44168 100644 if (bukkitEntity == null) { bukkitEntity = CraftEntity.getEntity(world.getServer(), this); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index b048343b7c..747d99dbe6 100644 +index b048343b7..747d99dbe 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -53,6 +53,10 @@ public class WorldServer extends World implements IAsyncTaskHandler { diff --git a/Spigot-Server-Patches/0301-Duplicate-UUID-Resolve-Option.patch b/Spigot-Server-Patches/0301-Duplicate-UUID-Resolve-Option.patch index caa8760e11..d7e26baa45 100644 --- a/Spigot-Server-Patches/0301-Duplicate-UUID-Resolve-Option.patch +++ b/Spigot-Server-Patches/0301-Duplicate-UUID-Resolve-Option.patch @@ -1,4 +1,4 @@ -From ffb9e895c678e0bc8bcd62042080e712d786e6dc Mon Sep 17 00:00:00 2001 +From 7a0a0416714c5b37aebde624c0c621c0b9c5612c Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 21 Jul 2018 14:27:34 -0400 Subject: [PATCH] Duplicate UUID Resolve Option @@ -33,7 +33,7 @@ But for those who are ok with leaving this inconsistent behavior, you may use WA It is recommended you regenerate the entities, as these were legit entities, and deserve your love. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 7bd7aa0d94..ba6d5b7ff5 100644 +index 7bd7aa0d9..ba6d5b7ff 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -430,4 +430,40 @@ public class PaperWorldConfig { @@ -78,7 +78,7 @@ index 7bd7aa0d94..ba6d5b7ff5 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index b37fa3829b..c56e435b19 100644 +index b37fa3829..95c6812d7 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -1,5 +1,10 @@ @@ -108,7 +108,7 @@ index b37fa3829b..c56e435b19 100644 } int k = MathHelper.floor(entity.locY / 16.0D); -@@ -865,6 +872,37 @@ public class Chunk implements IChunkAccess { +@@ -865,6 +872,35 @@ public class Chunk implements IChunkAccess { for (int j = 0; j < i; ++j) { List entityslice = aentityslice[j]; // Spigot @@ -126,13 +126,11 @@ index b37fa3829b..c56e435b19 100644 + switch (mode) { + case REGEN: { + entity.setUUID(UUID.randomUUID()); -+ logger.error("Duplicate UUID found used by " + other); -+ logger.error("Regenerated a new UUID for " + entity); ++ logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", regenerated UUID for " + entity + ". See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about."); + break; + } + case DELETE: { -+ logger.error("Duplicate UUID found used by " + other); -+ logger.error("Deleting duplicate entity " + entity); ++ logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", deleted entity " + entity + ". See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about."); + entity.die(); + iterator.remove(); + break; @@ -147,7 +145,7 @@ index b37fa3829b..c56e435b19 100644 this.world.a((Collection) entityslice); } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java -index b308f44168..b6d6d4f378 100644 +index b308f4416..b6d6d4f37 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -2734,6 +2734,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke @@ -159,7 +157,7 @@ index b308f44168..b6d6d4f378 100644 this.uniqueID = uuid; this.au = this.uniqueID.toString(); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 747d99dbe6..7a9f28421b 100644 +index 747d99dbe..7a9f28421 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -40,7 +40,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { diff --git a/Spigot-Server-Patches/0310-Mark-chunk-dirty-anytime-entities-change-to-guarante.patch b/Spigot-Server-Patches/0310-Mark-chunk-dirty-anytime-entities-change-to-guarante.patch new file mode 100644 index 0000000000..e7bd156ddf --- /dev/null +++ b/Spigot-Server-Patches/0310-Mark-chunk-dirty-anytime-entities-change-to-guarante.patch @@ -0,0 +1,30 @@ +From 37d9641af77fd0ec11e932162a0125bd53f05ce3 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Mon, 23 Jul 2018 22:18:31 -0400 +Subject: [PATCH] Mark chunk dirty anytime entities change to guarantee it + saves + + +diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java +index 95c6812d7..aa75cc420 100644 +--- a/src/main/java/net/minecraft/server/Chunk.java ++++ b/src/main/java/net/minecraft/server/Chunk.java +@@ -714,6 +714,7 @@ public class Chunk implements IChunkAccess { + entity.ag = this.locZ; + this.entitySlices[k].add(entity); + // Paper start ++ this.markDirty(); + if (entity instanceof EntityItem) { + itemCounts[k]++; + } else if (entity instanceof IInventory) { +@@ -745,6 +746,7 @@ public class Chunk implements IChunkAccess { + if (!this.entitySlices[i].remove(entity)) { + return; + } ++ this.markDirty(); + if (entity instanceof EntityItem) { + itemCounts[i]--; + } else if (entity instanceof IInventory) { +-- +2.18.0 + diff --git a/Spigot-Server-Patches/0311-Add-some-Debug-to-Chunk-Entity-slices.patch b/Spigot-Server-Patches/0311-Add-some-Debug-to-Chunk-Entity-slices.patch new file mode 100644 index 0000000000..14e6a515b3 --- /dev/null +++ b/Spigot-Server-Patches/0311-Add-some-Debug-to-Chunk-Entity-slices.patch @@ -0,0 +1,77 @@ +From 1a1fa5156619969d65be7638a7cd2f056c9a933c Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Mon, 23 Jul 2018 22:44:23 -0400 +Subject: [PATCH] Add some Debug to Chunk Entity slices + +If we detect unexpected state, log and try to recover + +This should hopefully avoid duplicate entities ever being created +if the entity was to end up in 2 different chunk slices + +diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java +index aa75cc420..56a74c606 100644 +--- a/src/main/java/net/minecraft/server/Chunk.java ++++ b/src/main/java/net/minecraft/server/Chunk.java +@@ -712,8 +712,33 @@ public class Chunk implements IChunkAccess { + entity.ae = this.locX; + entity.af = k; + entity.ag = this.locZ; +- this.entitySlices[k].add(entity); ++ + // Paper start ++ List entitySlice = this.entitySlices[k]; ++ boolean inThis = entitySlice.contains(entity); ++ if (entity.entitySlice != null || inThis) { ++ if (entity.entitySlice == entitySlice || inThis) { ++ LogManager.getLogger().warn(entity + " was already in this chunk section! Report this to https://github.com/PaperMC/Paper/issues/1223"); ++ new Throwable().printStackTrace(); ++ return; ++ } else { ++ LogManager.getLogger().warn(entity + " is still in another ChunkSection! Report this to https://github.com/PaperMC/Paper/issues/1223"); ++ ++ Chunk chunk = entity.getCurrentChunk(); ++ if (chunk != null) { ++ if (chunk != this) { ++ LogManager.getLogger().warn(entity + " was in another chunk at that! " + chunk.locX + "," + chunk.locZ); ++ } ++ chunk.removeEntity(entity); ++ } else { ++ removeEntity(entity); ++ } ++ new Throwable().printStackTrace(); ++ } ++ } ++ entity.entitySlice = entitySlice; ++ entitySlice.add(entity); ++ + this.markDirty(); + if (entity instanceof EntityItem) { + itemCounts[k]++; +@@ -746,6 +771,12 @@ public class Chunk implements IChunkAccess { + if (!this.entitySlices[i].remove(entity)) { + return; + } ++ if (entitySlices[i] == entity.entitySlice) { ++ entity.entitySlice = null; ++ } else { ++ LogManager.getLogger().warn(entity + " was removed from a entitySlice we did not expect. Report this to https://github.com/PaperMC/Paper/issues/1223"); ++ new Throwable().printStackTrace(); ++ } + this.markDirty(); + if (entity instanceof EntityItem) { + itemCounts[i]--; +diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java +index b6d6d4f37..bc4ba9f3c 100644 +--- a/src/main/java/net/minecraft/server/Entity.java ++++ b/src/main/java/net/minecraft/server/Entity.java +@@ -63,6 +63,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke + } + } + }; ++ Object entitySlice = null; + // Paper end + static boolean isLevelAtLeast(NBTTagCompound tag, int level) { + return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; +-- +2.18.0 +