Improvements to Logging Warnings/Dupe Entities - Resolves #1544

1) Removed "Regen" mode of Dupe UUID resolver, forced safe.
Some servers who updated before we had safe mode added still had this value.

There's really no reason to keep this mode, as we've seen that vanilla
triggers this often and 99.9999999% of cases will be an actual duplicate
that needs to be deleted.

2) Made Vanilla Debug messages about dupe UUIDs and dupe uuid resolve messages
only show up if the debug.entities flag is on. This will stop server owners
from panicing from seeing these logs, and stop opening bug reports on this,
only for us to tell you "don't worry about it".

3) Avoid adding entities to world that are already added to world.

This can be triggered by anything that causes an entity to be added
to the world during the chunk load process, such as chunk conversions.

Issue #1544 was a case of this.

4) Removed debug warning about ExpiringMap.

Nothing more I know to do about this anyways. We recover from it,
stop warning to reduce noise of issues to us.
This commit is contained in:
Aikar 2018-10-07 14:58:53 -04:00
parent 438ee3f487
commit 2a2d9fb508
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE
24 changed files with 155 additions and 160 deletions

View file

@ -1,4 +1,4 @@
From 06f6a8d9e4e27632a3122849abe57ff0e5966e7c Mon Sep 17 00:00:00 2001
From 23a899902be4cf2fe569776330edac2e5dd52740 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 21 Jul 2018 08:25:40 -0400
Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues
@ -17,22 +17,33 @@ index 42c1c47c58..3606c78843 100644
public CraftEntity getBukkitEntity() {
if (bukkitEntity == null) {
bukkitEntity = CraftEntity.getEntity(world.getServer(), this);
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index ee2cdb897c..a341f5de9a 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -115,6 +115,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
public boolean pvpMode;
public boolean keepSpawnInMemory = true;
public ChunkGenerator generator;
+ public static final boolean DEBUG_ENTITIES = Boolean.getBoolean("debug.entities"); // Paper
public boolean captureBlockStates = false;
public boolean captureTreeGeneration = false;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 27278078e4..f6becaae43 100644
index 27278078e4..7eab55e7c1 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -55,6 +55,10 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@@ -55,6 +55,9 @@ public class WorldServer extends World implements IAsyncTaskHandler {
// CraftBukkit start
public final DimensionManager dimension;
+ private static final boolean DEBUG_ENTITIES = Boolean.getBoolean("debug.entities"); // Paper
+ private static Throwable getAddToWorldStackTrace(Entity entity) {
+ return new Throwable(entity + " Added to world at " + new java.util.Date());
+ }
// Add env and gen to constructor
public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, PersistentCollection persistentcollection, WorldData worlddata, DimensionManager dimensionmanager, MethodProfiler methodprofiler, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) {
@@ -974,7 +978,12 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@@ -974,7 +977,12 @@ public class WorldServer extends World implements IAsyncTaskHandler {
private boolean j(Entity entity) {
if (entity.dead) {
@ -46,14 +57,16 @@ index 27278078e4..f6becaae43 100644
return false;
} else {
UUID uuid = entity.getUniqueID();
@@ -986,8 +995,14 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@@ -986,8 +994,15 @@ public class WorldServer extends World implements IAsyncTaskHandler {
this.g.remove(entity1);
} else {
if (!(entity instanceof EntityHuman)) {
- WorldServer.a.error("Keeping entity {} that already exists with UUID {} - " + entity1, EntityTypes.getName(entity1.P()), uuid.toString()); // CraftBukkit // Paper
+ WorldServer.a.error("Keeping entity {} that already exists with UUID {}", entity1, uuid.toString()); // CraftBukkit // Paper
WorldServer.a.error("Deleting duplicate entity {}", entity); // Paper
- WorldServer.a.error("Deleting duplicate entity {}", entity); // Paper
+ if (DEBUG_ENTITIES) {
+ WorldServer.a.error("Keeping entity {} that already exists with UUID {}", entity1, uuid.toString()); // CraftBukkit // Paper
+ WorldServer.a.error("Deleting duplicate entity {}", entity); // Paper
+
+ if (entity1.addedToWorldStack != null) {
+ entity1.addedToWorldStack.printStackTrace();
+ }

View file

@ -1,4 +1,4 @@
From ecfccf2374fd84352a1fa3fe4c2ea46d0720addd Mon Sep 17 00:00:00 2001
From 82ec8fd06e4557c6fca2c4a6f4c3ba002044c0e8 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 21 Jul 2018 14:27:34 -0400
Subject: [PATCH] Duplicate UUID Resolve Option
@ -33,16 +33,16 @@ 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 deb0d4f053..249af8b4c6 100644
index deb0d4f053..75b591bc2a 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -449,4 +449,47 @@ public class PaperWorldConfig {
@@ -449,4 +449,43 @@ public class PaperWorldConfig {
log("Bed Search Radius: " + bedSearchRadius);
}
}
+
+ public enum DuplicateUUIDMode {
+ SAFE_REGEN, REGEN, DELETE, NOTHING, WARN
+ SAFE_REGEN, DELETE, NOTHING, WARN
+ }
+ public DuplicateUUIDMode duplicateUUIDMode = DuplicateUUIDMode.SAFE_REGEN;
+ public int duplicateUUIDDeleteRange = 32;
@ -50,15 +50,12 @@ index deb0d4f053..249af8b4c6 100644
+ String desiredMode = getString("duplicate-uuid-resolver", "saferegen").toLowerCase().trim();
+ duplicateUUIDDeleteRange = getInt("duplicate-uuid-saferegen-delete-range", duplicateUUIDDeleteRange);
+ switch (desiredMode.toLowerCase()) {
+ case "regen":
+ case "regenerate":
+ case "saferegen":
+ case "saferegenerate":
+ duplicateUUIDMode = DuplicateUUIDMode.SAFE_REGEN;
+ log("Duplicate UUID Resolve: Safer Regenerate New UUID (Delete likely duplicates within " + duplicateUUIDDeleteRange + " blocks)");
+ break;
+ case "regen":
+ case "regenerate":
+ duplicateUUIDMode = DuplicateUUIDMode.REGEN;
+ log("Duplicate UUID Resolve: Regenerate New UUID");
+ log("Duplicate UUID Resolve: Regenerate New UUID if distant (Delete likely duplicates within " + duplicateUUIDDeleteRange + " blocks)");
+ break;
+ case "remove":
+ case "delete":
@ -69,7 +66,6 @@ index deb0d4f053..249af8b4c6 100644
+ case "nothing":
+ duplicateUUIDMode = DuplicateUUIDMode.NOTHING;
+ logError("Duplicate UUID Resolve: Do Nothing (no logs) - Warning, may lose indication of bad things happening");
+ logError("PaperMC Strongly discourages use of this setting! Triggering these messages means SOMETHING IS WRONG!");
+ break;
+ case "log":
+ case "warn":
@ -78,14 +74,14 @@ index deb0d4f053..249af8b4c6 100644
+ break;
+ default:
+ duplicateUUIDMode = DuplicateUUIDMode.WARN;
+ logError("Warning: Invalidate duplicate-uuid-resolver config " + desiredMode + " - must be one of: regen, delete, nothing, warn");
+ logError("Warning: Invalid duplicate-uuid-resolver config " + desiredMode + " - must be one of: regen, delete, nothing, warn");
+ log("Duplicate UUID Resolve: Warn (do nothing but log it happened, may be spammy)");
+ break;
+ }
+ }
}
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 0a40488586..60829fded7 100644
index 0a40488586..1245576e8a 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -1,5 +1,10 @@
@ -115,13 +111,13 @@ index 0a40488586..60829fded7 100644
}
int k = MathHelper.floor(entity.locY / 16.0D);
@@ -874,6 +881,51 @@ public class Chunk implements IChunkAccess {
@@ -874,6 +881,50 @@ public class Chunk implements IChunkAccess {
for (int j = 0; j < i; ++j) {
List entityslice = aentityslice[j]; // Spigot
+ // Paper start
+ DuplicateUUIDMode mode = world.paperConfig.duplicateUUIDMode;
+ if (mode == DuplicateUUIDMode.WARN || mode == DuplicateUUIDMode.DELETE || mode == DuplicateUUIDMode.REGEN || mode == DuplicateUUIDMode.SAFE_REGEN) {
+ if (mode == DuplicateUUIDMode.WARN || mode == DuplicateUUIDMode.DELETE || mode == DuplicateUUIDMode.SAFE_REGEN) {
+ Map<UUID, Entity> thisChunk = new HashMap<>();
+ for (Iterator<Entity> iterator = ((List<Entity>) entityslice).iterator(); iterator.hasNext(); ) {
+ Entity entity = iterator.next();
@ -136,27 +132,26 @@ index 0a40488586..60829fded7 100644
+ && java.util.Objects.equals(other.getSaveID(), entity.getSaveID())
+ && entity.getBukkitEntity().getLocation().distance(other.getBukkitEntity().getLocation()) < world.paperConfig.duplicateUUIDDeleteRange
+ ) {
+ 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.");
+ if (World.DEBUG_ENTITIES) 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();
+ iterator.remove();
+ continue;
+ }
+ if (other != null && !other.dead) {
+ switch (mode) {
+ case SAFE_REGEN:
+ case REGEN: {
+ case SAFE_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.");
+ if (World.DEBUG_ENTITIES) 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.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.");
+ if (World.DEBUG_ENTITIES) 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;
+ }
+ default:
+ logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", doing nothing to " + entity + ". See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about.");
+ if (World.DEBUG_ENTITIES) logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", doing nothing to " + entity + ". See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about.");
+ break;
+ }
+ }
@ -180,7 +175,7 @@ index 3606c78843..57adaf2a4c 100644
this.uniqueID = uuid;
this.au = this.uniqueID.toString();
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index ee2cdb897c..956eabd7dc 100644
index a341f5de9a..61c260a2fb 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -75,7 +75,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@ -193,7 +188,7 @@ index ee2cdb897c..956eabd7dc 100644
public final List<TileEntity> tileEntityListTick = Lists.newArrayList();
private final List<TileEntity> c = Lists.newArrayList();
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index f6becaae43..f7078ded5c 100644
index 7eab55e7c1..0e63a0b5cd 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -41,7 +41,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@ -205,31 +200,16 @@ index f6becaae43..f7078ded5c 100644
public boolean savingDisabled;
private boolean J;
private int emptyTime;
@@ -995,14 +995,17 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@@ -994,7 +994,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
this.g.remove(entity1);
} else {
if (!(entity instanceof EntityHuman)) {
- WorldServer.a.error("Keeping entity {} that already exists with UUID {}", entity1, uuid.toString()); // CraftBukkit // Paper
- WorldServer.a.error("Deleting duplicate entity {}", entity); // Paper
- if (DEBUG_ENTITIES) {
- if (entity1.addedToWorldStack != null) {
- entity1.addedToWorldStack.printStackTrace();
+ if (entity.world.paperConfig.duplicateUUIDMode != com.destroystokyo.paper.PaperWorldConfig.DuplicateUUIDMode.NOTHING) {
+ WorldServer.a.error("Keeping entity {} that already exists with UUID {}", entity1, uuid.toString()); // CraftBukkit // Paper
+ WorldServer.a.error("Duplicate entity {} will not be added to the world. See paper.yml duplicate-uuid-resolver and set this to either regen, delete or nothing to get rid of this message", entity); // Paper
+ if (DEBUG_ENTITIES) {
+ if (entity1.addedToWorldStack != null) {
+ entity1.addedToWorldStack.printStackTrace();
+ }
+ getAddToWorldStackTrace(entity).printStackTrace();
}
- getAddToWorldStackTrace(entity).printStackTrace();
}
+
return false;
}
+ if (DEBUG_ENTITIES && entity.world.paperConfig.duplicateUUIDMode != com.destroystokyo.paper.PaperWorldConfig.DuplicateUUIDMode.NOTHING) {
WorldServer.a.error("Keeping entity {} that already exists with UUID {}", entity1, uuid.toString()); // CraftBukkit // Paper
WorldServer.a.error("Deleting duplicate entity {}", entity); // Paper
@@ -1025,7 +1028,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@@ -1025,7 +1025,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
}
Entity old = this.entitiesByUUID.put(entity.getUniqueID(), entity);

View file

@ -1,11 +1,11 @@
From 13c3f44b26ba139b2efbe86eec73387824392748 Mon Sep 17 00:00:00 2001
From 0ac7a404449ddf6c3547d48f3c98b162638138af Mon Sep 17 00:00:00 2001
From: Hugo Manrique <hugmanrique@gmail.com>
Date: Mon, 23 Jul 2018 12:57:39 +0200
Subject: [PATCH] Option to prevent armor stands from doing entity lookups
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 249af8b4c6..4fbafb5bf2 100644
index 75b591bc2a..a2656abaf0 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -361,6 +361,11 @@ public class PaperWorldConfig {
@ -21,10 +21,10 @@ index 249af8b4c6..4fbafb5bf2 100644
private void maxEntityCollision() {
maxCollisionsPerEntity = getInt( "max-entity-collisions", this.spigotConfig.getInt("max-entity-collisions", 8) );
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 956eabd7dc..6605449a8b 100644
index 61c260a2fb..d58de13028 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1612,6 +1612,14 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1613,6 +1613,14 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
}

View file

@ -1,4 +1,4 @@
From ead1757140df48b12c98fc7cae969d7248308e56 Mon Sep 17 00:00:00 2001
From f94f20cf19c01d396b884f087d96197a74349396 Mon Sep 17 00:00:00 2001
From: Hugo Manrique <hugmanrique@gmail.com>
Date: Mon, 23 Jul 2018 14:22:26 +0200
Subject: [PATCH] Vanished players don't have rights
@ -64,10 +64,10 @@ index ea8f1c170a..fdfc0d442e 100644
return this.a.a();
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 6605449a8b..81777fce64 100644
index d58de13028..b3eaac23a6 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1594,6 +1594,37 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1595,6 +1595,37 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
}

View file

@ -1,4 +1,4 @@
From ebdfbe03ae5e227f04106f96b53064b6567f64ae Mon Sep 17 00:00:00 2001
From 1c77a390555dd8816d8eac24937a48a4f46a402e Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 23 Jul 2018 22:44:23 -0400
Subject: [PATCH] Add some Debug to Chunk Entity slices
@ -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 4e6ed1e349..d5937e4378 100644
index 3c3d44ffbd..0f79ad9588 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -709,8 +709,34 @@ public class Chunk implements IChunkAccess {
@ -64,7 +64,7 @@ index 4e6ed1e349..d5937e4378 100644
this.markDirty();
if (entity instanceof EntityItem) {
itemCounts[i]--;
@@ -1016,6 +1046,7 @@ public class Chunk implements IChunkAccess {
@@ -1015,6 +1045,7 @@ public class Chunk implements IChunkAccess {
}
// Spigot End
entity.setCurrentChunk(null); // Paper

View file

@ -1,4 +1,4 @@
From 420eba627bc5757d41f2994bf65859b5dca849c5 Mon Sep 17 00:00:00 2001
From 040c8d9195f7cbc40319ba43c89e4cb66d7a0256 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 28 Jul 2018 12:09:20 -0400
Subject: [PATCH] Always process chunk removal in removeEntity
@ -8,10 +8,10 @@ which can keep them in the chunk when they shouldnt be if done
during entity ticking.
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 81777fce64..597169b4cc 100644
index b3eaac23a6..0331512468 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1172,7 +1172,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1173,7 +1173,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
this.everyoneSleeping();
}
@ -20,7 +20,7 @@ index 81777fce64..597169b4cc 100644
int i = entity.ae;
int j = entity.ag;
@@ -1180,6 +1180,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1181,6 +1181,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
this.getChunkAt(i, j).b(entity);
}

View file

@ -1,4 +1,4 @@
From 924ae422b2731d52ed7074b64f7fdff6b61791f5 Mon Sep 17 00:00:00 2001
From 8948cdbcaadd59e45c1fc842cc8b5a75db06eeb1 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 28 Jul 2018 12:18:27 -0400
Subject: [PATCH] Ignore Dead Entities in entityList iteration
@ -35,10 +35,10 @@ index 965cd592f3..1dd56aec38 100644
public float length;
public float J;
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 597169b4cc..b18ea7154f 100644
index 0331512468..eb6d2b9d51 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1111,6 +1111,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1112,6 +1112,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
entity.valid = true; // CraftBukkit
@ -46,7 +46,7 @@ index 597169b4cc..b18ea7154f 100644
new com.destroystokyo.paper.event.entity.EntityAddToWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid
}
@@ -1179,6 +1180,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1180,6 +1181,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
if (entity.inChunk && this.isChunkLoaded(i, j, true)) {
this.getChunkAt(i, j).b(entity);
}
@ -54,7 +54,7 @@ index 597169b4cc..b18ea7154f 100644
if (!guardEntityList) { // Spigot - It will get removed after the tick if we are ticking // Paper - always remove from current chunk above
// CraftBukkit start - Decrement loop variable field if we've already ticked this entity
@@ -2389,6 +2391,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -2390,6 +2392,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@ -62,7 +62,7 @@ index 597169b4cc..b18ea7154f 100644
if (oclass.isAssignableFrom(entity.getClass()) && predicate.test((T) entity)) {
arraylist.add(entity);
@@ -2475,6 +2478,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -2476,6 +2479,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();

View file

@ -1,11 +1,11 @@
From 04b8f18d18f9287206e3e257d8d7d6d84d885ed7 Mon Sep 17 00:00:00 2001
From 246270f318b5ff7e763a68d8973f446b49e2d1ec Mon Sep 17 00:00:00 2001
From: willies952002 <admin@domnian.com>
Date: Mon, 30 Jul 2018 02:42:49 -0400
Subject: [PATCH] World EntityHuman Lookup Optimizations
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index b18ea7154f..aa94e399af 100644
index eb6d2b9d51..4cc7f7af0d 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -81,6 +81,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@ -16,7 +16,7 @@ index b18ea7154f..aa94e399af 100644
public final List<Entity> k = Lists.newArrayList();
protected final IntHashMap<Entity> entitiesById = new IntHashMap();
private final long F = 16777215L;
@@ -1095,6 +1096,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1096,6 +1097,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
EntityHuman entityhuman = (EntityHuman) entity;
this.players.add(entityhuman);
@ -25,7 +25,7 @@ index b18ea7154f..aa94e399af 100644
this.everyoneSleeping();
}
@@ -1137,6 +1140,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1138,6 +1141,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
entity.die();
if (entity instanceof EntityHuman) {
this.players.remove(entity);
@ -33,7 +33,7 @@ index b18ea7154f..aa94e399af 100644
// Spigot start
for ( WorldPersistentData worldData : worldMaps.a.values() )
{
@@ -1170,6 +1174,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1171,6 +1175,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
entity.die();
if (entity instanceof EntityHuman) {
this.players.remove(entity);
@ -41,7 +41,7 @@ index b18ea7154f..aa94e399af 100644
this.everyoneSleeping();
}
@@ -2719,6 +2724,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -2720,6 +2725,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@Nullable
public EntityHuman a(String s) {
@ -50,7 +50,7 @@ index b18ea7154f..aa94e399af 100644
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
@@ -2728,10 +2735,15 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -2729,10 +2736,15 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
return null;
@ -66,7 +66,7 @@ index b18ea7154f..aa94e399af 100644
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
@@ -2741,6 +2753,10 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -2742,6 +2754,10 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
return null;

View file

@ -1,4 +1,4 @@
From 24e97f8ee3dbd0f98ede75c2621e80107ecfe129 Mon Sep 17 00:00:00 2001
From 9bfc6b4bd66887fbc5b2641994f87db64f1ed69a Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 3 Aug 2018 22:47:46 -0400
Subject: [PATCH] Entity add to world fixes
@ -14,7 +14,7 @@ Fix this by differing entity add to world for all entities at the same time
the original entity is dead, overwrite it as the logic does for unloaod queued entities.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index d5937e4378..dfc3047a84 100644
index 0f79ad9588..a5f939f557 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -910,6 +910,7 @@ public class Chunk implements IChunkAccess {
@ -25,7 +25,7 @@ index d5937e4378..dfc3047a84 100644
for (int j = 0; j < i; ++j) {
List entityslice = aentityslice[j]; // Spigot
@@ -957,12 +958,11 @@ public class Chunk implements IChunkAccess {
@@ -956,12 +957,11 @@ public class Chunk implements IChunkAccess {
thisChunk.put(entity.uniqueID, entity);
}
}
@ -37,15 +37,15 @@ index d5937e4378..dfc3047a84 100644
+ toAdd.addAll(entityslice);
+ // Paper end
}
+ this.world.addChunkEntities(toAdd.stream().filter((entity) -> !(entity instanceof EntityHuman))); // Paper - add all at same time to avoid entities adding to world modifying slice state
+ this.world.addChunkEntities(toAdd.stream().filter((entity) -> !(entity instanceof EntityHuman || entity.valid))); // Paper - add all at same time to avoid entities adding to world modifying slice state, skip already added entities (not normal, but can happen)
// CraftBukkit start
org.bukkit.Server server = this.world.getServer();
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index aa94e399af..85570e4a5d 100644
index 4cc7f7af0d..2474b96382 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1102,6 +1102,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1103,6 +1103,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
this.getChunkAt(i, j).a(entity);
@ -53,7 +53,7 @@ index aa94e399af..85570e4a5d 100644
this.entityList.add(entity);
this.b(entity);
return true;
@@ -2507,9 +2508,13 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -2508,9 +2509,13 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
return j;
}
@ -68,10 +68,10 @@ index aa94e399af..85570e4a5d 100644
this.b(entity);
});
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index f7078ded5c..9cba1822bf 100644
index 0e63a0b5cd..72c661ef2d 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -991,7 +991,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@@ -990,7 +990,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
if (this.entitiesByUUID.containsKey(uuid)) {
Entity entity1 = (Entity) this.entitiesByUUID.get(uuid);

View file

@ -1,14 +1,14 @@
From 27d3ec80ce28800aaf9076345a2994ff5f710511 Mon Sep 17 00:00:00 2001
From acfd71d693f42e32e09b2035fc1d78bdff690938 Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Wed, 15 Aug 2018 01:26:09 -0700
Subject: [PATCH] Allow disabling armour stand ticking
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 4fbafb5bf2..31b2c71960 100644
index a2656abaf0..95fc2d8ed8 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -497,4 +497,10 @@ public class PaperWorldConfig {
@@ -493,4 +493,10 @@ public class PaperWorldConfig {
break;
}
}

View file

@ -1,4 +1,4 @@
From 96c008295d8de99bb2b3847c2c07cbc6dcaf4d85 Mon Sep 17 00:00:00 2001
From 1efc6803869785dd7deddc227ef1311457fb0667 Mon Sep 17 00:00:00 2001
From: Mystiflow <mystiflow@gmail.com>
Date: Fri, 6 Jul 2018 13:21:30 +0100
Subject: [PATCH] Send nearby packets from world player list not server list
@ -95,10 +95,10 @@ index e26405d341..23f390c221 100644
if (entityplayer != null && entityplayer.world == this.world && entityplayer.getId() != i) {
double d0 = (double) blockposition.getX() - entityplayer.locX;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 9cba1822bf..14905fceb0 100644
index 72c661ef2d..ad3fea9c97 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1090,7 +1090,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@@ -1087,7 +1087,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
}
// CraftBukkit end
if (super.strikeLightning(entity)) {
@ -107,7 +107,7 @@ index 9cba1822bf..14905fceb0 100644
return true;
} else {
return false;
@@ -1150,8 +1150,8 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@@ -1147,8 +1147,8 @@ public class WorldServer extends World implements IAsyncTaskHandler {
BlockActionData blockactiondata = (BlockActionData) this.d.removeFirst();
if (this.a(blockactiondata)) {

View file

@ -1,4 +1,4 @@
From 30fc63f03ee14456ee992b95357b7ada038bf4e6 Mon Sep 17 00:00:00 2001
From ef69ea8d6737f5239af634473c519654c0026121 Mon Sep 17 00:00:00 2001
From: Colin Godsey <crgodsey@gmail.com>
Date: Wed, 8 Aug 2018 10:10:06 -0600
Subject: [PATCH] Cache World Entity Type counts
@ -183,7 +183,7 @@ index 95d98b65cf..387570ed67 100644
if (l1 <= k) {
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 85570e4a5d..39175ea0ad 100644
index 2474b96382..a7dcfb4191 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -50,7 +50,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@ -204,7 +204,7 @@ index 85570e4a5d..39175ea0ad 100644
// Spigot end
protected final Set<Entity> g = com.google.common.collect.Sets.newHashSet(); public Set<Entity> getEntityUnloadQueue() { return g; };// Paper - OBFHELPER
//public final List<TileEntity> tileEntityList = Lists.newArrayList(); // Paper - remove unused list
@@ -143,7 +145,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -144,7 +146,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
@ -213,7 +213,7 @@ index 85570e4a5d..39175ea0ad 100644
public static boolean haveWeSilencedAPhysicsCrash;
public static String blockLocation;
private org.spigotmc.TickLimiter entityLimiter;
@@ -1187,6 +1189,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1188,6 +1190,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
this.getChunkAt(i, j).b(entity);
}
entity.shouldBeRemoved = true; // Paper

View file

@ -1,14 +1,14 @@
From df4ecee0af1df4edb57d94b00c33ead1d68ea27a Mon Sep 17 00:00:00 2001
From 69f7ce35c27fc02b9c1f01c4b57fc48da48179b4 Mon Sep 17 00:00:00 2001
From: Sotr <i@omc.hk>
Date: Thu, 23 Aug 2018 16:14:12 +0800
Subject: [PATCH] Add source block to BlockPhysicsEvent
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 39175ea0ad..4426798c74 100644
index a7dcfb4191..f713b0d3d0 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -629,7 +629,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -630,7 +630,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
// CraftBukkit start
CraftWorld world = ((WorldServer) this).getWorld();
if (world != null && !((WorldServer)this).stopPhysicsEvent) { // Paper

View file

@ -1,11 +1,11 @@
From 7dda32f30dc80cb6811a908ce404318fdea0bb48 Mon Sep 17 00:00:00 2001
From 09738247178ff3203eda24c65cf73b0a9ede6621 Mon Sep 17 00:00:00 2001
From: stonar96 <minecraft.stonar96@gmail.com>
Date: Mon, 20 Aug 2018 03:03:58 +0200
Subject: [PATCH] Anti-Xray
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index d818d39039..cc8fdedd5b 100644
index ac07bcc751..ca93fab889 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -1,7 +1,10 @@
@ -19,7 +19,7 @@ index d818d39039..cc8fdedd5b 100644
import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -512,4 +515,27 @@ public class PaperWorldConfig {
@@ -508,4 +511,27 @@ public class PaperWorldConfig {
this.armorStandTick = this.getBoolean("armor-stands-tick", this.armorStandTick);
log("ArmorStand ticking is " + (this.armorStandTick ? "enabled" : "disabled") + " by default");
}
@ -1049,7 +1049,7 @@ index 0000000000..37093419cf
+ }
+}
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index dfc3047a84..7857d871f4 100644
index a5f939f557..80ec314599 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -534,7 +534,7 @@ public class Chunk implements IChunkAccess {
@ -1510,7 +1510,7 @@ index 9242b95a52..395ce2e4ad 100644
if (enumskyblock == EnumSkyBlock.SKY) {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 4426798c74..650e605b5b 100644
index f713b0d3d0..2016051ef5 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1,6 +1,8 @@
@ -1522,7 +1522,7 @@ index 4426798c74..650e605b5b 100644
import com.destroystokyo.paper.event.server.ServerExceptionEvent;
import com.destroystokyo.paper.exception.ServerInternalException;
import com.google.common.base.MoreObjects;
@@ -143,6 +145,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -144,6 +146,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper
@ -1530,7 +1530,7 @@ index 4426798c74..650e605b5b 100644
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
public boolean guardEntityList; // Spigot // Paper - public
@@ -168,6 +171,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -169,6 +172,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
protected World(IDataManager idatamanager, @Nullable PersistentCollection persistentcollection, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag, ChunkGenerator gen, org.bukkit.World.Environment env) {
this.spigotConfig = new org.spigotmc.SpigotWorldConfig( worlddata.getName() ); // Spigot
this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(worlddata.getName(), this.spigotConfig); // Paper
@ -1538,7 +1538,7 @@ index 4426798c74..650e605b5b 100644
this.generator = gen;
this.world = new CraftWorld((WorldServer) this, gen, env);
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
@@ -410,6 +414,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -411,6 +415,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
// CraftBukkit end
IBlockData iblockdata1 = chunk.a(blockposition, iblockdata, (i & 64) != 0, (i & 1024) == 0); // CraftBukkit custom NO_PLACE flag

View file

@ -1,11 +1,11 @@
From 9d7bb190745b0418017f5f3b7afde878fb903ff6 Mon Sep 17 00:00:00 2001
From d6f4bf3cc3af82f439d4e22868097a514f3e586e Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 8 Aug 2018 16:33:21 -0600
Subject: [PATCH] Configurable speed for water flowing over lava
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index cc8fdedd5b..5bab0018da 100644
index ca93fab889..93bf8c6d3c 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -467,6 +467,12 @@ public class PaperWorldConfig {
@ -19,7 +19,7 @@ index cc8fdedd5b..5bab0018da 100644
+ }
+
public enum DuplicateUUIDMode {
SAFE_REGEN, REGEN, DELETE, NOTHING, WARN
SAFE_REGEN, DELETE, NOTHING, WARN
}
diff --git a/src/main/java/net/minecraft/server/BlockFluids.java b/src/main/java/net/minecraft/server/BlockFluids.java
index 5346eaa348..ec77cbd57e 100644

View file

@ -1,4 +1,4 @@
From 8fd650d43ab3b4f17957a91e7cd42997898a7c63 Mon Sep 17 00:00:00 2001
From 7972c755053a2eb8570b3501e8eb955686b05914 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 28 Aug 2018 21:35:05 -0400
Subject: [PATCH] Optimize Chunk#getPos
@ -6,7 +6,7 @@ Subject: [PATCH] Optimize Chunk#getPos
Don't create an object just to get chunk coords.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 7857d871f4..6abbbc057f 100644
index 80ec314599..6548bdbd31 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -169,8 +169,9 @@ public class Chunk implements IChunkAccess {
@ -20,7 +20,7 @@ index 7857d871f4..6abbbc057f 100644
public org.bukkit.Chunk bukkitChunk;
public boolean mustSave;
private boolean needsDecoration;
@@ -1191,7 +1192,7 @@ public class Chunk implements IChunkAccess {
@@ -1190,7 +1191,7 @@ public class Chunk implements IChunkAccess {
}
public ChunkCoordIntPair getPos() {

View file

@ -1,14 +1,14 @@
From 7d73bd83af6d5ec654addd52aff5bd878c96342f Mon Sep 17 00:00:00 2001
From 26e5f4a9dead4dec758399f9f3ad765c6cbc4a96 Mon Sep 17 00:00:00 2001
From: willies952002 <admin@domnian.com>
Date: Wed, 29 Aug 2018 00:37:42 -0400
Subject: [PATCH] Implement Force-Loaded Chunk API
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 650e605b5b..2ff8536d59 100644
index 2016051ef5..bcbc78bd8f 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -3023,6 +3023,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -3024,6 +3024,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
return forcedchunk != null && forcedchunk.a().contains(ChunkCoordIntPair.a(i, j));
}

View file

@ -1,4 +1,4 @@
From 35b56ab3643bde1b5b3a4b9f26d34c5d9d1b23e5 Mon Sep 17 00:00:00 2001
From 44b5fb3182caf56b8cd583b33e4c69406dfbeb5a Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 29 Aug 2018 21:59:22 -0400
Subject: [PATCH] Optimize getChunkIfLoaded type calls
@ -10,7 +10,7 @@ Will improve inlining across many hot methods.
Improve getBrightness to not do double chunk map lookups.
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index c0d48c33fc..5b57ea93c8 100644
index d07ba950eb..958a4084e6 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -378,7 +378,7 @@ public class ChunkProviderServer implements IChunkProvider {
@ -23,10 +23,10 @@ index c0d48c33fc..5b57ea93c8 100644
neighbor.setNeighborUnloaded(-x, -z);
chunk.setNeighborUnloaded(x, z);
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 2ff8536d59..0c42d042b1 100644
index bcbc78bd8f..af7cbb5fcf 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -165,7 +165,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -166,7 +166,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
public Chunk getChunkIfLoaded(int x, int z) {
@ -35,7 +35,7 @@ index 2ff8536d59..0c42d042b1 100644
}
protected World(IDataManager idatamanager, @Nullable PersistentCollection persistentcollection, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag, ChunkGenerator gen, org.bukkit.World.Environment env) {
@@ -721,7 +721,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -722,7 +722,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
blockposition = new BlockPosition(blockposition.getX(), 0, blockposition.getZ());
}
@ -45,7 +45,7 @@ index 2ff8536d59..0c42d042b1 100644
}
public void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i) {
@@ -2030,7 +2031,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -2031,7 +2032,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
if (blockposition.isInvalidYLocation()) { // Paper
return false;
} else {

View file

@ -1,11 +1,11 @@
From c52528255ec4ec0bc1e80e31f069731a2376d6e8 Mon Sep 17 00:00:00 2001
From 3d09204659809325eb40edd7532c90cc9bd8328e Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 10 Sep 2018 23:56:36 -0400
Subject: [PATCH] Prevent Mob AI Rules from Loading Chunks
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index debf47d9fd..01244c1d37 100644
index b8d87beae6..300c54c806 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -481,6 +481,7 @@ public class Chunk implements IChunkAccess {
@ -84,10 +84,10 @@ index 800e0046a8..bfa6c2eef8 100644
}
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 0c42d042b1..e52e4bb458 100644
index af7cbb5fcf..a2559f0c19 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -762,6 +762,18 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -763,6 +763,18 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
}

View file

@ -1,4 +1,4 @@
From 4771b93f2593ee779005428247ca5f36869b20b1 Mon Sep 17 00:00:00 2001
From 59333e20259c27501e5d9fef6bba91a0ee8ecfdd Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 16 Sep 2018 00:00:16 -0400
Subject: [PATCH] Optimize and Fix ExpiringMap Issues
@ -14,10 +14,10 @@ manipulation, and instead to run clean
once per tick per active expiring map.
diff --git a/src/main/java/net/minecraft/server/ExpiringMap.java b/src/main/java/net/minecraft/server/ExpiringMap.java
index 4006f5a69c..127de5c8df 100644
index 4006f5a69c..795e735420 100644
--- a/src/main/java/net/minecraft/server/ExpiringMap.java
+++ b/src/main/java/net/minecraft/server/ExpiringMap.java
@@ -2,38 +2,163 @@ package net.minecraft.server;
@@ -2,38 +2,165 @@ package net.minecraft.server;
import it.unimi.dsi.fastutil.longs.Long2LongLinkedOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2LongMap;
@ -35,6 +35,7 @@ index 4006f5a69c..127de5c8df 100644
private final int a;
- private final Long2LongMap b = new Long2LongLinkedOpenHashMap();
+ private final Long2LongMap ttl = new Long2LongLinkedOpenHashMap(); // Paper
+ private static final boolean DEBUG_EXPIRING_MAP = Boolean.getBoolean("debug.expiringmap");
public ExpiringMap(int i, int j) {
- super(i);
@ -149,7 +150,6 @@ index 4006f5a69c..127de5c8df 100644
+ }
+ private boolean registered = false;
+ private boolean hasLeaked = false;
+
+ // Break clean to its own method to be ticked
+ boolean clean() {
@ -172,20 +172,22 @@ index 4006f5a69c..127de5c8df 100644
+ int ttlSize = this.ttl.size();
+ int thisSize = this.size();
+ if (ttlSize < thisSize) {
+ if (!hasLeaked) { // log once
+ hasLeaked = true;
+ MinecraftServer.LOGGER.warn("WARNING: ExpiringMap desync (" + ttlSize + ":" + thisSize + ")- Memory leak risk! We will recover from this, but this means there is still a bug. Please do not open an issue about this. Mention it in Discord (we don't need everyone reporting the same thing)");
+ if (DEBUG_EXPIRING_MAP) {
+ MinecraftServer.LOGGER.warn("WARNING: ExpiringMap desync (ttl:" + ttlSize + " < actual:" + thisSize + ")");
+ }
+ try {
+ for (Entry<T> entry : this.long2ObjectEntrySet()) {
+ ttl.putIfAbsent(entry.getLongKey(), now);
+ }
+ } catch (Exception e) {
+ } catch (Exception ignored) {
+ } // Ignore any como's
+ } else if (ttlSize > this.size()) {
+ if (DEBUG_EXPIRING_MAP) {
+ MinecraftServer.LOGGER.warn("WARNING: ExpiringMap desync (ttl:" + ttlSize + " > actual:" + thisSize + ")");
+ }
+ try {
+ this.ttl.long2LongEntrySet().removeIf(entry -> !this.containsKey(entry.getLongKey()));
+ } catch (Exception e) {
+ } catch (Exception ignored) {
+ } // Ignore any como's
+ }
+ if (isEmpty()) {
@ -198,7 +200,7 @@ index 4006f5a69c..127de5c8df 100644
}
protected boolean a(T var1) {
@@ -51,8 +176,13 @@ public class ExpiringMap<T> extends Long2ObjectOpenHashMap<T> {
@@ -51,8 +178,13 @@ public class ExpiringMap<T> extends Long2ObjectOpenHashMap<T> {
}
public T get(long i) {

View file

@ -1,4 +1,4 @@
From 0f3d0e30c390cce2fd05de204c44b8ec87965c35 Mon Sep 17 00:00:00 2001
From a10d0f7e8c1c88b4cd66e8e6bddca04e69369ec1 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 21 Jul 2018 16:55:04 -0400
Subject: [PATCH] Async Chunk Loading and Generation
@ -392,7 +392,7 @@ index 0000000000..5c77b6e8e1
+
+}
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index fe40d62692..33d52447be 100644
index edfcb107bd..cb99888707 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -184,6 +184,7 @@ public class Chunk implements IChunkAccess {
@ -1736,7 +1736,7 @@ index f87182b5c4..574930f5fe 100644
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index e52e4bb458..13f69f1b82 100644
index a2559f0c19..bbcedb8fc7 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -46,7 +46,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
@ -1773,7 +1773,7 @@ index e52e4bb458..13f69f1b82 100644
public boolean allowMonsters;
public boolean allowAnimals;
private boolean J;
@@ -741,17 +759,42 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -742,17 +760,42 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
@ -1820,7 +1820,7 @@ index e52e4bb458..13f69f1b82 100644
// CraftBukkit end
if (blockposition.isInvalidYLocation()) { // Paper
return Blocks.VOID_AIR.getBlockData();
@@ -1022,6 +1065,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1023,6 +1066,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
@ -1980,10 +1980,10 @@ index fa99fe0146..4f49786aa3 100644
}
}
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 14905fceb0..c0aeccffbf 100644
index ad3fea9c97..0a76482638 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -732,7 +732,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@@ -731,7 +731,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
gen = new org.bukkit.craftbukkit.generator.NormalChunkGenerator(this, this.getSeed());
}

View file

@ -1,4 +1,4 @@
From dbce8545b454b4c8cbc4cb3d5e6d31eb400edce1 Mon Sep 17 00:00:00 2001
From 39fd972d4e2eb1a6ae58e4a8ca9203978ec102ec Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 28 Sep 2018 20:46:29 -0400
Subject: [PATCH] Optimize Light Recalculations
@ -14,7 +14,7 @@ Also optimizes to not repeatedly look up the same chunk for
light lookups.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 33d52447be..c6b002bb6b 100644
index cb99888707..027f98633e 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -347,7 +347,7 @@ public class Chunk implements IChunkAccess {
@ -36,10 +36,10 @@ index 33d52447be..c6b002bb6b 100644
int i1 = iblockdata.b(this.world, blockposition);
int j1 = iblockdata1.b(this.world, blockposition);
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 13f69f1b82..4179ba7cd8 100644
index bbcedb8fc7..a19e941174 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -444,7 +444,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -445,7 +445,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
} else {
IBlockData iblockdata2 = this.getType(blockposition);
@ -48,7 +48,7 @@ index 13f69f1b82..4179ba7cd8 100644
this.methodProfiler.a("checkLight");
chunk.runOrQueueLightUpdate(() -> this.r(blockposition)); // Paper - Queue light update
this.methodProfiler.e();
@@ -588,8 +588,9 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -589,8 +589,9 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
if (this.worldProvider.g()) {
@ -60,7 +60,7 @@ index 13f69f1b82..4179ba7cd8 100644
}
}
@@ -2293,6 +2294,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -2294,6 +2295,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
// CraftBukkit start - Use neighbor cache instead of looking up
Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4);

View file

@ -1,4 +1,4 @@
From 1e4ac163aedb580ae00b2bb02a1a2d8d14b808a6 Mon Sep 17 00:00:00 2001
From 8cbfb9a6df9fb67dc0cd66af6add5ae390f8f86f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 28 Sep 2018 21:49:53 -0400
Subject: [PATCH] Fix issues with entity loss due to unloaded chunks
@ -18,10 +18,10 @@ This change ensures the chunks are always loaded when entities are
added to the world, or a valid entity moves between chunks.
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 4179ba7cd8..d659ffe9ba 100644
index a19e941174..4d0c8cbd4b 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1146,7 +1146,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1147,7 +1147,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D);
@ -30,7 +30,7 @@ index 4179ba7cd8..d659ffe9ba 100644
// Paper start - Set origin location when the entity is being added to the world
if (entity.origin == null) {
@@ -1650,7 +1650,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
@@ -1651,7 +1651,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
this.getChunkAt(entity.ae, entity.ag).a(entity, entity.af);
}

View file

@ -1,4 +1,4 @@
From 0251a57dfdce649a258e23c9602f7fe6db686444 Mon Sep 17 00:00:00 2001
From ce4a54b81b3545127196bf2b77497aad6773f94f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 29 Sep 2018 01:18:16 -0400
Subject: [PATCH] Fix Sending Chunks to Client
@ -14,10 +14,10 @@ This fix always sends chunks to the client, and simply updates
the client anytime post processing is triggered with the new chunk data.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 6a6c68b066..bf800fcb72 100644
index 2ecac57a81..4258b1200a 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -1206,7 +1206,7 @@ public class Chunk implements IChunkAccess {
@@ -1205,7 +1205,7 @@ public class Chunk implements IChunkAccess {
}
public boolean isReady() {
@ -26,7 +26,7 @@ index 6a6c68b066..bf800fcb72 100644
}
public boolean v() {
@@ -1472,6 +1472,13 @@ public class Chunk implements IChunkAccess {
@@ -1471,6 +1471,13 @@ public class Chunk implements IChunkAccess {
this.h.clear();
this.a(ChunkStatus.POSTPROCESSED);
this.m.a(this);