Archiviert
13
0

Async chunk api/io/loading (#2308)

Dieser Commit ist enthalten in:
Spottedleaf 2019-08-18 16:40:04 -07:00 committet von Zach
Ursprung eee1a019f9
Commit 294e30462b
35 geänderte Dateien mit 4289 neuen und 213 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,4 @@
From 7f5c894288d4476ea577befbbb98c3eca8b59530 Mon Sep 17 00:00:00 2001
From 742264d273660d238ce3a7fa3bd46201db8a82fb Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 30 Mar 2016 19:36:20 -0400
Subject: [PATCH] MC Dev fixes
@ -357,6 +357,31 @@ index 0dda7aaf69..4e20cfba41 100644
}
}
diff --git a/src/main/java/net/minecraft/server/RegionFileSection.java b/src/main/java/net/minecraft/server/RegionFileSection.java
index a343a7b31d..4b3e0c0f01 100644
--- a/src/main/java/net/minecraft/server/RegionFileSection.java
+++ b/src/main/java/net/minecraft/server/RegionFileSection.java
@@ -82,9 +82,9 @@ public class RegionFileSection<R extends MinecraftSerializable> extends RegionFi
Optional<R> optional = this.d(i);
if (optional.isPresent()) {
- return (MinecraftSerializable) optional.get();
+ return optional.get(); // Paper - decompile fix
} else {
- R r0 = (MinecraftSerializable) this.f.apply(() -> {
+ R r0 = this.f.apply(() -> { // Paper - decompile fix
this.a(i);
});
@@ -123,7 +123,7 @@ public class RegionFileSection<R extends MinecraftSerializable> extends RegionFi
for (int l = 0; l < 16; ++l) {
long i1 = SectionPosition.a(chunkcoordintpair, l).v();
Optional<R> optional = optionaldynamic.get(Integer.toString(l)).get().map((dynamic2) -> {
- return (MinecraftSerializable) this.e.apply(() -> {
+ return this.e.apply(() -> { // Paper - decompile fix
this.a(i1);
}, dynamic2);
});
diff --git a/src/main/java/net/minecraft/server/RegistryBlockID.java b/src/main/java/net/minecraft/server/RegistryBlockID.java
index 7f89562e90..4efcb8b595 100644
--- a/src/main/java/net/minecraft/server/RegistryBlockID.java
@ -455,6 +480,28 @@ index c23a366b2c..0430ca5353 100644
}
}
diff --git a/src/main/java/net/minecraft/server/VillagePlace.java b/src/main/java/net/minecraft/server/VillagePlace.java
index b0e6ad773e..3169590641 100644
--- a/src/main/java/net/minecraft/server/VillagePlace.java
+++ b/src/main/java/net/minecraft/server/VillagePlace.java
@@ -157,7 +157,7 @@ public class VillagePlace extends RegionFileSection<VillagePlaceSection> {
}
private static boolean a(ChunkSection chunksection) {
- Stream stream = VillagePlaceType.f();
+ Stream<IBlockData> stream = VillagePlaceType.f(); // Paper - decompile fix
chunksection.getClass();
return stream.anyMatch(chunksection::a);
@@ -215,7 +215,7 @@ public class VillagePlace extends RegionFileSection<VillagePlaceSection> {
private final Predicate<? super VillagePlaceRecord> d;
- private Occupancy(Predicate predicate) {
+ private Occupancy(Predicate<? super VillagePlaceRecord> predicate) { // Paper - decompile fix
this.d = predicate;
}
diff --git a/src/main/java/net/minecraft/server/VillagerTrades.java b/src/main/java/net/minecraft/server/VillagerTrades.java
index 2fbb1f8df9..8cee460bd3 100644
--- a/src/main/java/net/minecraft/server/VillagerTrades.java
@ -507,5 +554,5 @@ index 0b950aae63..f5f540032f 100644
t0.a(nbttagcompound.getCompound("data"));
--
2.22.0
2.22.1

Datei anzeigen

@ -1,63 +0,0 @@
From 34e683e36fe14ee82ad3a444ffadd17470462f5f Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 6 May 2019 12:29:24 -0700
Subject: [PATCH] Async Chunk placeholder
Until we figure out Mojang's ticket system.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 91b65fde0..afdb6956b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -18,6 +18,7 @@ import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.objects.ObjectSortedSet;
@@ -2257,6 +2258,40 @@ public class CraftWorld implements World {
return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ());
}
+ // Paper start
+ private Chunk getChunkAtGen(int x, int z, boolean gen) {
+ // copied from loadChunk()
+ // this function is identical except we do not add a plugin ticket
+ IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, gen || isChunkGenerated(x, z) ? ChunkStatus.FULL : ChunkStatus.EMPTY, true);
+
+ // If generate = false, but the chunk already exists, we will get this back.
+ if (chunk instanceof ProtoChunkExtension) {
+ // We then cycle through again to get the full chunk immediately, rather than after the ticket addition
+ chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, true);
+ }
+
+ if (chunk instanceof net.minecraft.server.Chunk) {
+ return ((net.minecraft.server.Chunk)chunk).bukkitChunk;
+ }
+
+ return null;
+ }
+
+ @Override
+ public CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen) {
+ // TODO placeholder
+ if (Bukkit.isPrimaryThread()) {
+ return CompletableFuture.completedFuture(getChunkAtGen(x, z, gen));
+ } else {
+ CompletableFuture<Chunk> ret = new CompletableFuture<>();
+ net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> {
+ ret.complete(getChunkAtGen(x, z, gen));
+ });
+ return ret;
+ }
+ }
+ // Paper end
+
// Spigot start
@Override
public int getViewDistance() {
--
2.22.0

Datei anzeigen

@ -1,4 +1,4 @@
From ac0590e2d5af6b8fa96a15894b434ddc7a3458d4 Mon Sep 17 00:00:00 2001
From 4248f97eb65fef4cc66def1ab94ce98b5c26d154 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Fri, 10 May 2019 18:38:19 +0100
Subject: [PATCH] Fix CB call to changed postToMainThread method
@ -18,5 +18,5 @@ index 7680b88024..4187ba05bd 100644
@Override
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 5c0d14c68d85c4dd031f920b56997708fff20905 Mon Sep 17 00:00:00 2001
From c0175bc340b6ecab247b4972d98d21cc1a25e7ae Mon Sep 17 00:00:00 2001
From: Phoenix616 <mail@moep.tv>
Date: Sat, 27 Apr 2019 20:00:43 +0100
Subject: [PATCH] Fix sounds when item frames are modified (MC-123450)
@ -32,5 +32,5 @@ index 799036f268..9ad180d946 100644
this.entity = frame;
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From aeef538a6f37143d4cacf2d4c66298232d6a19e4 Mon Sep 17 00:00:00 2001
From 0e44f004120cb2ed3216a97092e6da88f4233340 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 13 May 2019 21:10:59 -0700
Subject: [PATCH] Fix CraftServer#isPrimaryThread and MinecraftServer
@ -42,5 +42,5 @@ index b89486beb1..7a8ab7d401 100644
@Override
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 0e9dbe2c59db9edfc72829af874179d9852437d3 Mon Sep 17 00:00:00 2001
From fe0d3a1329061e1007cac3067f00b4a3066cb1e2 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
@ -41,5 +41,5 @@ index 192b3be1f0..82c3bc60d0 100644
if (!(ichunkaccess instanceof Chunk)) {
return false;
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 0330cf125621b330638b4ecb80560a26fc409200 Mon Sep 17 00:00:00 2001
From a55ea9fd05f0520b014878afb447c0a092fc0a93 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
@ -244,5 +244,5 @@ index 82c3bc60d0..a6d0635ec1 100644
logger.error("Overwrote an existing entity " + old + " with " + entity);
if (DEBUG_ENTITIES) {
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 62a24d634c1218c35dea6fae2583e2706974ab65 Mon Sep 17 00:00:00 2001
From 90d05dc9e70d89f1d55c4f96b06311ab0a7e37a7 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Tue, 21 May 2019 02:34:04 +0100
Subject: [PATCH] improve CraftWorld#isChunkLoaded
@ -9,10 +9,10 @@ waiting for the execution queue to get to our request; We can just query
the chunk status and get a response now, vs having to wait
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 447b4324f..3d62debc7 100644
index 91b65fde05..b6ca8a9e94 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -401,14 +401,13 @@ public class CraftWorld implements World {
@@ -400,14 +400,13 @@ public class CraftWorld implements World {
@Override
public boolean isChunkLoaded(int x, int z) {
@ -30,5 +30,5 @@ index 447b4324f..3d62debc7 100644
throw new RuntimeException(ex);
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 334132e026377b7943f03223c055517f102a83cb Mon Sep 17 00:00:00 2001
From 1f10b9fd531350980dd9ff08281228be6f16f939 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 13 Sep 2014 23:14:43 -0400
Subject: [PATCH] Configurable Keep Spawn Loaded range per world
@ -6,7 +6,7 @@ Subject: [PATCH] Configurable Keep Spawn Loaded range per world
This lets you disable it for some worlds and lower it for others.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index d8bb13693..de11a91af 100644
index d8bb13693d..de11a91af6 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -483,4 +483,10 @@ public class PaperWorldConfig {
@ -21,7 +21,7 @@ index d8bb13693..de11a91af 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index c70ab3caf..c58f6f50d 100644
index c70ab3caf0..c58f6f50d3 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -577,6 +577,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@ -61,7 +61,7 @@ index c70ab3caf..c58f6f50d 100644
// CraftBukkit start
// this.nextTick = SystemUtils.getMonotonicMillis() + 10L;
diff --git a/src/main/java/net/minecraft/server/WorldLoadListener.java b/src/main/java/net/minecraft/server/WorldLoadListener.java
index d6762d385..7b6f5b2da 100644
index d6762d3853..7b6f5b2da0 100644
--- a/src/main/java/net/minecraft/server/WorldLoadListener.java
+++ b/src/main/java/net/minecraft/server/WorldLoadListener.java
@@ -9,4 +9,6 @@ public interface WorldLoadListener {
@ -72,7 +72,7 @@ index d6762d385..7b6f5b2da 100644
+ void setChunkRadius(int radius); // Paper - allow changing chunk radius
}
diff --git a/src/main/java/net/minecraft/server/WorldLoadListenerLogger.java b/src/main/java/net/minecraft/server/WorldLoadListenerLogger.java
index 3868572ae..ae77805f7 100644
index 3868572aed..ae77805f71 100644
--- a/src/main/java/net/minecraft/server/WorldLoadListenerLogger.java
+++ b/src/main/java/net/minecraft/server/WorldLoadListenerLogger.java
@@ -7,16 +7,24 @@ import org.apache.logging.log4j.Logger;
@ -103,7 +103,7 @@ index 3868572ae..ae77805f7 100644
@Override
public void a(ChunkCoordIntPair chunkcoordintpair) {
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index a6d0635ec..8ac49d8b9 100644
index a6d0635ec1..8ac49d8b91 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1513,13 +1513,85 @@ public class WorldServer extends World {
@ -196,10 +196,10 @@ index a6d0635ec..8ac49d8b9 100644
public LongSet getForceLoadedChunks() {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 66701f1cc..080f5abc1 100644
index b6ca8a9e94..3948de4674 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1851,15 +1851,21 @@ public class CraftWorld implements World {
@@ -1850,15 +1850,21 @@ public class CraftWorld implements World {
@Override
public void setKeepSpawnInMemory(boolean keepLoaded) {
@ -226,5 +226,5 @@ index 66701f1cc..080f5abc1 100644
@Override
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From dcab8a73f48cd67cd36bd1c1a216453f94a7b91c Mon Sep 17 00:00:00 2001
From 7ba63ef522932812bb156de4d28dfde7336b6872 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Fri, 24 May 2019 07:53:16 +0100
Subject: [PATCH] Fix some generation concurrency issues
@ -209,5 +209,5 @@ index ddf7268676..c2188ceef1 100644
}
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 7714e202d48c4aaed00476736342817ff5ed8484 Mon Sep 17 00:00:00 2001
From 4eadaf6901010d0f29d2a1e8705c28a07d454e8b Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Mon, 27 May 2019 17:35:39 -0500
Subject: [PATCH] MC-114618 - Fix EntityAreaEffectCloud from going negative
@ -23,5 +23,5 @@ index 3a8e105336..fe527aba52 100644
if (this.world.isClientSide) {
ParticleParam particleparam = this.getParticle();
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From a80c7dd8d8dde293eabadf950661cc3f5b5d4fca Mon Sep 17 00:00:00 2001
From 1536a61c14cc5fe7df1f034bf0f64eaabb8bb1f8 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Wed, 29 May 2019 04:01:22 +0100
Subject: [PATCH] ChunkMapDistance CME
@ -50,5 +50,5 @@ index 101eb58ace..63a688725e 100644
} else {
if (!this.l.isEmpty()) {
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From cfd6e121847944f05ffba9e6650966f15db044a6 Mon Sep 17 00:00:00 2001
From 23bfd69104bd51618d157c4cd09ba03441efddcf Mon Sep 17 00:00:00 2001
From: kickash32 <kickash32@gmail.com>
Date: Sun, 2 Jun 2019 01:22:02 -0400
Subject: [PATCH] Actually-Limit-Natural-Spawns-To-Limit
@ -93,5 +93,5 @@ index c6ea37ffbd..5e6559df0b 100644
@Nullable
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 282879b099576a7f5851f2306a9bfac9b6ac6f23 Mon Sep 17 00:00:00 2001
From b85ae6b421d6b419d24f90744fbf0285dae533cd Mon Sep 17 00:00:00 2001
From: simpleauthority <jacob@algorithmjunkie.com>
Date: Tue, 28 May 2019 03:48:51 -0700
Subject: [PATCH] Implement CraftBlockSoundGroup
@ -112,5 +112,5 @@ index 166c918d73..5296c6d9bf 100644
+ // Paper end
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 9867b160e76f323ac2623bae1440a178adb502f1 Mon Sep 17 00:00:00 2001
From 379ac9e206a7ea7e19c06067df3a8310b0969818 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 1 Jun 2019 13:00:55 -0700
Subject: [PATCH] Chunk debug command
@ -32,7 +32,7 @@ https://bugs.mojang.com/browse/MC-141484?focusedCommentId=528273&page=com.atlass
https://bugs.mojang.com/browse/MC-141484?focusedCommentId=528577&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-528577
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index 391726d99c..8db92edc36 100644
index d704fc79c0..09efbf7250 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -28,14 +28,14 @@ public class PaperCommand extends Command {
@ -457,5 +457,5 @@ index 0430ca5353..badbe6c19d 100644
return this.b;
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 24b13d1473de60e0424b5a62f4f92ffc471ebfc7 Mon Sep 17 00:00:00 2001
From 2e3ff1fe99c5b8551dd4f9da59b0fc482f301d48 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 9 Jun 2019 03:53:22 +0100
Subject: [PATCH] incremental chunk saving
@ -147,7 +147,7 @@ index 493770bf68..2be6fa0f07 100644
if (flag) {
List<PlayerChunk> list = (List) this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).peek(PlayerChunk::m).collect(Collectors.toList());
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 1003ea50d3..4148325a26 100644
index 8ac49d8b91..9fd14b573e 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -756,11 +756,44 @@ public class WorldServer extends World {
@ -197,5 +197,5 @@ index 1003ea50d3..4148325a26 100644
if (iprogressupdate != null) {
iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0]));
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 44d0cac4322b4f99b41506189e942406b720ffaf Mon Sep 17 00:00:00 2001
From 2ed06dd3efd74e5b1062640643ebca2956e731eb Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Mon, 10 Jun 2019 09:36:40 +0100
Subject: [PATCH] Catch exceptions from dispenser entity spawns
@ -24,5 +24,5 @@ index 976c72208f..fe3d9d5fa3 100644
// CraftBukkit end
return itemstack;
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From ab24b40041486e74bcff020d9e040ae3706915c8 Mon Sep 17 00:00:00 2001
From a35d57100af34be228d70a78e783305a54566e66 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 15 Jun 2019 08:54:33 -0700
Subject: [PATCH] Fix World#isChunkGenerated calls
@ -8,7 +8,7 @@ This patch also adds a chunk status cache on region files (note that
its only purpose is to cache the status on DISK)
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index ca5963b11..3894b0434 100644
index ca5963b11a..3894b04342 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -28,7 +28,7 @@ public class ChunkProviderServer extends IChunkProvider {
@ -43,7 +43,7 @@ index ca5963b11..3894b0434 100644
@Nullable
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
index e778c2e85..73f93e494 100644
index e778c2e857..73f93e4948 100644
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
@@ -410,6 +410,17 @@ public class ChunkRegionLoader {
@ -65,7 +65,7 @@ index e778c2e85..73f93e494 100644
if (nbttagcompound != null) {
ChunkStatus chunkstatus = ChunkStatus.a(nbttagcompound.getCompound("Level").getString("Status"));
diff --git a/src/main/java/net/minecraft/server/ChunkStatus.java b/src/main/java/net/minecraft/server/ChunkStatus.java
index dd1822d6f..e324989b4 100644
index dd1822d6ff..e324989b46 100644
--- a/src/main/java/net/minecraft/server/ChunkStatus.java
+++ b/src/main/java/net/minecraft/server/ChunkStatus.java
@@ -176,6 +176,7 @@ public class ChunkStatus {
@ -95,7 +95,7 @@ index dd1822d6f..e324989b4 100644
return (ChunkStatus) IRegistry.CHUNK_STATUS.get(MinecraftKey.a(s));
}
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
index 14a176d61..98590e233 100644
index 14a176d61d..98590e233a 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
@@ -70,6 +70,19 @@ public class PlayerChunk {
@ -119,7 +119,7 @@ index 14a176d61..98590e233 100644
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getStatusFutureUnchecked(ChunkStatus chunkstatus) {
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 2be6fa0f0..bdadbd436 100644
index 2be6fa0f07..bdadbd436e 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -891,11 +891,61 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -187,7 +187,7 @@ index 2be6fa0f0..bdadbd436 100644
boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) {
// Spigot start
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
index ccc3d6c7a..b487e8060 100644
index ccc3d6c7ad..b487e80602 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
@@ -31,6 +31,30 @@ public class RegionFile implements AutoCloseable {
@ -246,7 +246,7 @@ index ccc3d6c7a..b487e8060 100644
}
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
index 6f34d8aea..d2b328945 100644
index 6f34d8aea0..d2b3289450 100644
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
@@ -47,6 +47,12 @@ public abstract class RegionFileCache implements AutoCloseable {
@ -279,10 +279,18 @@ index 6f34d8aea..d2b328945 100644
printOversizedLog("ChunkTooLarge even after reduction. Trying in overzealous mode.", regionfile.file, chunkX, chunkZ);
// Eek, major fail. We have retry logic, so reduce threshholds and fall back
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 080f5abc1..f59b2e49c 100644
index 3948de4674..20e9fd8a79 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -406,8 +406,22 @@ public class CraftWorld implements World {
@@ -18,6 +18,7 @@ import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.objects.ObjectSortedSet;
@@ -405,8 +406,22 @@ public class CraftWorld implements World {
@Override
public boolean isChunkGenerated(int x, int z) {
@ -306,7 +314,7 @@ index 080f5abc1..f59b2e49c 100644
} catch (IOException ex) {
throw new RuntimeException(ex);
}
@@ -519,20 +533,49 @@ public class CraftWorld implements World {
@@ -518,20 +533,49 @@ public class CraftWorld implements World {
@Override
public boolean loadChunk(int x, int z, boolean generate) {
org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
@ -365,63 +373,7 @@ index 080f5abc1..f59b2e49c 100644
+ // Paper end
}
@Override
@@ -2265,21 +2308,44 @@ public class CraftWorld implements World {
// Paper start
private Chunk getChunkAtGen(int x, int z, boolean gen) {
- // copied from loadChunk()
- // this function is identical except we do not add a plugin ticket
- IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, gen || isChunkGenerated(x, z) ? ChunkStatus.FULL : ChunkStatus.EMPTY, true);
+ // Note: Copied from loadChunk()
+ ChunkCoordIntPair chunkPos = new ChunkCoordIntPair(x, z);
- // If generate = false, but the chunk already exists, we will get this back.
- if (chunk instanceof ProtoChunkExtension) {
- // We then cycle through again to get the full chunk immediately, rather than after the ticket addition
- chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, true);
- }
+ if (!gen) {
+
+ IChunkAccess immediate = world.getChunkProvider().getChunkAtImmediately(x, z);
+ if (immediate == null) {
+ immediate = world.getChunkProvider().playerChunkMap.getUnloadingChunk(x, z);
+ }
+ if (immediate != null) {
+ if (!(immediate instanceof ProtoChunkExtension) && !(immediate instanceof net.minecraft.server.Chunk)) {
+ return null; // not full status
+ }
+ return world.getChunkAt(x, z).bukkitChunk; // make sure we're at ticket level 33 or lower
+ }
+
+ net.minecraft.server.RegionFile file;
+ try {
+ file = world.getChunkProvider().playerChunkMap.getRegionFile(chunkPos, false);
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+
+ ChunkStatus status = file.getStatusIfCached(x, z);
+ if (!file.chunkExists(chunkPos) || (status != null && status != ChunkStatus.FULL)) {
+ return null;
+ }
+
+ IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.EMPTY, true);
+ if (!(chunk instanceof ProtoChunkExtension) && !(chunk instanceof net.minecraft.server.Chunk)) {
+ return null;
+ }
- if (chunk instanceof net.minecraft.server.Chunk) {
- return ((net.minecraft.server.Chunk)chunk).bukkitChunk;
+ // fall through to load
+ // we load at empty so we don't double-load chunk data in this case
}
- return null;
+ return world.getChunkAt(x, z).bukkitChunk;
}
@Override
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From d06b36e7d5bd3ef23b800fce2c461581d1d8c0b2 Mon Sep 17 00:00:00 2001
From cdadcf34bc202a34c0cde735f535a486f785a773 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 15 Jun 2019 10:28:25 -0700
Subject: [PATCH] Show blockstate location if we failed to read it
@ -33,5 +33,5 @@ index f6401e2cde..3e22d558ea 100644
public final boolean snapshotDisabled; // Paper
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 3aa0ab156ffd994ad737bc2f76af3d7475c8a9b0 Mon Sep 17 00:00:00 2001
From 0d67dccc3a8bf7bea2d579455ac07251f03f2472 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Fri, 21 Jun 2019 14:42:48 -0700
Subject: [PATCH] Log other thread in DataPaletteBlock lock failure
@ -47,5 +47,5 @@ index a3bb2e8779..1e2bca1e04 100644
crashreportsystemdetails.a("Thread dumps", (Object) s);
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From ced736fc443de0c3b20f67e4781b14aa63ecf6f9 Mon Sep 17 00:00:00 2001
From cbcd19008d052efff2a8e4f04de3e0f16c92a455 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 22 Jun 2019 04:20:47 -0700
Subject: [PATCH] Use ChunkStatus cache when saving protochunks
@ -24,5 +24,5 @@ index bdadbd436e..fbbd4d5dd0 100644
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 30e17b2ad5a927f202ccb708ab7d6d251db6b5eb Mon Sep 17 00:00:00 2001
From cb6f6fe1c447df7fd2155cced33591e2dd410ae9 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
@ -1725,5 +1725,5 @@ index 7772d59005..4570ed9991 100644
return section;
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From bd8d126fa7f77f55f6e29c10fcc77390f250e282 Mon Sep 17 00:00:00 2001
From fb5b05d9cbdd15c42b12c81e7444a6794728ac33 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 24 Mar 2019 01:01:32 -0400
Subject: [PATCH] Only count Natural Spawned mobs towards natural spawn mob
@ -38,7 +38,7 @@ index 929f5c3031..ff520d9e86 100644
public boolean asynchronous;
public EngineMode engineMode;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 4148325a26..7faa5dd84a 100644
index 9fd14b573e..1e5b15c2e2 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -899,6 +899,13 @@ public class WorldServer extends World {
@ -56,5 +56,5 @@ index 4148325a26..7faa5dd84a 100644
}
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 15ae33fdf438a0d55998add482f6964989fd98fa Mon Sep 17 00:00:00 2001
From 3c29bd01d31049fe243a948921c2c00a1dbeb13d Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 8 Jul 2019 00:13:36 -0700
Subject: [PATCH] Use getChunkIfLoadedImmediately in places
@ -79,5 +79,5 @@ index f86404f83a..92601c581c 100644
}
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From d96a4efc6bb4e9f5337a315866a58004213d3c6b Mon Sep 17 00:00:00 2001
From d8a7240ae87dc130e4e1db3cf1e65e79d9da2a88 Mon Sep 17 00:00:00 2001
From: Lucavon <lucavonlp@gmail.com>
Date: Tue, 23 Jul 2019 20:29:20 -0500
Subject: [PATCH] Configurable projectile relative velocity
@ -65,5 +65,5 @@ index 18d28a151a..bd4ca73f6d 100644
@Override
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From c9ebdc9e0b94a5c9a4f56cd940ce9c99ac7230e5 Mon Sep 17 00:00:00 2001
From 4ed947b04eb34215ca7c2f22bd492213348a01fd Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 28 Jul 2019 00:51:11 +0100
Subject: [PATCH] Mark entities as being ticked when notifying navigation
@ -25,5 +25,5 @@ index 1e5b15c2e2..84c16e2750 100644
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 6571748607bac393655db682f7cb6621e8bac280 Mon Sep 17 00:00:00 2001
From e7e0f94ce68757ad43c38a7f262757b0d885ad0c Mon Sep 17 00:00:00 2001
From: kickash32 <kickash32@gmail.com>
Date: Tue, 30 Jul 2019 03:17:16 +0500
Subject: [PATCH] offset item frame ticking
@ -18,5 +18,5 @@ index 3b282a18a2..2b4a849f48 100644
protected EnumDirection direction;
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 0739db695afc0dc5c7e9f6dbe6289075455cadee Mon Sep 17 00:00:00 2001
From 4e9e8fcb96e24d84f1ea01726960e000e0747fda Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 5 Aug 2019 08:24:01 -0700
Subject: [PATCH] Preserve old flush on save flag for reliable regionfiles
@ -6,7 +6,7 @@ Subject: [PATCH] Preserve old flush on save flag for reliable regionfiles
Originally this patch was in paper
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
index e6e412b7c1..b4c191d538 100644
index b487e80602..a8c8ace46c 100644
--- a/src/main/java/net/minecraft/server/RegionFile.java
+++ b/src/main/java/net/minecraft/server/RegionFile.java
@@ -349,7 +349,7 @@ public class RegionFile implements AutoCloseable {
@ -19,5 +19,5 @@ index e6e412b7c1..b4c191d538 100644
if (!FLUSH_ON_SAVE) {
return;
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From a788e2b42ef19a7ef34ee11da916bdf578a8eb9a Mon Sep 17 00:00:00 2001
From 930f77a8a2f97b5969f057112520bf94df821400 Mon Sep 17 00:00:00 2001
From: CullanP <cullanpage@gmail.com>
Date: Thu, 3 Mar 2016 02:13:38 -0600
Subject: [PATCH] Avoid hopper searches if there are no items
@ -14,7 +14,7 @@ And since minecart hoppers are used _very_ rarely near we can avoid alot of sear
Combined, this adds up a lot.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index d604f96c1..67dc837f4 100644
index d604f96c16..67dc837f43 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -84,6 +84,10 @@ public class Chunk implements IChunkAccess {
@ -90,7 +90,7 @@ index d604f96c1..67dc837f4 100644
while (iterator.hasNext()) {
diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java
index 56488b78d..56739e6ed 100644
index 56488b78dd..56739e6ed5 100644
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
@@ -11,6 +11,7 @@ public final class IEntitySelector {
@ -102,5 +102,5 @@ index 56488b78d..56739e6ed 100644
return entity instanceof IInventory && entity.isAlive();
};
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 6e3e4c0d0ef13a74817402992dc91eeb14611941 Mon Sep 17 00:00:00 2001
From a3e706da03ede31d3d5f297acb569baad24a7803 Mon Sep 17 00:00:00 2001
From: TheGreatKetchup <TheGreatKetchup@users.noreply.github.com>
Date: Thu, 1 Aug 2019 21:24:30 -0400
Subject: [PATCH] Fixed MC-156852
@ -12,7 +12,7 @@ issue in 1.8-1.12.
Originally solved by Gnembon on MC-5694 at bugs.mojang.com
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
index e5e9de542..c96564a59 100644
index e5e9de542b..c96564a59b 100644
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
@@ -218,6 +218,7 @@ public class PlayerInteractManager {
@ -24,5 +24,5 @@ index e5e9de542..c96564a59 100644
this.l = j;
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,11 +1,11 @@
From 5356f6eb7d8023a1e71837b544ef89f745274aaf Mon Sep 17 00:00:00 2001
From 62f3bf54c31e04625bbf93b067e1f542f3c6f6e4 Mon Sep 17 00:00:00 2001
From: kickash32 <kickash32@gmail.com>
Date: Mon, 3 Jun 2019 02:02:39 -0400
Subject: [PATCH] Implement alternative item-despawn-rate
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 318a470ee..e7bbeef74 100644
index 318a470eea..e7bbeef74d 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -1,12 +1,17 @@
@ -80,7 +80,7 @@ index 318a470ee..e7bbeef74 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
index 209169895..97e379090 100644
index 2091698953..97e3790908 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -5,6 +5,7 @@ import java.util.List;
@ -128,5 +128,5 @@ index 209169895..97e379090 100644
public Packet<?> N() {
return new PacketPlayOutSpawnEntity(this);
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From eb82ba85c2d5504bd270977a9708bd7fe621a1c7 Mon Sep 17 00:00:00 2001
From d97061fb09c251d90f2388a3ad3ef3975b063dd8 Mon Sep 17 00:00:00 2001
From: Paul Sauve <paul@burngames.net>
Date: Sun, 14 Jul 2019 21:05:03 -0500
Subject: [PATCH] Do less work if we have a custom Bukkit generator
@ -7,7 +7,7 @@ If the Bukkit generator already has a spawn, use it immediately instead
of spending time generating one that we won't use
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 451ad4f32..ad4e65e48 100644
index 84c16e2750..4497f6a601 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -663,12 +663,6 @@ public class WorldServer extends World {
@ -39,5 +39,5 @@ index 451ad4f32..ad4e65e48 100644
WorldServer.LOGGER.warn("Unable to find spawn biome");
}
--
2.22.0
2.22.1

Datei anzeigen

@ -1,4 +1,4 @@
From 798c94094b6037e2e6b5a50d4e2488e01365da71 Mon Sep 17 00:00:00 2001
From 3925d94376e662aa8711754eb27b22df40a42c0a Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Tue, 13 Aug 2019 06:35:17 -0700
Subject: [PATCH] Fix MC-158900
@ -7,7 +7,7 @@ The problem was we were checking isExpired() on the entry, but if it
was expired at that point, then it would be null.
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index a183bb450d..bf37c215c3 100644
index a183bb450d..3cb443c4ff 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -512,8 +512,10 @@ public abstract class PlayerList {
@ -24,5 +24,5 @@ index a183bb450d..bf37c215c3 100644
chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()});
if (gameprofilebanentry.getExpires() != null) {
--
2.22.0
2.22.1

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei anzeigen

@ -0,0 +1,315 @@
From 2567891663da05271689ca3b429a3a678ceff42e Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Fri, 19 Jul 2019 03:29:14 -0700
Subject: [PATCH] Reduce sync loads
This reduces calls to getChunkAt which would load chunks.
This patch also adds a tool to find calls which are doing this, however
it must be enabled by setting the startup flag -Dpaper.debug-sync-loads=true
To get a debug log for sync loads, the command is /paper syncloadinfo
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
index 09efbf7250..132397b3f3 100644
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
@@ -1,9 +1,13 @@
package com.destroystokyo.paper;
+import com.destroystokyo.paper.io.SyncLoadFinder;
import com.google.common.base.Functions;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.google.gson.JsonObject;
+import com.google.gson.internal.Streams;
+import com.google.gson.stream.JsonWriter;
import net.minecraft.server.*;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
@@ -18,6 +22,9 @@ import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Player;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.io.StringWriter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@@ -130,6 +137,9 @@ public class PaperCommand extends Command {
case "chunkinfo":
doChunkInfo(sender, args);
break;
+ case "syncloadinfo":
+ this.doSyncLoadInfo(sender, args);
+ break;
case "ver":
case "version":
Command ver = org.bukkit.Bukkit.getServer().getCommandMap().getCommand("version");
@@ -146,6 +156,40 @@ public class PaperCommand extends Command {
return true;
}
+ private void doSyncLoadInfo(CommandSender sender, String[] args) {
+ if (!SyncLoadFinder.ENABLED) {
+ sender.sendMessage(ChatColor.RED + "This command requires the server startup flag '-Dpaper.debug-sync-loads=true' to be set.");
+ return;
+ }
+ File file = new File(new File(new File("."), "debug"),
+ "sync-load-info" + DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss").format(LocalDateTime.now()) + ".txt");
+ file.getParentFile().mkdirs();
+ sender.sendMessage(ChatColor.GREEN + "Writing sync load info to " + file.toString());
+
+
+ try {
+ final JsonObject data = SyncLoadFinder.serialize();
+
+ StringWriter stringWriter = new StringWriter();
+ JsonWriter jsonWriter = new JsonWriter(stringWriter);
+ jsonWriter.setIndent(" ");
+ jsonWriter.setLenient(false);
+ Streams.write(data, jsonWriter);
+
+ String fileData = stringWriter.toString();
+
+ try (
+ PrintStream out = new PrintStream(new FileOutputStream(file), false, "UTF-8")
+ ) {
+ out.print(fileData);
+ }
+ sender.sendMessage(ChatColor.GREEN + "Successfully written sync load information!");
+ } catch (Throwable thr) {
+ sender.sendMessage(ChatColor.RED + "Failed to write sync load information");
+ thr.printStackTrace();
+ }
+ }
+
private void doChunkInfo(CommandSender sender, String[] args) {
List<org.bukkit.World> worlds;
if (args.length < 2 || args[1].equals("*")) {
diff --git a/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java
new file mode 100644
index 0000000000..59aec10329
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/io/SyncLoadFinder.java
@@ -0,0 +1,172 @@
+package com.destroystokyo.paper.io;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.mojang.datafixers.util.Pair;
+import it.unimi.dsi.fastutil.longs.Long2IntMap;
+import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
+import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
+import net.minecraft.server.World;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+public class SyncLoadFinder {
+
+ public static final boolean ENABLED = Boolean.getBoolean("paper.debug-sync-loads");
+
+ private static final WeakHashMap<World, Object2ObjectOpenHashMap<ThrowableWithEquals, SyncLoadInformation>> SYNC_LOADS = new WeakHashMap<>();
+
+ private static final class SyncLoadInformation {
+
+ public int times;
+
+ public final Long2IntOpenHashMap coordinateTimes = new Long2IntOpenHashMap();
+ }
+
+ public static void logSyncLoad(final World world, final int chunkX, final int chunkZ) {
+ if (!ENABLED) {
+ return;
+ }
+
+ final ThrowableWithEquals stacktrace = new ThrowableWithEquals(Thread.currentThread().getStackTrace());
+
+ SYNC_LOADS.compute(world, (final World keyInMap, Object2ObjectOpenHashMap<ThrowableWithEquals, SyncLoadInformation> map) -> {
+ if (map == null) {
+ map = new Object2ObjectOpenHashMap<>();
+ }
+
+ map.compute(stacktrace, (ThrowableWithEquals keyInMap0, SyncLoadInformation valueInMap) -> {
+ if (valueInMap == null) {
+ valueInMap = new SyncLoadInformation();
+ }
+
+ ++valueInMap.times;
+
+ valueInMap.coordinateTimes.compute(IOUtil.getCoordinateKey(chunkX, chunkZ), (Long keyInMap1, Integer valueInMap1) -> {
+ return valueInMap1 == null ? Integer.valueOf(1) : Integer.valueOf(valueInMap1.intValue() + 1);
+ });
+
+ return valueInMap;
+ });
+
+ return map;
+ });
+ }
+
+ public static JsonObject serialize() {
+ final JsonObject ret = new JsonObject();
+
+ final JsonArray worldsData = new JsonArray();
+
+ for (final Map.Entry<World, Object2ObjectOpenHashMap<ThrowableWithEquals, SyncLoadInformation>> entry : SYNC_LOADS.entrySet()) {
+ final World world = entry.getKey();
+
+ final JsonObject worldData = new JsonObject();
+
+ worldData.addProperty("name", world.getWorld().getName());
+
+ final List<Pair<ThrowableWithEquals, SyncLoadInformation>> data = new ArrayList<>();
+
+ entry.getValue().forEach((ThrowableWithEquals stacktrace, SyncLoadInformation times) -> {
+ data.add(new Pair<>(stacktrace, times));
+ });
+
+ data.sort((Pair<ThrowableWithEquals, SyncLoadInformation> pair1, Pair<ThrowableWithEquals, SyncLoadInformation> pair2) -> {
+ return Integer.compare(pair2.getSecond().times, pair1.getSecond().times); // reverse order
+ });
+
+ final JsonArray stacktraces = new JsonArray();
+
+ for (Pair<ThrowableWithEquals, SyncLoadInformation> pair : data) {
+ final JsonObject stacktrace = new JsonObject();
+
+ stacktrace.addProperty("times", pair.getSecond().times);
+
+ final JsonArray traces = new JsonArray();
+
+ for (StackTraceElement element : pair.getFirst().stacktrace) {
+ traces.add(String.valueOf(element));
+ }
+
+ stacktrace.add("stacktrace", traces);
+
+ final JsonArray coordinates = new JsonArray();
+
+ for (Long2IntMap.Entry coordinate : pair.getSecond().coordinateTimes.long2IntEntrySet()) {
+ final long key = coordinate.getLongKey();
+ final int times = coordinate.getIntValue();
+ coordinates.add("(" + IOUtil.getCoordinateX(key) + "," + IOUtil.getCoordinateZ(key) + "): " + times);
+ }
+
+ stacktrace.add("coordinates", coordinates);
+
+ stacktraces.add(stacktrace);
+ }
+
+
+ worldData.add("stacktraces", stacktraces);
+ worldsData.add(worldData);
+ }
+
+ ret.add("worlds", worldsData);
+
+ return ret;
+ }
+
+ static final class ThrowableWithEquals {
+
+ private final StackTraceElement[] stacktrace;
+ private final int hash;
+
+ public ThrowableWithEquals(final StackTraceElement[] stacktrace) {
+ this.stacktrace = stacktrace;
+ this.hash = ThrowableWithEquals.hash(stacktrace);
+ }
+
+ public static int hash(final StackTraceElement[] stacktrace) {
+ int hash = 0;
+
+ for (int i = 0; i < stacktrace.length; ++i) {
+ hash *= 31;
+ hash += stacktrace[i].hashCode();
+ }
+
+ return hash;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.hash;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null || obj.getClass() != this.getClass()) {
+ return false;
+ }
+
+ final ThrowableWithEquals other = (ThrowableWithEquals)obj;
+ final StackTraceElement[] otherStackTrace = other.stacktrace;
+
+ if (this.stacktrace.length != otherStackTrace.length) {
+ return false;
+ }
+
+ if (this == obj) {
+ return true;
+ }
+
+ for (int i = 0; i < this.stacktrace.length; ++i) {
+ if (!this.stacktrace[i].equals(otherStackTrace[i])) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 9138a256bd..9f9bebdb22 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -280,6 +280,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.asyncChunkTaskManager.raisePriority(x, z, com.destroystokyo.paper.io.PrioritizedTaskQueue.HIGHEST_PRIORITY);
com.destroystokyo.paper.io.chunk.ChunkTaskManager.pushChunkWait(this.world, x, z);
// Paper end
+ com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.world, x, z); // Paper - sync load info
this.world.timings.chunkAwait.startTiming(); // Paper
this.serverThreadQueue.awaitTasks(completablefuture::isDone);
com.destroystokyo.paper.io.chunk.ChunkTaskManager.popChunkWait(); // Paper - async chunk debug
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index b81b37445c..d3a0ed52bc 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1249,7 +1249,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
for (int i1 = i; i1 <= j; ++i1) {
for (int j1 = k; j1 <= l; ++j1) {
- Chunk chunk = this.getChunkProvider().getChunkAt(i1, j1, false);
+ Chunk chunk = (Chunk)this.getChunkIfLoadedImmediately(i1, j1); // Paper
if (chunk != null) {
chunk.a(entity, axisalignedbb, list, predicate);
@@ -1269,7 +1269,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
for (int i1 = i; i1 < j; ++i1) {
for (int j1 = k; j1 < l; ++j1) {
- Chunk chunk = this.getChunkProvider().getChunkAt(i1, j1, false);
+ Chunk chunk = (Chunk)this.getChunkIfLoadedImmediately(i1, j1); // Paper
if (chunk != null) {
chunk.a(entitytypes, axisalignedbb, list, predicate);
@@ -1291,7 +1291,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
for (int i1 = i; i1 < j; ++i1) {
for (int j1 = k; j1 < l; ++j1) {
- Chunk chunk = ichunkprovider.getChunkAt(i1, j1, false);
+ Chunk chunk = (Chunk)this.getChunkIfLoadedImmediately(i1, j1); // Paper
if (chunk != null) {
chunk.a(oclass, axisalignedbb, list, predicate);
--
2.22.1