Skip to content

Commit

Permalink
Make loadChunksForMoveAsync use new chunk system load calls
Browse files Browse the repository at this point in the history
This is to allow the call to work properly when on Folia,
as Folia does not have a main thread.
  • Loading branch information
Spottedleaf committed Jul 31, 2024
1 parent 58c7ea3 commit 0a1be9a
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 75 deletions.
149 changes: 101 additions & 48 deletions patches/server/0988-Moonrise-optimisation-patches.patch

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions patches/server/0990-disable-forced-empty-world-ticks.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] disable forced empty world ticks


diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index c759555241649cf5b355268066375341a54477f2..7da9729a6ac0684624f900a9e47f24e35bd3f3d9 100644
index b2c5ead035f583585b79f7eba51d66da89bf1259..067697f6762b115b3d500a298532f69f286b5d6f 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -729,7 +729,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -686,7 +686,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.

this.handlingTick = false;
gameprofilerfiller.pop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ custom renderers are in use, defaulting to the much simpler Vanilla system.
Additionally, numerous issues to player position tracking on maps has been fixed.

diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 7da9729a6ac0684624f900a9e47f24e35bd3f3d9..978208f74b6f1d3f859165e951d41013a5f00256 100644
index 067697f6762b115b3d500a298532f69f286b5d6f..6476a69d7d68998ecc398840e673952e61dcc647 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2537,6 +2537,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -2494,6 +2494,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
{
if ( iter.next().player == entity )
{
Expand Down
12 changes: 6 additions & 6 deletions patches/server/0997-Entity-Activation-Range-2.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Adds villagers as separate config
public net.minecraft.world.entity.Entity isInsidePortal

diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 978208f74b6f1d3f859165e951d41013a5f00256..1196eb573317ad01b6df0ae2d38aa17a72da2535 100644
index 6476a69d7d68998ecc398840e673952e61dcc647..3880ca95731c82bf48bb460f4c59a2c61970930b 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2,7 +2,6 @@ package net.minecraft.server.level;
Expand All @@ -28,7 +28,7 @@ index 978208f74b6f1d3f859165e951d41013a5f00256..1196eb573317ad01b6df0ae2d38aa17a
import com.google.common.collect.Lists;
import com.mojang.datafixers.DataFixer;
import com.mojang.datafixers.util.Pair;
@@ -1235,17 +1234,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -1192,17 +1191,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
++TimingHistory.entityTicks; // Paper - timings
// Spigot start
co.aikar.timings.Timing timer; // Paper
Expand All @@ -50,7 +50,7 @@ index 978208f74b6f1d3f859165e951d41013a5f00256..1196eb573317ad01b6df0ae2d38aa17a
try {
// Paper end - timings
entity.setOldPosAndRot();
@@ -1256,9 +1255,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -1213,9 +1212,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
return BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString();
});
gameprofilerfiller.incrementCounter("tickNonPassenger");
Expand All @@ -64,7 +64,7 @@ index 978208f74b6f1d3f859165e951d41013a5f00256..1196eb573317ad01b6df0ae2d38aa17a
Iterator iterator = entity.getPassengers().iterator();

while (iterator.hasNext()) {
@@ -1266,13 +1269,18 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -1223,13 +1226,18 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.

this.tickPassenger(entity, entity1);
}
Expand All @@ -84,7 +84,7 @@ index 978208f74b6f1d3f859165e951d41013a5f00256..1196eb573317ad01b6df0ae2d38aa17a
passenger.setOldPosAndRot();
++passenger.tickCount;
ProfilerFiller gameprofilerfiller = this.getProfiler();
@@ -1281,8 +1289,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -1238,8 +1246,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
return BuiltInRegistries.ENTITY_TYPE.getKey(passenger.getType()).toString();
});
gameprofilerfiller.incrementCounter("tickPassenger");
Expand All @@ -102,7 +102,7 @@ index 978208f74b6f1d3f859165e951d41013a5f00256..1196eb573317ad01b6df0ae2d38aa17a
gameprofilerfiller.pop();
Iterator iterator = passenger.getPassengers().iterator();

@@ -1292,6 +1309,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -1249,6 +1266,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
this.tickPassenger(passenger, entity2);
}

Expand Down
6 changes: 3 additions & 3 deletions patches/server/0999-Anti-Xray.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1104,10 +1104,10 @@ index 183b2191fa1c1b27adedf39593e1b5a223fb1279..8ead66c134688b11dca15f6509147e72

