diff --git a/build.gradle.kts b/build.gradle.kts index 9f6ca7e..a072754 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { java `maven-publish` id("com.github.johnrengelman.shadow") version "8.1.1" apply false - id("io.papermc.paperweight.patcher") version "1.5.11" + id("io.papermc.paperweight.patcher") version "1.5.12" } val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" diff --git a/gradle.properties b/gradle.properties index 4f3cbbc..7e1ef76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ group=dev.folia version=1.20.4-R0.1-SNAPSHOT mcVersion=1.20.4 -paperRef=b6001403e9703cadaa6e8c8558e732b91c3c6d6e +paperRef=5436d44bf2509ff89129f8790ee4643f09c72871 org.gradle.caching=true org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd49..e644113 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e09..b82aa23 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..25da30d 100755 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/patches/api/0005-Add-API-for-checking-ownership-of-region-by-position.patch b/patches/api/0005-Add-API-for-checking-ownership-of-region-by-position.patch index 4f54484..4977302 100644 --- a/patches/api/0005-Add-API-for-checking-ownership-of-region-by-position.patch +++ b/patches/api/0005-Add-API-for-checking-ownership-of-region-by-position.patch @@ -11,10 +11,10 @@ the schedulers depending on the result of the ownership check. diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index db46e3233edf18bd91a6da8612ccc9f0080d5c17..4d6de4f2c67b1f122768806443766bd20c5ae617 100644 +index 9a428153f34291bdc026a71f7e60e285b7794b0c..c37904d1aae749030620e1bbdb955e25c91ab1f8 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -2873,6 +2873,14 @@ public final class Bukkit { +@@ -2879,6 +2879,14 @@ public final class Bukkit { return server.isOwnedByCurrentRegion(entity); } // Paper end - Folia region threading API @@ -30,10 +30,10 @@ index db46e3233edf18bd91a6da8612ccc9f0080d5c17..4d6de4f2c67b1f122768806443766bd2 @NotNull public static Server.Spigot spigot() { diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 0eb61b090d6f8fa6d99735ff3680dac774c52c1f..d46f932b595495816ea038cf161bc7f2d85f177e 100644 +index 4ff1b38eb65f97344257204cf018f176f247ed36..15395ef52505087e7eef3b1a5981e787dcc16508 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2512,4 +2512,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2518,4 +2518,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ boolean isOwnedByCurrentRegion(@NotNull Entity entity); // Paper end - Folia region threading API diff --git a/patches/server/0001-Build-changes.patch b/patches/server/0001-Build-changes.patch index 7ccea01..c7a497f 100644 --- a/patches/server/0001-Build-changes.patch +++ b/patches/server/0001-Build-changes.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Build changes diff --git a/build.gradle.kts b/build.gradle.kts -index 241808d8619e17c0681f79acbbc98af5bf52dd89..905262067dabc7cbe5b08639fcefd3a996a937e0 100644 +index bcfe59b6efb628ee1e7f9d60667360d4d885fb6a..12f9f9d46c098c5c88058cb1f73ae39a7d1debd5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,8 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { @@ -32,7 +32,7 @@ index 241808d8619e17c0681f79acbbc98af5bf52dd89..905262067dabc7cbe5b08639fcefd3a9 "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, -@@ -155,7 +159,7 @@ fun TaskContainer.registerRunTask( +@@ -150,7 +154,7 @@ fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit ): TaskProvider = register(name) { @@ -93,7 +93,7 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..e2f704c115fd6e00960bb56bb0779f11 ).openBufferedStream()) { JsonObject json = new Gson().fromJson(reader, JsonObject.class); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 93b661e9cb7743aeff7da3972942cb73049a5e4c..c220b116b62e783d42364bae3d499e66a52241d1 100644 +index c8772c773f9933ed1d1debfe707af4373c458152..50055e362a0de853c169a38c6cbd8681b73fc96d 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1865,7 +1865,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { // Folia - region threading packetProcessing.push(listener); // Paper - detailed watchdog information try { // Paper - detailed watchdog information - if (MinecraftServer.getServer().hasStopped() || (listener instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) listener).processedDisconnect)) return; // CraftBukkit, MC-142590 + if (listener instanceof ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // CraftBukkit - Don't handle sync packets for kicked players @@ -91,7 +91,21 @@ public class PacketUtils { } // Paper end - detailed watchdog information @@ -10075,10 +10075,10 @@ index 3e2d5dcd62775b6ed7c0ce0ba51a71b635b1d644..98fb69a9adeb6eaab199aec127692acb + } + // Folia end - region threading throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD; - // CraftBukkit start - SPIGOT-5477, MC-142590 - } else if (MinecraftServer.getServer().hasStopped() || (listener instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) listener).processedDisconnect)) { + } + } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index c220b116b62e783d42364bae3d499e66a52241d1..1e658114879ad9bdb679b9230ac3eab643375f8b 100644 +index 50055e362a0de853c169a38c6cbd8681b73fc96d..cf06989ad1ab55bf6836abe4cdeed2fff31ac93f 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -203,7 +203,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop list = new ObjectArrayList(); @@ -13837,7 +13837,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 while (iterator.hasNext()) { // CraftBukkit start - fix SPIGOT-6362 -@@ -1871,7 +2027,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1882,7 +2038,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } try { @@ -13846,7 +13846,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 iterator = list.iterator(); while (iterator.hasNext()) { -@@ -1880,7 +2036,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1891,7 +2047,7 @@ public class ServerLevel extends Level implements WorldGenLevel { navigationabstract1.recomputePath(); } } finally { @@ -13855,7 +13855,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } } -@@ -1889,23 +2045,23 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1900,23 +2056,23 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public void updateNeighborsAt(BlockPos pos, Block sourceBlock) { @@ -13884,7 +13884,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } @Override -@@ -1936,7 +2092,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1947,7 +2103,7 @@ public class ServerLevel extends Level implements WorldGenLevel { explosion.clearToBlow(); } @@ -13893,7 +13893,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 while (iterator.hasNext()) { ServerPlayer entityplayer = (ServerPlayer) iterator.next(); -@@ -1951,25 +2107,28 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1962,25 +2118,28 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public void blockEvent(BlockPos pos, Block block, int type, int data) { @@ -13928,7 +13928,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } private boolean doBlockEvent(BlockEventData event) { -@@ -1980,12 +2139,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1991,12 +2150,12 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public LevelTicks getBlockTicks() { @@ -13943,7 +13943,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } @Nonnull -@@ -2009,7 +2168,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2020,7 +2179,7 @@ public class ServerLevel extends Level implements WorldGenLevel { public int sendParticles(ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) { // Paper start - Particle API @@ -13952,7 +13952,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } public int sendParticles(List receivers, @Nullable ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) { // Paper end - Particle API -@@ -2062,7 +2221,14 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2073,7 +2232,14 @@ public class ServerLevel extends Level implements WorldGenLevel { public Entity getEntityOrPart(int id) { Entity entity = (Entity) this.getEntities().get(id); @@ -13968,7 +13968,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } @Nullable -@@ -2240,6 +2406,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2251,6 +2417,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } public boolean setChunkForced(int x, int z, boolean forced) { @@ -13976,7 +13976,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 ForcedChunksSavedData forcedchunk = (ForcedChunksSavedData) this.getDataStorage().computeIfAbsent(ForcedChunksSavedData.factory(), "chunks"); ChunkPos chunkcoordintpair = new ChunkPos(x, z); long k = chunkcoordintpair.toLong(); -@@ -2248,7 +2415,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2259,7 +2426,7 @@ public class ServerLevel extends Level implements WorldGenLevel { if (forced) { flag1 = forcedchunk.getChunks().add(k); if (flag1) { @@ -13985,7 +13985,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } } else { flag1 = forcedchunk.getChunks().remove(k); -@@ -2276,13 +2443,18 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2287,13 +2454,18 @@ public class ServerLevel extends Level implements WorldGenLevel { BlockPos blockposition1 = pos.immutable(); optional.ifPresent((holder) -> { @@ -14007,7 +14007,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 // Paper start - Remove stale POIs if (optional.isEmpty() && this.getPoiManager().exists(blockposition1, poiType -> true)) { this.getPoiManager().remove(blockposition1); -@@ -2290,7 +2462,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2301,7 +2473,12 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper end - Remove stale POIs this.getPoiManager().add(blockposition1, holder); DebugPackets.sendPoiAddedPacket(this, blockposition1); @@ -14021,7 +14021,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 }); } } -@@ -2337,7 +2514,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2348,7 +2525,7 @@ public class ServerLevel extends Level implements WorldGenLevel { BufferedWriter bufferedwriter = Files.newBufferedWriter(path.resolve("stats.txt")); try { @@ -14030,7 +14030,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 NaturalSpawner.SpawnState spawnercreature_d = this.getChunkSource().getLastSpawnState(); if (spawnercreature_d != null) { -@@ -2351,7 +2528,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2362,7 +2539,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } bufferedwriter.write(String.format(Locale.ROOT, "entities: %s\n", this.entityLookup.getDebugInfo())); // Paper - rewrite chunk system @@ -14039,7 +14039,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 bufferedwriter.write(String.format(Locale.ROOT, "block_ticks: %d\n", this.getBlockTicks().count())); bufferedwriter.write(String.format(Locale.ROOT, "fluid_ticks: %d\n", this.getFluidTicks().count())); bufferedwriter.write("distance_manager: " + playerchunkmap.getDistanceManager().getDebugStatus() + "\n"); -@@ -2497,7 +2674,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2508,7 +2685,7 @@ public class ServerLevel extends Level implements WorldGenLevel { private void dumpBlockEntityTickers(Writer writer) throws IOException { CsvOutput csvwriter = CsvOutput.builder().addColumn("x").addColumn("y").addColumn("z").addColumn("type").build(writer); @@ -14048,7 +14048,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 while (iterator.hasNext()) { TickingBlockEntity tickingblockentity = (TickingBlockEntity) iterator.next(); -@@ -2510,7 +2687,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2521,7 +2698,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @VisibleForTesting public void clearBlockEvents(BoundingBox box) { @@ -14057,7 +14057,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 return box.isInside(blockactiondata.pos()); }); } -@@ -2519,7 +2696,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2530,7 +2707,7 @@ public class ServerLevel extends Level implements WorldGenLevel { public void blockUpdated(BlockPos pos, Block block) { if (!this.isDebug()) { // CraftBukkit start @@ -14066,7 +14066,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 return; } // CraftBukkit end -@@ -2562,9 +2739,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2573,9 +2750,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @VisibleForTesting public String getWatchdogStats() { @@ -14077,7 +14077,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } private static String getTypeCount(Iterable items, Function classifier) { -@@ -2597,6 +2772,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2608,6 +2783,12 @@ public class ServerLevel extends Level implements WorldGenLevel { public static void makeObsidianPlatform(ServerLevel worldserver, Entity entity) { // CraftBukkit end BlockPos blockposition = ServerLevel.END_SPAWN_POINT; @@ -14090,7 +14090,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 int i = blockposition.getX(); int j = blockposition.getY() - 2; int k = blockposition.getZ(); -@@ -2609,11 +2790,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2620,11 +2801,7 @@ public class ServerLevel extends Level implements WorldGenLevel { BlockPos.betweenClosed(i - 2, j, k - 2, i + 2, j, k + 2).forEach((blockposition1) -> { blockList.setBlock(blockposition1, Blocks.OBSIDIAN.defaultBlockState(), 3); }); @@ -14103,7 +14103,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 blockList.updateList(); } // CraftBukkit end -@@ -2634,13 +2811,14 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2645,13 +2822,14 @@ public class ServerLevel extends Level implements WorldGenLevel { } public void startTickingChunk(LevelChunk chunk) { @@ -14122,7 +14122,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } @Override -@@ -2662,7 +2840,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2673,7 +2851,7 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper end - rewrite chunk system } @@ -14131,7 +14131,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 // Paper start - optimize is ticking ready type functions io.papermc.paper.chunk.system.scheduling.NewChunkHolder chunkHolder = this.chunkTaskScheduler.chunkHolderManager.getChunkHolder(chunkPos); // isTicking implies the chunk is loaded, and the chunk is loaded now implies the entities are loaded -@@ -2717,7 +2895,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2728,7 +2906,7 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper start - optimize redstone (Alternate Current) @Override public alternate.current.wire.WireHandler getWireHandler() { @@ -14140,7 +14140,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } // Paper end - optimize redstone (Alternate Current) -@@ -2728,16 +2906,16 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2739,16 +2917,16 @@ public class ServerLevel extends Level implements WorldGenLevel { public void onCreated(Entity entity) {} public void onDestroyed(Entity entity) { @@ -14160,7 +14160,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 // Paper start - Reset pearls when they stop being ticked if (paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && entity instanceof net.minecraft.world.entity.projectile.ThrownEnderpearl pearl) { pearl.cachedOwner = null; -@@ -2748,6 +2926,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2759,6 +2937,7 @@ public class ServerLevel extends Level implements WorldGenLevel { public void onTrackingStart(Entity entity) { org.spigotmc.AsyncCatcher.catchOp("entity register"); // Spigot @@ -14168,7 +14168,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 // ServerLevel.this.getChunkSource().addEntity(entity); // Paper - ignore and warn about illegal addEntity calls instead of crashing server; moved down below valid=true if (entity instanceof ServerPlayer) { ServerPlayer entityplayer = (ServerPlayer) entity; -@@ -2765,7 +2944,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2776,7 +2955,7 @@ public class ServerLevel extends Level implements WorldGenLevel { Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")); } @@ -14177,7 +14177,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } if (entity instanceof EnderDragon) { -@@ -2776,7 +2955,9 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2787,7 +2966,9 @@ public class ServerLevel extends Level implements WorldGenLevel { for (int j = 0; j < i; ++j) { EnderDragonPart entitycomplexpart = aentitycomplexpart[j]; @@ -14187,7 +14187,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } } -@@ -2798,16 +2979,24 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2809,16 +2990,24 @@ public class ServerLevel extends Level implements WorldGenLevel { public void onTrackingEnd(Entity entity) { org.spigotmc.AsyncCatcher.catchOp("entity unregister"); // Spigot @@ -14213,7 +14213,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 map.carriedByPlayers.remove( (Player) entity ); for ( Iterator iter = (Iterator) map.carriedBy.iterator(); iter.hasNext(); ) { -@@ -2817,6 +3006,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2828,6 +3017,7 @@ public class ServerLevel extends Level implements WorldGenLevel { iter.remove(); } } @@ -14221,7 +14221,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } } } ); -@@ -2851,7 +3041,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2862,7 +3052,7 @@ public class ServerLevel extends Level implements WorldGenLevel { Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")); } @@ -14230,7 +14230,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 } if (entity instanceof EnderDragon) { -@@ -2862,13 +3052,16 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2873,13 +3063,16 @@ public class ServerLevel extends Level implements WorldGenLevel { for (int j = 0; j < i; ++j) { EnderDragonPart entitycomplexpart = aentitycomplexpart[j]; @@ -14248,7 +14248,7 @@ index bf5e47e8c3706590fdc0731bd9a5858b56d06136..f72e3d2decf8eb2a5a802bb1c6c8aa29 for (ServerPlayer player : ServerLevel.this.players) { player.getBukkitEntity().onEntityRemove(entity); diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 58591bf2f63b9c5e97d9ce4188dff3366968a178..add6fc106d3c38d97b48ec0df3ac2515c8c0486e 100644 +index b3781efbd3edcf102fe1bda5d6149915dc1127c6..36d074d1abed62b09ca808dc2774bc83a6fd5df7 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -191,7 +191,7 @@ import org.bukkit.inventory.MainHand; @@ -14967,7 +14967,7 @@ index 658e63ebde81dc14c8ab5850fb246dc0aab25dea..7e1f15ac8d2f7c86d4aba1be5df71705 public static TicketType create(String name, Comparator argumentComparator) { return new TicketType<>(name, argumentComparator, 0L); diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -index 5ece375eaf6bcc61864997a389bb5e24625e4505..33c1ef45ed620f8424c2c83dd30b674892ddffe3 100644 +index 9c3f8f79c2b3389a118dce9a1558edda52446833..8c455cda45ca2d724fbc140d53ffc7ecba3ca44c 100644 --- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java +++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java @@ -84,6 +84,13 @@ public class WorldGenRegion implements WorldGenLevel { @@ -15166,7 +15166,7 @@ index 586521a2cbb1d4dcfb912029f65e4363ec7674a7..6e95017f4c36208abdf344e3b7d55efe Collections.shuffle( this.connections ); } diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 87e5ee042ab2c052d25ab4c2521a68cf2e2d67b6..3b2508dc6cd4f70b09dce3b7e745e6efabaaa74e 100644 +index 860d33ac56680babd87358b1d7d2216dac3f7865..954809d8997750959541e6462668f17efd0b0f70 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -291,7 +291,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -16402,7 +16402,7 @@ index ea27b46eec01bda427653335f922ccd068cffcb5..e551d3b875eab6851b75041f418c9a08 return blockToFallLocation(blockState); } else { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index b2eff51f1ad1e702525ef298807ea7d2083f6218..79e9039d77a993d8f1e02942f87fac2a0bd9e8a8 100644 +index 0b4ed99658b083a83a90db1b32edb358da9e9514..518487d4cd489110bebcf75078935a95b5d3e9cf 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -170,7 +170,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -17409,7 +17409,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..79e9039d77a993d8f1e02942f87fac2a /** * Invoked only when the entity is truly removed from the server, never to be added to any world. diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 23570a0b1227a840b9c1e6ae326827ea655bb5f7..a8b47867f05af2a1a4409be5ff49ad0d95bebcae 100644 +index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a168ee46f 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -246,7 +246,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -18037,7 +18037,7 @@ index c34701f95580e4cf45fe086115563127432a28c5..fe95aa9389f7d11e1380445a1eeca50c }); diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index c7f06c3cfb737bd17a706798bf9cf0e1af5f0cc0..14fc53880808df4954575d3270b1f587eb6ac83b 100644 +index 29ce703a79f7893ac990ad80e0f1c1cf63546e6c..51bc4c0c8505e900cd3268048ac8cf71b2d22e6b 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java @@ -55,7 +55,7 @@ public class ItemEntity extends Entity implements TraceableEntity { @@ -19335,7 +19335,7 @@ index 90a82bd7977ebe520bdcc2ab99e11452d5cf4a21..b937437d4446fbf80376399067fd04dc private final double posX, posY, posZ; private final double minX, minY, minZ; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index bc89f9e90af3d69872a58c47a4c2545ba91b6ba5..52a7775e7aa375a043438d23204acd030ad35372 100644 +index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a43467129a65f999 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -115,10 +115,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -19482,8 +19482,8 @@ index bc89f9e90af3d69872a58c47a4c2545ba91b6ba5..52a7775e7aa375a043438d23204acd03 - this.capturedBlockStates.put(pos.immutable(), blockstate); + worldData.capturedBlockStates.put(pos.immutable(), blockstate); // Folia - region threading } - blockstate.setFlag(flags); // Paper - update the flag also blockstate.setData(state); + blockstate.setFlag(flags); @@ -937,10 +956,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // CraftBukkit start - capture blockstates @@ -21046,7 +21046,7 @@ index b8b78494449c0cd638f9706a803dc54e184d981f..b31f1e0522ff18fa5853af6104d46f98 return true; } else { diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index 6ec3fc801453fd54c25b642e6fa71c19b463311d..852fef18497435827a03e0056a09e5deb2525ed9 100644 +index 465458e8a7dbaf9afb32709a71c7b2620d1e1fd2..ff1a7b78fa010857daab7a306cb9483c98560b79 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -59,6 +59,13 @@ public class LevelChunk extends ChunkAccess { @@ -21896,10 +21896,10 @@ index b63effd92be5a8a75db6c37e5a1b91541020ec75..350fc61fd709453a86c9f7f6e4bccc43 @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1ac7d84381 100644 +index 01797d9791f19dfda4b168218eadeaae97f11eab..becb3b07876715d7c39ba4e7289cc5ac85f84412 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -192,7 +192,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -193,7 +193,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getTickableTileEntityCount() { @@ -21908,7 +21908,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a } @Override -@@ -254,7 +254,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -255,7 +255,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper start - per world spawn limits for (SpawnCategory spawnCategory : SpawnCategory.values()) { if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { @@ -21917,7 +21917,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a } } // Paper end - per world spawn limits -@@ -341,6 +341,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -342,6 +342,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Chunk getChunkAt(int x, int z) { @@ -21925,7 +21925,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a warnUnsafeChunk("getting a faraway chunk", x, z); // Paper // Paper start - add ticket to hold chunk for a little while longer if plugin accesses it net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); -@@ -364,7 +365,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -365,7 +366,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper start private void addTicket(int x, int z) { @@ -21934,7 +21934,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a } // Paper end -@@ -383,10 +384,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -384,10 +385,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean isChunkGenerated(int x, int z) { // Paper start - Fix this method @@ -21947,7 +21947,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a } ChunkAccess chunk = world.getChunkSource().getChunkAtImmediately(x, z); if (chunk == null) { -@@ -440,7 +441,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -441,7 +442,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { } private boolean unloadChunk0(int x, int z, boolean save) { @@ -21956,7 +21956,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a if (!this.isChunkLoaded(x, z)) { return true; } -@@ -455,7 +456,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -456,7 +457,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean regenerateChunk(int x, int z) { @@ -21965,7 +21965,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a warnUnsafeChunk("regenerating a faraway chunk", x, z); // Paper // Paper start - implement regenerateChunk method final ServerLevel serverLevel = this.world; -@@ -518,6 +519,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -519,6 +520,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean refreshChunk(int x, int z) { @@ -21973,7 +21973,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z)); if (playerChunk == null) return false; -@@ -553,7 +555,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -554,7 +556,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean loadChunk(int x, int z, boolean generate) { @@ -21982,7 +21982,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a warnUnsafeChunk("loading a faraway chunk", x, z); // Paper // Paper start - Optimize this method ChunkPos chunkPos = new ChunkPos(x, z); -@@ -622,7 +624,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -623,7 +625,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { DistanceManager chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; if (chunkDistanceManager.addRegionTicketAtDistance(TicketType.PLUGIN_TICKET, new ChunkPos(x, z), 2, plugin)) { // keep in-line with force loading, add at level 31 @@ -21991,7 +21991,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a return true; } -@@ -813,13 +815,15 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -833,13 +835,15 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { @@ -22012,7 +22012,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a BlockPos position = ((CraftBlockState) blockstate).getPosition(); net.minecraft.world.level.block.state.BlockState oldBlock = this.world.getBlockState(position); int flag = ((CraftBlockState) blockstate).getFlag(); -@@ -827,10 +831,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -847,10 +851,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { net.minecraft.world.level.block.state.BlockState newBlock = this.world.getBlockState(position); this.world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, newBlock, flag, 512); } @@ -22025,7 +22025,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a return false; } } -@@ -864,6 +868,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -884,6 +888,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setTime(long time) { @@ -22033,7 +22033,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a long margin = (time - this.getFullTime()) % 24000; if (margin < 0) margin += 24000; this.setFullTime(this.getFullTime() + margin); -@@ -876,6 +881,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -896,6 +901,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setFullTime(long time) { @@ -22041,7 +22041,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a // Notify anyone who's listening TimeSkipEvent event = new TimeSkipEvent(this, TimeSkipEvent.SkipReason.CUSTOM, time - this.world.getDayTime()); this.server.getPluginManager().callEvent(event); -@@ -903,7 +909,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -923,7 +929,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public long getGameTime() { @@ -22050,7 +22050,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a } @Override -@@ -923,11 +929,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -943,11 +949,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) { @@ -22064,7 +22064,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a return !world.explode(source != null ? ((org.bukkit.craftbukkit.entity.CraftEntity) source).getHandle() : null, loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks ? net.minecraft.world.level.Level.ExplosionInteraction.MOB : net.minecraft.world.level.Level.ExplosionInteraction.NONE).wasCanceled; } // Paper end -@@ -1004,6 +1012,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1024,6 +1032,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) { @@ -22072,7 +22072,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper // Transient load for this tick return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z); -@@ -1034,6 +1043,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1054,6 +1063,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setBiome(int x, int y, int z, Holder bb) { BlockPos pos = new BlockPos(x, 0, z); @@ -22080,7 +22080,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a if (this.world.hasChunkAt(pos)) { net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkAt(pos); -@@ -1344,6 +1354,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1364,6 +1374,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setStorm(boolean hasStorm) { @@ -22088,7 +22088,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.world.serverLevelData.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper - Add cause to Weather/ThunderChangeEvents this.setWeatherDuration(0); // Reset weather duration (legacy behaviour) this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) -@@ -1356,6 +1367,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1376,6 +1387,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setWeatherDuration(int duration) { @@ -22096,7 +22096,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.world.serverLevelData.setRainTime(duration); } -@@ -1366,6 +1378,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1386,6 +1398,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setThundering(boolean thundering) { @@ -22104,7 +22104,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.world.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper - Add cause to Weather/ThunderChangeEvents this.setThunderDuration(0); // Reset weather duration (legacy behaviour) this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) -@@ -1378,6 +1391,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1398,6 +1411,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setThunderDuration(int duration) { @@ -22112,7 +22112,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.world.serverLevelData.setThunderTime(duration); } -@@ -1388,6 +1402,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1408,6 +1422,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setClearWeatherDuration(int duration) { @@ -22120,7 +22120,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.world.serverLevelData.setClearWeatherTime(duration); } -@@ -1582,6 +1597,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1602,6 +1617,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setKeepSpawnInMemory(boolean keepLoaded) { @@ -22128,7 +22128,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a // Paper start - Configurable spawn radius if (keepLoaded == this.world.keepSpawnInMemory) { // do nothing, nothing has changed -@@ -1660,6 +1676,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1680,6 +1696,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setHardcore(boolean hardcore) { @@ -22136,7 +22136,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.world.serverLevelData.settings.hardcore = hardcore; } -@@ -1672,6 +1689,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1692,6 +1709,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns) { @@ -22144,7 +22144,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.setTicksPerSpawns(SpawnCategory.ANIMAL, ticksPerAnimalSpawns); } -@@ -1684,6 +1702,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1704,6 +1722,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns) { @@ -22152,7 +22152,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.setTicksPerSpawns(SpawnCategory.MONSTER, ticksPerMonsterSpawns); } -@@ -1696,6 +1715,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1716,6 +1735,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterSpawns(int ticksPerWaterSpawns) { @@ -22160,7 +22160,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.setTicksPerSpawns(SpawnCategory.WATER_ANIMAL, ticksPerWaterSpawns); } -@@ -1708,6 +1728,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1728,6 +1748,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterAmbientSpawns(int ticksPerWaterAmbientSpawns) { @@ -22168,7 +22168,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.setTicksPerSpawns(SpawnCategory.WATER_AMBIENT, ticksPerWaterAmbientSpawns); } -@@ -1720,6 +1741,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1740,6 +1761,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterUndergroundCreatureSpawns(int ticksPerWaterUndergroundCreatureSpawns) { @@ -22176,7 +22176,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.setTicksPerSpawns(SpawnCategory.WATER_UNDERGROUND_CREATURE, ticksPerWaterUndergroundCreatureSpawns); } -@@ -1732,11 +1754,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1752,11 +1774,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerAmbientSpawns(int ticksPerAmbientSpawns) { @@ -22190,7 +22190,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a Preconditions.checkArgument(spawnCategory != null, "SpawnCategory cannot be null"); Preconditions.checkArgument(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory.%s are not supported", spawnCategory); -@@ -1753,21 +1777,25 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1773,21 +1797,25 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { @@ -22216,7 +22216,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.server.getWorldMetadata().removeMetadata(this, metadataKey, owningPlugin); } -@@ -1780,6 +1808,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1800,6 +1828,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setMonsterSpawnLimit(int limit) { @@ -22224,7 +22224,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.setSpawnLimit(SpawnCategory.MONSTER, limit); } -@@ -1792,6 +1821,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1812,6 +1841,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setAnimalSpawnLimit(int limit) { @@ -22232,7 +22232,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.setSpawnLimit(SpawnCategory.ANIMAL, limit); } -@@ -1804,6 +1834,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1824,6 +1854,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterAnimalSpawnLimit(int limit) { @@ -22240,7 +22240,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.setSpawnLimit(SpawnCategory.WATER_ANIMAL, limit); } -@@ -1816,6 +1847,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1836,6 +1867,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterAmbientSpawnLimit(int limit) { @@ -22248,7 +22248,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.setSpawnLimit(SpawnCategory.WATER_AMBIENT, limit); } -@@ -1828,6 +1860,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1848,6 +1880,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterUndergroundCreatureSpawnLimit(int limit) { @@ -22256,7 +22256,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.setSpawnLimit(SpawnCategory.WATER_UNDERGROUND_CREATURE, limit); } -@@ -1840,6 +1873,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1860,6 +1893,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setAmbientSpawnLimit(int limit) { @@ -22264,7 +22264,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a this.setSpawnLimit(SpawnCategory.AMBIENT, limit); } -@@ -1862,6 +1896,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1882,6 +1916,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setSpawnLimit(SpawnCategory spawnCategory, int limit) { @@ -22272,7 +22272,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a Preconditions.checkArgument(spawnCategory != null, "SpawnCategory cannot be null"); Preconditions.checkArgument(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory.%s are not supported", spawnCategory); -@@ -1944,7 +1979,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1964,7 +1999,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(CraftSound.bukkitToMinecraftHolder(sound), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); @@ -22281,7 +22281,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a if (entityTracker != null) { entityTracker.broadcastAndSend(packet); } -@@ -1956,7 +1991,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1976,7 +2011,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(Holder.direct(SoundEvent.createVariableRangeEvent(new ResourceLocation(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); @@ -22290,7 +22290,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a if (entityTracker != null) { entityTracker.broadcastAndSend(packet); } -@@ -2045,6 +2080,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2065,6 +2100,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean setGameRuleValue(String rule, String value) { @@ -22298,7 +22298,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a // No null values allowed if (rule == null || value == null) return false; -@@ -2087,6 +2123,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2107,6 +2143,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean setGameRule(GameRule rule, T newValue) { @@ -22306,7 +22306,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a Preconditions.checkArgument(rule != null, "GameRule cannot be null"); Preconditions.checkArgument(newValue != null, "GameRule value cannot be null"); -@@ -2339,6 +2376,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2359,6 +2396,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) { @@ -22319,7 +22319,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a getHandle().gameEvent(sourceEntity != null ? ((CraftEntity) sourceEntity).getHandle(): null, net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.get(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(gameEvent.getKey())), org.bukkit.craftbukkit.util.CraftVector.toBlockPos(position)); } // Paper end -@@ -2459,7 +2502,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2479,7 +2522,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper start public java.util.concurrent.CompletableFuture getChunkAtAsync(int x, int z, boolean gen, boolean urgent) { warnUnsafeChunk("getting a faraway chunk async", x, z); // Paper @@ -22328,7 +22328,7 @@ index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1a net.minecraft.world.level.chunk.LevelChunk immediate = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); if (immediate != null) { return java.util.concurrent.CompletableFuture.completedFuture(new CraftChunk(immediate)); -@@ -2476,7 +2519,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2496,7 +2539,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { java.util.concurrent.CompletableFuture ret = new java.util.concurrent.CompletableFuture<>(); io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad(this.getHandle(), x, z, gen, ChunkStatus.FULL, true, priority, (c) -> { @@ -22543,7 +22543,7 @@ index 4b42ef2a876ea210d948238e63fd7a2b7035bb5b..b451b9df3233355fb16092edc3a4dd63 net.minecraft.server.level.ServerLevel level = this.world.getMinecraftWorld(); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java -index d11d854ae90b99aa2ce227994d07fe1fe9b4a60a..6a6d95dcad917dd60b47236a130bcd2c9425a529 100644 +index 2cfaa59a0bb6b5253b5a8dcc38ae65e0f085fd3f..5cf33427847068fc589ada9f731b985f791ac013 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -210,6 +210,12 @@ public class CraftBlockState implements BlockState { @@ -22559,16 +22559,16 @@ index d11d854ae90b99aa2ce227994d07fe1fe9b4a60a..6a6d95dcad917dd60b47236a130bcd2c if (block.getType() != this.getType()) { if (!force) { return false; -@@ -350,6 +356,9 @@ public class CraftBlockState implements BlockState { +@@ -340,6 +346,9 @@ public class CraftBlockState implements BlockState { @Override public java.util.Collection getDrops(org.bukkit.inventory.ItemStack item, org.bukkit.entity.Entity entity) { + // Folia start - region threading + io.papermc.paper.util.TickThread.ensureTickThread(world.getHandle(), position, "Cannot modify world asynchronously"); + // Folia end - region threading + this.requirePlaced(); net.minecraft.world.item.ItemStack nms = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item); - // Modelled off EntityHuman#hasBlock diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java index 3e93a6c489972ff2b4ecff3d83cc72b2d5c970f8..66dc7e20544c7000f4824b02cc3a31bc5c87f74c 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java @@ -22592,7 +22592,7 @@ index 3e93a6c489972ff2b4ecff3d83cc72b2d5c970f8..66dc7e20544c7000f4824b02cc3a31bc List offers = waitable.get(); if (offers == null) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 7cd7912cecbbbe2c32bfd9b85181115c6d316eb8..55ed79a802efa7a28cd487770a689119c64b7f40 100644 +index e8e4489bcd64fde1b3226bdc7a7cc612508bda3f..1cfe604573000fa9b32237313aa467875a891f3c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -234,6 +234,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @@ -22625,42 +22625,41 @@ index 7cd7912cecbbbe2c32bfd9b85181115c6d316eb8..55ed79a802efa7a28cd487770a689119 if (entityTracker == null) { return; -@@ -1062,30 +1067,43 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - Preconditions.checkArgument(location != null, "location"); +@@ -1032,29 +1037,43 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { location.checkFinite(); Location locationClone = location.clone(); // clone so we don't need to worry about mutations after this call. -- + - net.minecraft.server.level.ServerLevel world = ((CraftWorld)locationClone.getWorld()).getHandle(); + // Folia start - region threading java.util.concurrent.CompletableFuture ret = new java.util.concurrent.CompletableFuture<>(); - - world.loadChunksForMoveAsync(getHandle().getBoundingBoxAt(locationClone.getX(), locationClone.getY(), locationClone.getZ()), - this instanceof CraftPlayer ? ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGHER : ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, (list) -> { -- net.minecraft.server.level.ServerChunkCache chunkProviderServer = world.getChunkSource(); -- for (net.minecraft.world.level.chunk.ChunkAccess chunk : list) { -- chunkProviderServer.addTicketAtLevel(net.minecraft.server.level.TicketType.POST_TELEPORT, chunk.getPos(), 33, CraftEntity.this.getEntityId()); -- } -- net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> { -- try { -- ret.complete(CraftEntity.this.teleport(locationClone, cause) ? Boolean.TRUE : Boolean.FALSE); -- } catch (Throwable throwable) { -- if (throwable instanceof ThreadDeath) { -- throw (ThreadDeath)throwable; -- } -- net.minecraft.server.MinecraftServer.LOGGER.error("Failed to teleport entity " + CraftEntity.this, throwable); -- ret.completeExceptionally(throwable); +- net.minecraft.server.level.ServerChunkCache chunkProviderServer = world.getChunkSource(); +- for (net.minecraft.world.level.chunk.ChunkAccess chunk : list) { +- chunkProviderServer.addTicketAtLevel(net.minecraft.server.level.TicketType.POST_TELEPORT, chunk.getPos(), 33, CraftEntity.this.getEntityId()); + java.util.function.Consumer run = (Entity nmsEntity) -> { + boolean success = nmsEntity.teleportAsync( + ((CraftWorld)locationClone.getWorld()).getHandle(), + new net.minecraft.world.phys.Vec3(locationClone.getX(), locationClone.getY(), locationClone.getZ()), + locationClone.getYaw(), locationClone.getPitch(), net.minecraft.world.phys.Vec3.ZERO, + cause == null ? TeleportCause.UNKNOWN : cause, -+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_UNMOUNT, // preserve behavior with old API: dismount the entity so it can teleport ++ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS, // preserve behavior with old API: dismount the entity so it can teleport + (Entity entityTp) -> { + ret.complete(Boolean.TRUE); } +- net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> { +- try { +- ret.complete(CraftEntity.this.teleport(locationClone, cause, teleportFlags) ? Boolean.TRUE : Boolean.FALSE); +- } catch (Throwable throwable) { +- if (throwable instanceof ThreadDeath) { +- throw (ThreadDeath)throwable; +- } +- net.minecraft.server.MinecraftServer.LOGGER.error("Failed to teleport entity " + CraftEntity.this, throwable); +- ret.completeExceptionally(throwable); +- } +- }); - }); -- }); + ); + if (!success) { + ret.complete(Boolean.FALSE); @@ -22672,7 +22671,7 @@ index 7cd7912cecbbbe2c32bfd9b85181115c6d316eb8..55ed79a802efa7a28cd487770a689119 + } + boolean scheduled = this.taskScheduler.schedule( + // success -+ run, ++ run, + // retired + (Entity nmsEntity) -> { + ret.complete(Boolean.FALSE); @@ -22687,10 +22686,10 @@ index 7cd7912cecbbbe2c32bfd9b85181115c6d316eb8..55ed79a802efa7a28cd487770a689119 return ret; + // Folia end - region threading } + // Paper end - more teleport API / async chunk API - @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 616d2e479d91673695ade0db151a0099b568904f..14a5eda367dd46fe7c9b5f76df80840f938c06ea 100644 +index e77bf7f432387bdfa7f69d31b014e8cd254fd4ca..8db8ceb161557b9803c3bda80f3e57b8626191c3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -560,7 +560,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -22733,10 +22732,10 @@ index 616d2e479d91673695ade0db151a0099b568904f..14a5eda367dd46fe7c9b5f76df80840f entry.updatePlayer(this.getHandle()); } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index cb3e9672f375a1a660757a05362729ddb5ca7504..eb9146287d8d241273a3edec1ca8bd955106c186 100644 +index c0823c612de9dc2a64cc797f061eef25c5f31359..ccab0ec21a6827475d97654f1b54c166ccb99085 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -942,7 +942,7 @@ public class CraftEventFactory { +@@ -943,7 +943,7 @@ public class CraftEventFactory { return CraftEventFactory.handleBlockSpreadEvent(world, source, target, block, 2); } @@ -22745,7 +22744,7 @@ index cb3e9672f375a1a660757a05362729ddb5ca7504..eb9146287d8d241273a3edec1ca8bd95 public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState block, int flag) { // Suppress during worldgen -@@ -954,7 +954,7 @@ public class CraftEventFactory { +@@ -955,7 +955,7 @@ public class CraftEventFactory { CraftBlockState state = CraftBlockStates.getBlockState(world, target, flag); state.setData(block); @@ -22754,7 +22753,7 @@ index cb3e9672f375a1a660757a05362729ddb5ca7504..eb9146287d8d241273a3edec1ca8bd95 Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { -@@ -2140,7 +2140,7 @@ public class CraftEventFactory { +@@ -2146,7 +2146,7 @@ public class CraftEventFactory { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemStack.copyWithCount(1)); org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), CraftVector.toBukkit(to)); @@ -22776,7 +22775,7 @@ index e85b9bb3f9c225d289a4959921970b9963881199..b00e3b9b628f3d2a2fdbf1d2c7790496 if (!this.isAsyncScheduler && !task.isSync()) { this.asyncScheduler.handle(task, delay); diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 1324f05de8106032ce290e928cf106fb4f450517..20178003ee9a0314266d4fc6a589e9d509a25072 100644 +index 3c7a771c48cc2732cc038ca11bb93ec5f8c2d667..d365e26799822f39af2d5a27761bb8b41308297e 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -382,6 +382,12 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -22811,7 +22810,7 @@ index 86a20c91beff6b27e6ec886e49ba902b216106f2..96007426144b78f91c12614f04350855 return this.handle; } diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index c39894e824334f1dc52e0466cf9d84f7e219be70..f8718d91f4c15c74d6e6dd5f60f7f05f45f63655 100644 +index 3283ed99c35ffed6805567705e0518d9f84feedc..4fc4690d03fd5f39e019f16845954052210c7361 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -52,7 +52,7 @@ public class ActivationRange @@ -22869,7 +22868,7 @@ index c39894e824334f1dc52e0466cf9d84f7e219be70..f8718d91f4c15c74d6e6dd5f60f7f05f /** * Initializes an entities type on construction to specify what group this -@@ -174,10 +175,11 @@ public class ActivationRange +@@ -176,10 +177,11 @@ public class ActivationRange final int waterActivationRange = world.spigotConfig.waterActivationRange; final int flyingActivationRange = world.spigotConfig.flyingMonsterActivationRange; final int villagerActivationRange = world.spigotConfig.villagerActivationRange; @@ -22885,7 +22884,7 @@ index c39894e824334f1dc52e0466cf9d84f7e219be70..f8718d91f4c15c74d6e6dd5f60f7f05f final ServerChunkCache chunkProvider = (ServerChunkCache) world.getChunkSource(); // Paper end -@@ -191,9 +193,9 @@ public class ActivationRange +@@ -193,9 +195,9 @@ public class ActivationRange // Paper end maxRange = Math.min( ( world.spigotConfig.simulationDistance << 4 ) - 8, maxRange ); @@ -22897,7 +22896,7 @@ index c39894e824334f1dc52e0466cf9d84f7e219be70..f8718d91f4c15c74d6e6dd5f60f7f05f if ( world.spigotConfig.ignoreSpectatorActivation && player.isSpectator() ) { continue; -@@ -201,26 +203,33 @@ public class ActivationRange +@@ -203,26 +205,33 @@ public class ActivationRange // Paper start int worldHeight = world.getHeight(); @@ -22941,7 +22940,7 @@ index c39894e824334f1dc52e0466cf9d84f7e219be70..f8718d91f4c15c74d6e6dd5f60f7f05f } // Paper end } -@@ -232,18 +241,18 @@ public class ActivationRange +@@ -234,18 +243,18 @@ public class ActivationRange * * @param chunk */ @@ -22965,7 +22964,7 @@ index c39894e824334f1dc52e0466cf9d84f7e219be70..f8718d91f4c15c74d6e6dd5f60f7f05f } } } -@@ -266,10 +275,10 @@ public class ActivationRange +@@ -268,10 +277,10 @@ public class ActivationRange if (entity.getRemainingFireTicks() > 0) { return 2; } @@ -22978,7 +22977,7 @@ index c39894e824334f1dc52e0466cf9d84f7e219be70..f8718d91f4c15c74d6e6dd5f60f7f05f // Paper end // quick checks. if ( (entity.activationType != ActivationType.WATER && entity.wasTouchingWater && entity.isPushedByFluid()) ) // Paper -@@ -392,19 +401,19 @@ public class ActivationRange +@@ -394,19 +403,19 @@ public class ActivationRange } // Paper end diff --git a/patches/server/0006-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch b/patches/server/0006-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch index b0e19f6..96453f2 100644 --- a/patches/server/0006-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch +++ b/patches/server/0006-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch @@ -29,7 +29,7 @@ index 41bf71d116ffc5431586ce54abba7f8def6c1dcf..519da6886613b8460e989767b1a21e31 } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 79e9039d77a993d8f1e02942f87fac2a0bd9e8a8..1d77bc6bdb87de1ad6c8740376391dedcaa73089 100644 +index 518487d4cd489110bebcf75078935a95b5d3e9cf..1119b6a7f307763c13ef48bcd7643539082aebdc 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -2930,6 +2930,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -288,10 +288,10 @@ index ccda0d7a96c201905f0f62dcb0e5b278a51dee9f..3ba6c46e0f5bc5f6b5994d41aaa9c4dd } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java -index 3a749f78be3968e499e096196eaaa0b433a53c06..6b2907f9fb74e5a5bbc7084d22318794b97dd1b7 100644 +index 0fd2677181d741e553b9825c8c319a209194ec46..a3a5c77b264a40911ddcee9b8c593fd07b3041d7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java -@@ -133,8 +133,16 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { +@@ -135,6 +135,13 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { this.getHandle().setShotFromCrossbow(shotFromCrossbow); } @@ -302,6 +302,11 @@ index 3a749f78be3968e499e096196eaaa0b433a53c06..6b2907f9fb74e5a5bbc7084d22318794 + } + // Folia end - region threading + + @Override + public ItemStack getItem() { + return CraftItemStack.asBukkitCopy(this.getHandle().pickupItemStack); +@@ -149,6 +156,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { + @Override public net.minecraft.world.entity.projectile.AbstractArrow getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading @@ -897,7 +902,7 @@ index d657fd2c507a5b215aeab0a5f3e9c2ee892a27c8..9fc90b162aab15a9cd60b02aba563181 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 55ed79a802efa7a28cd487770a689119c64b7f40..73316307666674f9f6e7ddb964e2ec2583743c79 100644 +index 1cfe604573000fa9b32237313aa467875a891f3c..8c7e01972888df4ccbaccc4eebceeeb5ab357f4c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -491,7 +491,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @@ -1359,10 +1364,10 @@ index 8746f80d08df5501b32958eb123aa7d814573ddf..c6c6eb55f4649e18beef9832c2ea7b9d } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -index acbb64010cd59668aa1bcb52ff1220789cadb1d3..35958bb85389ca0ed02f567e0fd9f4a9dbc66ff2 100644 +index 7984365c8290ac9e526a413b56e1c8c0841e330c..0c468a1324996137eba5d1927d38a39859b705f0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -@@ -291,8 +291,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { +@@ -292,8 +292,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { this.mode = mode; } @@ -1590,10 +1595,10 @@ index e9f471e60af0725ec34e2985d63ae9ea9f88590a..6a443f42ecec16abea3ddf7bc2e85bb8 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -index 993844ee3d76591be38e8d27eba37ff8723443b1..ac46baf473a9cf366b9b1ab3d59e8ab7097bc656 100644 +index c4a166a0c226c6083c25c58145d9631d4296e615..ee1d3f33cf5f3cfc7909dbc33178df69bd656ab8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -@@ -454,6 +454,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { +@@ -470,6 +470,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { this.getHandle().invulnerableTime = ticks; } @@ -1607,7 +1612,7 @@ index 993844ee3d76591be38e8d27eba37ff8723443b1..ac46baf473a9cf366b9b1ab3d59e8ab7 @Override public int getNoActionTicks() { return this.getHandle().getNoActionTime(); -@@ -467,6 +474,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { +@@ -483,6 +490,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public net.minecraft.world.entity.LivingEntity getHandle() { @@ -2135,7 +2140,7 @@ index 2638c341bc02f201f7ab17fdebcdbdf3a7ec05bf..0f5c2d31a2dea13a46ba81e353393633 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 14a5eda367dd46fe7c9b5f76df80840f938c06ea..d2902fc7f3b7af59f181bd1e12435d946db7ad23 100644 +index 8db8ceb161557b9803c3bda80f3e57b8626191c3..b0a70287ff1fc9b3d5eba322d949aaf510b165d2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -580,7 +580,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -2147,7 +2152,7 @@ index 14a5eda367dd46fe7c9b5f76df80840f938c06ea..d2902fc7f3b7af59f181bd1e12435d94 final ServerGamePacketListenerImpl connection = this.getHandle().connection; if (connection != null) { connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message, cause); -@@ -2209,9 +2209,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2207,9 +2207,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this; } @@ -2165,7 +2170,7 @@ index 14a5eda367dd46fe7c9b5f76df80840f938c06ea..d2902fc7f3b7af59f181bd1e12435d94 } public void setHandle(final ServerPlayer entity) { -@@ -3266,7 +3273,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -3264,7 +3271,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { { if ( CraftPlayer.this.getHealth() <= 0 && CraftPlayer.this.isOnline() ) { diff --git a/patches/server/0007-Disable-mid-tick-task-execution.patch b/patches/server/0007-Disable-mid-tick-task-execution.patch index df63970..b1562a1 100644 --- a/patches/server/0007-Disable-mid-tick-task-execution.patch +++ b/patches/server/0007-Disable-mid-tick-task-execution.patch @@ -10,7 +10,7 @@ the impact from scaling the region threads, but is not a fix to the underlying issue. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 1e658114879ad9bdb679b9230ac3eab643375f8b..6b07179212ec0bdb6b68294c996b9dfee8fc81cb 100644 +index cf06989ad1ab55bf6836abe4cdeed2fff31ac93f..82b18aebb7c1472efdadc4b2e959fbdb3116fbe3 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1476,6 +1476,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop