13
0
geforkt von Mirrors/Paper

Add "Safe Regen" Duplicate UUID resolver and make default

After witnessing behavior of the regeneration logs, its clear that Vanilla
has had bugs with saving duplicate entities for a while....

Some entities are saved in multiple chunks, and now we are bringing those duplicates
out that use to never surface.

This mode will analyze if the entity appears to be a duplicate (near the other dupe uuid)
and delete the entity instead.

This should reduce regenerations to entities that are nowhere near each other, and
therefore more likely to be subject to real UUID collisions due to our
previous bug, and therefor should survive the chunk load.
Dieser Commit ist enthalten in:
Aikar 2018-08-02 23:06:03 -04:00
Ursprung 8930ecd00e
Commit 4128c348c2
2 geänderte Dateien mit 23 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -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 {

Datei anzeigen

@ -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 {