private ClientboundLevelChunkWithLightPacket(RegistryFriendlyByteBuf buf) {
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 1196eb573317ad01b6df0ae2d38aa17a72da2535..a5320b96148d79f8d2493060718688786466e6dd 100644
index 3880ca95731c82bf48bb460f4c59a2c61970930b..4fea1670cb7b731145c0769cf9c2e2485bdd1d6b 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -534,7 +534,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -491,7 +491,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
// Holder holder = worlddimension.type(); // CraftBukkit - decompile error

// Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
Expand Down Expand Up @@ -1155,7 +1155,7 @@ index 32634e45ac8433648e49e47e20081e15ad41ff15..dafa2cf7d3c49fc5bdcd68d2a9528127
if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) {
new io.papermc.paper.event.packet.PlayerChunkLoadEvent(new org.bukkit.craftbukkit.CraftChunk(chunk), handler.getPlayer().getBukkitEntity()).callEvent();
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 9b1a6d8351fb473eec75a2fd08fb892b770e3586..0d0b07c9199be9ca0d5ac3feb1d44f149ba69283 100644
index eec536d493575f593dd71c63944b047566f3822d..0a97d45f96b3b3cd12fa99373fcb5999c3fba96b 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -414,7 +414,7 @@ public abstract class PlayerList {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ index 0000000000000000000000000000000000000000..33cd90c30c22200a4e1ae64f40a0bf78
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index a5320b96148d79f8d2493060718688786466e6dd..472655c55b1f5c213da9b6c1940a353bafdac509 100644
index 4fea1670cb7b731145c0769cf9c2e2485bdd1d6b..3f1428b282987e1c4cd2fb5b035df5170cd09e00 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -228,6 +228,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
Expand All @@ -2020,7 +2020,7 @@ index a5320b96148d79f8d2493060718688786466e6dd..472655c55b1f5c213da9b6c1940a353b

public LevelChunk getChunkIfLoaded(int x, int z) {
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
@@ -2468,6 +2469,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -2425,6 +2426,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
return crashreportsystemdetails;
}

Expand All @@ -2035,7 +2035,7 @@ index a5320b96148d79f8d2493060718688786466e6dd..472655c55b1f5c213da9b6c1940a353b

EntityCallbacks() {}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index ae7cd8df617dba09abb9ca1108aff719a9c3304f..9501a2527bb0db91dd5494ccb4066b9629993e59 100644
index 87cde688976a45aa8848586b5371b3ab493813ea..5c4eaa6bcf20b0fcec14bd5ef76ea6f29a8613a2 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -2013,4 +2013,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
Expand Down
4 changes: 2 additions & 2 deletions patches/server/1034-Lag-compensation-ticks.patch
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ index 93ebdbfad4f9f300f31a124d8d4b36c4f5ce382c..a2875f7cdfb6b43ed59cff41ab4122a0
this.profiler.push(() -> {
String s = String.valueOf(worldserver);
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 472655c55b1f5c213da9b6c1940a353bafdac509..86288143a54e1d786672a81c05698b37fa5d8de2 100644
index 3f1428b282987e1c4cd2fb5b035df5170cd09e00..415b7839544d269a562b2bceeaa416a1a89be96e 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -528,6 +528,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -485,6 +485,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
return this.entityTickingChunks;
}
// Paper end - rewrite chunk system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ index d0d36a57ec4896bcb74970f8fb24d8f3e17db133..e2c24813f59c2fd075c740ac1842a38f
});
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 86288143a54e1d786672a81c05698b37fa5d8de2..1d74a728c03e2c6ffe0e795a5f24eac471a75157 100644
index 415b7839544d269a562b2bceeaa416a1a89be96e..6d8a5c2b0d95828abbd99914d1d308522b89529f 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1242,7 +1242,26 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -1199,7 +1199,26 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.

}

Expand All @@ -106,7 +106,7 @@ index 86288143a54e1d786672a81c05698b37fa5d8de2..1d74a728c03e2c6ffe0e795a5f24eac4
++TimingHistory.entityTicks; // Paper - timings
// Spigot start
co.aikar.timings.Timing timer; // Paper
@@ -1282,7 +1301,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -1239,7 +1258,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
this.tickPassenger(entity, entity1);
}
// } finally { timer.stopTiming(); } // Paper - timings - move up
Expand Down
8 changes: 4 additions & 4 deletions patches/server/1036-Write-SavedData-IO-async.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Write SavedData IO async
Co-Authored-By: Shane Freeder <theboyetronic@gmail.com>

diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index cdb9160244cc69acd36ac9afcfe109a15ab2ab58..8a0b00d645e4cf2ca96ec7e8ebc6ef726a0ab8b0 100644
index 4a5dc7fd4eb1a7ab1ec371f0f107de882f88149c..dcb5651d1d9b10b40430fb2f713beedf68336704 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -369,6 +369,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
Expand All @@ -24,10 +24,10 @@ index cdb9160244cc69acd36ac9afcfe109a15ab2ab58..8a0b00d645e4cf2ca96ec7e8ebc6ef72

// CraftBukkit start - modelled on below
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 1d74a728c03e2c6ffe0e795a5f24eac471a75157..46e8dd8dae25e1b2124e9c8031844fbe96eb6e1a 100644
index 6d8a5c2b0d95828abbd99914d1d308522b89529f..e50df5a1f3b89b3d0687d6584bdd977f8b71a3f6 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1373,7 +1373,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -1330,7 +1330,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel"));
}

Expand All @@ -36,7 +36,7 @@ index 1d74a728c03e2c6ffe0e795a5f24eac471a75157..46e8dd8dae25e1b2124e9c8031844fbe
if (progressListener != null) {
progressListener.progressStage(Component.translatable("menu.savingChunks"));
}
@@ -1404,12 +1404,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -1361,12 +1361,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
// CraftBukkit end
}

Expand Down
4 changes: 2 additions & 2 deletions patches/server/1039-Incremental-chunk-and-player-saving.patch
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ index a2875f7cdfb6b43ed59cff41ab4122a08c4cc57f..45695abbeb0a6d47b31b23ba6c464f17
try (co.aikar.timings.Timing ignored = MinecraftTimings.processTasksTimer.startTiming()) {
this.runAllTasks();
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 46e8dd8dae25e1b2124e9c8031844fbe96eb6e1a..2766ec28f028c0bd672009928bf64c1a6e5d07d6 100644
index e50df5a1f3b89b3d0687d6584bdd977f8b71a3f6..2fe9d9b38c01d04416843fdd48d3e33899b7de63 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1358,6 +1358,35 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -1315,6 +1315,35 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
return !this.server.isUnderSpawnProtection(this, pos, player) && this.getWorldBorder().isWithinBounds(pos);
}

Expand Down

1 comment on commit 0a1be9a

@ChengYi0224
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using this build, my server frequently restores block states. The restored borders are clearly chunk borders. It never happens before until I update to this build 123. Previously using build 109.

Please sign in to comment.