diff --git a/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch b/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch index 6b4e7c518f..a1f35d958c 100644 --- a/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch +++ b/Spigot-Server-Patches/Add-some-Debug-to-Chunk-Entity-slices.patch @@ -9,7 +9,7 @@ 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 27b73acdee..be3ac2d940 100644 +index ccb30d5bfd..94b294e87b 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ public class Chunk { diff --git a/Spigot-Server-Patches/Duplicate-UUID-Resolve-Option.patch b/Spigot-Server-Patches/Duplicate-UUID-Resolve-Option.patch index 5377509981..e0cd02936b 100644 --- a/Spigot-Server-Patches/Duplicate-UUID-Resolve-Option.patch +++ b/Spigot-Server-Patches/Duplicate-UUID-Resolve-Option.patch @@ -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 14c8edeffc..1f4e438c1f 100644 +index 14c8edeffc..46ec852b6c 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -42,12 +42,16 @@ index 14c8edeffc..1f4e438c1f 100644 } + + public enum DuplicateUUIDMode { -+ REGEN, DELETE, NOTHING, WARN ++ SAFE_REGEN, REGEN, DELETE, NOTHING, WARN + } -+ public DuplicateUUIDMode duplicateUUIDMode = DuplicateUUIDMode.REGEN; ++ public DuplicateUUIDMode duplicateUUIDMode = DuplicateUUIDMode.SAFE_REGEN; + private void repairDuplicateUUID() { -+ String desiredMode = getString("duplicate-uuid-resolver", "regenerate").toLowerCase().trim(); ++ String desiredMode = getString("duplicate-uuid-resolver", "saferegen").toLowerCase().trim(); + switch (desiredMode.toLowerCase()) { ++ case "saferegen": ++ case "saferegenerate": ++ duplicateUUIDMode = DuplicateUUIDMode.SAFE_REGEN; ++ log("Duplicate UUID Resolve: Safer Regenerate New UUID (Delete likely duplicates)"); + case "regen": + case "regenerate": + duplicateUUIDMode = DuplicateUUIDMode.REGEN; @@ -78,7 +82,7 @@ index 14c8edeffc..1f4e438c1f 100644 + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java -index f1815d3766..74612a3924 100644 +index 4757081090..4018410485 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -0,0 +0,0 @@ @@ -123,8 +127,19 @@ index f1815d3766..74612a3924 100644 + if (other == null || other.dead || world.getEntityUnloadQueue().contains(other)) { + other = thisChunk.get(entity.uniqueID); + } ++ ++ if (mode == DuplicateUUIDMode.SAFE_REGEN && other != null && !other.dead && ++ !world.getEntityUnloadQueue().contains(other) ++ && java.util.Objects.equals(other.getSaveID(), entity.getSaveID()) ++ && entity.getBukkitEntity().getLocation().distance(other.getBukkitEntity().getLocation()) < 24 ++ ) { ++ logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", deleted entity " + entity + " because it was near the duplicate and likely an actual duplicate. See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about."); ++ entity.die(); ++ continue; ++ } + if (other != null && !other.dead) { + switch (mode) { ++ case SAFE_REGEN: + case REGEN: { + entity.setUUID(UUID.randomUUID()); + 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."); @@ -149,7 +164,7 @@ index f1815d3766..74612a3924 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 93ab050fa6..fdabb1e369 100644 +index 7b856cad91..eb8904a728 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener, KeyedObject { // Paper @@ -161,7 +176,7 @@ index 93ab050fa6..fdabb1e369 100644 this.uniqueID = uuid; this.ar = this.uniqueID.toString(); diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 52adee8806..b4de3b515a 100644 +index d5cd289c21..57217bec2b 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {