diff --git a/build.gradle.kts b/build.gradle.kts index ac9387f3b..3ef73fe6f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,8 +3,7 @@ import io.papermc.paperweight.tasks.RebuildGitPatches plugins { java `maven-publish` - id("com.github.johnrengelman.shadow") version "8.1.1" apply false - id("io.papermc.paperweight.patcher") version "1.5.15" + id("io.papermc.paperweight.patcher") version "1.7.1" } val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" @@ -17,7 +16,7 @@ repositories { } dependencies { - remapper("net.fabricmc:tiny-remapper:0.10.1:fat") + remapper("net.fabricmc:tiny-remapper:0.10.2:fat") decompiler("org.vineflower:vineflower:1.10.1") paperclip("io.papermc:paperclip:3.0.3") } @@ -28,7 +27,7 @@ allprojects { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } } } @@ -36,7 +35,7 @@ allprojects { subprojects { tasks.withType { options.encoding = Charsets.UTF_8.name() - options.release.set(17) + options.release.set(21) } tasks.withType { options.encoding = Charsets.UTF_8.name() @@ -76,7 +75,6 @@ paperweight { tasks.generateDevelopmentBundle { apiCoordinates.set("dev.folia:folia-api") - mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi") libraryRepositories.addAll( "https://repo.maven.apache.org/maven2/", paperMavenPublicUrl, diff --git a/gradle.properties b/gradle.properties index 519e942f4..5ac4d33e9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ group=dev.folia +version=1.20.6-R0.1-SNAPSHOT +mcVersion=1.20.6 -version=1.20.4-R0.1-SNAPSHOT -mcVersion=1.20.4 -paperRef=7ac24a18940da12beb39a030113f6e459f348e2f +paperRef=d8d59e0cdeda3f7e9da337b6d489f306fc5e76c9 org.gradle.caching=true org.gradle.parallel=true diff --git a/patches/api/0002-Region-scheduler-API.patch b/patches/api/0002-Region-scheduler-API.patch index 0c50c05e2..51ee1d946 100644 --- a/patches/api/0002-Region-scheduler-API.patch +++ b/patches/api/0002-Region-scheduler-API.patch @@ -7,10 +7,10 @@ Add both a location based scheduler, an entity based scheduler, and a global region scheduler. diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -index fc2dae69165776d08274e34a69962cc70445f411..06149045a44148bf0af5f52952ff0092fe2c70cb 100644 +index 07a9c9e254188c251165ca84c8e961fccda01175..d42e586f6be226a9aaf344d49f7dd7dc7566005f 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -@@ -544,9 +544,9 @@ public final class SimplePluginManager implements PluginManager { +@@ -556,9 +556,9 @@ public final class SimplePluginManager implements PluginManager { } try { 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 497730282..a8baaee28 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 9a428153f34291bdc026a71f7e60e285b7794b0c..c37904d1aae749030620e1bbdb955e25c91ab1f8 100644 +index 71f1c361ebccbe83193c37ec3a90faa4085001c3..67c021f6d5d2afed92c7ceb4f511e3a43bbe2417 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -2879,6 +2879,14 @@ public final class Bukkit { +@@ -2902,6 +2902,14 @@ public final class Bukkit { return server.isOwnedByCurrentRegion(entity); } // Paper end - Folia region threading API @@ -30,10 +30,10 @@ index 9a428153f34291bdc026a71f7e60e285b7794b0c..c37904d1aae749030620e1bbdb955e25 @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 4ff1b38eb65f97344257204cf018f176f247ed36..15395ef52505087e7eef3b1a5981e787dcc16508 100644 +index c8595ffcfcbdd79794d464415287d46acef72b72..d4c5b06fe4be177442ef1abaf1b223c6c2845930 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2518,4 +2518,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2542,4 +2542,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 4a934a4ec..1a5591c1f 100644 --- a/patches/server/0001-Build-changes.patch +++ b/patches/server/0001-Build-changes.patch @@ -5,34 +5,38 @@ Subject: [PATCH] Build changes diff --git a/build.gradle.kts b/build.gradle.kts -index bcfe59b6efb628ee1e7f9d60667360d4d885fb6a..12f9f9d46c098c5c88058cb1f73ae39a7d1debd5 100644 +index 4998aff0b7cb084dcda15c6a18bbe45e99b6000a..eb2f9941b24af591f1e56339b97f5284a765cf81 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -13,8 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { +@@ -13,7 +13,7 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { val alsoShade: Configuration by configurations.creating dependencies { - implementation(project(":paper-api")) -- implementation(project(":paper-mojangapi")) -+ // Folia start -+ implementation(project(":folia-api")) -+ implementation("io.papermc.paper:paper-mojangapi:${project.version}") { -+ exclude("io.papermc.paper", "paper-api") -+ } -+ // Folia end ++ implementation(project(":folia-api")) // Folia // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -71,7 +75,7 @@ tasks.jar { +@@ -80,14 +80,14 @@ tasks.jar { + val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", - "Implementation-Title" to "CraftBukkit", -- "Implementation-Version" to "git-Paper-$implementationVersion", -+ "Implementation-Version" to "git-Folia-$implementationVersion", // Folia +- "Implementation-Title" to "Paper", ++ "Implementation-Title" to "Folia", // Folia + "Implementation-Version" to implementationVersion, "Implementation-Vendor" to date, // Paper - "Specification-Title" to "Bukkit", +- "Specification-Title" to "Paper", ++ "Specification-Title" to "Folia", // Folia "Specification-Version" to project.version, -@@ -150,7 +154,7 @@ fun TaskContainer.registerRunTask( + "Specification-Vendor" to "Paper Team", +- "Brand-Id" to "papermc:paper", +- "Brand-Name" to "Paper", ++ "Brand-Id" to "papermc:folia", // Folia ++ "Brand-Name" to "Folia", // Folia + "Build-Number" to (build ?: ""), + "Build-Time" to Instant.now().toString(), + "Git-Branch" to gitBranch, // Paper +@@ -144,7 +144,7 @@ fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit ): TaskProvider = register(name) { @@ -69,55 +73,43 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..cb60d58d4a7556dd896f31d0cd249f86 metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> { Map> map = new HashMap<>(); diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java -index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..e2f704c115fd6e00960bb56bb0779f1100c89c17 100644 +index 532306cacd52579cdf37e4aca25887b1ed3ba6a1..29bd788ae8bc61c1e62a4f84b9e259931a7041ce 100644 --- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java -@@ -31,8 +31,8 @@ public class PaperVersionFetcher implements VersionFetcher { - @Nonnull - @Override - public Component getVersionMessage(@Nonnull String serverVersion) { -- String[] parts = serverVersion.substring("git-Paper-".length()).split("[-\\s]"); -- final Component updateMessage = getUpdateStatusMessage("PaperMC/Paper", GITHUB_BRANCH_NAME, parts[0]); -+ String[] parts = serverVersion.substring("git-Folia-".length()).split("[-\\s]"); // Folia -+ final Component updateMessage = getUpdateStatusMessage("PaperMC/Folia", GITHUB_BRANCH_NAME, parts[0]); // Folia - final Component history = getHistory(); +@@ -49,7 +49,7 @@ public class PaperVersionFetcher implements VersionFetcher { + if (build.buildNumber().isEmpty() && build.gitCommit().isEmpty()) { + updateMessage = text("You are running a development version without access to version information", color(0xFF5300)); + } else { +- updateMessage = getUpdateStatusMessage("PaperMC/Paper", build); ++ updateMessage = getUpdateStatusMessage("PaperMC/Folia", build); // Folia + } + final @Nullable Component history = this.getHistory(); - return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage; -@@ -85,7 +85,7 @@ public class PaperVersionFetcher implements VersionFetcher { - if (siteApiVersion == null) { return -1; } +@@ -86,7 +86,7 @@ public class PaperVersionFetcher implements VersionFetcher { + private static int fetchDistanceFromSiteApi(final ServerBuildInfo build, final int jenkinsBuild) { try { - try (BufferedReader reader = Resources.asCharSource( -- new URL("https://api.papermc.io/v2/projects/paper/versions/" + siteApiVersion), -+ new URL("https://api.papermc.io/v2/projects/folia/versions/" + siteApiVersion), // Folia + try (final BufferedReader reader = Resources.asCharSource( +- URI.create("https://api.papermc.io/v2/projects/paper/versions/" + build.minecraftVersionId()).toURL(), ++ URI.create("https://api.papermc.io/v2/projects/folia/versions/" + build.minecraftVersionId()).toURL(), // Folia Charsets.UTF_8 ).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 2dc07e5ef249636e85ad9c78e3729e9e066a8fe8..6c42592bfaf85f23f7ff9966d7869aa0237f59c5 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 explosionDensityCache = new HashMap<>(64, 0.25f); ++ public final PathTypeCache pathTypesByPosCache = new PathTypeCache(); + + // not transient + public java.util.ArrayDeque redstoneUpdateInfos; @@ -8796,7 +8799,7 @@ index e08f4e39db4ee3fed62e37364d17dcc5c5683504..7e92e14cdb9f3d895550991b2ea154a6 } } diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java -index ee0331a6bc40cdde08d926fd8eb1dc642630c2e5..feea642338c7fdd96d9c4d2ea5564f1c3743195c 100644 +index ee8e9c0e3690e78f3cc621ddfca89ea4256d4803..c3271b6048cf61d7d4e5fa66c5f925c1c8c82ca6 100644 --- a/src/main/java/io/papermc/paper/util/CollisionUtil.java +++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java @@ -1623,7 +1623,7 @@ public final class CollisionUtil { @@ -8853,7 +8856,7 @@ index 413e4b6da027876dbbe8eb78f2568a440f431547..3a7dbcb9964723b8ed5e6b0a1ee42679 throw new RuntimeException(); } diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java -index e028353e0261310afc42ca0454b723d9f1ffc131..08d282400644be5949f28eb879b333cc221da2cc 100644 +index 1d6b3fe2ce240af4ede61588795456b046eee6c9..bb915f30997059f22c9002b1ddc1c3aecbf4e979 100644 --- a/src/main/java/io/papermc/paper/util/MCUtil.java +++ b/src/main/java/io/papermc/paper/util/MCUtil.java @@ -337,6 +337,7 @@ public final class MCUtil { @@ -9352,10 +9355,10 @@ index 0000000000000000000000000000000000000000..cf9b66afc1762dbe2c625f09f9e804ca + } +} diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java -index f341813e9713e39bfe142ca34b751de3d8efd25b..7793797dfae906e5181dff517a7d04c95e869a37 100644 +index 59d7e8a3d83d3ab7aa28606401bb129ccaeff240..164202089b4ad0ab832a444e818ffd39aa966e70 100644 --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java -@@ -68,7 +68,7 @@ public class CommandSourceStack implements ExecutionCommandSource(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper - Brigadier API @@ -9476,19 +9479,6 @@ index b7f338e982d0dcab99137ab6dc200b82ac6b7cba..4f25b35a037e6c697e5e345f38b94a8e } private void runSync(ServerPlayer player, Collection bukkit, RootCommandNode rootcommandnode) { -diff --git a/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java -index bc2e763a848b4bf7e9598ffe1ca2aa35a9af4677..9496464d1400009d523b84373e8b47fdc1085ce3 100644 ---- a/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java -+++ b/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java -@@ -32,7 +32,7 @@ public abstract class AbstractProjectileDispenseBehavior extends DefaultDispense - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ())); -- if (!DispenserBlock.eventFired) { -+ if (!DispenserBlock.eventFired.get()) { // Folia - region threading - worldserver.getCraftServer().getPluginManager().callEvent(event); - } - diff --git a/src/main/java/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java index 6df0db8b4cdab23494ea34236949ece4989110a3..2fd670d941bd575f99def28732ffee29f37a3182 100644 --- a/src/main/java/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java @@ -9516,10 +9506,10 @@ index f28705547a62da790f5df071400986aacba39367..4bbed8e057a32ce22d768392cebc2711 } diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6afcff8675f 100644 +index 5dab1e10303177e5a4d97a91ee46ede66f30ae35..2e701ff7dc2c04f77e2f003cae0416483b290217 100644 --- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -222,7 +222,7 @@ public interface DispenseItemBehavior { +@@ -114,7 +114,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -9528,7 +9518,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -281,7 +281,7 @@ public interface DispenseItemBehavior { +@@ -173,7 +173,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -9537,7 +9527,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -338,7 +338,7 @@ public interface DispenseItemBehavior { +@@ -228,7 +228,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) list.get(0).getBukkitEntity()); @@ -9546,7 +9536,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af world.getCraftServer().getPluginManager().callEvent(event); } -@@ -394,7 +394,7 @@ public interface DispenseItemBehavior { +@@ -284,7 +284,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorseabstract.getBukkitEntity()); @@ -9555,7 +9545,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af world.getCraftServer().getPluginManager().callEvent(event); } -@@ -468,7 +468,7 @@ public interface DispenseItemBehavior { +@@ -358,7 +358,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorsechestedabstract.getBukkitEntity()); @@ -9564,25 +9554,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af world.getCraftServer().getPluginManager().callEvent(event); } -@@ -507,7 +507,7 @@ public interface DispenseItemBehavior { - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(enumdirection.getStepX(), enumdirection.getStepY(), enumdirection.getStepZ())); -- if (!DispenserBlock.eventFired) { -+ if (!DispenserBlock.eventFired.get()) { // Folia - region threading - worldserver.getCraftServer().getPluginManager().callEvent(event); - } - -@@ -565,7 +565,7 @@ public interface DispenseItemBehavior { - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5)); -- if (!DispenserBlock.eventFired) { -+ if (!DispenserBlock.eventFired.get()) { // Folia - region threading - worldserver.getCraftServer().getPluginManager().callEvent(event); - } - -@@ -645,7 +645,7 @@ public interface DispenseItemBehavior { +@@ -430,7 +430,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); @@ -9591,7 +9563,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -722,7 +722,7 @@ public interface DispenseItemBehavior { +@@ -506,7 +506,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -9600,7 +9572,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -769,7 +769,7 @@ public interface DispenseItemBehavior { +@@ -553,7 +553,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack); // Paper - ignore stack size on damageable items BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -9609,7 +9581,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -830,7 +830,7 @@ public interface DispenseItemBehavior { +@@ -616,7 +616,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -9618,7 +9590,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -848,7 +848,8 @@ public interface DispenseItemBehavior { +@@ -634,7 +634,8 @@ public interface DispenseItemBehavior { } } @@ -9628,8 +9600,8 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af // CraftBukkit end if (!BoneMealItem.growCrop(stack, worldserver, blockposition) && !BoneMealItem.growWaterPlant(stack, worldserver, blockposition, (Direction) null)) { -@@ -857,13 +858,13 @@ public interface DispenseItemBehavior { - worldserver.levelEvent(1505, blockposition, 0); +@@ -643,13 +644,13 @@ public interface DispenseItemBehavior { + worldserver.levelEvent(1505, blockposition, 15); } // CraftBukkit start - worldserver.captureTreeGeneration = false; @@ -9648,7 +9620,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af StructureGrowEvent structureEvent = null; if (treeType != null) { structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks); -@@ -899,7 +900,7 @@ public interface DispenseItemBehavior { +@@ -685,7 +686,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D)); @@ -9657,7 +9629,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -956,7 +957,7 @@ public interface DispenseItemBehavior { +@@ -742,7 +743,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -9666,7 +9638,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -1005,7 +1006,7 @@ public interface DispenseItemBehavior { +@@ -791,7 +792,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -9675,7 +9647,7 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -1078,7 +1079,7 @@ public interface DispenseItemBehavior { +@@ -864,7 +865,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - only single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -9684,11 +9656,33 @@ index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6af worldserver.getCraftServer().getPluginManager().callEvent(event); } +@@ -946,7 +947,7 @@ public interface DispenseItemBehavior { + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) list.get(0).getBukkitEntity()); +- if (!DispenserBlock.eventFired) { ++ if (!DispenserBlock.eventFired.get()) { // Folia - region threading + world.getCraftServer().getPluginManager().callEvent(event); + } + +diff --git a/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java +index e37d2d29f3ba67cfe28abe4847a3dca07121f0be..067f888fdaeced3350c858e2b825a3841b539193 100644 +--- a/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java ++++ b/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java +@@ -45,7 +45,7 @@ public class ProjectileDispenseBehavior extends DefaultDispenseItemBehavior { + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ())); +- if (!DispenserBlock.eventFired) { ++ if (!DispenserBlock.eventFired.get()) { // Folia - region threading + worldserver.getCraftServer().getPluginManager().callEvent(event); + } + diff --git a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java -index 8d65cdb013706a932c2c73231108b2810b99e1c7..728e2f00de43b5363fdee2d982acab2614e45bcb 100644 +index a024c697a65bbab27408da1d6a75e531d9719b47..bd8c333e91dff03196ec9e5730225cb37ab83da4 100644 --- a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java -@@ -40,7 +40,7 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior { +@@ -41,7 +41,7 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack); // Paper - ignore stack size on damageable items BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -9711,19 +9705,19 @@ index cb308808906a8cdb127df8284e106e00553473ca..05bc1f010b50e673e9a185d96e338bae } diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508f88a0376 100644 +index 02833deaa2bb7e5abc655bc1bdbe15c4b3ac7119..f38ffc4fbde0f25578ebcc4ec3bf0afe079a10c8 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -84,7 +84,7 @@ public class Connection extends SimpleChannelInboundHandler> { - return new DefaultEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper - }); +@@ -93,7 +93,7 @@ public class Connection extends SimpleChannelInboundHandler> { + private static final ProtocolInfo INITIAL_PROTOCOL = HandshakeProtocols.SERVERBOUND; private final PacketFlow receiving; -- private final Queue pendingActions = Queues.newConcurrentLinkedQueue(); -+ private final Queue pendingActions = new ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue<>(); // Folia - region threading - connection fixes + private volatile boolean sendLoginDisconnect = true; +- private final Queue pendingActions = Queues.newConcurrentLinkedQueue(); // Paper ++ private final Queue pendingActions = new ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue<>(); // Paper // Folia - region threading - connection fixes public Channel channel; public SocketAddress address; // Spigot Start -@@ -99,7 +99,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -108,7 +108,7 @@ public class Connection extends SimpleChannelInboundHandler> { @Nullable private Component disconnectedReason; private boolean encrypted; @@ -9732,7 +9726,7 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 private int receivedPackets; private int sentPackets; private float averageReceivedPackets; -@@ -153,6 +153,32 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -163,6 +163,32 @@ public class Connection extends SimpleChannelInboundHandler> { this.receiving = side; } @@ -9765,7 +9759,7 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception { super.channelActive(channelhandlercontext); this.channel = channelhandlercontext.channel(); -@@ -163,7 +189,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -173,7 +199,7 @@ public class Connection extends SimpleChannelInboundHandler> { if (this.delayedDisconnect != null) { this.disconnect(this.delayedDisconnect); } @@ -9773,8 +9767,8 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 + this.becomeActive = true; // Folia - region threading } - public static void setInitialProtocolAttributes(Channel channel) { -@@ -387,7 +413,7 @@ public class Connection extends SimpleChannelInboundHandler> { + public void channelInactive(ChannelHandlerContext channelhandlercontext) { +@@ -442,7 +468,7 @@ public class Connection extends SimpleChannelInboundHandler> { } packet.onPacketDispatch(this.getPlayer()); @@ -9783,7 +9777,7 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 || (io.papermc.paper.util.MCUtil.isMainThread() && packet.isReady() && this.pendingActions.isEmpty() && (packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty())))) { this.sendPacket(packet, callbacks, flush); -@@ -416,11 +442,12 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -471,11 +497,12 @@ public class Connection extends SimpleChannelInboundHandler> { } public void runOnceConnected(Consumer task) { @@ -9797,7 +9791,7 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 } } -@@ -479,10 +506,11 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -534,10 +561,11 @@ public class Connection extends SimpleChannelInboundHandler> { } public void flushChannel() { @@ -9810,7 +9804,7 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 } } -@@ -517,53 +545,61 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -555,53 +583,61 @@ public class Connection extends SimpleChannelInboundHandler> { // Paper start - Optimize network: Rewrite this to be safer if ran off main thread private boolean flushQueue() { @@ -9827,8 +9821,8 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 - } - return false; + return this.processQueue(); // Folia - region threading - connection fixes -+ } -+ + } + + // Folia start - region threading - connection fixes + // allow only one thread to be flushing the queue at once to ensure packets are written in the order they are sent + // into the queue @@ -9836,8 +9830,8 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 + + private static boolean canWrite(WrappedConsumer queued) { + return queued != null && (!(queued instanceof PacketSendAction packet) || packet.packet.isReady()); - } - ++ } ++ + private boolean canWritePackets() { + return canWrite(this.pendingActions.peek()); + } @@ -9906,7 +9900,7 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 } // Paper end - Optimize network -@@ -572,21 +608,41 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -610,19 +646,39 @@ public class Connection extends SimpleChannelInboundHandler> { private static int currTick; // Paper - Buffer joins to world public void tick() { this.flushQueue(); @@ -9945,9 +9939,7 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 + // Folia end - region threading PacketListener packetlistener = this.packetListener; - if (packetlistener instanceof TickablePacketListener) { - TickablePacketListener tickablepacketlistener = (TickablePacketListener) packetlistener; - + if (packetlistener instanceof TickablePacketListener tickablepacketlistener) { // Paper start - Buffer joins to world - if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener) - || loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.VERIFYING @@ -9955,9 +9947,9 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 + if (true) { // Folia - region threading // Paper start - detailed watchdog information net.minecraft.network.protocol.PacketUtils.packetProcessing.push(this.packetListener); - try { // Paper end - detailed watchdog information -@@ -598,7 +654,7 @@ public class Connection extends SimpleChannelInboundHandler> { - // Paper end - Buffer joins to world + try { +@@ -633,7 +689,7 @@ public class Connection extends SimpleChannelInboundHandler> { + } // Paper end - Buffer joins to world } - if (!this.isConnected() && !this.disconnectionHandled) { @@ -9965,7 +9957,7 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 this.handleDisconnection(); } -@@ -644,6 +700,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -679,6 +735,7 @@ public class Connection extends SimpleChannelInboundHandler> { this.channel.close(); // We can't wait as this may be called from an event loop. this.disconnectedReason = disconnectReason; } @@ -9973,7 +9965,7 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 } -@@ -823,10 +880,10 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -874,10 +931,10 @@ public class Connection extends SimpleChannelInboundHandler> { public void handleDisconnection() { if (this.channel != null && !this.channel.isOpen()) { @@ -9986,7 +9978,7 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 PacketListener packetlistener = this.getPacketListener(); PacketListener packetlistener1 = packetlistener != null ? packetlistener : this.disconnectListener; -@@ -858,6 +915,22 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -909,6 +966,22 @@ public class Connection extends SimpleChannelInboundHandler> { } } // Paper end - Add PlayerConnectionCloseEvent @@ -10009,7 +10001,7 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 } } -@@ -878,15 +951,25 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -929,15 +1002,25 @@ public class Connection extends SimpleChannelInboundHandler> { // Paper start - Optimize network public void clearPacketQueue() { final net.minecraft.server.level.ServerPlayer player = getPlayer(); @@ -10042,10 +10034,10 @@ index a536ebcf29d8ef0ed32863bd8d5e70f7a0636e8d..936f8663b23908ac5de2076401a5d508 private static class InnerUtil { // Attempt to hide these methods from ProtocolLib, so it doesn't accidently pick them up. diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -index 83302c252f54481f239522e5c6861ccfe233070a..1192503d2729b3f14aa2936c2060df9884870cb4 100644 +index 57e76b53e5e314c3e6b8856010f7a84188121582..9f07a1a5e2c082d16de068de6f47bf8fb06ba99a 100644 --- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java +++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -@@ -44,7 +44,7 @@ public class PacketUtils { +@@ -45,7 +45,7 @@ public class PacketUtils { public static void ensureRunningOnSameThread(Packet packet, T listener, BlockableEventLoop engine) throws RunningOnDifferentThreadException { if (!engine.isSameThread()) { @@ -10054,7 +10046,7 @@ index 83302c252f54481f239522e5c6861ccfe233070a..1192503d2729b3f14aa2936c2060df98 packetProcessing.push(listener); // Paper - detailed watchdog information try { // Paper - detailed watchdog information if (listener instanceof ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // CraftBukkit - Don't handle sync packets for kicked players -@@ -91,7 +91,21 @@ public class PacketUtils { +@@ -74,7 +74,21 @@ public class PacketUtils { } // Paper end - detailed watchdog information @@ -10078,10 +10070,10 @@ index 83302c252f54481f239522e5c6861ccfe233070a..1192503d2729b3f14aa2936c2060df98 } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 6c42592bfaf85f23f7ff9966d7869aa0237f59c5..4e94de4a3184fd36119bf39beccff62ac561c1e4 100644 +index dbc86b8d4d2af6e5f7e678f2bb77fd39b85c04c5..cd63ccf69ce701079d780afaff0d784ec0e4f535 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 processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); public int autosavePeriod; - public Commands vanillaCommandDispatcher; -@@ -306,13 +305,41 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop S spin(Function serverFactory) { AtomicReference atomicreference = new AtomicReference(); Thread thread = new io.papermc.paper.util.TickThread(() -> { // Paper - rewrite chunk system -@@ -348,7 +375,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 ? Mth.square(ChunkProgressListener.calculateDiameter(i)) : 0; + +- while (chunkproviderserver.getTickingGenerated() < j) { +- // CraftBukkit start +- // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS; +- this.executeModerately(); +- } ++ // Folia - region threading // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS; - this.executeModerately(); + //this.executeModerately(); // Folia - region threading // Iterator iterator = this.levels.values().iterator(); - } // Paper - Configurable Keep Spawn Loaded range per world -@@ -837,7 +880,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { - return worldserver + " " + worldserver.dimension().location(); -@@ -1721,7 +1800,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop attribute) { diff --git a/src/main/java/net/minecraft/server/commands/ClearInventoryCommands.java b/src/main/java/net/minecraft/server/commands/ClearInventoryCommands.java -index 64ea52a5402f252165a5d8bf4fbd4ec257e7558e..af49f41e9a4e07e32c5de8edad4d2be7c9b19088 100644 +index 4e6171ca870649114d4c7460baad2982173da09e..f8f0d33c663e6b9adac9f7e3eb21b5a6ff860c5d 100644 --- a/src/main/java/net/minecraft/server/commands/ClearInventoryCommands.java +++ b/src/main/java/net/minecraft/server/commands/ClearInventoryCommands.java -@@ -62,9 +62,14 @@ public class ClearInventoryCommands { +@@ -65,9 +65,14 @@ public class ClearInventoryCommands { int i = 0; for (ServerPlayer serverPlayer : targets) { @@ -11152,12 +11154,12 @@ index a046a0b1519806ff3d987e6402f152b60a3a6f4c..60649ced046fa126ef59b7a2dc3e6b5e } } diff --git a/src/main/java/net/minecraft/server/commands/EffectCommands.java b/src/main/java/net/minecraft/server/commands/EffectCommands.java -index ebe50e2e69d346ce9266ed3f180d91ceb58008bd..227acbe74ff009c9275542af734852e3044b111b 100644 +index ed6336065a0061af095d3395b927b8976443cb68..5a6f53cfaded2df14a82ee7639cdd0bb4728012e 100644 --- a/src/main/java/net/minecraft/server/commands/EffectCommands.java +++ b/src/main/java/net/minecraft/server/commands/EffectCommands.java @@ -84,7 +84,15 @@ public class EffectCommands { if (entity instanceof LivingEntity) { - MobEffectInstance mobeffect = new MobEffectInstance(mobeffectlist, k, amplifier, false, showParticles); + MobEffectInstance mobeffect = new MobEffectInstance(statusEffect, k, amplifier, false, showParticles); - if (((LivingEntity) entity).addEffect(mobeffect, source.getEntity(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit + // Folia start - region threading @@ -11194,7 +11196,7 @@ index ebe50e2e69d346ce9266ed3f180d91ceb58008bd..227acbe74ff009c9275542af734852e3 while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); -- if (entity instanceof LivingEntity && ((LivingEntity) entity).removeEffect(mobeffectlist, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit +- if (entity instanceof LivingEntity && ((LivingEntity) entity).removeEffect(statusEffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit + if (entity instanceof LivingEntity) { // CraftBukkit // Folia - region threading ++i; + // Folia start - region threading @@ -11202,14 +11204,14 @@ index ebe50e2e69d346ce9266ed3f180d91ceb58008bd..227acbe74ff009c9275542af734852e3 + if (!(nmsEntity instanceof LivingEntity)) { + return; + } -+ ((LivingEntity) nmsEntity).removeEffect(mobeffectlist, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND); ++ ((LivingEntity) nmsEntity).removeEffect(statusEffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND); + }, null, 1L); + // Folia end - region threading } } diff --git a/src/main/java/net/minecraft/server/commands/EnchantCommand.java b/src/main/java/net/minecraft/server/commands/EnchantCommand.java -index 15bfe2e58d16864af29b04c17181ebf45fa21eba..3844b593c918a1f41c48acd1a3231eb43b483e41 100644 +index 84f1ba6275f04624f46ccd772924b5e075e7b205..1c489bab7d0422473e104d558f686a2024f1abbb 100644 --- a/src/main/java/net/minecraft/server/commands/EnchantCommand.java +++ b/src/main/java/net/minecraft/server/commands/EnchantCommand.java @@ -68,49 +68,76 @@ public class EnchantCommand { @@ -11238,7 +11240,7 @@ index 15bfe2e58d16864af29b04c17181ebf45fa21eba..3844b593c918a1f41c48acd1a3231eb4 - ItemStack itemStack = livingEntity.getMainHandItem(); - if (!itemStack.isEmpty()) { - if (enchantment2.canEnchant(itemStack) -- && EnchantmentHelper.isEnchantmentCompatible(EnchantmentHelper.getEnchantments(itemStack).keySet(), enchantment2)) { +- && EnchantmentHelper.isEnchantmentCompatible(EnchantmentHelper.getEnchantmentsForCrafting(itemStack).keySet(), enchantment2)) { - itemStack.enchant(enchantment2, level); - i++; - } else if (targets.size() == 1) { @@ -11250,7 +11252,7 @@ index 15bfe2e58d16864af29b04c17181ebf45fa21eba..3844b593c918a1f41c48acd1a3231eb4 + ItemStack itemStack = livingEntity.getMainHandItem(); + if (!itemStack.isEmpty()) { + if (enchantment2.canEnchant(itemStack) -+ && EnchantmentHelper.isEnchantmentCompatible(EnchantmentHelper.getEnchantments(itemStack).keySet(), enchantment2)) { ++ && EnchantmentHelper.isEnchantmentCompatible(EnchantmentHelper.getEnchantmentsForCrafting(itemStack).keySet(), enchantment2)) { + itemStack.enchant(enchantment2, level); + possibleSingleDisplayName.set(livingEntity.getDisplayName()); + changed.incrementAndGet(); @@ -11309,7 +11311,7 @@ index 15bfe2e58d16864af29b04c17181ebf45fa21eba..3844b593c918a1f41c48acd1a3231eb4 + // Folia end - region threading } diff --git a/src/main/java/net/minecraft/server/commands/ExperienceCommand.java b/src/main/java/net/minecraft/server/commands/ExperienceCommand.java -index 337c2fe92a2727d3b0b9a0387c2ccaa2cbd48e9f..a795b750118845720b6aa101ab1e2f8ee37a91ed 100644 +index 775eb9fd56c2d0eafcfb04ab97ddb270ba3faca9..a5a69f87fe9d35c489a57d4d93e9ad54ed458d30 100644 --- a/src/main/java/net/minecraft/server/commands/ExperienceCommand.java +++ b/src/main/java/net/minecraft/server/commands/ExperienceCommand.java @@ -131,14 +131,18 @@ public class ExperienceCommand { @@ -11350,7 +11352,7 @@ index 337c2fe92a2727d3b0b9a0387c2ccaa2cbd48e9f..a795b750118845720b6aa101ab1e2f8e if (i == 0) { diff --git a/src/main/java/net/minecraft/server/commands/FillBiomeCommand.java b/src/main/java/net/minecraft/server/commands/FillBiomeCommand.java -index 6fbb6d215cffe12b8476eca1497698fdd5ac4111..d9056196b99ada4186e6642e0860727abd237a36 100644 +index c5bba5ce879b336b43e742eaa21d661dcee379aa..a1a3afd2c65d71ca6f5ad8828097402cbc353461 100644 --- a/src/main/java/net/minecraft/server/commands/FillBiomeCommand.java +++ b/src/main/java/net/minecraft/server/commands/FillBiomeCommand.java @@ -106,6 +106,16 @@ public class FillBiomeCommand { @@ -11381,7 +11383,7 @@ index 6fbb6d215cffe12b8476eca1497698fdd5ac4111..d9056196b99ada4186e6642e0860727a + (boundingBox.maxX() + buffer) >> 4, + (boundingBox.minZ() - buffer) >> 4, + (boundingBox.maxZ() + buffer) >> 4, -+ net.minecraft.world.level.chunk.ChunkStatus.FULL, ++ net.minecraft.world.level.chunk.status.ChunkStatus.FULL, + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, + (chunks) -> { + sendMessage(feedbackConsumer, () -> { @@ -11401,7 +11403,7 @@ index 6fbb6d215cffe12b8476eca1497698fdd5ac4111..d9056196b99ada4186e6642e0860727a } diff --git a/src/main/java/net/minecraft/server/commands/FillCommand.java b/src/main/java/net/minecraft/server/commands/FillCommand.java -index 4f61284c0d4ad6cd1b485956f5185552fd7800f8..67c313dedf354b09bb782d60e70673e08f17e03d 100644 +index 0509e28f79d13615b5baefc34799b0ad2df071be..95bb9d341ff28d37934ceba4ef07c95211cf578a 100644 --- a/src/main/java/net/minecraft/server/commands/FillCommand.java +++ b/src/main/java/net/minecraft/server/commands/FillCommand.java @@ -151,6 +151,12 @@ public class FillCommand { @@ -11429,7 +11431,7 @@ index 4f61284c0d4ad6cd1b485956f5185552fd7800f8..67c313dedf354b09bb782d60e70673e0 + (range.maxX() + buffer) >> 4, + (range.minZ() - buffer) >> 4, + (range.maxZ() + buffer) >> 4, -+ net.minecraft.world.level.chunk.ChunkStatus.FULL, ++ net.minecraft.world.level.chunk.status.ChunkStatus.FULL, + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, + (chunks) -> { + try { // Folia end - region threading @@ -11452,7 +11454,7 @@ index 4f61284c0d4ad6cd1b485956f5185552fd7800f8..67c313dedf354b09bb782d60e70673e0 } diff --git a/src/main/java/net/minecraft/server/commands/ForceLoadCommand.java b/src/main/java/net/minecraft/server/commands/ForceLoadCommand.java -index 2e6d55f5582310038db10ace47bc10e171359634..fdd27cbc02ac58c2a2d85c0db00fa347073e915f 100644 +index 255211f47a1678f714b1e04b31298976ada8a781..87275b46c4411fd51d6572ec7b3f924e347d4ed7 100644 --- a/src/main/java/net/minecraft/server/commands/ForceLoadCommand.java +++ b/src/main/java/net/minecraft/server/commands/ForceLoadCommand.java @@ -97,7 +97,17 @@ public class ForceLoadCommand { @@ -11526,11 +11528,11 @@ index 2e6d55f5582310038db10ace47bc10e171359634..fdd27cbc02ac58c2a2d85c0db00fa347 int i = Math.min(from.x(), to.x()); int j = Math.min(from.z(), to.z()); int k = Math.max(from.x(), to.x()); -@@ -206,11 +231,18 @@ public class ForceLoadCommand { +@@ -207,11 +232,18 @@ public class ForceLoadCommand { ); } -- return r; +- return u; + return; // Folia - region threading } } @@ -11571,10 +11573,10 @@ index d1da3600dc07107309b20ebe6e7c0c4da0e8de76..a2075133b0e8ea6299dec0fa5125e429 return i; diff --git a/src/main/java/net/minecraft/server/commands/GiveCommand.java b/src/main/java/net/minecraft/server/commands/GiveCommand.java -index 1b459a8ee8a6bc039e742d65796bc76660a1c765..4efd0b529ee0431fb4dc76a950ab8f98856f622b 100644 +index 47355158e5e762540a10dc67b23092a0fc53bce3..b450b4f876d8f18a9f51ef0c594d4471e0d5a6c4 100644 --- a/src/main/java/net/minecraft/server/commands/GiveCommand.java +++ b/src/main/java/net/minecraft/server/commands/GiveCommand.java -@@ -56,6 +56,7 @@ public class GiveCommand { +@@ -89,6 +89,7 @@ public class GiveCommand { l -= i1; ItemStack itemstack1 = item.createItemStack(i1, false); @@ -11582,7 +11584,7 @@ index 1b459a8ee8a6bc039e742d65796bc76660a1c765..4efd0b529ee0431fb4dc76a950ab8f98 boolean flag = entityplayer.getInventory().add(itemstack1); ItemEntity entityitem; -@@ -75,6 +76,7 @@ public class GiveCommand { +@@ -107,6 +108,7 @@ public class GiveCommand { entityitem.setTarget(entityplayer.getUUID()); } } @@ -11606,7 +11608,7 @@ index c2974a6bd6851b54d1df2689195d896baf4906ee..57f5c571e63355b0e32480f31b9e5c81 if (targets.size() == 1) { diff --git a/src/main/java/net/minecraft/server/commands/PlaceCommand.java b/src/main/java/net/minecraft/server/commands/PlaceCommand.java -index a78ac2c2a536abb0a77371c3d8a9ce0dc5084c38..4f0c962231562c13be8980f98a7d801ab292ab38 100644 +index 00fe31a486121eabd6c1e6fc85b94ecede8a609e..212b4e7a0b1ea796fe3a2e11808e4abd09d466a8 100644 --- a/src/main/java/net/minecraft/server/commands/PlaceCommand.java +++ b/src/main/java/net/minecraft/server/commands/PlaceCommand.java @@ -88,12 +88,25 @@ public class PlaceCommand { @@ -11627,7 +11629,7 @@ index a78ac2c2a536abb0a77371c3d8a9ce0dc5084c38..4f0c962231562c13be8980f98a7d801a PlaceCommand.checkLoaded(worldserver, new ChunkPos(chunkcoordintpair.x - 1, chunkcoordintpair.z - 1), new ChunkPos(chunkcoordintpair.x + 1, chunkcoordintpair.z + 1)); + // Folia start - region threading + worldserver.loadChunksAsync( -+ pos, 16, net.minecraft.world.level.chunk.ChunkStatus.FULL, ++ pos, 16, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, + (chunks) -> { + try { @@ -11635,7 +11637,7 @@ index a78ac2c2a536abb0a77371c3d8a9ce0dc5084c38..4f0c962231562c13be8980f98a7d801a if (!worldgenfeatureconfigured.place(worldserver, worldserver.getChunkSource().getGenerator(), worldserver.getRandom(), pos)) { throw PlaceCommand.ERROR_FEATURE_FAILED.create(); } else { -@@ -102,27 +115,57 @@ public class PlaceCommand { +@@ -102,8 +115,16 @@ public class PlaceCommand { source.sendSuccess(() -> { return Component.translatable("commands.place.feature.success", s, pos.getX(), pos.getY(), pos.getZ()); }, true); @@ -11653,11 +11655,13 @@ index a78ac2c2a536abb0a77371c3d8a9ce0dc5084c38..4f0c962231562c13be8980f98a7d801a } public static int placeJigsaw(CommandSourceStack source, Holder structurePool, ResourceLocation id, int maxDepth, BlockPos pos) throws CommandSyntaxException { - ServerLevel worldserver = source.getLevel(); +@@ -111,20 +132,42 @@ public class PlaceCommand { + ChunkPos chunkcoordintpair = new ChunkPos(pos); + PlaceCommand.checkLoaded(worldserver, chunkcoordintpair, chunkcoordintpair); + // Folia start - region threading + worldserver.loadChunksAsync( -+ pos, 16, net.minecraft.world.level.chunk.ChunkStatus.FULL, ++ pos, 16, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, + (chunks) -> { + try { @@ -11687,7 +11691,7 @@ index a78ac2c2a536abb0a77371c3d8a9ce0dc5084c38..4f0c962231562c13be8980f98a7d801a ChunkGenerator chunkgenerator = worldserver.getChunkSource().getGenerator(); + // Folia start - region threading + worldserver.loadChunksAsync( -+ pos, 16, net.minecraft.world.level.chunk.ChunkStatus.FULL, ++ pos, 16, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, + (chunks) -> { + try { @@ -11695,7 +11699,7 @@ index a78ac2c2a536abb0a77371c3d8a9ce0dc5084c38..4f0c962231562c13be8980f98a7d801a StructureStart structurestart = structure1.generate(source.registryAccess(), chunkgenerator, chunkgenerator.getBiomeSource(), worldserver.getChunkSource().randomState(), worldserver.getStructureManager(), worldserver.getSeed(), new ChunkPos(pos), 0, worldserver, (holder) -> { return true; }); -@@ -144,12 +187,27 @@ public class PlaceCommand { +@@ -146,12 +189,27 @@ public class PlaceCommand { source.sendSuccess(() -> { return Component.translatable("commands.place.structure.success", s, pos.getX(), pos.getY(), pos.getZ()); }, true); @@ -11716,7 +11720,7 @@ index a78ac2c2a536abb0a77371c3d8a9ce0dc5084c38..4f0c962231562c13be8980f98a7d801a ServerLevel worldserver = source.getLevel(); + // Folia start - region threading + worldserver.loadChunksAsync( -+ pos, 16, net.minecraft.world.level.chunk.ChunkStatus.FULL, ++ pos, 16, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, + (chunks) -> { + try { @@ -11724,7 +11728,7 @@ index a78ac2c2a536abb0a77371c3d8a9ce0dc5084c38..4f0c962231562c13be8980f98a7d801a StructureTemplateManager structuretemplatemanager = worldserver.getStructureManager(); Optional optional; -@@ -180,9 +238,17 @@ public class PlaceCommand { +@@ -182,9 +240,17 @@ public class PlaceCommand { source.sendSuccess(() -> { return Component.translatable("commands.place.template.success", Component.translationArg(id), pos.getX(), pos.getY(), pos.getZ()); }, true); @@ -11837,7 +11841,7 @@ index 15db9368227dbc29d07d74e85bd126b345b526b6..161ae9c5f9ff0e8cdf3bb3c6bb1d0686 } // Paper end - Add PlayerSetSpawnEvent diff --git a/src/main/java/net/minecraft/server/commands/SummonCommand.java b/src/main/java/net/minecraft/server/commands/SummonCommand.java -index e2b44b8ddb8afc6e1f7dddadb434c2268f284809..c2980f5bd826e3fb91fd19b3b0889034f3389976 100644 +index 798999be50d26be357ef3c6d5b9383ce4d1048c1..af9b3ea74379d52f2ff08cb81e87a0a61062097a 100644 --- a/src/main/java/net/minecraft/server/commands/SummonCommand.java +++ b/src/main/java/net/minecraft/server/commands/SummonCommand.java @@ -64,11 +64,18 @@ public class SummonCommand { @@ -11845,13 +11849,13 @@ index e2b44b8ddb8afc6e1f7dddadb434c2268f284809..c2980f5bd826e3fb91fd19b3b0889034 throw SummonCommand.ERROR_FAILED.create(); } else { - if (initialize && entity instanceof Mob) { -- ((Mob) entity).finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.COMMAND, (SpawnGroupData) null, (CompoundTag) null); +- ((Mob) entity).finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.COMMAND, (SpawnGroupData) null); - } + // Folia start - region threading + io.papermc.paper.threadedregions.RegionizedServer.getInstance().taskQueue.queueTickTaskQueue( + worldserver, entity.chunkPosition().x, entity.chunkPosition().z, () -> { + if (initialize && entity instanceof Mob) { -+ ((Mob) entity).finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.COMMAND, (SpawnGroupData) null, (CompoundTag) null); ++ ((Mob) entity).finalizeSpawn(source.getLevel(), source.getLevel().getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.COMMAND, (SpawnGroupData) null); + } + worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND); + } @@ -11864,7 +11868,7 @@ index e2b44b8ddb8afc6e1f7dddadb434c2268f284809..c2980f5bd826e3fb91fd19b3b0889034 } else { return entity; diff --git a/src/main/java/net/minecraft/server/commands/TeleportCommand.java b/src/main/java/net/minecraft/server/commands/TeleportCommand.java -index 2ddd033e1c3a2e5c8950b93c838491923803ccce..2450885ef59ad32fbfadfe03f95f9ba24b8a6886 100644 +index 54851f6cc0d5fddb32a9a1e84a4f5ae41af18758..4a13ac9f5342a1b8dc155431eb33f045f87c9196 100644 --- a/src/main/java/net/minecraft/server/commands/TeleportCommand.java +++ b/src/main/java/net/minecraft/server/commands/TeleportCommand.java @@ -77,7 +77,7 @@ public class TeleportCommand { @@ -11948,7 +11952,7 @@ index 44fcd43a466fb47d31ab05e44bafbef3c4cae63f..2989750a75b3dd244cf8f9ca78769308 } } diff --git a/src/main/java/net/minecraft/server/commands/WeatherCommand.java b/src/main/java/net/minecraft/server/commands/WeatherCommand.java -index 3100dcd0bbba9e109c26f5932c648cd2bab212d7..e17fcbe35cb7293ac72d49c1fa659e70dc0b38ff 100644 +index fc6e88aacdd5b508678d0c229be2e86db8128ecd..203e7a2a1cc235cbfdb0d794191c27683d4ba5a7 100644 --- a/src/main/java/net/minecraft/server/commands/WeatherCommand.java +++ b/src/main/java/net/minecraft/server/commands/WeatherCommand.java @@ -48,20 +48,26 @@ public class WeatherCommand { @@ -11956,7 +11960,7 @@ index 3100dcd0bbba9e109c26f5932c648cd2bab212d7..e17fcbe35cb7293ac72d49c1fa659e70 private static int setClear(CommandSourceStack source, int duration) { + io.papermc.paper.threadedregions.RegionizedServer.getInstance().addTask(() -> { // Folia - region threading - source.getLevel().setWeatherParameters(getDuration(source, duration, ServerLevel.RAIN_DELAY), 0, false, false); + source.getServer().overworld().setWeatherParameters(getDuration(source, duration, ServerLevel.RAIN_DELAY), 0, false, false); source.sendSuccess(() -> Component.translatable("commands.weather.set.clear"), true); + }); // Folia - region threading return duration; @@ -11964,7 +11968,7 @@ index 3100dcd0bbba9e109c26f5932c648cd2bab212d7..e17fcbe35cb7293ac72d49c1fa659e70 private static int setRain(CommandSourceStack source, int duration) { + io.papermc.paper.threadedregions.RegionizedServer.getInstance().addTask(() -> { // Folia - region threading - source.getLevel().setWeatherParameters(0, getDuration(source, duration, ServerLevel.RAIN_DURATION), true, false); + source.getServer().overworld().setWeatherParameters(0, getDuration(source, duration, ServerLevel.RAIN_DURATION), true, false); source.sendSuccess(() -> Component.translatable("commands.weather.set.rain"), true); + }); // Folia - region threading return duration; @@ -11972,7 +11976,7 @@ index 3100dcd0bbba9e109c26f5932c648cd2bab212d7..e17fcbe35cb7293ac72d49c1fa659e70 private static int setThunder(CommandSourceStack source, int duration) { + io.papermc.paper.threadedregions.RegionizedServer.getInstance().addTask(() -> { // Folia - region threading - source.getLevel().setWeatherParameters(0, getDuration(source, duration, ServerLevel.THUNDER_DURATION), true, true); + source.getServer().overworld().setWeatherParameters(0, getDuration(source, duration, ServerLevel.THUNDER_DURATION), true, true); source.sendSuccess(() -> Component.translatable("commands.weather.set.thunder"), true); + }); // Folia - region threading return duration; @@ -12156,10 +12160,10 @@ index 812f2adc6fc20aa126e629284fe594a923b24540..0a5e6961fb37e9a53cd39b1bd233e020 } } diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 68d268b6fff126e8645b6deec3fb549ea2286b77..6b3242117d62175de462d04e4d178b49ae2521e9 100644 +index 2eb9c584cc77237f1c82d880a51a3f8b51008d73..bd333ffb44798069e180cad67c07d86425253024 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -443,9 +443,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -463,9 +463,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } @Override @@ -12172,7 +12176,7 @@ index 68d268b6fff126e8645b6deec3fb549ea2286b77..6b3242117d62175de462d04e4d178b49 } @Override -@@ -767,7 +767,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -787,7 +787,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface Waitable[] waitableArray = new Waitable[1]; // Paper rconConsoleSource.prepareForCommand(); final java.util.concurrent.atomic.AtomicReference command = new java.util.concurrent.atomic.AtomicReference<>(s); // Paper @@ -12181,7 +12185,7 @@ index 68d268b6fff126e8645b6deec3fb549ea2286b77..6b3242117d62175de462d04e4d178b49 CommandSourceStack wrapper = rconConsoleSource.createCommandSourceStack(); RemoteServerCommandEvent event = new RemoteServerCommandEvent(rconConsoleSource.getBukkitSender(wrapper), s); this.server.getPluginManager().callEvent(event); -@@ -791,7 +791,16 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -811,7 +811,16 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface ConsoleInput serverCommand = new ConsoleInput(event.getCommand(), wrapper); this.server.dispatchServerCommand(event.getSender(), serverCommand); } // Paper @@ -12200,10 +12204,10 @@ index 68d268b6fff126e8645b6deec3fb549ea2286b77..6b3242117d62175de462d04e4d178b49 if (waitableArray[0] != null) { //noinspection unchecked diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 627a88ec8c3b215b19b55a6d461c8754b4fcd1e8..4e8b325cad5ef1a59ac3ba725d3de6e43d0fd5d6 100644 +index 472b9494f8a34a8ba90d6a2936b0db7530a229ad..e41a352141614a0578af6019bc55f96ea323e090 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java -@@ -81,7 +81,7 @@ public class ChunkHolder { +@@ -79,7 +79,7 @@ public class ChunkHolder { public void onChunkAdd() { // Paper start - optimise chunk tick iteration if (this.needsBroadcastChanges()) { @@ -12212,7 +12216,7 @@ index 627a88ec8c3b215b19b55a6d461c8754b4fcd1e8..4e8b325cad5ef1a59ac3ba725d3de6e4 } // Paper end - optimise chunk tick iteration } -@@ -89,7 +89,7 @@ public class ChunkHolder { +@@ -87,7 +87,7 @@ public class ChunkHolder { public void onChunkRemove() { // Paper start - optimise chunk tick iteration if (this.needsBroadcastChanges()) { @@ -12221,7 +12225,7 @@ index 627a88ec8c3b215b19b55a6d461c8754b4fcd1e8..4e8b325cad5ef1a59ac3ba725d3de6e4 } // Paper end - optimise chunk tick iteration } -@@ -284,7 +284,7 @@ public class ChunkHolder { +@@ -270,7 +270,7 @@ public class ChunkHolder { private void addToBroadcastMap() { io.papermc.paper.util.TickThread.ensureTickThread(this.chunkMap.level, this.pos, "Asynchronous ChunkHolder update is not allowed"); @@ -12231,12 +12235,12 @@ index 627a88ec8c3b215b19b55a6d461c8754b4fcd1e8..4e8b325cad5ef1a59ac3ba725d3de6e4 // Paper end - optimise chunk tick iteration diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569dc702e1aa 100644 +index 7fb9ba3dadb1eca4a1000ea8cf4d13fed2b7db1e..c75990f0549a1267ecb591227b0f97fa8707bc40 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -137,77 +137,41 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - private final AtomicInteger tickingGenerated; - public final StructureTemplateManager structureTemplateManager; // Paper - rewrite chunk system +@@ -139,8 +139,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + public final ChunkMap.ChunkDistanceManager distanceManager; + public final AtomicInteger tickingGenerated; // Paper - public private final String storageName; - private final PlayerMap playerMap; - public final Int2ObjectMap entityMap; @@ -12245,7 +12249,8 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d private final Long2ByteMap chunkTypeCache; private final Long2LongMap chunkSaveCooldowns; private final Queue unloadQueue; - public int serverViewDistance; +@@ -148,69 +148,33 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + private WorldGenContext worldGenContext; public final WorldGenContext getWorldGenContext() { return this.worldGenContext; } // Paper - rewrite chunk system // Paper start - distance maps - private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>(); @@ -12321,7 +12326,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d } // Paper end // Paper start -@@ -239,19 +203,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -242,19 +206,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public final ChunkHolder getUnloadingChunkHolder(int chunkX, int chunkZ) { return null; // Paper - rewrite chunk system } @@ -12336,7 +12341,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d // Paper end - optimise chunk tick iteration public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier persistentStateManagerFactory, int viewDistance, boolean dsync) { - super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); + super(new RegionStorageInfo(session.getLevelId(), world.dimension(), "chunk"), session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); // Paper - rewrite chunk system this.tickingGenerated = new AtomicInteger(); - this.playerMap = new PlayerMap(); @@ -12346,8 +12351,8 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d this.chunkTypeCache = new Long2ByteOpenHashMap(); this.chunkSaveCooldowns = new Long2LongOpenHashMap(); this.unloadQueue = Queues.newConcurrentLinkedQueue(); -@@ -296,57 +260,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - this.setServerViewDistance(viewDistance); +@@ -298,57 +262,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + this.worldGenContext = new WorldGenContext(world, chunkGenerator, structureTemplateManager, this.lightEngine); // Paper start this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new); - this.regionManagers.add(this.dataRegionManager); @@ -12408,7 +12413,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d } // Paper end -@@ -667,6 +592,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -691,6 +616,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper start - duplicate uuid resolving // rets true if to prevent the entity from being added public static boolean checkDupeUUID(ServerLevel level, Entity entity) { @@ -12421,7 +12426,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode mode = level.paperConfig().entities.spawning.duplicateUuid.mode; if (mode != io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode.WARN && mode != io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode.DELETE -@@ -913,6 +844,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -931,6 +862,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkcoordintpair, boolean reducedRange) { @@ -12460,7 +12465,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d int chunkRange = this.level.spigotConfig.mobSpawnRange; chunkRange = (chunkRange > this.level.spigotConfig.viewDistance) ? (byte) this.level.spigotConfig.viewDistance : chunkRange; chunkRange = (chunkRange > 8) ? 8 : chunkRange; -@@ -924,7 +887,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -942,7 +905,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (!this.distanceManager.hasPlayersNearby(chunkcoordintpair.toLong())) { return false; } else { @@ -12469,7 +12474,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d ServerPlayer entityplayer; -@@ -956,7 +919,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -974,7 +937,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return List.of(); } else { Builder builder = ImmutableList.builder(); @@ -12478,7 +12483,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d while (iterator.hasNext()) { ServerPlayer entityplayer = (ServerPlayer) iterator.next(); -@@ -985,25 +948,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1003,25 +966,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } void updatePlayerStatus(ServerPlayer player, boolean added) { @@ -12508,7 +12513,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d this.removePlayerFromDistanceMaps(player); // Paper - distance maps // Paper - handled by player chunk loader -@@ -1018,31 +975,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1036,31 +993,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public void move(ServerPlayer player) { @@ -12544,7 +12549,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d // Paper - replaced by PlayerChunkLoader } -@@ -1073,9 +1012,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1091,9 +1030,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public void addEntity(Entity entity) { org.spigotmc.AsyncCatcher.catchOp("entity track"); // Spigot // Paper start - ignore and warn about illegal addEntity calls instead of crashing server @@ -12556,7 +12561,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d return; } // Paper end - ignore and warn about illegal addEntity calls instead of crashing server -@@ -1088,27 +1027,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1106,27 +1045,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (i != 0) { int j = entitytypes.updateInterval(); @@ -12592,9 +12597,9 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d } } -@@ -1122,16 +1059,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - ServerPlayer entityplayer = (ServerPlayer) entity; - +@@ -1138,16 +1075,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + org.spigotmc.AsyncCatcher.catchOp("entity untrack"); // Spigot + if (entity instanceof ServerPlayer entityplayer) { this.updatePlayerStatus(entityplayer, false); - ObjectIterator objectiterator = this.entityMap.values().iterator(); - @@ -12616,7 +12621,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d if (playerchunkmap_entitytracker1 != null) { playerchunkmap_entitytracker1.broadcastRemoved(); -@@ -1139,82 +1076,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1155,82 +1092,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider entity.tracker = null; // Paper - We're no longer tracked } @@ -12660,8 +12665,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d } } - // Paper end - optimised tracker -+ // Folia end - region threading - replace entity tracking ticking - +- - protected void tick() { - // Paper start - optimized tracker - if (true) { @@ -12681,7 +12685,8 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d - SectionPos sectionposition = playerchunkmap_entitytracker.lastSectionPos; - SectionPos sectionposition1 = SectionPos.of((EntityAccess) playerchunkmap_entitytracker.entity); - boolean flag = !Objects.equals(sectionposition, sectionposition1); -- ++ // Folia end - region threading - replace entity tracking ticking + - if (flag) { - playerchunkmap_entitytracker.updatePlayers(list1); - Entity entity = playerchunkmap_entitytracker.entity; @@ -12721,7 +12726,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d if (playerchunkmap_entitytracker != null) { playerchunkmap_entitytracker.broadcast(packet); -@@ -1223,7 +1115,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1239,7 +1131,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } protected void broadcastAndSend(Entity entity, Packet packet) { @@ -12730,7 +12735,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d if (playerchunkmap_entitytracker != null) { playerchunkmap_entitytracker.broadcastAndSend(packet); -@@ -1400,6 +1292,78 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1414,6 +1306,78 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } } @@ -12809,7 +12814,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d public void updatePlayer(ServerPlayer player) { org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot -@@ -1423,9 +1387,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1437,9 +1401,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } } // Paper end - Configurable entity tracking range by Y @@ -12826,7 +12831,7 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..d45f4efd66380ace44fb0aa3f8a2569d } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java -index 7c425ac50c83757b66a2178bc19d4c920b82f12f..584ee79355f1825b42bc98e508a3678b22886831 100644 +index cdb3c2cde5d9133ef60cf96d91762e6a7c8aeb4a..8c42c1f0d67f437423bf6d3958c6409f44556d5c 100644 --- a/src/main/java/net/minecraft/server/level/DistanceManager.java +++ b/src/main/java/net/minecraft/server/level/DistanceManager.java @@ -191,11 +191,11 @@ public abstract class DistanceManager { @@ -12844,10 +12849,10 @@ index 7c425ac50c83757b66a2178bc19d4c920b82f12f..584ee79355f1825b42bc98e508a3678b public String getDebugStatus() { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdead22d6916 100644 +index b99f50604bafecbc68835974c9ed0caa91911a40..034218c47afa99a0623b1f9c9b7830ae6da4322d 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -58,23 +58,20 @@ public class ServerChunkCache extends ChunkSource { +@@ -56,23 +56,20 @@ public class ServerChunkCache extends ChunkSource { public final ServerChunkCache.MainThreadExecutor mainThreadProcessor; public final ChunkMap chunkMap; private final DimensionDataStorage dataStorage; @@ -12876,7 +12881,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea // Paper end public ServerChunkCache(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor workerExecutor, ChunkGenerator chunkGenerator, int viewDistance, int simulationDistance, boolean dsync, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier persistentStateManagerFactory) { -@@ -107,52 +104,23 @@ public class ServerChunkCache extends ChunkSource { +@@ -105,52 +102,23 @@ public class ServerChunkCache extends ChunkSource { } public void addLoadedChunk(LevelChunk chunk) { @@ -12936,7 +12941,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea } public final LevelChunk getChunkAtIfLoadedMainThreadNoCache(int x, int z) { -@@ -197,26 +165,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -195,26 +163,7 @@ public class ServerChunkCache extends ChunkSource { public LevelChunk getChunkAtIfLoadedImmediately(int x, int z) { long k = ChunkPos.asLong(x, z); @@ -12964,15 +12969,15 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea } // Paper end -@@ -314,6 +263,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -308,6 +257,7 @@ public class ServerChunkCache extends ChunkSource { } - public CompletableFuture> getChunkFuture(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { + public CompletableFuture> getChunkFuture(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { + if (true) throw new UnsupportedOperationException(); // Folia - region threading boolean flag1 = io.papermc.paper.util.TickThread.isTickThread(); // Paper - rewrite chunk system CompletableFuture completablefuture; -@@ -499,10 +449,11 @@ public class ServerChunkCache extends ChunkSource { +@@ -497,10 +447,11 @@ public class ServerChunkCache extends ChunkSource { } private void tickChunks() { @@ -12987,7 +12992,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea if (!this.level.isDebug()) { ProfilerFiller gameprofilerfiller = this.level.getProfiler(); -@@ -522,7 +473,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -520,7 +471,7 @@ public class ServerChunkCache extends ChunkSource { NaturalSpawner.SpawnState spawnercreature_d; // moved down if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled // re-set mob counts @@ -12996,7 +13001,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea // Paper start - per player mob spawning backoff for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) { player.mobCounts[ii] = 0; -@@ -535,22 +486,22 @@ public class ServerChunkCache extends ChunkSource { +@@ -533,22 +484,22 @@ public class ServerChunkCache extends ChunkSource { } // Paper end - per player mob spawning backoff } @@ -13025,7 +13030,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea player.playerNaturallySpawnedEvent = null; player.lastEntitySpawnRadiusSquared = -1.0; continue; -@@ -566,7 +517,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -564,7 +515,7 @@ public class ServerChunkCache extends ChunkSource { com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(player.getBukkitEntity(), (byte)chunkRange); event.callEvent(); if (event.isCancelled() || event.getSpawnRadius() < 0) { @@ -13034,7 +13039,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea player.playerNaturallySpawnedEvent = null; player.lastEntitySpawnRadiusSquared = -1.0; continue; -@@ -576,13 +527,13 @@ public class ServerChunkCache extends ChunkSource { +@@ -574,13 +525,13 @@ public class ServerChunkCache extends ChunkSource { int chunkX = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getX()); int chunkZ = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getZ()); @@ -13050,7 +13055,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea // Paper - optimise chunk tick iteration int chunksTicked = 0; // Paper -@@ -590,10 +541,10 @@ public class ServerChunkCache extends ChunkSource { +@@ -588,10 +539,10 @@ public class ServerChunkCache extends ChunkSource { io.papermc.paper.util.player.NearbyPlayers nearbyPlayers = this.chunkMap.getNearbyPlayers(); // Paper - optimise chunk tick iteration Iterator chunkIterator; if (this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { @@ -13064,7 +13069,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea while (chunkIterator.hasNext()) { shuffled.add(chunkIterator.next()); } -@@ -663,17 +614,21 @@ public class ServerChunkCache extends ChunkSource { +@@ -661,17 +612,21 @@ public class ServerChunkCache extends ChunkSource { // Paper - optimise chunk tick iteration this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing // Paper start - optimise chunk tick iteration @@ -13094,7 +13099,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea // Paper end - optimise chunk tick iteration this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing // Paper - optimise chunk tick iteration -@@ -736,14 +691,19 @@ public class ServerChunkCache extends ChunkSource { +@@ -734,14 +689,19 @@ public class ServerChunkCache extends ChunkSource { @Override public void onLightUpdate(LightLayer type, SectionPos pos) { @@ -13116,7 +13121,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea } public void addRegionTicket(TicketType ticketType, ChunkPos pos, int radius, T argument) { -@@ -815,7 +775,8 @@ public class ServerChunkCache extends ChunkSource { +@@ -813,7 +773,8 @@ public class ServerChunkCache extends ChunkSource { @Nullable @VisibleForDebug public NaturalSpawner.SpawnState getLastSpawnState() { @@ -13126,7 +13131,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea } public void removeTicketsOnClosing() { -@@ -848,8 +809,43 @@ public class ServerChunkCache extends ChunkSource { +@@ -846,8 +807,43 @@ public class ServerChunkCache extends ChunkSource { return ServerChunkCache.this.mainThread; } @@ -13170,7 +13175,7 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea ServerChunkCache.this.level.getProfiler().incrementCounter("runTask"); super.doRunTask(task); } -@@ -857,10 +853,15 @@ public class ServerChunkCache extends ChunkSource { +@@ -855,10 +851,15 @@ public class ServerChunkCache extends ChunkSource { @Override // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task public boolean pollTask() { @@ -13188,13 +13193,13 @@ index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..d532043f33825ce2971d9e53f290cdea } diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8 100644 +index ca56a0b596976448da6bb2a0e82b3d5cd4133e12..559b6d0e3611b506ff10e5ae7c42b35f0d710173 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -193,37 +193,35 @@ public class ServerLevel extends Level implements WorldGenLevel { - public final ServerChunkCache chunkSource; +@@ -197,38 +197,36 @@ public class ServerLevel extends Level implements WorldGenLevel { private final MinecraftServer server; public final PrimaryLevelData serverLevelData; // CraftBukkit - type + private int lastSpawnChunkRadius; - final EntityTickList entityTickList; + //final EntityTickList entityTickList; // Folia - region threading //public final PersistentEntitySectionManager entityManager; // Paper - rewrite chunk system @@ -13205,8 +13210,10 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 private final PortalForcer portalForcer; - private final LevelTicks blockTicks; - private final LevelTicks fluidTicks; +- private final PathTypeCache pathTypesByPosCache; + //private final LevelTicks blockTicks; // Folia - region threading + //private final LevelTicks fluidTicks; // Folia - region threading ++ //private final PathTypeCache pathTypesByPosCache; // Folia - region threading final Set navigatingMobs; volatile boolean isUpdatingNavigations; protected final Raids raids; @@ -13238,7 +13245,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 public LevelChunk getChunkIfLoaded(int x, int z) { return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately -@@ -253,6 +251,36 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -258,6 +256,36 @@ public class ServerLevel extends Level implements WorldGenLevel { ServerChunkCache chunkProvider = this.getChunkSource(); @@ -13275,7 +13282,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 for (int cx = minChunkX; cx <= maxChunkX; ++cx) { for (int cz = minChunkZ; cz <= maxChunkZ; ++cz) { if (chunkProvider.getChunkAtIfLoadedImmediately(cx, cz) == null) { -@@ -511,7 +539,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -516,7 +544,7 @@ public class ServerLevel extends Level implements WorldGenLevel { public final int getRegionChunkShift() { // placeholder for folia @@ -13284,7 +13291,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } // Paper end - rewrite chunk system -@@ -566,14 +594,14 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -571,14 +599,14 @@ public class ServerLevel extends Level implements WorldGenLevel { } // Paper end - optimise getPlayerByUUID // Paper start - lag compensation @@ -13302,7 +13309,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } // Paper end - lag compensation // Paper start - optimise nearby player retrieval -@@ -620,7 +648,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -625,7 +653,7 @@ public class ServerLevel extends Level implements WorldGenLevel { ServerPlayer nearest = null; double nearestDist = Double.MAX_VALUE; @@ -13311,7 +13318,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 double dist = player.distanceToSqr(x, y, z); if (dist >= nearestDist) { continue; -@@ -676,7 +704,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -681,7 +709,7 @@ public class ServerLevel extends Level implements WorldGenLevel { return nearest; } else { @@ -13320,7 +13327,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } } -@@ -685,6 +713,58 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -690,6 +718,58 @@ public class ServerLevel extends Level implements WorldGenLevel { return this.getNearestPlayer(targetPredicate, null, x, y, z); } // Paper end - optimise nearby player retrieval @@ -13379,7 +13386,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 // Add env and gen to constructor, IWorldDataServer -> WorldDataServer public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { -@@ -697,13 +777,13 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -702,14 +782,14 @@ public class ServerLevel extends Level implements WorldGenLevel { this.convertable = convertable_conversionsession; this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); // CraftBukkit end @@ -13387,10 +13394,12 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 - this.entityTickList = new EntityTickList(); - this.blockTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); - this.fluidTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); +- this.pathTypesByPosCache = new PathTypeCache(); + this.players = new java.util.concurrent.CopyOnWriteArrayList<>(); // Folia - region threading + //this.entityTickList = new EntityTickList(); // Folia - region threading + //this.blockTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); // Folia - moved to RegioniedWorldData + //this.fluidTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); // Folia - moved to RegioniedWorldData ++ //this.pathTypesByPosCache = new PathTypeCache(); // Folia - moved to RegioniedWorldData this.navigatingMobs = new ObjectOpenHashSet(); - this.blockEvents = new ObjectLinkedOpenHashSet(); - this.blockEventsToReschedule = new ArrayList(64); @@ -13399,7 +13408,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 this.dragonParts = new Int2ObjectOpenHashMap(); this.tickTime = flag1; this.server = minecraftserver; -@@ -742,7 +822,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -748,7 +828,7 @@ public class ServerLevel extends Level implements WorldGenLevel { }); this.chunkSource.getGeneratorState().ensureStructuresGenerated(); this.portalForcer = new PortalForcer(this); @@ -13408,7 +13417,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 this.prepareWeather(); this.getWorldBorder().setAbsoluteMaxSize(minecraftserver.getAbsoluteMaxWorldSize()); this.raids = (Raids) this.getDataStorage().computeIfAbsent(Raids.factory(this), Raids.getFileId(this.dimensionTypeRegistration())); -@@ -769,7 +849,14 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -775,7 +855,14 @@ public class ServerLevel extends Level implements WorldGenLevel { this.chunkTaskScheduler = new io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler(this, io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.workerThreads); // Paper - rewrite chunk system this.entityLookup = new io.papermc.paper.chunk.system.entity.EntityLookup(this, new EntityCallbacks()); // Paper - rewrite chunk system @@ -13423,7 +13432,12 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 // Paper start @Override -@@ -802,44 +889,27 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -804,48 +891,32 @@ public class ServerLevel extends Level implements WorldGenLevel { + return this.getChunkSource().getGenerator().getBiomeSource().getNoiseBiome(biomeX, biomeY, biomeZ, this.getChunkSource().randomState().sampler()); + } + ++ @Override // Folia - region threading + public StructureManager structureManager() { return this.structureManager; } @@ -13476,7 +13490,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 if (flag) { this.tickTime(); } -@@ -847,11 +917,11 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -853,11 +924,11 @@ public class ServerLevel extends Level implements WorldGenLevel { gameprofilerfiller.popPush("tickPending"); this.timings.scheduledBlocks.startTiming(); // Paper if (!this.isDebug() && flag) { @@ -13491,7 +13505,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 gameprofilerfiller.pop(); } this.timings.scheduledBlocks.stopTiming(); // Paper -@@ -874,9 +944,9 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -880,9 +951,9 @@ public class ServerLevel extends Level implements WorldGenLevel { this.timings.doSounds.stopTiming(); // Spigot } @@ -13503,7 +13517,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 if (flag1) { this.resetEmptyTime(); -@@ -886,20 +956,30 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -892,20 +963,30 @@ public class ServerLevel extends Level implements WorldGenLevel { gameprofilerfiller.push("entities"); this.timings.tickEntities.startTiming(); // Spigot if (this.dragonFight != null && flag) { @@ -13535,7 +13549,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 gameprofilerfiller.pop(); if (true || this.chunkSource.chunkMap.getDistanceManager().inEntityTickingRange(entity.chunkPosition().toLong())) { // Paper - now always true if in the ticking list Entity entity1 = entity.getVehicle(); -@@ -930,6 +1010,31 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -936,6 +1017,31 @@ public class ServerLevel extends Level implements WorldGenLevel { gameprofilerfiller.pop(); } @@ -13567,7 +13581,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 @Override public boolean shouldTickBlocksAt(long chunkPos) { // Paper start - replace player chunk loader system -@@ -940,11 +1045,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -946,11 +1052,12 @@ public class ServerLevel extends Level implements WorldGenLevel { protected void tickTime() { if (this.tickTime) { @@ -13584,7 +13598,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 this.setDayTime(this.levelData.getDayTime() + 1L); } -@@ -973,15 +1079,23 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -979,15 +1086,23 @@ public class ServerLevel extends Level implements WorldGenLevel { private void wakeUpAllPlayers() { this.sleepStatus.removeAllSleepers(); (this.players.stream().filter(LivingEntity::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> { // CraftBukkit - decompile error @@ -13611,7 +13625,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 ChunkPos chunkcoordintpair = chunk.getPos(); boolean flag = this.isRaining(); int j = chunkcoordintpair.getMinBlockX(); -@@ -989,7 +1103,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -995,7 +1110,7 @@ public class ServerLevel extends Level implements WorldGenLevel { ProfilerFiller gameprofilerfiller = this.getProfiler(); gameprofilerfiller.push("thunder"); @@ -13620,7 +13634,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder blockposition.set(this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15))); // Paper -@@ -1045,7 +1159,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1051,7 +1166,7 @@ public class ServerLevel extends Level implements WorldGenLevel { int yPos = (sectionIndex + minSection) << 4; for (int a = 0; a < randomTickSpeed; ++a) { int tickingBlocks = section.tickingList.size(); @@ -13629,7 +13643,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 if (index >= tickingBlocks) { continue; } -@@ -1059,7 +1173,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1065,7 +1180,7 @@ public class ServerLevel extends Level implements WorldGenLevel { BlockPos blockposition2 = blockposition.set(j + randomX, randomY, k + randomZ); BlockState iblockdata = com.destroystokyo.paper.util.maplist.IBlockDataList.getBlockDataFromRaw(raw); @@ -13638,7 +13652,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } // We drop the fluid tick since LAVA is ALREADY TICKED by the above method (See LiquidBlock). // TODO CHECK ON UPDATE (ping the Canadian) -@@ -1164,7 +1278,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1170,7 +1285,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } public boolean isHandlingTick() { @@ -13647,7 +13661,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } public boolean canSleepThroughNights() { -@@ -1196,6 +1310,14 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1202,6 +1317,14 @@ public class ServerLevel extends Level implements WorldGenLevel { } public void updateSleepingPlayerList() { @@ -13662,7 +13676,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 if (!this.players.isEmpty() && this.sleepStatus.update(this.players)) { this.announceSleepStatus(); } -@@ -1207,7 +1329,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1213,7 +1336,7 @@ public class ServerLevel extends Level implements WorldGenLevel { return this.server.getScoreboard(); } @@ -13671,7 +13685,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 boolean flag = this.isRaining(); if (this.dimensionType().hasSkyLight()) { -@@ -1293,23 +1415,24 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1299,23 +1422,24 @@ public class ServerLevel extends Level implements WorldGenLevel { this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } // */ @@ -13705,7 +13719,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } } // CraftBukkit end -@@ -1374,7 +1497,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1380,7 +1504,7 @@ public class ServerLevel extends Level implements WorldGenLevel { public void tickNonPassenger(Entity entity) { // Paper start - log detailed entity tick information @@ -13714,7 +13728,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 try { if (currentlyTickingEntity.get() == null) { currentlyTickingEntity.lazySet(entity); -@@ -1407,7 +1530,16 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1413,7 +1537,16 @@ public class ServerLevel extends Level implements WorldGenLevel { if (isActive) { // Paper - EAR 2 TimingHistory.activatedEntityTicks++; entity.tick(); @@ -13732,7 +13746,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } else { entity.inactiveTick(); } // Paper - EAR 2 this.getProfiler().pop(); } finally { timer.stopTiming(); } // Paper - timings -@@ -1430,7 +1562,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1436,7 +1569,7 @@ public class ServerLevel extends Level implements WorldGenLevel { private void tickPassenger(Entity vehicle, Entity passenger) { if (!passenger.isRemoved() && passenger.getVehicle() == vehicle) { @@ -13741,7 +13755,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 // Paper - EAR 2 final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(passenger); co.aikar.timings.Timing timer = isActive ? passenger.getType().passengerTickTimer.startTiming() : passenger.getType().passengerInactiveTickTimer.startTiming(); // Paper -@@ -1447,7 +1579,16 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1453,7 +1586,16 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper start - EAR 2 if (isActive) { passenger.rideTick(); @@ -13759,7 +13773,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } else { passenger.setDeltaMovement(Vec3.ZERO); passenger.inactiveTick(); -@@ -1536,20 +1677,22 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1542,20 +1684,22 @@ public class ServerLevel extends Level implements WorldGenLevel { } else if (close) { chunkproviderserver.close(false); } // Paper - rewrite chunk system @@ -13767,7 +13781,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 - ServerLevel worldserver1 = this; - - this.serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings()); -- this.serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save()); +- this.serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save(this.registryAccess())); - this.convertable.saveDataTag(this.server.registryAccess(), this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); - // CraftBukkit end + // Folia - move into saveLevelData @@ -13783,14 +13797,14 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 + ServerLevel worldserver1 = this; + + this.serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings()); -+ this.serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save()); ++ this.serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save(this.registryAccess())); + this.convertable.saveDataTag(this.server.registryAccess(), this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); + // Folia end - moved into saveLevelData + this.getChunkSource().getDataStorage().save(async); // Paper - Write SavedData IO async } -@@ -1603,6 +1746,19 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1609,6 +1753,19 @@ public class ServerLevel extends Level implements WorldGenLevel { return list; } @@ -13810,7 +13824,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 @Nullable public ServerPlayer getRandomPlayer() { List list = this.getPlayers(LivingEntity::isAlive); -@@ -1690,8 +1846,8 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1696,8 +1853,8 @@ public class ServerLevel extends Level implements WorldGenLevel { } else { if (entity instanceof net.minecraft.world.entity.item.ItemEntity itemEntity && itemEntity.getItem().isEmpty()) return false; // Paper - Prevent empty items from being added // Paper start - capture all item additions to the world @@ -13821,7 +13835,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 return true; } // Paper end - capture all item additions to the world -@@ -1846,7 +2002,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1852,21 +2009,22 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public void sendBlockUpdated(BlockPos pos, BlockState oldState, BlockState newState, int flags) { @@ -13830,16 +13844,24 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 String s = "recursive call to sendBlockUpdated"; Util.logAndPauseIfInIde("recursive call to sendBlockUpdated", new IllegalStateException("recursive call to sendBlockUpdated")); -@@ -1859,7 +2015,7 @@ public class ServerLevel extends Level implements WorldGenLevel { + } + + this.getChunkSource().blockChanged(pos); +- this.pathTypesByPosCache.invalidate(pos); ++ final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = this.getCurrentWorldData(); // Folia - region threading ++ regionizedWorldData.pathTypesByPosCache.invalidate(pos); // Folia - region threading + if (this.paperConfig().misc.updatePathfindingOnBlockUpdate) { // Paper - option to disable pathfinding updates + VoxelShape voxelshape = oldState.getCollisionShape(this, pos); + VoxelShape voxelshape1 = newState.getCollisionShape(this, pos); if (Shapes.joinIsNotEmpty(voxelshape, voxelshape1, BooleanOp.NOT_SAME)) { List list = new ObjectArrayList(); - Iterator iterator = this.navigatingMobs.iterator(); -+ Iterator iterator = this.getCurrentWorldData().getNavigatingMobs(); // Folia - region threading ++ Iterator iterator = regionizedWorldData.getNavigatingMobs(); // Folia - region threading while (iterator.hasNext()) { // CraftBukkit start - fix SPIGOT-6362 -@@ -1882,7 +2038,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1889,7 +2047,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } try { @@ -13848,7 +13870,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 iterator = list.iterator(); while (iterator.hasNext()) { -@@ -1891,7 +2047,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1898,7 +2056,7 @@ public class ServerLevel extends Level implements WorldGenLevel { navigationabstract1.recomputePath(); } } finally { @@ -13857,7 +13879,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } } -@@ -1900,23 +2056,23 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1907,23 +2065,23 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public void updateNeighborsAt(BlockPos pos, Block sourceBlock) { @@ -13886,7 +13908,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } @Override -@@ -1947,7 +2103,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1954,7 +2112,7 @@ public class ServerLevel extends Level implements WorldGenLevel { explosion.clearToBlow(); } @@ -13895,7 +13917,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 while (iterator.hasNext()) { ServerPlayer entityplayer = (ServerPlayer) iterator.next(); -@@ -1962,25 +2118,28 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1969,25 +2127,28 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public void blockEvent(BlockPos pos, Block block, int type, int data) { @@ -13930,7 +13952,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } private boolean doBlockEvent(BlockEventData event) { -@@ -1991,12 +2150,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1998,12 +2159,12 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public LevelTicks getBlockTicks() { @@ -13945,7 +13967,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } @Nonnull -@@ -2020,7 +2179,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2027,7 +2188,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 @@ -13954,7 +13976,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } 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 -@@ -2073,7 +2232,14 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2080,7 +2241,14 @@ public class ServerLevel extends Level implements WorldGenLevel { public Entity getEntityOrPart(int id) { Entity entity = (Entity) this.getEntities().get(id); @@ -13970,15 +13992,15 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } @Nullable -@@ -2128,6 +2294,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2135,6 +2303,7 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper start - Call missing map initialize event and set id final DimensionDataStorage storage = this.getServer().overworld().getDataStorage(); + synchronized (storage.cache) { // Folia - region threading - final net.minecraft.world.level.saveddata.SavedData existing = storage.cache.get(id); - if (existing == null && !storage.cache.containsKey(id)) { - final net.minecraft.world.level.saveddata.SavedData.Factory factory = MapItemSavedData.factory(); -@@ -2143,6 +2310,7 @@ public class ServerLevel extends Level implements WorldGenLevel { + final net.minecraft.world.level.saveddata.SavedData existing = storage.cache.get(id.key()); + if (existing == null && !storage.cache.containsKey(id.key())) { + final MapItemSavedData worldmap = (MapItemSavedData) this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), id.key()); +@@ -2149,6 +2318,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } return existing instanceof MapItemSavedData data ? data : null; @@ -13986,7 +14008,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 // Paper end - Call missing map initialize event and set id } -@@ -2251,6 +2419,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2198,6 +2368,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } public boolean setChunkForced(int x, int z, boolean forced) { @@ -13994,7 +14016,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 ForcedChunksSavedData forcedchunk = (ForcedChunksSavedData) this.getDataStorage().computeIfAbsent(ForcedChunksSavedData.factory(), "chunks"); ChunkPos chunkcoordintpair = new ChunkPos(x, z); long k = chunkcoordintpair.toLong(); -@@ -2259,7 +2428,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2206,7 +2377,7 @@ public class ServerLevel extends Level implements WorldGenLevel { if (forced) { flag1 = forcedchunk.getChunks().add(k); if (flag1) { @@ -14003,7 +14025,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } } else { flag1 = forcedchunk.getChunks().remove(k); -@@ -2287,13 +2456,18 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2234,13 +2405,18 @@ public class ServerLevel extends Level implements WorldGenLevel { BlockPos blockposition1 = pos.immutable(); optional.ifPresent((holder) -> { @@ -14025,7 +14047,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 // Paper start - Remove stale POIs if (optional.isEmpty() && this.getPoiManager().exists(blockposition1, poiType -> true)) { this.getPoiManager().remove(blockposition1); -@@ -2301,7 +2475,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2248,7 +2424,12 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper end - Remove stale POIs this.getPoiManager().add(blockposition1, holder); DebugPackets.sendPoiAddedPacket(this, blockposition1); @@ -14039,7 +14061,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 }); } } -@@ -2348,7 +2527,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2295,7 +2476,7 @@ public class ServerLevel extends Level implements WorldGenLevel { BufferedWriter bufferedwriter = Files.newBufferedWriter(path.resolve("stats.txt")); try { @@ -14048,7 +14070,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 NaturalSpawner.SpawnState spawnercreature_d = this.getChunkSource().getLastSpawnState(); if (spawnercreature_d != null) { -@@ -2362,7 +2541,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2309,7 +2490,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } bufferedwriter.write(String.format(Locale.ROOT, "entities: %s\n", this.entityLookup.getDebugInfo())); // Paper - rewrite chunk system @@ -14057,7 +14079,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 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"); -@@ -2508,7 +2687,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2455,7 +2636,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); @@ -14066,7 +14088,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 while (iterator.hasNext()) { TickingBlockEntity tickingblockentity = (TickingBlockEntity) iterator.next(); -@@ -2521,7 +2700,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2468,7 +2649,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @VisibleForTesting public void clearBlockEvents(BoundingBox box) { @@ -14075,7 +14097,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 return box.isInside(blockactiondata.pos()); }); } -@@ -2530,7 +2709,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2477,7 +2658,7 @@ public class ServerLevel extends Level implements WorldGenLevel { public void blockUpdated(BlockPos pos, Block block) { if (!this.isDebug()) { // CraftBukkit start @@ -14084,7 +14106,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 return; } // CraftBukkit end -@@ -2573,9 +2752,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2520,9 +2701,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @VisibleForTesting public String getWatchdogStats() { @@ -14095,7 +14117,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } private static String getTypeCount(Iterable items, Function classifier) { -@@ -2608,6 +2785,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2555,6 +2734,12 @@ public class ServerLevel extends Level implements WorldGenLevel { public static void makeObsidianPlatform(ServerLevel worldserver, Entity entity) { // CraftBukkit end BlockPos blockposition = ServerLevel.END_SPAWN_POINT; @@ -14108,7 +14130,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 int i = blockposition.getX(); int j = blockposition.getY() - 2; int k = blockposition.getZ(); -@@ -2620,11 +2803,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2567,11 +2752,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); }); @@ -14121,7 +14143,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 blockList.updateList(); } // CraftBukkit end -@@ -2645,13 +2824,14 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2592,17 +2773,18 @@ public class ServerLevel extends Level implements WorldGenLevel { } public void startTickingChunk(LevelChunk chunk) { @@ -14139,8 +14161,13 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 + // Folia end - region threading } + public PathTypeCache getPathTypeCache() { +- return this.pathTypesByPosCache; ++ return this.getCurrentWorldData().pathTypesByPosCache; // Folia - region threading + } + @Override -@@ -2673,7 +2853,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2624,7 +2806,7 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper end - rewrite chunk system } @@ -14149,7 +14176,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 // 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 -@@ -2728,7 +2908,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2684,7 +2866,7 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper start - optimize redstone (Alternate Current) @Override public alternate.current.wire.WireHandler getWireHandler() { @@ -14158,7 +14185,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } // Paper end - optimize redstone (Alternate Current) -@@ -2739,16 +2919,16 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2695,16 +2877,16 @@ public class ServerLevel extends Level implements WorldGenLevel { public void onCreated(Entity entity) {} public void onDestroyed(Entity entity) { @@ -14178,15 +14205,15 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 // 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; -@@ -2759,6 +2939,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2715,6 +2897,7 @@ public class ServerLevel extends Level implements WorldGenLevel { public void onTrackingStart(Entity entity) { org.spigotmc.AsyncCatcher.catchOp("entity register"); // Spigot + ServerLevel.this.getCurrentWorldData().addLoadedEntity(entity); // Folia - region threading // 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; -@@ -2776,7 +2957,7 @@ public class ServerLevel extends Level implements WorldGenLevel { + if (entity instanceof ServerPlayer entityplayer) { + ServerLevel.this.players.add(entityplayer); +@@ -2728,7 +2911,7 @@ public class ServerLevel extends Level implements WorldGenLevel { Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")); } @@ -14194,8 +14221,8 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 + ServerLevel.this.getCurrentWorldData().addNavigatingMob(entityinsentient); // Folia - region threading } - if (entity instanceof EnderDragon) { -@@ -2787,7 +2968,9 @@ public class ServerLevel extends Level implements WorldGenLevel { + if (entity instanceof EnderDragon entityenderdragon) { +@@ -2738,7 +2921,9 @@ public class ServerLevel extends Level implements WorldGenLevel { for (int j = 0; j < i; ++j) { EnderDragonPart entitycomplexpart = aentitycomplexpart[j]; @@ -14205,7 +14232,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } } -@@ -2809,16 +2992,24 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2760,16 +2945,24 @@ public class ServerLevel extends Level implements WorldGenLevel { public void onTrackingEnd(Entity entity) { org.spigotmc.AsyncCatcher.catchOp("entity unregister"); // Spigot @@ -14231,7 +14258,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 map.carriedByPlayers.remove( (Player) entity ); for ( Iterator iter = (Iterator) map.carriedBy.iterator(); iter.hasNext(); ) { -@@ -2828,6 +3019,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2779,6 +2972,7 @@ public class ServerLevel extends Level implements WorldGenLevel { iter.remove(); } } @@ -14239,7 +14266,7 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 } } } ); -@@ -2862,7 +3054,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2809,7 +3003,7 @@ public class ServerLevel extends Level implements WorldGenLevel { Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")); } @@ -14247,8 +14274,8 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 + ServerLevel.this.getCurrentWorldData().removeNavigatingMob(entityinsentient); // Folia - region threading } - if (entity instanceof EnderDragon) { -@@ -2873,13 +3065,16 @@ public class ServerLevel extends Level implements WorldGenLevel { + if (entity instanceof EnderDragon entityenderdragon) { +@@ -2819,13 +3013,16 @@ public class ServerLevel extends Level implements WorldGenLevel { for (int j = 0; j < i; ++j) { EnderDragonPart entitycomplexpart = aentitycomplexpart[j]; @@ -14266,10 +14293,10 @@ index 502bdc726b7890b00ee36871d905dea44e8719e3..2f799ead36f0f22afe7dc4b688e59ef2 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 b3781efbd3edcf102fe1bda5d6149915dc1127c6..36d074d1abed62b09ca808dc2774bc83a6fd5df7 100644 +index c10401e587a710d49c4af481c1e531b4bf51f755..080c0128e4fab68bcf9739737a44c736e1f87bc0 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; +@@ -199,7 +199,7 @@ import org.bukkit.inventory.MainHand; public class ServerPlayer extends Player { private static final Logger LOGGER = LogUtils.getLogger(); @@ -14278,7 +14305,7 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..36d074d1abed62b09ca808dc2774bc83 private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32; private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10; private static final int FLY_STAT_RECORDING_SPEED = 25; -@@ -470,51 +470,151 @@ public class ServerPlayer extends Player { +@@ -496,51 +496,151 @@ public class ServerPlayer extends Player { } // CraftBukkit end @@ -14415,7 +14442,7 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..36d074d1abed62b09ca808dc2774bc83 + + // this call requires to return a location with loaded chunks, so we need to schedule a load here + io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad( -+ world, selected.getX() >> 4, selected.getZ() >> 4, net.minecraft.world.level.chunk.ChunkStatus.FULL, ++ world, selected.getX() >> 4, selected.getZ() >> 4, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, + true, ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGHER, + (unused) -> { + completeSpawn(world, selected, toComplete); @@ -14460,7 +14487,7 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..36d074d1abed62b09ca808dc2774bc83 return horizontalSpawnArea <= 16 ? horizontalSpawnArea - 1 : 17; } -@@ -1169,6 +1269,337 @@ public class ServerPlayer extends Player { +@@ -1246,6 +1346,337 @@ public class ServerPlayer extends Player { } } @@ -14756,7 +14783,7 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..36d074d1abed62b09ca808dc2774bc83 + playerlist.sendAllPlayerInfo(this); + this.onUpdateAbilities(); + for (MobEffectInstance mobEffect : this.getActiveEffects()) { -+ this.connection.send(new ClientboundUpdateMobEffectPacket(this.getId(), mobEffect)); ++ this.connection.send(new ClientboundUpdateMobEffectPacket(this.getId(), mobEffect, false)); + } + + this.triggerDimensionChangeTriggers(originWorld); @@ -14798,7 +14825,7 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..36d074d1abed62b09ca808dc2774bc83 @Nullable @Override public Entity changeDimension(ServerLevel destination) { -@@ -1178,6 +1609,11 @@ public class ServerPlayer extends Player { +@@ -1255,6 +1686,11 @@ public class ServerPlayer extends Player { @Nullable public Entity changeDimension(ServerLevel worldserver, PlayerTeleportEvent.TeleportCause cause) { @@ -14810,7 +14837,7 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..36d074d1abed62b09ca808dc2774bc83 // CraftBukkit end if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154 // this.isChangingDimension = true; // CraftBukkit - Moved down and into PlayerList#changeDimension -@@ -2232,6 +2668,12 @@ public class ServerPlayer extends Player { +@@ -2324,6 +2760,12 @@ public class ServerPlayer extends Player { public void setCamera(@Nullable Entity entity) { Entity entity1 = this.getCamera(); @@ -14823,7 +14850,7 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..36d074d1abed62b09ca808dc2774bc83 this.camera = (Entity) (entity == null ? this : entity); if (entity1 != this.camera) { // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity -@@ -2733,7 +3175,7 @@ public class ServerPlayer extends Player { +@@ -2841,7 +3283,7 @@ public class ServerPlayer extends Player { this.experienceLevel = this.newLevel; this.totalExperience = this.newTotalExp; this.experienceProgress = 0; @@ -14833,10 +14860,10 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..36d074d1abed62b09ca808dc2774bc83 this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DEATH); this.effectsDirty = true; diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -index a7b217ddbcbf92513bd38101fdfca2075505e267..8d2d0852ca5d137a74ba7be9a58e45c6bb832552 100644 +index 5cedce1f432f6b809b25269242a16477682c824f..990879f69e4ee37d6633c77ea31433736dd154f8 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -128,7 +128,7 @@ public class ServerPlayerGameMode { +@@ -131,7 +131,7 @@ public class ServerPlayerGameMode { BlockState iblockdata; if (this.hasDelayedDestroy) { @@ -14845,7 +14872,7 @@ index a7b217ddbcbf92513bd38101fdfca2075505e267..8d2d0852ca5d137a74ba7be9a58e45c6 if (iblockdata == null || iblockdata.isAir()) { // Paper - Don't allow digging into unloaded chunks this.hasDelayedDestroy = false; } else { -@@ -141,7 +141,7 @@ public class ServerPlayerGameMode { +@@ -144,7 +144,7 @@ public class ServerPlayerGameMode { } } else if (this.isDestroyingBlock) { // Paper start - Don't allow digging into unloaded chunks; don't want to do same logic as above, return instead @@ -14854,7 +14881,7 @@ index a7b217ddbcbf92513bd38101fdfca2075505e267..8d2d0852ca5d137a74ba7be9a58e45c6 if (iblockdata == null) { this.isDestroyingBlock = false; return; -@@ -416,7 +416,7 @@ public class ServerPlayerGameMode { +@@ -419,7 +419,7 @@ public class ServerPlayerGameMode { } else { // CraftBukkit start org.bukkit.block.BlockState state = bblock.getState(); @@ -14863,7 +14890,7 @@ index a7b217ddbcbf92513bd38101fdfca2075505e267..8d2d0852ca5d137a74ba7be9a58e45c6 // CraftBukkit end BlockState iblockdata1 = block.playerWillDestroy(this.level, pos, iblockdata, this.player); boolean flag = this.level.removeBlock(pos, false); -@@ -444,8 +444,8 @@ public class ServerPlayerGameMode { +@@ -447,8 +447,8 @@ public class ServerPlayerGameMode { // return true; // CraftBukkit } // CraftBukkit start @@ -14875,7 +14902,7 @@ index a7b217ddbcbf92513bd38101fdfca2075505e267..8d2d0852ca5d137a74ba7be9a58e45c6 org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, itemsToDrop); // Paper - capture all item additions to the world } diff --git a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java -index 17b624294fc0cab2976e3804e6c9a24b91a0e3aa..7c10a1f9f7bcb1711a05cddabe0cc86258d49a57 100644 +index 8ef22f8f0d6da49247a90152e5cfa9ffc7f596a4..cc274fee6cd0a8b532ea2cf7be2876d9f5a708ee 100644 --- a/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java +++ b/src/main/java/net/minecraft/server/level/ThreadedLevelLightEngine.java @@ -103,10 +103,15 @@ public class ThreadedLevelLightEngine extends LevelLightEngine implements AutoCl @@ -14985,16 +15012,17 @@ 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 9c3f8f79c2b3389a118dce9a1558edda52446833..8c455cda45ca2d724fbc140d53ffc7ecba3ca44c 100644 +index 1351423a12c19a01f602a202832372a399e6a867..888cf5257fba032b9edd95a89e71ca8b4ed1fb81 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 { +@@ -87,6 +87,14 @@ public class WorldGenRegion implements WorldGenLevel { private final AtomicLong subTickCount = new AtomicLong(); private static final ResourceLocation WORLDGEN_REGION_RANDOM = new ResourceLocation("worldgen_region_random"); + // Folia start - region threading ++ private final net.minecraft.world.level.StructureManager structureManager; + @Override -+ public StructureManager structureManager() { ++ public net.minecraft.world.level.StructureManager structureManager() { + return this.structureManager; + } + // Folia end - region threading @@ -15002,12 +15030,20 @@ index 9c3f8f79c2b3389a118dce9a1558edda52446833..8c455cda45ca2d724fbc140d53ffc7ec public WorldGenRegion(ServerLevel world, List chunks, ChunkStatus status, int placementRadius) { this.generatingStatus = status; this.writeRadiusCutoff = placementRadius; +@@ -106,6 +114,7 @@ public class WorldGenRegion implements WorldGenLevel { + this.biomeManager = new BiomeManager(this, BiomeManager.obfuscateSeed(this.seed)); + this.firstPos = ((ChunkAccess) chunks.get(0)).getPos(); + this.lastPos = ((ChunkAccess) chunks.get(chunks.size() - 1)).getPos(); ++ this.structureManager = world.structureManager().forWorldGenRegion(this); // Folia - region threading + } + } + diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 0306771b8f90dcdd77f151c19c6c2d75c41f8feb..22f0d91df0a81040d72c499fbff32b3a9d41598f 100644 +index 308aef9c4933b2bcdd622a34b68efab4a220fe4d..f907dbb55369395058091dd75ae435d2025d94dd 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -75,6 +75,10 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - // CraftBukkit end +@@ -107,6 +107,10 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + } + // Folia start - region threading @@ -15017,7 +15053,7 @@ index 0306771b8f90dcdd77f151c19c6c2d75c41f8feb..22f0d91df0a81040d72c499fbff32b3a @Override public void onDisconnect(Component reason) { // Paper start - Fix kick event leave message not being sent -@@ -82,10 +86,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -114,10 +118,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } public void onDisconnect(Component reason, @Nullable net.kyori.adventure.text.Component quitMessage) { // Paper end - Fix kick event leave message not being sent @@ -15036,7 +15072,7 @@ index 0306771b8f90dcdd77f151c19c6c2d75c41f8feb..22f0d91df0a81040d72c499fbff32b3a } -@@ -99,9 +111,9 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -131,9 +143,9 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack this.keepAlivePending = false; } else if (!this.isSingleplayerOwner()) { // Paper start - This needs to be handled on the main thread for plugins @@ -15048,7 +15084,7 @@ index 0306771b8f90dcdd77f151c19c6c2d75c41f8feb..22f0d91df0a81040d72c499fbff32b3a // Paper end - This needs to be handled on the main thread for plugins } -@@ -292,24 +304,8 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -348,24 +360,8 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack if (this.processedDisconnect) { return; } @@ -15075,7 +15111,7 @@ index 0306771b8f90dcdd77f151c19c6c2d75c41f8feb..22f0d91df0a81040d72c499fbff32b3a return; } -@@ -340,7 +336,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -396,7 +392,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack Objects.requireNonNull(this.connection); // CraftBukkit - Don't wait @@ -15085,18 +15121,18 @@ index 0306771b8f90dcdd77f151c19c6c2d75c41f8feb..22f0d91df0a81040d72c499fbff32b3a protected boolean isSingleplayerOwner() { diff --git a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -index 87c5690774363edc1b7ebff10b041e48c0a6d56d..18113fdd0d3f269e2ffb3b661d6adfa5b20d7386 100644 +index e4086bea596e5f5d71491e0b7ad650d76939b8f9..5de4b707c9bf512649924a99afed55d657d03c44 100644 --- a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -@@ -43,6 +43,7 @@ public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketLis - @Nullable - private ConfigurationTask currentTask; +@@ -46,6 +46,7 @@ public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketLis private ClientInformation clientInformation; + @Nullable + private SynchronizeRegistriesTask synchronizeRegistriesTask; + public boolean switchToMain = false; // Folia - region threading - rewrite login process - public ServerConfigurationPacketListenerImpl(MinecraftServer minecraftserver, Connection networkmanager, CommonListenerCookie commonlistenercookie, ServerPlayer player) { // CraftBukkit - super(minecraftserver, networkmanager, commonlistenercookie, player); // CraftBukkit -@@ -131,7 +132,57 @@ public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketLis + // CraftBukkit start + public ServerConfigurationPacketListenerImpl(MinecraftServer minecraftserver, Connection networkmanager, CommonListenerCookie commonlistenercookie, ServerPlayer player) { +@@ -150,7 +151,58 @@ public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketLis ServerPlayer entityplayer = playerlist.getPlayerForLogin(this.gameProfile, this.clientInformation, this.player); // CraftBukkit @@ -15134,7 +15170,7 @@ index 87c5690774363edc1b7ebff10b041e48c0a6d56d..18113fdd0d3f269e2ffb3b661d6adfa5 + ServerConfigurationPacketListenerImpl.this.connection, + entityplayer, + clientData, -+ data.getValue(), ++ java.util.Optional.ofNullable(data.getValue()), + lastKnownName.getValue(), + loc + ); @@ -15150,16 +15186,17 @@ index 87c5690774363edc1b7ebff10b041e48c0a6d56d..18113fdd0d3f269e2ffb3b661d6adfa5 + // assume toComplete will not be invoked + // ensure global tick thread owns the connection again, to properly disconnect it + this.switchToMain = false; ++ throw new RuntimeException(throwable); + } + // Folia end - region threading - rewrite login process - this.connection.resumeInboundAfterProtocolChange(); } catch (Exception exception) { ServerConfigurationPacketListenerImpl.LOGGER.error("Couldn't place player in world", exception); + // Paper start - Debugging diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java -index 586521a2cbb1d4dcfb912029f65e4363ec7674a7..6e95017f4c36208abdf344e3b7d55efe2d5b4e10 100644 +index 8aff5129f85ab5729b3da2e465871be62d15bdf2..8044271ff01dfc6808f5a3b60be74f6ddeee1e8f 100644 --- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java +++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java -@@ -152,10 +152,13 @@ public class ServerConnectionListener { +@@ -161,10 +161,13 @@ public class ServerConnectionListener { }); } // Paper end - Add support for proxy protocol @@ -15174,7 +15211,7 @@ index 586521a2cbb1d4dcfb912029f65e4363ec7674a7..6e95017f4c36208abdf344e3b7d55efe } }).group(eventloopgroup).localAddress(address)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit // Paper - Unix domain socket support } -@@ -218,7 +221,7 @@ public class ServerConnectionListener { +@@ -226,7 +229,7 @@ public class ServerConnectionListener { // Spigot Start this.addPending(); // Paper - prevent blocking on adding a new connection while the server is ticking // This prevents players from 'gaming' the server, and strategically relogging to increase their position in the tick order @@ -15184,10 +15221,10 @@ 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 fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c62957226eb3 100644 +index b9b3277c8ed94e0cd30b20b9c00a33eaad48e5ac..b4c4e72ddd09231747f82962a9d2883c6415ce30 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 +@@ -300,7 +300,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl private final LastSeenMessagesValidator lastSeenMessages = new LastSeenMessagesValidator(20); private final MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault(); private final FutureChain chatMessageChain; @@ -15196,10 +15233,10 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); // Paper - Limit client sign length public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player, CommonListenerCookie clientData) { -@@ -309,10 +309,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -317,10 +317,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } - // CraftBukkit start - add fields + // CraftBukkit start - add fields and methods - private int lastTick = MinecraftServer.currentTick; + private long lastTick = Util.getMillis() / 50L; // Folia - region threading private int allowedPlayerTicks = 1; @@ -15210,7 +15247,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 private int dropCount = 0; private boolean hasMoved = false; -@@ -324,8 +324,21 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -332,8 +332,21 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl private boolean justTeleported = false; // CraftBukkit end @@ -15232,7 +15269,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 if (this.ackBlockChangesUpTo > -1) { this.send(new ClientboundBlockChangedAckPacket(this.ackBlockChangesUpTo)); this.ackBlockChangesUpTo = -1; -@@ -374,7 +387,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -382,7 +395,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.aboveGroundVehicleTickCount = 0; } @@ -15241,7 +15278,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 // CraftBukkit start for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !this.chatSpamTickCount.compareAndSet(spam, spam - 1); ) ; if (tabSpamLimiter.get() > 0) tabSpamLimiter.getAndDecrement(); // Paper - configurable tab spam limits -@@ -411,6 +424,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -431,6 +444,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.lastGoodX = this.player.getX(); this.lastGoodY = this.player.getY(); this.lastGoodZ = this.player.getZ(); @@ -15261,7 +15298,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 } @Override -@@ -511,9 +537,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -531,9 +557,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // Paper end - fix large move vectors killing the server // CraftBukkit start - handle custom speeds and skipped ticks @@ -15274,7 +15311,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 ++this.receivedMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount; -@@ -587,7 +614,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -607,7 +634,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } entity.absMoveTo(d3, d4, d5, f, f1); @@ -15283,7 +15320,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 // Paper start - optimise out extra getCubes boolean teleportBack = flag2; // violating this is always a fail -@@ -600,11 +627,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -620,11 +647,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } if (teleportBack) { // Paper end - optimise out extra getCubes entity.absMoveTo(d0, d1, d2, f, f1); @@ -15304,7 +15341,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 // CraftBukkit start - fire PlayerMoveEvent Player player = this.getCraftPlayer(); if (!this.hasMoved) { -@@ -644,7 +679,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -664,7 +699,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // If the event is cancelled we move the player back to their old location. if (event.isCancelled()) { @@ -15313,7 +15350,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 return; } -@@ -652,7 +687,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -672,7 +707,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. // We only do this if the Event was not cancelled. if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { @@ -15322,7 +15359,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 return; } -@@ -768,7 +803,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -788,7 +823,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // Paper - AsyncTabCompleteEvent; run this async // CraftBukkit start if (this.chatSpamTickCount.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamLimit && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper - configurable tab spam limits @@ -15331,7 +15368,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 return; } // CraftBukkit end -@@ -780,7 +815,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -800,7 +835,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // Paper start final int index; if (packet.getCommand().length() > 64 && ((index = packet.getCommand().indexOf(' ')) == -1 || index >= 64)) { @@ -15340,7 +15377,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 return; } // Paper end -@@ -805,7 +840,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -825,7 +860,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } // This needs to be on main @@ -15349,7 +15386,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 } else if (!completions.isEmpty()) { final com.mojang.brigadier.suggestion.SuggestionsBuilder builder0 = new com.mojang.brigadier.suggestion.SuggestionsBuilder(packet.getCommand(), stringreader.getTotalLength()); final com.mojang.brigadier.suggestion.SuggestionsBuilder builder = builder0.createOffset(builder0.getInput().lastIndexOf(' ') + 1); -@@ -1146,7 +1181,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1165,7 +1200,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length; if (byteLength > 256 * 4) { ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with with a page too large!"); @@ -15358,7 +15395,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 return; } byteTotal += byteLength; -@@ -1169,17 +1204,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1188,17 +1223,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (byteTotal > byteAllowed) { ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send too large of a book. Book Size: " + byteTotal + " - Allowed: "+ byteAllowed + " - Pages: " + pageList.size()); @@ -15378,9 +15415,9 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 - this.lastBookTick = MinecraftServer.currentTick; + this.lastBookTick = this.lastTick; // CraftBukkit end - int i = packet.getSlot(); + int i = packet.slot(); -@@ -1199,7 +1234,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1218,7 +1253,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.updateBookContents(list1, i); }; @@ -15401,7 +15438,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 } } -@@ -1385,9 +1432,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1374,9 +1421,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl int i = this.receivedMovePacketCount - this.knownMovePacketCount; // CraftBukkit start - handle custom speeds and skipped ticks @@ -15414,7 +15451,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 if (i > Math.max(this.allowedPlayerTicks, 5)) { ServerGamePacketListenerImpl.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName().getString(), i); -@@ -1577,7 +1625,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1568,7 +1616,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // If the event is cancelled we move the player back to their old location. if (event.isCancelled()) { @@ -15423,7 +15460,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 return; } -@@ -1585,7 +1633,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1576,7 +1624,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. // We only do this if the Event was not cancelled. if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { @@ -15432,7 +15469,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 return; } -@@ -1805,9 +1853,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1803,9 +1851,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (!this.player.isSpectator()) { // limit how quickly items can be dropped // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick. @@ -15444,7 +15481,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 } else { // Else we increment the drop count and check the amount. this.dropCount++; -@@ -1835,7 +1883,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1833,7 +1881,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl case ABORT_DESTROY_BLOCK: case STOP_DESTROY_BLOCK: // Paper start - Don't allow digging into unloaded chunks @@ -15453,13 +15490,13 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 this.player.connection.ackBlockChangesUpTo(packet.getSequence()); return; } -@@ -1919,7 +1967,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1916,7 +1964,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + // Paper end - improve distance check BlockPos blockposition = movingobjectpositionblock.getBlockPos(); - Vec3 vec3d1 = Vec3.atCenterOf(blockposition); -- if (this.player.getEyePosition().distanceToSqr(vec3d1) <= ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) { -+ if (io.papermc.paper.util.TickThread.isTickThreadFor(this.player.serverLevel(), blockposition.getX() >> 4, blockposition.getZ() >> 4, 8) && this.player.getEyePosition().distanceToSqr(vec3d1) <= ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) { // Folia - do not allow players to interact with blocks outside the current region - Vec3 vec3d2 = vec3d.subtract(vec3d1); +- if (this.player.canInteractWithBlock(blockposition, 1.0D)) { ++ if (io.papermc.paper.util.TickThread.isTickThreadFor(this.player.serverLevel(), blockposition.getX() >> 4, blockposition.getZ() >> 4, 8) && this.player.canInteractWithBlock(blockposition, 1.0D)) { // Folia - do not allow players to interact with blocks outside the current region + Vec3 vec3d1 = vec3d.subtract(Vec3.atCenterOf(blockposition)); double d0 = 1.0000001D; @@ -2033,7 +2081,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -15471,7 +15508,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 return; } } -@@ -2070,7 +2118,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2068,7 +2116,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } // CraftBukkit end ServerGamePacketListenerImpl.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), reason.getString()); @@ -15480,7 +15517,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 super.onDisconnect(reason, quitMessage); // Paper - Fix kick event leave message not being sent } -@@ -2079,6 +2127,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2077,6 +2125,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.removePlayerFromWorld(null); } @@ -15489,7 +15526,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 private void removePlayerFromWorld(@Nullable net.kyori.adventure.text.Component quitMessage) { // Paper end - Fix kick event leave message not being sent this.chatMessageChain.close(); -@@ -2091,6 +2141,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2089,6 +2139,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.player.disconnect(); // Paper start - Adventure quitMessage = quitMessage == null ? this.server.getPlayerList().remove(this.player) : this.server.getPlayerList().remove(this.player, quitMessage); // Paper - pass in quitMessage to fix kick message not being used @@ -15498,43 +15535,16 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) { this.server.getPlayerList().broadcastSystemMessage(PaperAdventure.asVanilla(quitMessage), false); // Paper end -@@ -2143,7 +2195,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - } - // CraftBukkit end - if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.message())) { -+ // Folia - region threading - this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add cause -+ // Folia - region threading - } else { - Optional optional = this.tryHandleChat(packet.lastSeenMessages()); - -@@ -2175,21 +2229,22 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - @Override - public void handleChatCommand(ServerboundChatCommandPacket packet) { - if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.command())) { -+ // Folia - region threading - this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper -+ // Folia - region threading - } else { - Optional optional = this.tryHandleChat(packet.lastSeenMessages()); - - if (optional.isPresent()) { -- this.server.submit(() -> { -+ this.player.getBukkitEntity().taskScheduler.schedule((ServerPlayer player) -> { // Folia - region threading - // CraftBukkit start - SPIGOT-7346: Prevent disconnected players from executing commands - if (this.player.hasDisconnected()) { - return; - } - // CraftBukkit end -- - this.performChatCommand(packet, (LastSeenMessages) optional.get()); - this.detectRateSpam("/" + packet.command()); // Spigot -- }); -+ }, null, 1L); // Folia - region threading +@@ -2337,7 +2389,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + this.player.resetLastActionTime(); + // CraftBukkit start + if (sync) { +- this.server.execute(runnable); ++ this.player.getBukkitEntity().taskScheduler.schedule((ServerPlayer player) -> runnable.run(), null, 1L); // Folia - region threading + } else { + runnable.run(); } - - } -@@ -2323,7 +2378,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2395,7 +2447,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl String originalFormat = event.getFormat(), originalMessage = event.getMessage(); this.cserver.getPluginManager().callEvent(event); @@ -15543,7 +15553,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 // Evil plugins still listening to deprecated event final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), event.getRecipients()); queueEvent.setCancelled(event.isCancelled()); -@@ -2434,6 +2489,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2493,6 +2545,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (s.isEmpty()) { ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message"); } else if (this.getCraftPlayer().isConversing()) { @@ -15551,7 +15561,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 final String conversationInput = s; this.server.processQueue.add(new Runnable() { @Override -@@ -2674,8 +2730,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2724,8 +2777,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // Spigot End public void switchToConfig() { @@ -15575,10 +15585,10 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 + // once waitingForSwitchToConfig is set, the global tick thread will own the connection + } // Folia end - rewrite login process - move connection ownership to global region + this.waitingForSwitchToConfig = true; // Folia - rewrite login process - fix bad ordering of this field write - moved down - this.send(new ClientboundStartConfigurationPacket()); + this.send(ClientboundStartConfigurationPacket.INSTANCE); + this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); } - -@@ -2700,7 +2773,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2751,7 +2821,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.player.resetLastActionTime(); this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); @@ -15587,7 +15597,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 if (!worldserver.getWorldBorder().isWithinBounds(entity.blockPosition())) { return; } -@@ -2830,6 +2903,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2895,6 +2965,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl switch (packetplayinclientcommand_enumclientcommand) { case PERFORM_RESPAWN: if (this.player.wonGame) { @@ -15600,7 +15610,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 this.player.wonGame = false; this.player = this.server.getPlayerList().respawn(this.player, this.server.getLevel(this.player.getRespawnDimension()), true, null, true, RespawnReason.END_PORTAL, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag.END_PORTAL); // Paper - Expand PlayerRespawnEvent CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); -@@ -2838,6 +2917,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2903,6 +2979,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl return; } @@ -15619,7 +15629,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 this.player = this.server.getPlayerList().respawn(this.player, false, RespawnReason.DEATH); if (this.server.isHardcore()) { this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper - Expand PlayerGameModeChangeEvent -@@ -3209,7 +3300,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -3274,7 +3362,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // Paper start - auto recipe limit if (!org.bukkit.Bukkit.isPrimaryThread()) { if (this.recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) { @@ -15628,7 +15638,7 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 return; } } -@@ -3378,7 +3469,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -3443,7 +3531,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.filterTextPacket(list).thenAcceptAsync((list1) -> { this.updateSignText(packet, list1); @@ -15649,10 +15659,10 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..e7b510dee355a9865bd67f5aea52c629 private void updateSignText(ServerboundSignUpdatePacket packet, List signText) { diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index c5fa9f4d28f9a7f64a50a902ee5e631bfc00119c..58cdb65083134680230d7070f9f6209f2d32873b 100644 +index b656741eb68adeb04bf995f1045902cb6bd5f2e7..734f745ce383c8398fdedeb6fd71277e1482a4a6 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -83,7 +83,11 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -104,7 +104,11 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, } // Paper end - Do not allow logins while the server is shutting down if (this.state == ServerLoginPacketListenerImpl.State.VERIFYING) { @@ -15665,16 +15675,16 @@ index c5fa9f4d28f9a7f64a50a902ee5e631bfc00119c..58cdb65083134680230d7070f9f6209f this.verifyLoginAndFinishConnectionSetup((GameProfile) Objects.requireNonNull(this.authenticatedProfile)); } // Paper - prevent logins to be processed even though disconnect was called } -@@ -205,7 +209,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -250,7 +254,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, })); } -- boolean flag = playerlist.disconnectAllPlayersWithProfile(profile, this.player); // CraftBukkit - add player reference -+ boolean flag = false && playerlist.disconnectAllPlayersWithProfile(profile, this.player); // CraftBukkit - add player reference // Folia - rewrite login process - always false here +- boolean flag = playerlist.disconnectAllPlayersWithProfile(gameprofile, this.player); // CraftBukkit - add player reference ++ boolean flag = false && playerlist.disconnectAllPlayersWithProfile(gameprofile, this.player); // CraftBukkit - add player reference // Folia - rewrite login process - always false here if (flag) { this.state = ServerLoginPacketListenerImpl.State.WAITING_FOR_DUPE_DISCONNECT; -@@ -325,7 +329,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -370,7 +374,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, uniqueId = gameprofile.getId(); // Paper end - Add more fields to AsyncPlayerPreLoginEvent @@ -15736,10 +15746,10 @@ index 8b1da1fb5ca27432a39aff6dbc452b793268dab5..e83f3676d5a194fa8d3d1567edcb4b6f // Guess we don't have a date } diff --git a/src/main/java/net/minecraft/server/players/OldUsersConverter.java b/src/main/java/net/minecraft/server/players/OldUsersConverter.java -index 45d4638d568ea2aee805aa1b0542533019e5870d..599feff33b43623d7c6bd22158afa730efd5370d 100644 +index 653856d0b8dcf2baf4cc77a276f17c8cc1fa717e..3f5639f26f249ca10e03826231d087ab715b7ce7 100644 --- a/src/main/java/net/minecraft/server/players/OldUsersConverter.java +++ b/src/main/java/net/minecraft/server/players/OldUsersConverter.java -@@ -510,7 +510,7 @@ public class OldUsersConverter { +@@ -516,7 +516,7 @@ public class OldUsersConverter { Date date1; try { @@ -15749,10 +15759,10 @@ index 45d4638d568ea2aee805aa1b0542533019e5870d..599feff33b43623d7c6bd22158afa730 date1 = fallback; } diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630e7659443 100644 +index a2142930b4d4b05987c90496fb9d733d99040aa0..67b832c9a36f8af245e381c7fa3c56a7e9becd1e 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -132,10 +132,10 @@ public abstract class PlayerList { +@@ -134,10 +134,10 @@ public abstract class PlayerList { public static final Component DUPLICATE_LOGIN_DISCONNECT_MESSAGE = Component.translatable("multiplayer.disconnect.duplicate_login"); private static final Logger LOGGER = LogUtils.getLogger(); private static final int SEND_PLAYER_INFO_INTERVAL = 600; @@ -15765,7 +15775,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 private final UserBanList bans; private final IpBanList ipBans; private final ServerOpList ops; -@@ -156,9 +156,63 @@ public abstract class PlayerList { +@@ -158,9 +158,63 @@ public abstract class PlayerList { // CraftBukkit start private CraftServer cserver; @@ -15830,7 +15840,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 public PlayerList(MinecraftServer server, LayeredRegistryAccess registryManager, PlayerDataStorage saveHandler, int maxPlayers) { this.cserver = server.server = new CraftServer((DedicatedServer) server, this); server.console = new com.destroystokyo.paper.console.TerminalConsoleCommandSender(); // Paper -@@ -179,7 +233,7 @@ public abstract class PlayerList { +@@ -181,7 +235,7 @@ public abstract class PlayerList { } abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor @@ -15845,10 +15855,10 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 } + // Folia start - region threading - rewrite login process + // must write to these before toComplete is invoked -+ data.setValue(nbttagcompound); ++ data.setValue(optional.orElse(null)); + lastKnownName.setValue(s); + // Folia end - region threading - rewrite login process - if (nbttagcompound == null || invalidPlayerWorld) { + if (optional.isEmpty() || invalidPlayerWorld[0]) { // Paper end - reset to main world spawn if first spawn or invalid world - player.fudgeSpawnLocation(worldserver1); // Paper - Don't move existing players to world spawn + ServerPlayer.fudgeSpawnLocation(worldserver1, player, toComplete); // Paper - Don't move existing players to world spawn // Folia - region threading @@ -15866,9 +15876,9 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 + // Folia start - region threading - rewrite login process + return; + } -+ // nbttagcomound -> player data ++ // optional -> player data + // s -> last known name -+ public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie clientData, CompoundTag nbttagcompound, String s, Location selectedSpawn) { ++ public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie clientData, Optional optional, String s, Location selectedSpawn) { + ServerLevel worldserver1 = ((CraftWorld)selectedSpawn.getWorld()).getHandle(); + player.setPosRaw(selectedSpawn.getX(), selectedSpawn.getY(), selectedSpawn.getZ()); + player.lastSave = System.nanoTime(); // changed to nanoTime @@ -15886,16 +15896,16 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 worldserver1 = ((CraftWorld) loc.getWorld()).getHandle(); @@ -288,6 +366,10 @@ public abstract class PlayerList { - player.loadGameTypes(nbttagcompound); + player.loadGameTypes((CompoundTag) optional.orElse(null)); // CraftBukkit - decompile error ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, clientData); + // Folia start - rewrite login process + // only after setting the connection listener to game type, add the connection to this regions list + worldserver1.getCurrentWorldData().connections.add(connection); + // Folia end - rewrite login process + + connection.setupInboundProtocol(GameProtocols.SERVERBOUND.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection); GameRules gamerules = worldserver1.getGameRules(); - boolean flag = gamerules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN); - boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); -@@ -303,7 +385,7 @@ public abstract class PlayerList { +@@ -305,7 +387,7 @@ public abstract class PlayerList { this.sendPlayerPermissionLevel(player); player.getStats().markAllDirty(); player.getRecipeBook().sendInitialRecipeBook(player); @@ -15904,7 +15914,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 this.server.invalidateStatus(); MutableComponent ichatmutablecomponent; -@@ -345,7 +427,7 @@ public abstract class PlayerList { +@@ -347,7 +429,7 @@ public abstract class PlayerList { this.cserver.getPluginManager().callEvent(playerJoinEvent); if (!player.connection.isAcceptingMessages()) { @@ -15913,7 +15923,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 } final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); -@@ -360,8 +442,7 @@ public abstract class PlayerList { +@@ -362,8 +444,7 @@ public abstract class PlayerList { ClientboundPlayerInfoUpdatePacket packet = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player)); // Paper - Add Listing API for Player final List onlinePlayers = Lists.newArrayListWithExpectedSize(this.players.size() - 1); // Paper - Use single player info update packet on join @@ -15923,7 +15933,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 if (entityplayer1.getBukkitEntity().canSee(bukkitPlayer)) { // Paper start - Add Listing API for Player -@@ -483,7 +564,7 @@ public abstract class PlayerList { +@@ -482,7 +563,7 @@ public abstract class PlayerList { // Paper start - Configurable player collision; Add to collideRule team if needed final net.minecraft.world.scores.Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard(); final PlayerTeam collideRuleTeam = scoreboard.getPlayerTeam(this.collideRuleTeamName); @@ -15932,7 +15942,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam); } // Paper end - Configurable player collision -@@ -577,7 +658,7 @@ public abstract class PlayerList { +@@ -575,7 +656,7 @@ public abstract class PlayerList { protected void save(ServerPlayer player) { if (!player.getBukkitEntity().isPersistent()) return; // CraftBukkit @@ -15941,7 +15951,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 this.playerIo.save(player); ServerStatsCounter serverstatisticmanager = (ServerStatsCounter) player.getStats(); // CraftBukkit -@@ -617,7 +698,7 @@ public abstract class PlayerList { +@@ -615,7 +696,7 @@ public abstract class PlayerList { // CraftBukkit end // Paper start - Configurable player collision; Remove from collideRule team if needed @@ -15950,7 +15960,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 final net.minecraft.world.scores.Scoreboard scoreBoard = this.server.getLevel(Level.OVERWORLD).getScoreboard(); final PlayerTeam team = scoreBoard.getPlayersTeam(this.collideRuleTeamName); if (entityplayer.getTeam() == team && team != null) { -@@ -657,7 +738,7 @@ public abstract class PlayerList { +@@ -655,7 +736,7 @@ public abstract class PlayerList { entityplayer.unRide(); worldserver.removePlayerImmediately(entityplayer, Entity.RemovalReason.UNLOADED_WITH_PLAYER); @@ -15959,7 +15969,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 entityplayer.getAdvancements().stopListening(); this.players.remove(entityplayer); this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot -@@ -676,8 +757,7 @@ public abstract class PlayerList { +@@ -674,8 +755,7 @@ public abstract class PlayerList { // CraftBukkit start // this.broadcastAll(new ClientboundPlayerInfoRemovePacket(List.of(entityplayer.getUUID()))); ClientboundPlayerInfoRemovePacket packet = new ClientboundPlayerInfoRemovePacket(List.of(entityplayer.getUUID())); @@ -15969,7 +15979,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { entityplayer2.connection.send(packet); -@@ -702,19 +782,12 @@ public abstract class PlayerList { +@@ -700,19 +780,12 @@ public abstract class PlayerList { ServerPlayer entityplayer; @@ -15991,7 +16001,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 } // Instead of kicking then returning, we need to store the kick reason -@@ -733,7 +806,7 @@ public abstract class PlayerList { +@@ -732,7 +805,7 @@ public abstract class PlayerList { ichatmutablecomponent = Component.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason()); if (gameprofilebanentry.getExpires() != null) { @@ -16000,7 +16010,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 } // return chatmessage; -@@ -746,14 +819,14 @@ public abstract class PlayerList { +@@ -745,14 +818,14 @@ public abstract class PlayerList { ichatmutablecomponent = Component.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason()); if (ipbanentry.getExpires() != null) { @@ -16017,7 +16027,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 event.disallow(PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure } } -@@ -819,6 +892,11 @@ public abstract class PlayerList { +@@ -818,6 +891,11 @@ public abstract class PlayerList { public ServerPlayer respawn(ServerPlayer entityplayer, ServerLevel worldserver, boolean flag, Location location, boolean avoidSuffocation, RespawnReason reason, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag...respawnFlags) { // Paper end - Expand PlayerRespawnEvent @@ -16029,7 +16039,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 entityplayer.stopRiding(); // CraftBukkit this.players.remove(entityplayer); this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot -@@ -1018,10 +1096,10 @@ public abstract class PlayerList { +@@ -1017,10 +1095,10 @@ public abstract class PlayerList { public void tick() { if (++this.sendAllPlayerInfoIn > 600) { // CraftBukkit start @@ -16043,7 +16053,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 @Override public boolean test(ServerPlayer input) { return target.getBukkitEntity().canSee(input.getBukkitEntity()); -@@ -1047,18 +1125,17 @@ public abstract class PlayerList { +@@ -1046,18 +1124,17 @@ public abstract class PlayerList { // CraftBukkit start - add a world/entity limited version public void broadcastAll(Packet packet, net.minecraft.world.entity.player.Player entityhuman) { @@ -16066,7 +16076,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 } } -@@ -1102,8 +1179,7 @@ public abstract class PlayerList { +@@ -1101,8 +1178,7 @@ public abstract class PlayerList { if (scoreboardteam == null) { this.broadcastSystemMessage(message, false); } else { @@ -16076,7 +16086,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 if (entityplayer.getTeam() != scoreboardteam) { entityplayer.sendSystemMessage(message); -@@ -1114,10 +1190,12 @@ public abstract class PlayerList { +@@ -1113,10 +1189,12 @@ public abstract class PlayerList { } public String[] getPlayerNamesArray() { @@ -16092,7 +16102,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 } return astring; -@@ -1136,7 +1214,9 @@ public abstract class PlayerList { +@@ -1135,7 +1213,9 @@ public abstract class PlayerList { ServerPlayer entityplayer = this.getPlayer(profile.getId()); if (entityplayer != null) { @@ -16102,7 +16112,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 } } -@@ -1146,7 +1226,10 @@ public abstract class PlayerList { +@@ -1145,7 +1225,10 @@ public abstract class PlayerList { ServerPlayer entityplayer = this.getPlayer(profile.getId()); if (entityplayer != null) { @@ -16113,7 +16123,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 } } -@@ -1207,8 +1290,7 @@ public abstract class PlayerList { +@@ -1206,8 +1289,7 @@ public abstract class PlayerList { } public void broadcast(@Nullable net.minecraft.world.entity.player.Player player, double x, double y, double z, double distance, ResourceKey worldKey, Packet packet) { @@ -16123,7 +16133,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 // CraftBukkit start - Test if player receiving packet can see the source of the packet if (player != null && !entityplayer.getBukkitEntity().canSee(player.getBukkitEntity())) { -@@ -1238,12 +1320,21 @@ public abstract class PlayerList { +@@ -1237,12 +1319,21 @@ public abstract class PlayerList { io.papermc.paper.util.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main MinecraftTimings.savePlayers.startTiming(); // Paper int numSaved = 0; @@ -16150,7 +16160,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 } // Paper end - Incremental chunk and player saving } -@@ -1362,6 +1453,20 @@ public abstract class PlayerList { +@@ -1361,6 +1452,20 @@ public abstract class PlayerList { } public void removeAll(boolean isRestarting) { @@ -16171,7 +16181,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 // Paper end // CraftBukkit start - disconnect safely for (ServerPlayer player : this.players) { -@@ -1371,7 +1476,7 @@ public abstract class PlayerList { +@@ -1370,7 +1475,7 @@ public abstract class PlayerList { // CraftBukkit end // Paper start - Configurable player collision; Remove collideRule team if it exists @@ -16181,7 +16191,7 @@ index 1e5f709115007ff19901c0a6c3cf884d9e4d3a6c..08daa5ed0b4b599836b97eef1e53e630 final PlayerTeam team = scoreboard.getPlayersTeam(this.collideRuleTeamName); if (team != null) scoreboard.removePlayerTeam(team); diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java -index 7e133752ccb1ea7c0b4fa781feb1a88e2cfdcf6d..9756d1750f40bda0578f4c965953a27c384e7db2 100644 +index c038da20b76c0b7b1c18471b20be01e849d29f3a..87114cc9ce7489ff8e29e2d88ebb0d47eb68232e 100644 --- a/src/main/java/net/minecraft/server/players/StoredUserList.java +++ b/src/main/java/net/minecraft/server/players/StoredUserList.java @@ -103,6 +103,7 @@ public abstract class StoredUserList> { @@ -16267,10 +16277,10 @@ index 0793dfe47e68a2b48b010aad5b12dcfa1701293a..50e3ad4ce20915943fbd9115cec221a3 @Override public boolean remove(Object object) { diff --git a/src/main/java/net/minecraft/util/SpawnUtil.java b/src/main/java/net/minecraft/util/SpawnUtil.java -index c5d54abfcbd74c3041d9a46f77705460fa65ce30..025bf2306851347a12035d81e4dd92a47dc00dba 100644 +index 5c8e36ea8287029b1789719c687bac1a2c4c3a69..db0fe7fa257842eacd250f4cae6f549b9a0a91c9 100644 --- a/src/main/java/net/minecraft/util/SpawnUtil.java +++ b/src/main/java/net/minecraft/util/SpawnUtil.java -@@ -59,7 +59,7 @@ public class SpawnUtil { +@@ -58,7 +58,7 @@ public class SpawnUtil { return Optional.of(t0); } @@ -16280,10 +16290,10 @@ index c5d54abfcbd74c3041d9a46f77705460fa65ce30..025bf2306851347a12035d81e4dd92a4 } } diff --git a/src/main/java/net/minecraft/world/RandomSequences.java b/src/main/java/net/minecraft/world/RandomSequences.java -index a9bbe79831183e119562e27038e4a9c651529bf4..645c0823718a4013aba149c693b267ea59691d2d 100644 +index 24c60dd75bbb59e33d64db70cd31f1f2c1c55c4a..b31681b770dd7e52b434d237124d6d823f7c6a5a 100644 --- a/src/main/java/net/minecraft/world/RandomSequences.java +++ b/src/main/java/net/minecraft/world/RandomSequences.java -@@ -20,7 +20,7 @@ public class RandomSequences extends SavedData { +@@ -21,7 +21,7 @@ public class RandomSequences extends SavedData { private int salt; private boolean includeWorldSeed = true; private boolean includeSequenceId = true; @@ -16291,8 +16301,8 @@ index a9bbe79831183e119562e27038e4a9c651529bf4..645c0823718a4013aba149c693b267ea + private final Map sequences = new java.util.concurrent.ConcurrentHashMap<>(); // Folia - region threading public static SavedData.Factory factory(long seed) { - return new SavedData.Factory<>(() -> new RandomSequences(seed), nbt -> load(seed, nbt), DataFixTypes.SAVED_DATA_RANDOM_SEQUENCES); -@@ -113,61 +113,61 @@ public class RandomSequences extends SavedData { + return new SavedData.Factory<>(() -> new RandomSequences(seed), (nbt, registryLookup) -> load(seed, nbt), DataFixTypes.SAVED_DATA_RANDOM_SEQUENCES); +@@ -114,61 +114,61 @@ public class RandomSequences extends SavedData { @Override public RandomSource fork() { RandomSequences.this.setDirty(); @@ -16365,19 +16375,19 @@ index a9bbe79831183e119562e27038e4a9c651529bf4..645c0823718a4013aba149c693b267ea @Override diff --git a/src/main/java/net/minecraft/world/damagesource/CombatTracker.java b/src/main/java/net/minecraft/world/damagesource/CombatTracker.java -index 7056c8ca7a87748f14142c6af274aae492f29f1c..c92063c527aef85c932453d4761fd1955542dd98 100644 +index 99a7e9eb75231c15bd8bb24fbb4e296bc9fdedff..695f5b452d0abc4e474e8e55134a122d3d216c5a 100644 --- a/src/main/java/net/minecraft/world/damagesource/CombatTracker.java +++ b/src/main/java/net/minecraft/world/damagesource/CombatTracker.java -@@ -52,7 +52,7 @@ public class CombatTracker { +@@ -53,7 +53,7 @@ public class CombatTracker { } private Component getMessageForAssistedFall(Entity attacker, Component attackerDisplayName, String itemDeathTranslationKey, String deathTranslationKey) { - ItemStack itemStack = attacker instanceof LivingEntity livingEntity ? livingEntity.getMainHandItem() : ItemStack.EMPTY; + ItemStack itemStack = attacker instanceof LivingEntity livingEntity && io.papermc.paper.util.TickThread.isTickThreadFor(livingEntity) ? livingEntity.getMainHandItem() : ItemStack.EMPTY; // Folia - region threading - return !itemStack.isEmpty() && itemStack.hasCustomHoverName() + return !itemStack.isEmpty() && itemStack.has(DataComponents.CUSTOM_NAME) ? Component.translatable(itemDeathTranslationKey, this.mob.getDisplayName(), attackerDisplayName, itemStack.getDisplayName()) : Component.translatable(deathTranslationKey, this.mob.getDisplayName(), attackerDisplayName); -@@ -79,7 +79,7 @@ public class CombatTracker { +@@ -80,7 +80,7 @@ public class CombatTracker { @Nullable private static Component getDisplayName(@Nullable Entity entity) { @@ -16387,10 +16397,10 @@ index 7056c8ca7a87748f14142c6af274aae492f29f1c..c92063c527aef85c932453d4761fd195 public Component getDeathMessage() { diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java -index b26e4d58ea1898a5e4b31c3d6ab33f38835ab2c6..90781fffbb7e6293d3a30d6041dc30186c84caaf 100644 +index dd9638bdb228a53e72820e0e7cf6fe6fcc08fe4b..0fa04cab50f885f0e03215859c4919c843521d59 100644 --- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java +++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java -@@ -156,13 +156,13 @@ public class DamageSource { +@@ -173,13 +173,13 @@ public class DamageSource { LivingEntity entityliving1 = killed.getKillCredit(); String s1 = s + ".player"; @@ -16420,10 +16430,10 @@ index e9df8f8541b8a1b85c7d2925ff3cba813007a1ef..35e3e67c0c74f95007c55ee8fb44822a 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 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19c8ead97c 100644 +index 2bc85351e6e52f90da5fdb29d8d042a06132d742..8d3737dc1381cb0c179912c7cb215e1585cf772f 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 +@@ -173,7 +173,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // Paper start - Share random for entities to make them more random public static RandomSource SHARED_RANDOM = new RandomRandomSource(); @@ -16432,7 +16442,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 private boolean locked = false; @Override -@@ -244,7 +244,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -247,7 +247,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper public boolean collisionLoadChunks = false; // Paper @@ -16441,7 +16451,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 public @org.jetbrains.annotations.Nullable net.minecraft.server.level.ChunkMap.TrackedEntity tracker; // Paper public CraftEntity getBukkitEntity() { -@@ -378,7 +378,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -380,7 +380,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess private boolean hasGlowingTag; private final Set tags; private final double[] pistonDeltas; @@ -16450,7 +16460,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 private EntityDimensions dimensions; private float eyeHeight; public boolean isInPowderSnow; -@@ -479,28 +479,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -481,28 +481,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.isLegacyTrackingEntity = isLegacyTrackingEntity; } @@ -16480,7 +16490,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 // Paper end - optimise entity tracking public float getBukkitYaw() { return this.yRot; -@@ -567,6 +546,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -569,6 +548,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess public boolean updatingSectionStatus = false; // Paper end @@ -16500,7 +16510,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -825,6 +817,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -869,6 +861,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // CraftBukkit start public void postTick() { @@ -16513,7 +16523,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle if (!(this instanceof ServerPlayer) && this.isAlive()) { // Paper - don't attempt to teleport dead entities this.handleNetherPortal(); -@@ -847,7 +845,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -891,7 +889,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.walkDistO = this.walkDist; this.xRotO = this.getXRot(); this.yRotO = this.getYRot(); @@ -16522,7 +16532,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -1105,8 +1103,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1147,8 +1145,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } else { this.wasOnFire = this.isOnFire(); if (movementType == MoverType.PISTON) { @@ -16533,7 +16543,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 movement = this.limitPistonMovement(movement); if (movement.equals(Vec3.ZERO)) { return; -@@ -1433,7 +1431,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1475,7 +1473,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess if (movement.lengthSqr() <= 1.0E-7D) { return movement; } else { @@ -16542,7 +16552,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 if (i != this.pistonDeltasGameTime) { Arrays.fill(this.pistonDeltas, 0.0D); -@@ -3018,7 +3016,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3080,7 +3078,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.passengers = ImmutableList.copyOf(list); } @@ -16551,7 +16561,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 } } -@@ -3066,7 +3064,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3128,7 +3126,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } entity.boardingCooldown = 60; @@ -16560,7 +16570,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 } return true; // CraftBukkit } -@@ -3346,6 +3344,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3393,6 +3391,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @Nullable public PlayerTeam getTeam() { @@ -16572,7 +16582,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper - Perf: Disable Scoreboards for non players by default return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -3635,6 +3638,775 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3682,6 +3685,775 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.portalEntrancePos = original.portalEntrancePos; } @@ -17173,7 +17183,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 + destination.loadChunksAsync( + // add 32 so that the final search for a portal frame doesn't load any chunks + targetPos, portalSearchRadius + 32, -+ net.minecraft.world.level.chunk.ChunkStatus.EMPTY, ++ net.minecraft.world.level.chunk.status.ChunkStatus.EMPTY, + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH, + (chunks) -> { + BlockUtil.FoundRectangle portal = @@ -17348,7 +17358,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 @Nullable public Entity changeDimension(ServerLevel destination) { // CraftBukkit start -@@ -3643,6 +4415,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3690,6 +4462,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @Nullable public Entity teleportTo(ServerLevel worldserver, Vec3 location) { @@ -17360,7 +17370,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 // CraftBukkit end // Paper start - Fix item duplication and teleport issues if (!this.isAlive() || !this.valid) { -@@ -3735,6 +4512,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3782,6 +4559,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } } @@ -17373,7 +17383,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 protected void removeAfterChangingDimensions() { this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION, null); // CraftBukkit - add Bukkit remove cause } -@@ -4669,7 +5452,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4726,7 +5509,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } } // Paper end - Fix MC-4 @@ -17383,7 +17393,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 synchronized (this.posLock) { // Paper this.position = new Vec3(x, y, z); } // Paper -@@ -4690,7 +5474,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4747,7 +5531,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // Paper start - Block invalid positions and bounding box; don't allow desync of pos and AABB // hanging has its own special logic @@ -17392,7 +17402,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 this.setBoundingBox(this.makeBoundingBox()); } // Paper end - Block invalid positions and bounding box -@@ -4777,6 +5561,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4832,6 +5616,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return this.removalReason != null; } @@ -17405,7 +17415,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 @Nullable public Entity.RemovalReason getRemovalReason() { return this.removalReason; -@@ -4800,6 +5590,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4855,6 +5645,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit end final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers @@ -17415,7 +17425,7 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 if (this.removalReason == null) { this.removalReason = entity_removalreason; } -@@ -4822,6 +5615,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4877,6 +5670,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.removalReason = null; } @@ -17427,10 +17437,10 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..fe07f0881f5835974f00c65498a31a19 /** * 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 e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a168ee46f 100644 +index 517e10c3d8b1549cd30fd0e7cf2bcb35e88eb8ed..533ecd7e2666c2735483953e5a0426939e928ec5 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 { +@@ -256,7 +256,7 @@ public abstract class LivingEntity extends Entity implements Attackable { private Optional lastClimbablePos; @Nullable private DamageSource lastDamageSource; @@ -17439,7 +17449,7 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a protected int autoSpinAttackTicks; private float swimAmount; private float swimAmountO; -@@ -276,6 +276,21 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -287,6 +287,21 @@ public abstract class LivingEntity extends Entity implements Attackable { ++this.noActionTime; // Above all the floats } // Spigot end @@ -17461,7 +17471,7 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a protected LivingEntity(EntityType type, Level world) { super(type, world); -@@ -481,7 +496,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -494,7 +509,7 @@ public abstract class LivingEntity extends Entity implements Attackable { if (this.isDeadOrDying() && this.level().shouldTickDeath(this)) { this.tickDeath(); @@ -17470,7 +17480,7 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a if (this.lastHurtByPlayerTime > 0) { --this.lastHurtByPlayerTime; -@@ -627,11 +642,14 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -648,11 +663,14 @@ public abstract class LivingEntity extends Entity implements Attackable { return true; } @@ -17487,7 +17497,7 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a } } -@@ -860,9 +878,9 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -891,9 +909,9 @@ public abstract class LivingEntity extends Entity implements Attackable { } this.hurtTime = nbt.getShort("HurtTime"); @@ -17497,9 +17507,9 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a - if (nbt.contains("Team", 8)) { + if (false && nbt.contains("Team", 8)) { // Folia start - region threading String s = nbt.getString("Team"); - PlayerTeam scoreboardteam = this.level().getScoreboard().getPlayerTeam(s); - if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof net.minecraft.world.entity.player.Player)) { scoreboardteam = null; } // Paper - Perf: Disable Scoreboards for non players by default -@@ -1149,6 +1167,7 @@ public abstract class LivingEntity extends Entity implements Attackable { + Scoreboard scoreboard = this.level().getScoreboard(); + PlayerTeam scoreboardteam = scoreboard.getPlayerTeam(s); +@@ -1170,6 +1188,7 @@ public abstract class LivingEntity extends Entity implements Attackable { public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent) { // Paper end - Don't fire sync event during generation // org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API @@ -17507,16 +17517,16 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a if (this.isTickingEffects) { this.effectsToProcess.add(new ProcessableEffect(mobeffect, cause)); return true; -@@ -1573,7 +1592,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1592,7 +1611,7 @@ public abstract class LivingEntity extends Entity implements Attackable { if (flag2) { this.lastDamageSource = source; - this.lastDamageStamp = this.level().getGameTime(); + this.lastDamageStamp = this.level().getRedstoneGameTime(); // Folia - region threading - } + Iterator iterator = this.getActiveEffects().iterator(); - if (this instanceof ServerPlayer) { -@@ -1656,7 +1675,7 @@ public abstract class LivingEntity extends Entity implements Attackable { + while (iterator.hasNext()) { +@@ -1682,7 +1701,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @Nullable public DamageSource getLastDamageSource() { @@ -17525,7 +17535,7 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a this.lastDamageSource = null; } -@@ -2359,7 +2378,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2412,7 +2431,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @Nullable public LivingEntity getKillCredit() { @@ -17534,7 +17544,7 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a } public final float getMaxHealth() { -@@ -2437,7 +2456,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2490,7 +2509,7 @@ public abstract class LivingEntity extends Entity implements Attackable { this.hurt(this.damageSources().generic(), 0.0F); this.lastDamageSource = damageSource; @@ -17543,7 +17553,7 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a } @Override -@@ -3502,7 +3521,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3494,7 +3513,7 @@ public abstract class LivingEntity extends Entity implements Attackable { this.pushEntities(); this.level().getProfiler().pop(); // Paper start - Add EntityMoveEvent @@ -17552,7 +17562,7 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { Location from = new Location(this.level().getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); Location to = new Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -@@ -4195,7 +4214,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -4183,7 +4202,7 @@ public abstract class LivingEntity extends Entity implements Attackable { BlockPos blockposition = BlockPos.containing(d0, d1, d2); Level world = this.level(); @@ -17562,10 +17572,10 @@ index e9bb7feb591032904516d1b9374f486d8a7d066c..73e0c2ec5ab8cf54767755f31d1a8d0a while (!flag2 && blockposition.getY() > world.getMinBuildHeight()) { diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index d2c92df28475f0a32a0134324eb0a5609a9afb99..3228d15fc21fec08e8683f96c829935a1de6cf45 100644 +index e89f9c3e887601d8461eb967ae0bf582b672f631..ef5cd008de4d145b67c70e48ae21ea969aedb1f0 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -138,6 +138,14 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -153,6 +153,14 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti public boolean aware = true; // CraftBukkit @@ -17580,7 +17590,7 @@ index d2c92df28475f0a32a0134324eb0a5609a9afb99..3228d15fc21fec08e8683f96c829935a protected Mob(EntityType type, Level world) { super(type, world); this.handItems = NonNullList.withSize(2, ItemStack.EMPTY); -@@ -289,9 +297,21 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -298,9 +306,21 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti @Nullable @Override public LivingEntity getTarget() { @@ -17600,9 +17610,9 @@ index d2c92df28475f0a32a0134324eb0a5609a9afb99..3228d15fc21fec08e8683f96c829935a + // Folia end - region threading + public org.bukkit.craftbukkit.entity.CraftMob getBukkitMob() { return (org.bukkit.craftbukkit.entity.CraftMob) super.getBukkitEntity(); } // Paper - public void setTarget(@Nullable LivingEntity target) { - // CraftBukkit start - fire event -@@ -299,7 +319,7 @@ public abstract class Mob extends LivingEntity implements Targeting { + + @Nullable +@@ -314,7 +334,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti } public boolean setTarget(LivingEntity entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) { @@ -17611,16 +17621,7 @@ index d2c92df28475f0a32a0134324eb0a5609a9afb99..3228d15fc21fec08e8683f96c829935a if (fireEvent) { if (reason == EntityTargetEvent.TargetReason.UNKNOWN && this.getTarget() != null && entityliving == null) { reason = this.getTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; -@@ -909,7 +929,7 @@ public abstract class Mob extends LivingEntity implements Targeting { - this.level().getProfiler().push("sensing"); - this.sensing.tick(); - this.level().getProfiler().pop(); -- int i = this.level().getServer().getTickCount() + this.getId(); -+ int i = this.tickCount + this.getId(); // Folia - region threading - - if (i % 2 != 0 && this.tickCount > 1) { - this.level().getProfiler().push("targetSelector"); -@@ -1759,6 +1779,17 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1879,6 +1899,17 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti this.goalSelector.removeAllGoals(predicate); } @@ -17638,7 +17639,7 @@ index d2c92df28475f0a32a0134324eb0a5609a9afb99..3228d15fc21fec08e8683f96c829935a @Override protected void removeAfterChangingDimensions() { super.removeAfterChangingDimensions(); -@@ -1767,12 +1798,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1887,12 +1918,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit this.dropLeash(true, event.isDropLeash()); // Paper end - Expand EntityUnleashEvent @@ -17692,10 +17693,10 @@ index 7302d397d39d8400527ab2da4adaf8d792256749..cb92900d5528b953ec4c9f071a75a064 .getType(globalPos.pos()) .ifPresent( diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java -index c0da573e3818a1dd2c1ef5a61c7cb34934b0a252..d34a3018264ec196ef57151af3c1d584b0576c68 100644 +index edd29c2f4d0151d512618115a8fb4b7423171491..cb6fa1c7345fac3808897ecd46ed2314f2aff139 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java -@@ -70,7 +70,7 @@ public class FollowOwnerGoal extends Goal { +@@ -71,7 +71,7 @@ public class FollowOwnerGoal extends Goal { @Override public boolean canContinueToUse() { @@ -17704,7 +17705,7 @@ index c0da573e3818a1dd2c1ef5a61c7cb34934b0a252..d34a3018264ec196ef57151af3c1d584 } private boolean unableToMove() { -@@ -96,7 +96,7 @@ public class FollowOwnerGoal extends Goal { +@@ -97,7 +97,7 @@ public class FollowOwnerGoal extends Goal { if (this.tamable.distanceToSqr(this.owner) <= 16 * 16) this.tamable.getLookControl().setLookAt(this.owner, 10.0F, (float) this.tamable.getMaxHeadXRot()); // Paper - Limit pet look distance if (--this.timeToRecalcPath <= 0) { this.timeToRecalcPath = this.adjustedTickDelay(10); @@ -17713,7 +17714,7 @@ index c0da573e3818a1dd2c1ef5a61c7cb34934b0a252..d34a3018264ec196ef57151af3c1d584 this.teleportToOwner(); } else { this.navigation.moveTo((Entity) this.owner, this.speedModifier); -@@ -107,6 +107,11 @@ public class FollowOwnerGoal extends Goal { +@@ -108,6 +108,11 @@ public class FollowOwnerGoal extends Goal { private void teleportToOwner() { BlockPos blockposition = this.owner.blockPosition(); @@ -17725,7 +17726,7 @@ index c0da573e3818a1dd2c1ef5a61c7cb34934b0a252..d34a3018264ec196ef57151af3c1d584 for (int i = 0; i < 10; ++i) { int j = this.randomIntInclusive(-3, 3); -@@ -133,7 +138,21 @@ public class FollowOwnerGoal extends Goal { +@@ -134,7 +139,21 @@ public class FollowOwnerGoal extends Goal { return false; } Location to = event.getTo(); @@ -17749,7 +17750,7 @@ index c0da573e3818a1dd2c1ef5a61c7cb34934b0a252..d34a3018264ec196ef57151af3c1d584 this.navigation.stop(); return true; diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -index 74ae984ac41bcdd2cc45f1bec461cdc5f69977c6..a978b9c3edb64a5a0b91166b20fa28a3d9e8b2f8 100644 +index 62634bedd97c5be9ecce24ab0cff205715a68da8..197bbc149e9bf270a304c987ef76373c780b6a86 100644 --- a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java +++ b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java @@ -42,6 +42,11 @@ public class GroundPathNavigation extends PathNavigation { @@ -17765,7 +17766,7 @@ index 74ae984ac41bcdd2cc45f1bec461cdc5f69977c6..a978b9c3edb64a5a0b91166b20fa28a3 .getChunkSource() .getChunkNow(SectionPos.blockToSectionCoord(target.getX()), SectionPos.blockToSectionCoord(target.getZ())); diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -index e3a7eaf31ab19cc9f23a0c87649b74bb42976cb4..1a364f9857608413813c8c2ca5b71ec8c90fe8b6 100644 +index 2e9991e6b3c05584002744a2ee2579b1dba218b2..7873462c6146b7431011a2b73eb7414f61afbccf 100644 --- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java @@ -80,11 +80,11 @@ public abstract class PathNavigation { @@ -17782,7 +17783,7 @@ index e3a7eaf31ab19cc9f23a0c87649b74bb42976cb4..1a364f9857608413813c8c2ca5b71ec8 this.hasDelayedRecomputation = false; } } else { -@@ -199,7 +199,7 @@ public abstract class PathNavigation { +@@ -203,7 +203,7 @@ public abstract class PathNavigation { public boolean moveTo(Entity entity, double speed) { // Paper start - Perf: Optimise pathfinding @@ -17791,7 +17792,7 @@ index e3a7eaf31ab19cc9f23a0c87649b74bb42976cb4..1a364f9857608413813c8c2ca5b71ec8 return false; } // Paper end - Perf: Optimise pathfinding -@@ -211,7 +211,7 @@ public abstract class PathNavigation { +@@ -215,7 +215,7 @@ public abstract class PathNavigation { return true; } else { this.pathfindFailures++; @@ -17801,10 +17802,10 @@ index e3a7eaf31ab19cc9f23a0c87649b74bb42976cb4..1a364f9857608413813c8c2ca5b71ec8 } // Paper end - Perf: Optimise pathfinding diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/TemptingSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/TemptingSensor.java -index e3242cf9a6ad51a23c5781142198dec30c8f376d..f32f5982ceb368b240062b9b8ac0141be59e2f1e 100644 +index 4d5372b80b2b1906ecf5bf7e75df08b5d3792bfd..9ee62edd8f71244ea406f19cdd62fa5a94b85a3d 100644 --- a/src/main/java/net/minecraft/world/entity/ai/sensing/TemptingSensor.java +++ b/src/main/java/net/minecraft/world/entity/ai/sensing/TemptingSensor.java -@@ -37,7 +37,7 @@ public class TemptingSensor extends Sensor { +@@ -38,7 +38,7 @@ public class TemptingSensor extends Sensor { protected void doTick(ServerLevel world, PathfinderMob entity) { Brain behaviorcontroller = entity.getBrain(); @@ -17814,10 +17815,10 @@ index e3242cf9a6ad51a23c5781142198dec30c8f376d..f32f5982ceb368b240062b9b8ac0141b }).filter((entityplayer) -> { return entity.closerThan(entityplayer, 10.0D); diff --git a/src/main/java/net/minecraft/world/entity/ai/village/VillageSiege.java b/src/main/java/net/minecraft/world/entity/ai/village/VillageSiege.java -index 2b5b2869589991be37a4f128faabbff50e661470..c8d4878a0574a603bbb4bce45d1fb4d84b7ac6ce 100644 +index 36dec6cd78a0990ba3c09a4a748c259ef5c0a2ff..316b5db25f749854052449c1a2a48f20b8ead05b 100644 --- a/src/main/java/net/minecraft/world/entity/ai/village/VillageSiege.java +++ b/src/main/java/net/minecraft/world/entity/ai/village/VillageSiege.java -@@ -22,62 +22,66 @@ import org.slf4j.Logger; +@@ -21,62 +21,66 @@ import org.slf4j.Logger; public class VillageSiege implements CustomSpawner { private static final Logger LOGGER = LogUtils.getLogger(); @@ -17905,7 +17906,7 @@ index 2b5b2869589991be37a4f128faabbff50e661470..c8d4878a0574a603bbb4bce45d1fb4d8 while (iterator.hasNext()) { Player entityhuman = (Player) iterator.next(); -@@ -89,12 +93,12 @@ public class VillageSiege implements CustomSpawner { +@@ -88,12 +92,12 @@ public class VillageSiege implements CustomSpawner { for (int i = 0; i < 10; ++i) { float f = world.random.nextFloat() * 6.2831855F; @@ -17924,7 +17925,7 @@ index 2b5b2869589991be37a4f128faabbff50e661470..c8d4878a0574a603bbb4bce45d1fb4d8 break; } } -@@ -108,13 +112,15 @@ public class VillageSiege implements CustomSpawner { +@@ -107,13 +111,15 @@ public class VillageSiege implements CustomSpawner { } private void trySpawn(ServerLevel world) { @@ -17938,10 +17939,10 @@ index 2b5b2869589991be37a4f128faabbff50e661470..c8d4878a0574a603bbb4bce45d1fb4d8 try { entityzombie = new Zombie(world); + entityzombie.moveTo(vec3d.x, vec3d.y, vec3d.z, world.random.nextFloat() * 360.0F, 0.0F); // Folia - region threading - move up - entityzombie.finalizeSpawn(world, world.getCurrentDifficultyAt(entityzombie.blockPosition()), MobSpawnType.EVENT, (SpawnGroupData) null, (CompoundTag) null); + entityzombie.finalizeSpawn(world, world.getCurrentDifficultyAt(entityzombie.blockPosition()), MobSpawnType.EVENT, (SpawnGroupData) null); } catch (Exception exception) { VillageSiege.LOGGER.warn("Failed to create zombie for village siege at {}", vec3d, exception); -@@ -122,7 +128,7 @@ public class VillageSiege implements CustomSpawner { +@@ -121,7 +127,7 @@ public class VillageSiege implements CustomSpawner { return; } @@ -17950,7 +17951,7 @@ index 2b5b2869589991be37a4f128faabbff50e661470..c8d4878a0574a603bbb4bce45d1fb4d8 world.addFreshEntityWithPassengers(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_INVASION); // CraftBukkit } } -@@ -143,7 +149,7 @@ public class VillageSiege implements CustomSpawner { +@@ -142,7 +148,7 @@ public class VillageSiege implements CustomSpawner { return null; } @@ -17960,10 +17961,10 @@ index 2b5b2869589991be37a4f128faabbff50e661470..c8d4878a0574a603bbb4bce45d1fb4d8 SIEGE_CAN_ACTIVATE, SIEGE_TONIGHT, SIEGE_DONE; diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java -index 61a06706f1468a8d4cceb9fb2aae61cf56bd991d..79e9e5ece5859938ca0c86ead4c25cf5bde9da27 100644 +index c6f193339fdcbcc938d4eafdcad0b112cf1698d5..cf69b4ed4a40015a23d053230c3f326a700788ef 100644 --- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java +++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java -@@ -48,11 +48,13 @@ public class PoiManager extends SectionStorage { +@@ -50,11 +50,13 @@ public class PoiManager extends SectionStorage { } protected void updateDistanceTracking(long section) { @@ -17977,7 +17978,7 @@ index 61a06706f1468a8d4cceb9fb2aae61cf56bd991d..79e9e5ece5859938ca0c86ead4c25cf5 } // Paper end - rewrite chunk system -@@ -215,8 +217,10 @@ public class PoiManager extends SectionStorage { +@@ -229,8 +231,10 @@ public class PoiManager extends SectionStorage { } public int sectionsToVillage(SectionPos pos) { @@ -17988,7 +17989,7 @@ index 61a06706f1468a8d4cceb9fb2aae61cf56bd991d..79e9e5ece5859938ca0c86ead4c25cf5 } boolean isVillageCenter(long pos) { -@@ -230,7 +234,9 @@ public class PoiManager extends SectionStorage { +@@ -244,7 +248,9 @@ public class PoiManager extends SectionStorage { @Override public void tick(BooleanSupplier shouldKeepTicking) { @@ -17999,10 +18000,10 @@ index 61a06706f1468a8d4cceb9fb2aae61cf56bd991d..79e9e5ece5859938ca0c86ead4c25cf5 @Override diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java -index f9521a6e115f0c975a7885b024c99eae300b63bf..9f1791e60061934fc89a13258f3fab9f67f3a45c 100644 +index 0dfb8109fd8c022b079da00f6a0e3fc85b57bf7a..cdc431ab27b1837b852c8fb559d0324b94d33311 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Bee.java +++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java -@@ -1043,6 +1043,11 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { +@@ -1025,6 +1025,11 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { @Override public boolean canBeeUse() { @@ -18014,7 +18015,7 @@ index f9521a6e115f0c975a7885b024c99eae300b63bf..9f1791e60061934fc89a13258f3fab9f return Bee.this.hivePos != null && !Bee.this.hasRestriction() && Bee.this.wantsToEnterHive() && !this.hasReachedTarget(Bee.this.hivePos) && Bee.this.level().getBlockState(Bee.this.hivePos).is(BlockTags.BEEHIVES); } -@@ -1159,6 +1164,11 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { +@@ -1141,6 +1146,11 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { @Override public boolean canBeeUse() { @@ -18027,24 +18028,24 @@ index f9521a6e115f0c975a7885b024c99eae300b63bf..9f1791e60061934fc89a13258f3fab9f } diff --git a/src/main/java/net/minecraft/world/entity/animal/Cat.java b/src/main/java/net/minecraft/world/entity/animal/Cat.java -index f760ce7d9df79ef58f8963de3e901cba3e12fcaa..03bd7038bda7bd3bf592eab39ec6d985e07e3b8d 100644 +index 07559b9629d4ecb40b511256f400a781e39820e0..1cd5f0178c016736ebaf0f4449262da680cc2fab 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Cat.java +++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java -@@ -364,7 +364,7 @@ public class Cat extends TamableAnimal implements VariantHolder { - }); +@@ -367,7 +367,7 @@ public class Cat extends TamableAnimal implements VariantHolder= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate // CraftBukkit start - fire ItemDespawnEvent -@@ -549,14 +548,20 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -560,14 +559,20 @@ public class ItemEntity extends Entity implements TraceableEntity { return false; } @@ -18147,18 +18148,18 @@ index 29ce703a79f7893ac990ad80e0f1c1cf63546e6c..51bc4c0c8505e900cd3268048ac8cf71 return entity; } diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index e712bd07ea2946167782473a536e0c72fab4bccd..94d1cc62f1b0b60882541764e7272c248689b831 100644 +index f1f352ec0e51f5db59254841a06c176c5a876fc9..f11a701b3434b95342a6e8e89f5dea0d0080eff0 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -72,7 +72,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -75,7 +75,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { @Override public void tick() { - if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot + if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().getCurrentWorldData().currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot // Folia - region threading - if (!this.isNoGravity()) { - this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D)); - } + this.applyGravity(); + this.move(MoverType.SELF, this.getDeltaMovement()); + // Paper start - Configurable TNT height nerf @@ -114,7 +114,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { */ // Send position and velocity updates to nearby players on every tick while the TNT is in water. @@ -18169,10 +18170,10 @@ index e712bd07ea2946167782473a536e0c72fab4bccd..94d1cc62f1b0b60882541764e7272c24 net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket velocityPacket = new net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket(this); net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket positionPacket = new net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket(this); diff --git a/src/main/java/net/minecraft/world/entity/monster/Vex.java b/src/main/java/net/minecraft/world/entity/monster/Vex.java -index f443006c1e32feee97b32312814e2447a50c45e2..3cf7fe301cb445bf1592a398a5a17b1a4d4a6dd3 100644 +index fd3b37dde54623ba38186efb2a64d364c86b81d2..f21beb135e336dcd5aa46e7f0229f29ec780545a 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Vex.java +++ b/src/main/java/net/minecraft/world/entity/monster/Vex.java -@@ -370,7 +370,7 @@ public class Vex extends Monster implements TraceableEntity { +@@ -349,7 +349,7 @@ public class Vex extends Monster implements TraceableEntity { public void tick() { BlockPos blockposition = Vex.this.getBoundOrigin(); @@ -18182,10 +18183,10 @@ index f443006c1e32feee97b32312814e2447a50c45e2..3cf7fe301cb445bf1592a398a5a17b1a } diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java -index 5c40e994007dbf46ebc12c1e6a6ca90379471b74..723ef6e7a3618c30087ce2ac50811dbe638881ec 100644 +index e42dfc62bb179be1ab01b0096c05c6549d38abbc..3715411f337e6adea36fe1ceb2e93e830f703cda 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java -@@ -95,7 +95,7 @@ public class Zombie extends Monster { +@@ -92,7 +92,7 @@ public class Zombie extends Monster { private boolean canBreakDoors; private int inWaterTime; public int conversionTime; @@ -18194,7 +18195,7 @@ index 5c40e994007dbf46ebc12c1e6a6ca90379471b74..723ef6e7a3618c30087ce2ac50811dbe private boolean shouldBurnInDay = true; // Paper - Add more Zombie API public Zombie(EntityType type, Level world) { -@@ -218,10 +218,7 @@ public class Zombie extends Monster { +@@ -215,10 +215,7 @@ public class Zombie extends Monster { public void tick() { if (!this.level().isClientSide && this.isAlive() && !this.isNoAi()) { if (this.isUnderWaterConverting()) { @@ -18206,7 +18207,7 @@ index 5c40e994007dbf46ebc12c1e6a6ca90379471b74..723ef6e7a3618c30087ce2ac50811dbe if (this.conversionTime < 0) { this.doUnderWaterConversion(); } -@@ -238,7 +235,7 @@ public class Zombie extends Monster { +@@ -235,7 +232,7 @@ public class Zombie extends Monster { } super.tick(); @@ -18215,7 +18216,7 @@ index 5c40e994007dbf46ebc12c1e6a6ca90379471b74..723ef6e7a3618c30087ce2ac50811dbe } @Override -@@ -277,7 +274,7 @@ public class Zombie extends Monster { +@@ -274,7 +271,7 @@ public class Zombie extends Monster { } // Paper end - Add more Zombie API public void startUnderWaterConversion(int ticksUntilWaterConversion) { @@ -18225,19 +18226,19 @@ index 5c40e994007dbf46ebc12c1e6a6ca90379471b74..723ef6e7a3618c30087ce2ac50811dbe this.getEntityData().set(Zombie.DATA_DROWNED_CONVERSION_ID, true); } diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java -index 7de9d012e7416eaa0189b513a0972c846e93c4b6..9375c3732114f7a993ea96ed71531940af38c628 100644 +index f38acc96f71298e40ce9433e7759fd223ca55e48..474e94390eb68a56c81d91a736b72f6d00577971 100644 --- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -73,7 +73,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { +@@ -71,7 +71,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { @Nullable - private CompoundTag tradeOffers; + private MerchantOffers tradeOffers; private int villagerXp; - private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field + // private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field // Folia - region threading - restore original timers public ZombieVillager(EntityType type, Level world) { super(type, world); -@@ -148,10 +148,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { +@@ -152,10 +152,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { public void tick() { if (!this.level().isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); @@ -18249,7 +18250,7 @@ index 7de9d012e7416eaa0189b513a0972c846e93c4b6..9375c3732114f7a993ea96ed71531940 this.villagerConversionTime -= i; if (this.villagerConversionTime <= 0) { -@@ -160,7 +157,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { +@@ -164,7 +161,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { } super.tick(); @@ -18259,11 +18260,11 @@ index 7de9d012e7416eaa0189b513a0972c846e93c4b6..9375c3732114f7a993ea96ed71531940 @Override diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java -index 4e6c2f6b2e54a4c126e9a026b9cad05ce835ad66..d2fbeb0e4e3e681b22455b9cf2d125dcb4de0a56 100644 +index d323cf157f2a910916baa9ce3f7e5bc81648c47d..57355dfc6c52e038ef92b7bf7cf7af5b5672704a 100644 --- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -212,10 +212,18 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa - this.readInventoryFromTag(nbt); +@@ -220,10 +220,18 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa + this.readInventoryFromTag(nbt, this.registryAccess()); } + // Folia start - region threading @@ -18283,10 +18284,10 @@ index 4e6c2f6b2e54a4c126e9a026b9cad05ce835ad66..d2fbeb0e4e3e681b22455b9cf2d125dc } diff --git a/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java b/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java -index 5d1610eddcaf0cf65c726a5438b42e53bab85332..dd8e1bb65d7832d173e460eb4d8e97a8ba1ba26e 100644 +index e0e5046c84941a8d17e18c177f3daea9cb631940..61adcf62cb738d7dd5c785780824f64c56b82082 100644 --- a/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java +++ b/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java -@@ -19,17 +19,18 @@ import net.minecraft.world.phys.AABB; +@@ -18,17 +18,18 @@ import net.minecraft.world.phys.AABB; public class CatSpawner implements CustomSpawner { private static final int TICK_DELAY = 1200; @@ -18311,7 +18312,7 @@ index 5d1610eddcaf0cf65c726a5438b42e53bab85332..dd8e1bb65d7832d173e460eb4d8e97a8 return 0; } else { diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java -index 24044795d8e0f1fb15a4f2f5401f44897092f2a3..3eeff0cd8563939c656b5ded8470cab016903f25 100644 +index a7930f9875aa4aca997caaead46ecdc21e5e11d7..6339967b154af1ca9632c7b8b315d612f4b80ea2 100644 --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java +++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java @@ -204,7 +204,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler @@ -18323,7 +18324,7 @@ index 24044795d8e0f1fb15a4f2f5401f44897092f2a3..3eeff0cd8563939c656b5ded8470cab0 } @Override -@@ -730,6 +730,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -722,6 +722,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler ServerLevel worldserver = minecraftserver.getLevel(globalpos.dimension()); if (worldserver != null) { @@ -18332,7 +18333,7 @@ index 24044795d8e0f1fb15a4f2f5401f44897092f2a3..3eeff0cd8563939c656b5ded8470cab0 PoiManager villageplace = worldserver.getPoiManager(); Optional> optional = villageplace.getType(globalpos.pos()); BiPredicate> bipredicate = (BiPredicate) Villager.POI_MEMORIES.get(pos); -@@ -738,6 +740,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -730,6 +732,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler villageplace.release(globalpos.pos()); DebugPackets.sendPoiTicketCountPacket(worldserver, globalpos.pos()); } @@ -18341,7 +18342,7 @@ index 24044795d8e0f1fb15a4f2f5401f44897092f2a3..3eeff0cd8563939c656b5ded8470cab0 } }); diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java -index d7bddedb19c10f62fd1f7d3128453ad706ed16be..948749a0a3ef9d06f0482bc5331a52836a6eb6a3 100644 +index c72b6ea5530e54fc373c701028e1c147cea34b59..6677b4cc23253a1b7dfbc2e12e666699bbadbdb4 100644 --- a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java +++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java @@ -32,16 +32,14 @@ public class WanderingTraderSpawner implements CustomSpawner { @@ -18434,10 +18435,10 @@ index d7bddedb19c10f62fd1f7d3128453ad706ed16be..948749a0a3ef9d06f0482bc5331a5283 entityvillagertrader.setWanderTarget(blockposition1); entityvillagertrader.restrictTo(blockposition1, 16); diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 567704f61034363e48ef2a5b5566ebdc91682297..579eb5a81281ca36c145153d8c24a517242ffe18 100644 +index 093d1388ff90ad59110a37536b6639f939549068..448a6c8d73652824157c50cf4883d4d4d9b5db80 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1528,6 +1528,14 @@ public abstract class Player extends LivingEntity { +@@ -1533,6 +1533,14 @@ public abstract class Player extends LivingEntity { } @@ -18453,10 +18454,10 @@ index 567704f61034363e48ef2a5b5566ebdc91682297..579eb5a81281ca36c145153d8c24a517 return false; } diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -index e8faca6e443239968f0111519f9e5cd018ed3297..88aa1a41be9f596e07af3632def749aff9ea3363 100644 +index 31b8a8bf78d52b5f11b68e780ec09bf78e7bda84..3305c0642c9cd71c7e7c627fd8f9585d53f8b1f4 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -157,6 +157,11 @@ public abstract class AbstractArrow extends Projectile { +@@ -163,6 +163,11 @@ public abstract class AbstractArrow extends Projectile { @Override public void tick() { super.tick(); @@ -18469,10 +18470,10 @@ index e8faca6e443239968f0111519f9e5cd018ed3297..88aa1a41be9f596e07af3632def749af Vec3 vec3d = this.getDeltaMovement(); diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -index 20ce474b72894a8bb3fc21018b9d79bbdc8bb14b..cd150b14afe46dcc5d96eb11106bf2bb4744c944 100644 +index a81d6a52674ddf7f818a7665cccd21dd8ea86cbe..b8c981f9d0b284cc459f4d230150ee49090ab346 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -@@ -91,6 +91,11 @@ public abstract class AbstractHurtingProjectile extends Projectile { +@@ -81,6 +81,11 @@ public abstract class AbstractHurtingProjectile extends Projectile { this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { super.tick(); @@ -18482,13 +18483,13 @@ index 20ce474b72894a8bb3fc21018b9d79bbdc8bb14b..cd150b14afe46dcc5d96eb11106bf2bb + } + // Folia end - region threading - make sure entities do not move into regions they do not own if (this.shouldBurn()) { - this.setSecondsOnFire(1); + this.igniteForSeconds(1); } diff --git a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -index 813c4a52c8ddd70e252125ebfd3654346c71f13c..2deddd55d6571bbab50ff8cdc6b705df9199f287 100644 +index 3df4005b6ddc075e5922c1e96e4ceb21d8b8ea43..1589934764196c870d171554173e48cd1e7a4d51 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -131,6 +131,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { +@@ -134,6 +134,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { }); } @@ -18501,7 +18502,7 @@ index 813c4a52c8ddd70e252125ebfd3654346c71f13c..2deddd55d6571bbab50ff8cdc6b705df if (this.attachedToEntity != null) { if (this.attachedToEntity.isFallFlying()) { diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -index 91497f5e6c07fcf1b05eca6846c51e1a15ed3bc0..16f847a21b0c636e8af332b999df4469b19cc943 100644 +index 35299affb699d745804a3b60cb78b9323f3e068e..485a8526778d51753a7c90bc672f5fcd3bb99811 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java @@ -105,7 +105,7 @@ public class FishingHook extends Projectile { @@ -18533,7 +18534,7 @@ index 91497f5e6c07fcf1b05eca6846c51e1a15ed3bc0..16f847a21b0c636e8af332b999df4469 ItemStack itemstack = player.getMainHandItem(); ItemStack itemstack1 = player.getOffhandItem(); boolean flag = itemstack.is(Items.FISHING_ROD); -@@ -613,10 +619,18 @@ public class FishingHook extends Projectile { +@@ -614,10 +620,18 @@ public class FishingHook extends Projectile { @Override public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) { // CraftBukkit end @@ -18554,10 +18555,10 @@ index 91497f5e6c07fcf1b05eca6846c51e1a15ed3bc0..16f847a21b0c636e8af332b999df4469 public void onClientRemoval() { this.updateOwnerInfo((FishingHook) null); diff --git a/src/main/java/net/minecraft/world/entity/projectile/LlamaSpit.java b/src/main/java/net/minecraft/world/entity/projectile/LlamaSpit.java -index 8f5376543cca9cbfb2a014f67ec373d984b0df64..85a0f7b30db57a68133b38f42c17ac6e585fd629 100644 +index ffd01d24cbfc90e2a8807757e61b2cf20a944354..4ead19577f218dc3bd84260da8968c0fa00d7710 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/LlamaSpit.java +++ b/src/main/java/net/minecraft/world/entity/projectile/LlamaSpit.java -@@ -32,6 +32,11 @@ public class LlamaSpit extends Projectile { +@@ -38,6 +38,11 @@ public class LlamaSpit extends Projectile { @Override public void tick() { super.tick(); @@ -18570,10 +18571,10 @@ index 8f5376543cca9cbfb2a014f67ec373d984b0df64..85a0f7b30db57a68133b38f42c17ac6e HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index 156809090f1f83ad68e7e2477a3cfddac5757a8e..10d7c64fb3a9bafdcdae99f8dc87017722341337 100644 +index 74c596264d4da551437bd2a23e1c70022cfc73fc..a8d2f7a9d0bcb6db0b38ac30b098d59951053b47 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -70,9 +70,20 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -71,9 +71,20 @@ public abstract class Projectile extends Entity implements TraceableEntity { } // Paper end - Refresh ProjectileSource for projectiles @@ -18594,7 +18595,7 @@ index 156809090f1f83ad68e7e2477a3cfddac5757a8e..10d7c64fb3a9bafdcdae99f8dc870177 if (this.cachedOwner != null && !this.cachedOwner.isRemoved()) { this.refreshProjectileSource(false); // Paper - Refresh ProjectileSource for projectiles return this.cachedOwner; -@@ -304,7 +315,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -343,7 +354,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { public boolean mayInteract(Level world, BlockPos pos) { Entity entity = this.getOwner(); @@ -18604,7 +18605,7 @@ index 156809090f1f83ad68e7e2477a3cfddac5757a8e..10d7c64fb3a9bafdcdae99f8dc870177 public boolean mayBreak(Level world) { diff --git a/src/main/java/net/minecraft/world/entity/projectile/SmallFireball.java b/src/main/java/net/minecraft/world/entity/projectile/SmallFireball.java -index 6724fe4470aeea338eb4cfd10a7e61fbcac1e5b7..b6797d84356425945037d32b55c0d08c4699c8bf 100644 +index 3a11ad32d95088a5aca713a1a6a984cc22d4fa9a..6e16c7494490d584785ac8f06fe0f3dae236a97a 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/SmallFireball.java +++ b/src/main/java/net/minecraft/world/entity/projectile/SmallFireball.java @@ -26,7 +26,7 @@ public class SmallFireball extends Fireball { @@ -18617,7 +18618,7 @@ index 6724fe4470aeea338eb4cfd10a7e61fbcac1e5b7..b6797d84356425945037d32b55c0d08c } // CraftBukkit end diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java -index ab777952bda1651796ed41e8a7fc6621f27db9aa..6b9365eba3339578ee2984605240b74db2b8a6c0 100644 +index 5b32364f1452e1b395b91921d045060fd94881b8..51f2ec6dd466c12282a68d07b46b8478f25c5135 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java @@ -44,6 +44,11 @@ public abstract class ThrowableProjectile extends Projectile { @@ -18633,10 +18634,10 @@ index ab777952bda1651796ed41e8a7fc6621f27db9aa..6b9365eba3339578ee2984605240b74d boolean flag = false; diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -index 1fb1e729d6879568d8b4943071fa940325b2e5b0..0c4b158d574ad0e9e257532ac3b9a3a34497216f 100644 +index 519755b7f8bc7e8bb9fab135fc5bf7de3a9419f9..b3b7c61db5e640acdc9f4aa70ebf1d8b8e3ec272 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -46,6 +46,78 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -45,6 +45,78 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { entityHitResult.getEntity().hurt(this.damageSources().thrown(this, this.getOwner()), 0.0F); } @@ -18715,7 +18716,7 @@ index 1fb1e729d6879568d8b4943071fa940325b2e5b0..0c4b158d574ad0e9e257532ac3b9a3a3 @Override protected void onHit(HitResult hitResult) { super.onHit(hitResult); -@@ -55,6 +127,20 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -54,6 +126,20 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { } if (!this.level().isClientSide && !this.isRemoved()) { @@ -18736,7 +18737,7 @@ index 1fb1e729d6879568d8b4943071fa940325b2e5b0..0c4b158d574ad0e9e257532ac3b9a3a3 Entity entity = this.getOwner(); if (entity instanceof ServerPlayer) { -@@ -113,6 +199,14 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -112,6 +198,14 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { } @@ -18752,10 +18753,10 @@ index 1fb1e729d6879568d8b4943071fa940325b2e5b0..0c4b158d574ad0e9e257532ac3b9a3a3 @Override public Entity changeDimension(ServerLevel destination) { diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java -index bf2c23fad919820512ce031cf28a000b249b2876..2905dab1f9b3dd846261c5b0777d073927882825 100644 +index fdff9788eaf663be79214b2ca491f0f0444f6136..7c9d63c94f36c1702fc48570b07393375c77bd21 100644 --- a/src/main/java/net/minecraft/world/entity/raid/Raid.java +++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java -@@ -112,6 +112,13 @@ public class Raid { +@@ -116,6 +116,13 @@ public class Raid { public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(PDC_TYPE_REGISTRY); // Paper end @@ -18769,7 +18770,7 @@ index bf2c23fad919820512ce031cf28a000b249b2876..2905dab1f9b3dd846261c5b0777d0739 public Raid(int id, ServerLevel world, BlockPos pos) { this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); this.random = RandomSource.create(); -@@ -225,7 +232,7 @@ public class Raid { +@@ -229,7 +236,7 @@ public class Raid { return (entityplayer) -> { BlockPos blockposition = entityplayer.blockPosition(); @@ -18778,7 +18779,7 @@ index bf2c23fad919820512ce031cf28a000b249b2876..2905dab1f9b3dd846261c5b0777d0739 }; } -@@ -541,7 +548,7 @@ public class Raid { +@@ -553,7 +560,7 @@ public class Raid { boolean flag = true; Collection collection = this.raidEvent.getPlayers(); long i = this.random.nextLong(); @@ -18788,10 +18789,10 @@ index bf2c23fad919820512ce031cf28a000b249b2876..2905dab1f9b3dd846261c5b0777d0739 while (iterator.hasNext()) { ServerPlayer entityplayer = (ServerPlayer) iterator.next(); diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java -index 93bbf7556f9599e9dd90761085a57d78bd521867..15e1ce9d50f176e475295f7d5e8d039f49e84ad8 100644 +index 98e558338b5d9fb03869d2cc21b3e90eb45b95f6..3d3ce2c3be74ce09ae1dbeec4540d72b84c72ed8 100644 --- a/src/main/java/net/minecraft/world/entity/raid/Raider.java +++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java -@@ -94,7 +94,7 @@ public abstract class Raider extends PatrollingMonster { +@@ -96,7 +96,7 @@ public abstract class Raider extends PatrollingMonster { if (this.canJoinRaid()) { if (raid == null) { @@ -18801,10 +18802,10 @@ index 93bbf7556f9599e9dd90761085a57d78bd521867..15e1ce9d50f176e475295f7d5e8d039f if (raid1 != null && Raids.canJoinRaid(this, raid1)) { diff --git a/src/main/java/net/minecraft/world/entity/raid/Raids.java b/src/main/java/net/minecraft/world/entity/raid/Raids.java -index 31831811ce16265e9828fa34d9e67d8ac195d723..287024eaee26390a469162d63045a7cb1bfc20cf 100644 +index 8c60f71270d909c10e6617eb64b8fdb42deb73e9..1e441e723382518aff228656a1cb27559bdfd49a 100644 --- a/src/main/java/net/minecraft/world/entity/raid/Raids.java +++ b/src/main/java/net/minecraft/world/entity/raid/Raids.java -@@ -29,9 +29,9 @@ import net.minecraft.world.phys.Vec3; +@@ -26,9 +26,9 @@ import net.minecraft.world.phys.Vec3; public class Raids extends SavedData { private static final String RAID_FILE_ID = "raids"; @@ -18816,7 +18817,7 @@ index 31831811ce16265e9828fa34d9e67d8ac195d723..287024eaee26390a469162d63045a7cb private int tick; public static SavedData.Factory factory(ServerLevel world) { -@@ -44,7 +44,7 @@ public class Raids extends SavedData { +@@ -41,7 +41,7 @@ public class Raids extends SavedData { public Raids(ServerLevel world) { this.level = world; @@ -18825,7 +18826,7 @@ index 31831811ce16265e9828fa34d9e67d8ac195d723..287024eaee26390a469162d63045a7cb this.setDirty(); } -@@ -52,12 +52,26 @@ public class Raids extends SavedData { +@@ -49,12 +49,26 @@ public class Raids extends SavedData { return (Raid) this.raidMap.get(id); } @@ -18836,12 +18837,12 @@ index 31831811ce16265e9828fa34d9e67d8ac195d723..287024eaee26390a469162d63045a7cb + if (this.tick % 200 == 0) { + this.setDirty(); + } ++ // Folia end - make raids thread-safe + } -+ // Folia end - make raids thread-safe + + public void tick() { + // Folia - make raids thread-safe - move to globalTick() - Iterator iterator = this.raidMap.values().iterator(); + Iterator iterator = this.raidMap.values().iterator(); while (iterator.hasNext()) { Raid raid = (Raid) iterator.next(); @@ -18853,7 +18854,7 @@ index 31831811ce16265e9828fa34d9e67d8ac195d723..287024eaee26390a469162d63045a7cb if (this.level.getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) { raid.stop(); -@@ -71,14 +85,17 @@ public class Raids extends SavedData { +@@ -68,14 +82,17 @@ public class Raids extends SavedData { } } @@ -18874,7 +18875,7 @@ index 31831811ce16265e9828fa34d9e67d8ac195d723..287024eaee26390a469162d63045a7cb return raider != null && raid != null && raid.getLevel() != null ? raider.isAlive() && raider.canJoinRaid() && raider.getNoActionTime() <= 2400 && raider.level().dimensionType() == raid.getLevel().dimensionType() : false; } -@@ -91,7 +108,7 @@ public class Raids extends SavedData { +@@ -88,7 +105,7 @@ public class Raids extends SavedData { } else { DimensionType dimensionmanager = player.level().dimensionType(); @@ -18882,8 +18883,8 @@ index 31831811ce16265e9828fa34d9e67d8ac195d723..287024eaee26390a469162d63045a7cb + if (!dimensionmanager.hasRaids() || !io.papermc.paper.util.TickThread.isTickThreadFor(this.level, player.chunkPosition().x, player.chunkPosition().z, 8)) { // Folia - region threading return null; } else { - BlockPos blockposition = player.blockPosition(); -@@ -171,7 +188,7 @@ public class Raids extends SavedData { + List list = this.level.getPoiManager().getInRange((holder) -> { +@@ -150,7 +167,7 @@ public class Raids extends SavedData { public static Raids load(ServerLevel world, CompoundTag nbt) { Raids persistentraid = new Raids(world); @@ -18892,16 +18893,16 @@ index 31831811ce16265e9828fa34d9e67d8ac195d723..287024eaee26390a469162d63045a7cb persistentraid.tick = nbt.getInt("Tick"); ListTag nbttaglist = nbt.getList("Raids", 10); -@@ -187,7 +204,7 @@ public class Raids extends SavedData { +@@ -166,7 +183,7 @@ public class Raids extends SavedData { @Override - public CompoundTag save(CompoundTag nbt) { + public CompoundTag save(CompoundTag nbt, HolderLookup.Provider registryLookup) { - nbt.putInt("NextAvailableID", this.nextAvailableID); + nbt.putInt("NextAvailableID", this.nextAvailableID.get()); // Folia - make raids thread-safe nbt.putInt("Tick", this.tick); ListTag nbttaglist = new ListTag(); Iterator iterator = this.raidMap.values().iterator(); -@@ -209,7 +226,7 @@ public class Raids extends SavedData { +@@ -188,7 +205,7 @@ public class Raids extends SavedData { } private int getUniqueId() { @@ -18910,7 +18911,7 @@ index 31831811ce16265e9828fa34d9e67d8ac195d723..287024eaee26390a469162d63045a7cb } @Nullable -@@ -220,6 +237,11 @@ public class Raids extends SavedData { +@@ -199,6 +216,11 @@ public class Raids extends SavedData { while (iterator.hasNext()) { Raid raid1 = (Raid) iterator.next(); @@ -18923,7 +18924,7 @@ index 31831811ce16265e9828fa34d9e67d8ac195d723..287024eaee26390a469162d63045a7cb if (raid1.isActive() && d1 < d0) { diff --git a/src/main/java/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java b/src/main/java/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java -index 88b00556322f078b8a9d28fb7c759bb8c84bfcf0..9badca2723f43e4caddb741252caeaf5f57ba9d6 100644 +index 83ef2c3e7b06152b9e68f90002c35e77f148347d..4fa3084cc8d6f4e4ed7722adac40c71ef1b60d43 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java @@ -150,5 +150,11 @@ public class MinecartCommandBlock extends AbstractMinecart { @@ -18939,10 +18940,10 @@ index 88b00556322f078b8a9d28fb7c759bb8c84bfcf0..9badca2723f43e4caddb741252caeaf5 } } diff --git a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java -index 761142374f793a1cd4228936b21a68d7a0458894..b04f06aeb62cdc0f498dc97049bf27862da51b1d 100644 +index d7f8464bf3eed0e42a5fc7f14a5b243d171f8b5e..97bd1d7b4613c977376e43e180d8ec2a15acbcca 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java -@@ -127,7 +127,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +@@ -132,7 +132,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper // Paper start public void immunize() { @@ -18952,10 +18953,10 @@ index 761142374f793a1cd4228936b21a68d7a0458894..b04f06aeb62cdc0f498dc97049bf2786 // Paper end diff --git a/src/main/java/net/minecraft/world/item/ArmorItem.java b/src/main/java/net/minecraft/world/item/ArmorItem.java -index 6b81be03f87967124b046708557e05d519aa79e4..2220ac02eec17c0791e5b4ce8f5e085333471127 100644 +index 786e4a8700cb84b16dd9b8892a0d1d5803924d81..eddfb0d0e265129db48959c816899415572acebd 100644 --- a/src/main/java/net/minecraft/world/item/ArmorItem.java +++ b/src/main/java/net/minecraft/world/item/ArmorItem.java -@@ -75,7 +75,7 @@ public class ArmorItem extends Item implements Equipable { +@@ -77,7 +77,7 @@ public class ArmorItem extends Item implements Equipable { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity()); @@ -18965,11 +18966,11 @@ index 6b81be03f87967124b046708557e05d519aa79e4..2220ac02eec17c0791e5b4ce8f5e0853 } diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 1ad126d992d95062a3db08374db7a927f23a0cac..43d8f91cdbc4e197f2811fb406a7dae8a8ebfdc1 100644 +index 893efb2c4a07c33d41e934279dd914a9dbd4ef79..40556d5cfc161de1af5c7fc679edf6b2110cf7e9 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -379,31 +379,32 @@ public final class ItemStack { - CompoundTag oldData = this.getTagClone(); +@@ -400,31 +400,32 @@ public final class ItemStack implements DataComponentHolder { + DataComponentPatch oldData = this.getComponentsPatch(); int oldCount = this.getCount(); ServerLevel world = (ServerLevel) context.getLevel(); + io.papermc.paper.threadedregions.RegionizedWorldData worldData = world.getCurrentWorldData(); // Folia - region threading @@ -18990,14 +18991,14 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..43d8f91cdbc4e197f2811fb406a7dae8 - world.captureBlockStates = false; + worldData.captureBlockStates = false; // Folia - region threading } - CompoundTag newData = this.getTagClone(); + DataComponentPatch newData = this.components.asPatch(); // Paper - Directly access components as patch instead of getComponentsPatch as said method yields EMPTY on items with count 0 int newCount = this.getCount(); this.setCount(oldCount); - this.setTagClone(oldData); + this.restorePatch(oldData); - if (enuminteractionresult.consumesAction() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { - world.captureTreeGeneration = false; + if (enuminteractionresult.consumesAction() && worldData.captureTreeGeneration && worldData.capturedBlockStates.size() > 0) { // Folia - region threading -+ world.getCurrentWorldData().captureTreeGeneration = false; // Folia - region threading ++ worldData.captureTreeGeneration = false; Location location = CraftLocation.toBukkit(blockposition, world.getWorld()); - TreeType treeType = SaplingBlock.treeType; - SaplingBlock.treeType = null; @@ -19010,7 +19011,7 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..43d8f91cdbc4e197f2811fb406a7dae8 StructureGrowEvent structureEvent = null; if (treeType != null) { boolean isBonemeal = this.getItem() == Items.BONE_MEAL; -@@ -429,16 +430,16 @@ public final class ItemStack { +@@ -450,16 +451,16 @@ public final class ItemStack implements DataComponentHolder { entityhuman.awardStat(Stats.ITEM_USED.get(item)); // SPIGOT-7236 - award stat } @@ -19021,7 +19022,7 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..43d8f91cdbc4e197f2811fb406a7dae8 - world.captureTreeGeneration = false; + worldData.captureTreeGeneration = false; // Folia - region threading - if (entityhuman != null && enuminteractionresult.shouldAwardStats()) { + if (entityhuman != null && enuminteractionresult.indicateItemUse()) { InteractionHand enumhand = context.getHand(); org.bukkit.event.block.BlockPlaceEvent placeEvent = null; - List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); @@ -19031,7 +19032,7 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..43d8f91cdbc4e197f2811fb406a7dae8 if (blocks.size() > 1) { placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, enumhand, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ()); } else if (blocks.size() == 1 && item != Items.POWDER_SNOW_BUCKET) { // Paper - Fix cancelled powdered snow bucket placement -@@ -449,13 +450,13 @@ public final class ItemStack { +@@ -470,13 +471,13 @@ public final class ItemStack implements DataComponentHolder { enuminteractionresult = InteractionResult.FAIL; // cancel placement // PAIL: Remove this when MC-99075 fixed placeEvent.getPlayer().updateInventory(); @@ -19048,7 +19049,7 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..43d8f91cdbc4e197f2811fb406a7dae8 // Brute force all possible updates // Paper start - Don't resync blocks -@@ -464,7 +465,7 @@ public final class ItemStack { +@@ -485,7 +486,7 @@ public final class ItemStack implements DataComponentHolder { // ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir))); // } // Paper end - Don't resync blocks @@ -19056,8 +19057,8 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..43d8f91cdbc4e197f2811fb406a7dae8 + SignItem.openSign.set(null); // SPIGOT-6758 - Reset on early return // Folia - region threading } else { // Change the stack to its new contents if it hasn't been tampered with. - if (this.getCount() == oldCount && Objects.equals(this.tag, oldData)) { -@@ -472,7 +473,7 @@ public final class ItemStack { + if (this.getCount() == oldCount && Objects.equals(this.components.asPatch(), oldData)) { +@@ -493,7 +494,7 @@ public final class ItemStack implements DataComponentHolder { this.setCount(newCount); } @@ -19066,7 +19067,7 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..43d8f91cdbc4e197f2811fb406a7dae8 world.setBlockEntity(e.getValue()); } -@@ -523,15 +524,15 @@ public final class ItemStack { +@@ -544,15 +545,15 @@ public final class ItemStack implements DataComponentHolder { } // SPIGOT-4678 @@ -19086,7 +19087,7 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..43d8f91cdbc4e197f2811fb406a7dae8 } } -@@ -559,8 +560,8 @@ public final class ItemStack { +@@ -580,8 +581,8 @@ public final class ItemStack implements DataComponentHolder { entityhuman.awardStat(Stats.ITEM_USED.get(item)); } } @@ -19098,10 +19099,10 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..43d8f91cdbc4e197f2811fb406a7dae8 return enuminteractionresult; diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java -index d8dd99ec8bf7444c5a3c426db3a9c13e334dc0ff..5204449e94eeadb9b0485a0b4ff876196f40051c 100644 +index ce461b1a8d7fab87ae28e30205f6fab67f1808b6..957396b145b1d1adf265f8b9aaeba052758f007a 100644 --- a/src/main/java/net/minecraft/world/item/MapItem.java +++ b/src/main/java/net/minecraft/world/item/MapItem.java -@@ -95,6 +95,7 @@ public class MapItem extends ComplexItem { +@@ -69,6 +69,7 @@ public class MapItem extends ComplexItem { } public void update(Level world, Entity entity, MapItemSavedData state) { @@ -19109,63 +19110,62 @@ index d8dd99ec8bf7444c5a3c426db3a9c13e334dc0ff..5204449e94eeadb9b0485a0b4ff87619 if (world.dimension() == state.dimension && entity instanceof Player) { int i = 1 << state.scale; int j = state.centerX; -@@ -126,9 +127,9 @@ public class MapItem extends ComplexItem { - int j2 = (j / i + k1 - 64) * i; - int k2 = (k / i + l1 - 64) * i; +@@ -98,8 +99,8 @@ public class MapItem extends ComplexItem { + int r = (j / i + o - 64) * i; + int s = (k / i + p - 64) * i; Multiset multiset = LinkedHashMultiset.create(); -- LevelChunk chunk = world.getChunkIfLoaded(SectionPos.blockToSectionCoord(j2), SectionPos.blockToSectionCoord(k2)); // Paper - Maps shouldn't load chunks -+ LevelChunk chunk = world.getChunkIfLoaded(SectionPos.blockToSectionCoord(j2), SectionPos.blockToSectionCoord(k2)); // Paper - Maps shouldn't load chunks // Folia - super important that it uses getChunkIfLoaded - -- if (chunk != null && !chunk.isEmpty()) { // Paper - Maps shouldn't load chunks -+ if (chunk != null && !chunk.isEmpty() && io.papermc.paper.util.TickThread.isTickThreadFor((ServerLevel)world, chunk.getPos())) { // Paper - Maps shouldn't load chunks // Folia - make sure chunk is owned - int l2 = 0; - double d1 = 0.0D; - int i3; -@@ -219,6 +220,7 @@ public class MapItem extends ComplexItem { +- LevelChunk levelChunk = world.getChunkIfLoaded(SectionPos.blockToSectionCoord(r), SectionPos.blockToSectionCoord(s)); // Paper - Maps shouldn't load chunks +- if (levelChunk != null && !levelChunk.isEmpty()) { // Paper - Maps shouldn't load chunks ++ LevelChunk levelChunk = world.getChunkIfLoaded(SectionPos.blockToSectionCoord(r), SectionPos.blockToSectionCoord(s)); // Paper - Maps shouldn't load chunks // Folia - super important that it uses getChunkIfLoaded ++ if (levelChunk != null && !levelChunk.isEmpty() && io.papermc.paper.util.TickThread.isTickThreadFor((ServerLevel)world, levelChunk.getPos())) { // Paper - Maps shouldn't load chunks // Folia - make sure chunk is owned + int t = 0; + double e = 0.0; + if (world.dimensionType().hasCeiling()) { +@@ -181,6 +182,7 @@ public class MapItem extends ComplexItem { + } } - } + } // Folia - make map data thread-safe } private BlockState getCorrectStateForFluidBlock(Level world, BlockState state, BlockPos pos) { -@@ -235,6 +237,7 @@ public class MapItem extends ComplexItem { - MapItemSavedData worldmap = MapItem.getSavedData(map, world); - - if (worldmap != null) { -+ synchronized (worldmap) { // Folia - make map data thread-safe - if (world.dimension() == worldmap.dimension) { - int i = 1 << worldmap.scale; - int j = worldmap.centerX; -@@ -309,6 +312,7 @@ public class MapItem extends ComplexItem { +@@ -195,6 +197,7 @@ public class MapItem extends ComplexItem { + public static void renderBiomePreviewMap(ServerLevel world, ItemStack map) { + MapItemSavedData mapItemSavedData = getSavedData(map, world); + if (mapItemSavedData != null) { ++ synchronized (mapItemSavedData) { // Folia - make map data thread-safe + if (world.dimension() == mapItemSavedData.dimension) { + int i = 1 << mapItemSavedData.scale; + int j = mapItemSavedData.centerX; +@@ -264,6 +267,7 @@ public class MapItem extends ComplexItem { + } } - } + } // Folia - make map data thread-safe } } -@@ -318,6 +322,7 @@ public class MapItem extends ComplexItem { - MapItemSavedData worldmap = MapItem.getSavedData(stack, world); - - if (worldmap != null) { -+ synchronized (worldmap) { // Folia - region threading - if (entity instanceof Player) { - Player entityhuman = (Player) entity; - -@@ -327,6 +332,7 @@ public class MapItem extends ComplexItem { - if (!worldmap.locked && (selected || entity instanceof Player && ((Player) entity).getOffhandItem() == stack)) { - this.update(world, entity, worldmap); +@@ -272,6 +276,7 @@ public class MapItem extends ComplexItem { + if (!world.isClientSide) { + MapItemSavedData mapItemSavedData = getSavedData(stack, world); + if (mapItemSavedData != null) { ++ synchronized (mapItemSavedData) { // Folia - region threading + if (entity instanceof Player player) { + mapItemSavedData.tickCarriedBy(player, stack); + } +@@ -279,6 +284,7 @@ public class MapItem extends ComplexItem { + if (!mapItemSavedData.locked && (selected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) { + this.update(world, entity, mapItemSavedData); } + } // Folia - region threading - } } + } diff --git a/src/main/java/net/minecraft/world/item/MinecartItem.java b/src/main/java/net/minecraft/world/item/MinecartItem.java -index 3aa73cd44aa8c86b78c35bc1788e4f83018c49ed..cfead7686da25d2cd9203256962170d7a2d77289 100644 +index 66074445d3908b9bb1c8d70e1e27d057720ec8e5..90d45a589751231f01342b5861435b1cfb47a79e 100644 --- a/src/main/java/net/minecraft/world/item/MinecartItem.java +++ b/src/main/java/net/minecraft/world/item/MinecartItem.java -@@ -70,7 +70,7 @@ public class MinecartItem extends Item { +@@ -71,7 +71,7 @@ public class MinecartItem extends Item { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2)); @@ -19197,10 +19197,10 @@ index 21c25026da4117b2cb2c85576d2def945a97dbe2..e0b51cb4ef9e847dc9a2e66f2c87c94d } } diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java -index 524b0f1086c01888fe0b76e180c40915d16a1eb9..50b3025189938374886c7e2725dd3e4d54ac2160 100644 +index e6bfcc50cdf728216084bc00a5bb8b6b3b8f72e4..b8a571fcc44f67ac8f6089e039a8620bf6c40603 100644 --- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java +++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java -@@ -20,7 +20,7 @@ import net.minecraft.world.phys.Vec3; +@@ -22,7 +22,7 @@ import net.minecraft.world.phys.Vec3; public abstract class BaseCommandBlock implements CommandSource { @@ -19209,7 +19209,7 @@ index 524b0f1086c01888fe0b76e180c40915d16a1eb9..50b3025189938374886c7e2725dd3e4d private static final Component DEFAULT_NAME = Component.literal("@"); private long lastExecution = -1L; private boolean updateLastExecution = true; -@@ -111,6 +111,7 @@ public abstract class BaseCommandBlock implements CommandSource { +@@ -117,6 +117,7 @@ public abstract class BaseCommandBlock implements CommandSource { } public boolean performCommand(Level world) { @@ -19217,8 +19217,8 @@ index 524b0f1086c01888fe0b76e180c40915d16a1eb9..50b3025189938374886c7e2725dd3e4d if (!world.isClientSide && world.getGameTime() != this.lastExecution) { if ("Searge".equalsIgnoreCase(this.command)) { this.lastOutput = Component.literal("#itzlipofutzli"); -@@ -169,11 +170,14 @@ public abstract class BaseCommandBlock implements CommandSource { - +@@ -175,11 +176,14 @@ public abstract class BaseCommandBlock implements CommandSource { + this.customName = customName; } + public void threadCheck() {} // Folia @@ -19327,10 +19327,10 @@ index ea0aee88c7d901034427db201c1b2430f8a1d522..2a147a839e78b1d7bfb5eea869754025 return player; } diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 90a82bd7977ebe520bdcc2ab99e11452d5cf4a21..b937437d4446fbf80376399067fd04dc7f95e64a 100644 +index 082b804f4793f72e76361f5427f0358273454b3d..f079fc7ada73dbf5cf21ae78ec4aaebdaa116b1a 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -870,17 +870,18 @@ public class Explosion { +@@ -878,17 +878,18 @@ public class Explosion { if (!this.level.paperConfig().environment.optimizeExplosions) { return this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise explosions } @@ -19353,10 +19353,10 @@ 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 ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a43467129a65f999 100644 +index b4ef3ad2c17168085372f1fe46809f02d9dfe74a..c038be43af1af9b077060ae26bb63756de02cdd0 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 { +@@ -114,10 +114,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public static final int TICKS_PER_DAY = 24000; public static final int MAX_ENTITY_SPAWN_Y = 20000000; public static final int MIN_ENTITY_SPAWN_Y = -20000000; @@ -19371,7 +19371,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 public final Thread thread; private final boolean isDebug; private int skyDarken; -@@ -128,7 +128,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -127,7 +127,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public float rainLevel; protected float oThunderLevel; public float thunderLevel; @@ -19380,7 +19380,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 /** @deprecated */ @Deprecated private final RandomSource threadSafeRandom = RandomSource.createThreadSafe(); -@@ -142,7 +142,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -140,27 +140,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable { private final ResourceKey dimension; private final RegistryAccess registryAccess; private final DamageSources damageSources; @@ -19389,8 +19389,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 // CraftBukkit start Added the following private final CraftWorld world; -@@ -150,20 +150,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - public boolean keepSpawnInMemory = true; + public boolean pvpMode; public org.bukkit.generator.ChunkGenerator generator; - public boolean preventPoiUpdated = false; // CraftBukkit - SPIGOT-5710 @@ -19413,7 +19412,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot // Paper start - add paper world config private final io.papermc.paper.configuration.WorldConfiguration paperConfig; -@@ -177,9 +167,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -174,9 +164,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public static BlockPos lastPhysicsProblem; // Spigot private org.spigotmc.TickLimiter entityLimiter; private org.spigotmc.TickLimiter tileLimiter; @@ -19426,7 +19425,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 // Paper start - fix and optimise world upgrading // copied from below -@@ -216,6 +206,33 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -213,6 +203,33 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public abstract ResourceKey getTypeKey(); @@ -19460,7 +19459,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config; Async-Anti-Xray: Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config -@@ -259,7 +276,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -253,7 +270,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.thread = Thread.currentThread(); this.biomeManager = new BiomeManager(this, i); this.isDebug = flag1; @@ -19469,7 +19468,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 this.registryAccess = iregistrycustom; this.damageSources = new DamageSources(iregistrycustom); // CraftBukkit start -@@ -848,8 +865,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -841,8 +858,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Nullable public final BlockState getBlockStateIfLoaded(BlockPos pos) { // CraftBukkit start - tree generation @@ -19480,7 +19479,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 if (previous != null) { return previous.getHandle(); } -@@ -911,16 +928,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -904,16 +921,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) { @@ -19502,7 +19501,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 } blockstate.setData(state); blockstate.setFlag(flags); -@@ -937,10 +956,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -930,10 +949,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // CraftBukkit start - capture blockstates boolean captured = false; @@ -19515,7 +19514,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 captured = true; } // CraftBukkit end -@@ -950,8 +969,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -943,8 +962,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (iblockdata1 == null) { // CraftBukkit start - remove blockstate if failed (or the same) @@ -19526,7 +19525,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 } // CraftBukkit end return false; -@@ -988,7 +1007,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -981,7 +1000,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { */ // CraftBukkit start @@ -19535,7 +19534,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 // Modularize client and physic updates // Spigot start try { -@@ -1038,7 +1057,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1031,7 +1050,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { iblockdata1.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam CraftWorld world = ((ServerLevel) this).getWorld(); boolean cancelledUpdates = false; // Paper - Fix block place logic @@ -19544,7 +19543,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata)); this.getCraftServer().getPluginManager().callEvent(event); -@@ -1052,7 +1071,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1045,7 +1064,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } // CraftBukkit start - SPIGOT-5710 @@ -19553,7 +19552,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); } // CraftBukkit end -@@ -1136,7 +1155,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1129,7 +1148,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public void neighborShapeChanged(Direction direction, BlockState neighborState, BlockPos pos, BlockPos neighborPos, int flags, int maxUpdateDepth) { @@ -19562,7 +19561,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 } @Override -@@ -1161,11 +1180,34 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1154,11 +1173,34 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return this.getChunkSource().getLightEngine(); } @@ -19599,7 +19598,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 if (previous != null) { return previous.getHandle(); } -@@ -1262,7 +1304,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1253,7 +1295,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } public void addBlockEntityTicker(TickingBlockEntity ticker) { @@ -19608,7 +19607,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 } protected void tickBlockEntities() { -@@ -1270,11 +1312,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1261,11 +1303,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { gameprofilerfiller.push("blockEntities"); this.timings.tileEntityPending.startTiming(); // Spigot @@ -19624,7 +19623,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 this.timings.tileEntityPending.stopTiming(); // Spigot this.timings.tileEntityTick.startTiming(); // Spigot -@@ -1285,9 +1326,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1276,9 +1317,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { int tilesThisCycle = 0; var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet(); // Paper - Fix MC-117075; use removeAll toRemove.add(null); // Paper - Fix MC-117075 @@ -19636,7 +19635,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 // Spigot end if (tickingblockentity.isRemoved()) { -@@ -1298,19 +1338,19 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1289,19 +1329,19 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } else if (flag && this.shouldTickBlocksAt(tickingblockentity.getPos())) { tickingblockentity.tick(); // Paper start - execute chunk tasks during tick @@ -19661,7 +19660,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 } public void guardEntityTick(Consumer tickConsumer, T entity) { -@@ -1323,7 +1363,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1314,7 +1354,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ()); MinecraftServer.LOGGER.error(msg, throwable); getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, throwable))); // Paper - ServerExceptionEvent @@ -19671,7 +19670,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 // Paper end - Prevent block entity and entity crashes } } -@@ -1423,9 +1464,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1419,9 +1460,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Nullable public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) { @@ -19687,7 +19686,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 return blockEntity; } // Paper end - Perf: Optimize capturedTileEntities lookup -@@ -1438,8 +1484,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1434,8 +1480,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (!this.isOutsideBuildHeight(blockposition)) { // CraftBukkit start @@ -19698,7 +19697,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 return; } // CraftBukkit end -@@ -1519,6 +1565,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1515,6 +1561,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public List getEntities(@Nullable Entity except, AABB box, Predicate predicate) { @@ -19706,7 +19705,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 this.getProfiler().incrementCounter("getEntities"); List list = Lists.newArrayList(); ((ServerLevel)this).getEntityLookup().getEntities(except, box, list, predicate); // Paper - optimise this call -@@ -1538,6 +1585,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1534,6 +1581,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } public void getEntities(EntityTypeTest filter, AABB box, Predicate predicate, List result, int limit) { @@ -19714,7 +19713,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 this.getProfiler().incrementCounter("getEntities"); // Paper start - optimise this call //TODO use limit -@@ -1575,13 +1623,30 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1571,13 +1619,30 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public void disconnect() {} @@ -19747,7 +19746,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 public boolean mayInteract(Player player, BlockPos pos) { return true; -@@ -1785,8 +1850,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1777,8 +1842,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } public final BlockPos.MutableBlockPos getRandomBlockPosition(int x, int y, int z, int l, BlockPos.MutableBlockPos out) { // Paper end @@ -19757,7 +19756,7 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 out.set(x + (i1 & 15), y + (i1 >> 16 & l), z + (i1 >> 8 & 15)); // Paper - change to setValues call return out; // Paper -@@ -1817,7 +1881,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1809,7 +1873,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public long nextSubTickCount() { @@ -19767,10 +19766,10 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..2c0ce270c947c7fc1d7e0163a4346712 @Override diff --git a/src/main/java/net/minecraft/world/level/LevelAccessor.java b/src/main/java/net/minecraft/world/level/LevelAccessor.java -index bd9ac874b2d4333bc5c3a79657d63f1bd41fd8c8..f706159a85fe463806b44c768dc9d438a6a1d958 100644 +index 54d13eebc9b01e9d77f51011b7de95b80bc21669..47c3e7f15e1ba9ea8a1c1bb1a0af61dd78dc1b85 100644 --- a/src/main/java/net/minecraft/world/level/LevelAccessor.java +++ b/src/main/java/net/minecraft/world/level/LevelAccessor.java -@@ -35,12 +35,22 @@ public interface LevelAccessor extends CommonLevelAccessor, LevelTimeAccess { +@@ -38,12 +38,22 @@ public interface LevelAccessor extends CommonLevelAccessor, LevelTimeAccess { LevelTickAccess getBlockTicks(); @@ -19784,19 +19783,19 @@ index bd9ac874b2d4333bc5c3a79657d63f1bd41fd8c8..f706159a85fe463806b44c768dc9d438 + } + // Folia end - region threading + - default ScheduledTick createTick(BlockPos pos, T type, int delay, TickPriority priority) { // CraftBukkit - decompile error + private ScheduledTick createTick(BlockPos pos, T type, int delay, TickPriority priority) { - return new ScheduledTick<>(type, pos, this.getLevelData().getGameTime() + (long) delay, priority, this.nextSubTickCount()); + return new ScheduledTick<>(type, pos, this.getRedstoneGameTime() + (long) delay, priority, this.nextSubTickCount()); // Folia - region threading } - default ScheduledTick createTick(BlockPos pos, T type, int delay) { // CraftBukkit - decompile error + private ScheduledTick createTick(BlockPos pos, T type, int delay) { - return new ScheduledTick<>(type, pos, this.getLevelData().getGameTime() + (long) delay, this.nextSubTickCount()); + return new ScheduledTick<>(type, pos, this.getRedstoneGameTime() + (long) delay, this.nextSubTickCount()); // Folia - region threading } default void scheduleTick(BlockPos pos, Block block, int delay, TickPriority priority) { diff --git a/src/main/java/net/minecraft/world/level/LevelReader.java b/src/main/java/net/minecraft/world/level/LevelReader.java -index dab86988686cf7c926b7432b8a4afffd7a23327a..a956c88b82ca39c18f933369c8db2df8722a2e2c 100644 +index 32bfeb9aa87b43a9d2ce46dcc99dbd0ff355b412..440fb4f9b2804b71a6cf7e5fddbd0386d4b2af02 100644 --- a/src/main/java/net/minecraft/world/level/LevelReader.java +++ b/src/main/java/net/minecraft/world/level/LevelReader.java @@ -205,6 +205,25 @@ public interface LevelReader extends BlockAndTintGetter, CollisionGetter, Signal @@ -19826,10 +19825,10 @@ index dab86988686cf7c926b7432b8a4afffd7a23327a..a956c88b82ca39c18f933369c8db2df8 default boolean hasChunksAt(int minX, int minZ, int maxX, int maxZ) { int i = SectionPos.blockToSectionCoord(minX); diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index da7489986848316fed029b71d1bc4e1248c9c9a8..9c1263fdc3731e04ac28c6d0ed904ecdc3ea3038 100644 +index ed8032495af9ce9c23419224814b8d27e4a97c17..db64d88dc26f10304bd10f771f811fcbfaa34bc8 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -146,7 +146,7 @@ public final class NaturalSpawner { +@@ -141,7 +141,7 @@ public final class NaturalSpawner { int limit = enumcreaturetype.getMaxInstancesPerChunk(); SpawnCategory spawnCategory = CraftSpawnCategory.toBukkit(enumcreaturetype); if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { @@ -19856,10 +19855,10 @@ index 3d377b9e461040405e0a7dcbd72d1506b48eb44e..782890e227ff9dab44dd92327979c201 // CraftBukkit start this.addFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); diff --git a/src/main/java/net/minecraft/world/level/StructureManager.java b/src/main/java/net/minecraft/world/level/StructureManager.java -index 07eb481380e8fd4e492f36342ba633579c1b624e..9f3a8f26f4ecd33ea0e4c82a40c9432c094ac899 100644 +index 54972cce2314eff774250101df43a9b7074e9604..0c4942895a83ce1392dd1e71a00ab6d0cb15dab7 100644 --- a/src/main/java/net/minecraft/world/level/StructureManager.java +++ b/src/main/java/net/minecraft/world/level/StructureManager.java -@@ -46,11 +46,7 @@ public class StructureManager { +@@ -48,11 +48,7 @@ public class StructureManager { } public List startsForStructure(ChunkPos pos, Predicate predicate) { @@ -19872,25 +19871,30 @@ index 07eb481380e8fd4e492f36342ba633579c1b624e..9f3a8f26f4ecd33ea0e4c82a40c9432c // Paper end - Fix swamp hut cat generation deadlock Builder builder = ImmutableList.builder(); -@@ -116,15 +112,11 @@ public class StructureManager { +@@ -121,20 +117,11 @@ public class StructureManager { } - public StructureStart getStructureWithPieceAt(BlockPos pos, TagKey structureTag) { + public StructureStart getStructureWithPieceAt(BlockPos pos, Predicate> predicate) { - // Paper start - Fix swamp hut cat generation deadlock -- return this.getStructureWithPieceAt(pos, structureTag, null); +- return this.getStructureWithPieceAt(pos, predicate, null); +- } +- +- public StructureStart getStructureWithPieceAt(BlockPos pos, TagKey tag, @Nullable ServerLevelAccessor levelAccessor) { +- return this.getStructureWithPieceAt(pos, structure -> structure.is(tag), levelAccessor); - } -- public StructureStart getStructureWithPieceAt(BlockPos pos, TagKey structureTag, @Nullable ServerLevelAccessor levelAccessor) { +- +- public StructureStart getStructureWithPieceAt(BlockPos pos, Predicate> predicate, @Nullable ServerLevelAccessor levelAccessor) { - // Paper end - Fix swamp hut cat generation deadlock + // Folia - region threading Registry registry = this.registryAccess().registryOrThrow(Registries.STRUCTURE); for (StructureStart structureStart : this.startsForStructure( -- new ChunkPos(pos), structure -> registry.getHolder(registry.getId(structure)).map(reference -> reference.is(structureTag)).orElse(false), levelAccessor // Paper - Fix swamp hut cat generation deadlock -+ new ChunkPos(pos), structure -> registry.getHolder(registry.getId(structure)).map(reference -> reference.is(structureTag)).orElse(false) // Paper - Fix swamp hut cat generation deadlock // Folia - region threading +- new ChunkPos(pos), structure -> registry.getHolder(registry.getId(structure)).map(predicate::test).orElse(false), levelAccessor // Paper - Fix swamp hut cat generation deadlock ++ new ChunkPos(pos), structure -> registry.getHolder(registry.getId(structure)).map(predicate::test).orElse(false) // Paper - Fix swamp hut cat generation deadlock // Folia - region threading )) { if (this.structureHasPieceAt(pos, structureStart)) { return structureStart; -@@ -169,7 +161,7 @@ public class StructureManager { +@@ -179,7 +166,7 @@ public class StructureManager { } public void addReference(StructureStart structureStart) { @@ -19900,10 +19904,10 @@ index 07eb481380e8fd4e492f36342ba633579c1b624e..9f3a8f26f4ecd33ea0e4c82a40c9432c } diff --git a/src/main/java/net/minecraft/world/level/block/BedBlock.java b/src/main/java/net/minecraft/world/level/block/BedBlock.java -index 38fcde81d797dc46409f5a9ed426fe296d79bdfa..11ba667fd0fe79513d505b34eb0cf1ec66fc2842 100644 +index 85d598c3354ee62f0fd1b26e485e0084967c0380..8492c8fd3ff448d559b33f27b549180918aedeea 100644 --- a/src/main/java/net/minecraft/world/level/block/BedBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java -@@ -367,7 +367,7 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock +@@ -365,7 +365,7 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock world.setBlock(blockposition1, (BlockState) state.setValue(BedBlock.PART, BedPart.HEAD), 3); // CraftBukkit start - SPIGOT-7315: Don't updated if we capture block states @@ -19913,10 +19917,10 @@ index 38fcde81d797dc46409f5a9ed426fe296d79bdfa..11ba667fd0fe79513d505b34eb0cf1ec } // CraftBukkit end diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java -index 22036ed3ea0629bc12981a8d91a03e55cc2117d6..6df3913145aaf37f9a1b7dc77fed12f6952d77e6 100644 +index cf8b8c8efd1c9c81eb5f02d75bd75875eb66771f..b266cc2319177366471ee0bbf570a931974b642a 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -398,8 +398,8 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -390,8 +390,8 @@ public class Block extends BlockBehaviour implements ItemLike { entityitem.setDefaultPickUpDelay(); // CraftBukkit start @@ -19928,11 +19932,11 @@ index 22036ed3ea0629bc12981a8d91a03e55cc2117d6..6df3913145aaf37f9a1b7dc77fed12f6 world.addFreshEntity(entityitem); } diff --git a/src/main/java/net/minecraft/world/level/block/BushBlock.java b/src/main/java/net/minecraft/world/level/block/BushBlock.java -index bed3d9c781c7d3ca260027b4737970889a54689c..46c81d73813c6607d95062358e6e3cd05ffe3192 100644 +index a7b4b5600e3c889c69ac22294899713d50b5fe5c..08847aff604a254e82b4a7d31281953ef04462dd 100644 --- a/src/main/java/net/minecraft/world/level/block/BushBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BushBlock.java @@ -28,7 +28,7 @@ public abstract class BushBlock extends Block { - public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { + protected BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { // CraftBukkit start if (!state.canSurvive(world, pos)) { - if (!(world instanceof net.minecraft.server.level.ServerLevel && ((net.minecraft.server.level.ServerLevel) world).hasPhysicsEvent) || !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) { // Paper @@ -19941,7 +19945,7 @@ index bed3d9c781c7d3ca260027b4737970889a54689c..46c81d73813c6607d95062358e6e3cd0 } } diff --git a/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java b/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java -index de6f00d03223939386aa2ccfdec1e696a68313d7..eb7c2c5b762dbadbe9ccbddc37757bdf97ea4bfe 100644 +index 26ec4838c476b8091f80aeac61db8041d5c89e88..82d333b2644c7af7137f155bfd10e03e8d7e9adc 100644 --- a/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java @@ -120,7 +120,7 @@ public class DaylightDetectorBlock extends BaseEntityBlock { @@ -19954,11 +19958,11 @@ index de6f00d03223939386aa2ccfdec1e696a68313d7..eb7c2c5b762dbadbe9ccbddc37757bdf } diff --git a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java -index 644e64850479cea20a98b8a65503ccf3a34fd32a..321779653c5b1f528673b7aad01f544cc200be58 100644 +index f6edfea463b3725d3a79aca38825e86dbf82175c..92cab51f6b3eeb07b574bd3ba82d736e8880acae 100644 --- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java -@@ -49,7 +49,7 @@ public class DispenserBlock extends BaseEntityBlock { - object2objectopenhashmap.defaultReturnValue(new DefaultDispenseItemBehavior()); +@@ -51,7 +51,7 @@ public class DispenserBlock extends BaseEntityBlock { + object2objectopenhashmap.defaultReturnValue(DispenserBlock.DEFAULT_BEHAVIOR); }); private static final int TRIGGER_DURATION = 4; - public static boolean eventFired = false; // CraftBukkit @@ -19966,7 +19970,7 @@ index 644e64850479cea20a98b8a65503ccf3a34fd32a..321779653c5b1f528673b7aad01f544c @Override public MapCodec codec() { -@@ -105,7 +105,7 @@ public class DispenserBlock extends BaseEntityBlock { +@@ -111,7 +111,7 @@ public class DispenserBlock extends BaseEntityBlock { if (idispensebehavior != DispenseItemBehavior.NOOP) { if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockPreDispenseEvent(world, pos, itemstack, i)) return; // Paper - Add BlockPreDispenseEvent @@ -19976,7 +19980,7 @@ index 644e64850479cea20a98b8a65503ccf3a34fd32a..321779653c5b1f528673b7aad01f544c } diff --git a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java -index 03b5ab8251497c0c94467f90e6663a0dc766babb..4fb595a8300ce2b163540603c7a2b002869a84c1 100644 +index f446c40c4d90307c568faa2866800f5326634df6..455be3cd52cf21bc37d54b8d408e458da7ae9b72 100644 --- a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java @@ -102,7 +102,7 @@ public class DoublePlantBlock extends BushBlock { @@ -19989,7 +19993,7 @@ index 03b5ab8251497c0c94467f90e6663a0dc766babb..4fb595a8300ce2b163540603c7a2b002 } // CraftBukkit end diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java -index 4ba24bced9a2de4616a0418857d3738e0e322ea0..afc9445941b984cc1122839e4a8a17cf27aa966e 100644 +index 7272d70c672b54dcf595beafd7a2ed33c96e35cb..aeac09f628bd04070fd302842c304a7dfd39b229 100644 --- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java +++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java @@ -64,7 +64,7 @@ public class EndPortalBlock extends BaseEntityBlock { @@ -20002,12 +20006,12 @@ index 4ba24bced9a2de4616a0418857d3738e0e322ea0..afc9445941b984cc1122839e4a8a17cf } // Paper end - move all of this logic into portal tick diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java -index 6e4c852c93f2418ea69e485ed3a10cbe3a6e3bd2..ab2b9b85b844cf3e6ef5a0379fa3279b85a7328c 100644 +index d59e33e7326489c6d55d316d0130f22235f4c63c..edb22983a17cc22ba01ee28a9ebc685aaae117eb 100644 --- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java -@@ -92,8 +92,8 @@ public class FarmBlock extends Block { +@@ -93,8 +93,8 @@ public class FarmBlock extends Block { @Override - public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { int i = (Integer) state.getValue(FarmBlock.MOISTURE); - if (i > 0 && world.paperConfig().tickRates.wetFarmland != 1 && (world.paperConfig().tickRates.wetFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.wetFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks - if (i == 0 && world.paperConfig().tickRates.dryFarmland != 1 && (world.paperConfig().tickRates.dryFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.dryFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks @@ -20017,7 +20021,7 @@ index 6e4c852c93f2418ea69e485ed3a10cbe3a6e3bd2..ab2b9b85b844cf3e6ef5a0379fa3279b if (!FarmBlock.isNearWater(world, pos) && !world.isRainingAt(pos.above())) { if (i > 0) { diff --git a/src/main/java/net/minecraft/world/level/block/FungusBlock.java b/src/main/java/net/minecraft/world/level/block/FungusBlock.java -index 50d7235cf2ef036451db708c45a063d037051ae9..c0433491be43bb8cc6d00e32edf7699a79f7a251 100644 +index 454f95ba814b375e97189430b498c0e7486fbd94..59874de6c66f48984d9ba35c6886595027259765 100644 --- a/src/main/java/net/minecraft/world/level/block/FungusBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FungusBlock.java @@ -76,9 +76,9 @@ public class FungusBlock extends BushBlock implements BonemealableBlock { @@ -20033,7 +20037,7 @@ index 50d7235cf2ef036451db708c45a063d037051ae9..c0433491be43bb8cc6d00e32edf7699a // CraftBukkit end ((ConfiguredFeature) holder.value()).place(world, world.getChunkSource().getGenerator(), random, pos); diff --git a/src/main/java/net/minecraft/world/level/block/HoneyBlock.java b/src/main/java/net/minecraft/world/level/block/HoneyBlock.java -index 409b4818840916a8ddbfc1ee87c8c22902939f38..c1f6922168f5d996e80aeb4035822d5506712b6b 100644 +index c6f7815b5fad3aad4635208aa2e5c6739e13cb45..be52d9e56559704c7f258502b4c2919a245d2c2f 100644 --- a/src/main/java/net/minecraft/world/level/block/HoneyBlock.java +++ b/src/main/java/net/minecraft/world/level/block/HoneyBlock.java @@ -86,7 +86,7 @@ public class HoneyBlock extends HalfTransparentBlock { @@ -20046,7 +20050,7 @@ index 409b4818840916a8ddbfc1ee87c8c22902939f38..c1f6922168f5d996e80aeb4035822d55 } } diff --git a/src/main/java/net/minecraft/world/level/block/LightningRodBlock.java b/src/main/java/net/minecraft/world/level/block/LightningRodBlock.java -index ec4aaaca2160312452d724dc6639ac8c4fa42ae4..e1f67599724f67f4f1321f219af8099e8c54e9e7 100644 +index d230ead6042239178bd5c3345aa5366e3082637f..35edc3fef7584178ad15e8c2b939896e4c8ca3e0 100644 --- a/src/main/java/net/minecraft/world/level/block/LightningRodBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LightningRodBlock.java @@ -119,7 +119,7 @@ public class LightningRodBlock extends RodBlock implements SimpleWaterloggedBloc @@ -20059,7 +20063,7 @@ index ec4aaaca2160312452d724dc6639ac8c4fa42ae4..e1f67599724f67f4f1321f219af8099e } } diff --git a/src/main/java/net/minecraft/world/level/block/MushroomBlock.java b/src/main/java/net/minecraft/world/level/block/MushroomBlock.java -index 1f27ae8abd5891a0b8057b454f2210b088b4e95a..a978a6130f5f6fdd1dab194e753cbe2491713c9d 100644 +index 1172d85c5c26ab2142343d91149766e5993cb36a..99d42fdf822c13e8d491b665220d61579143c8e6 100644 --- a/src/main/java/net/minecraft/world/level/block/MushroomBlock.java +++ b/src/main/java/net/minecraft/world/level/block/MushroomBlock.java @@ -105,7 +105,7 @@ public class MushroomBlock extends BushBlock implements BonemealableBlock { @@ -20072,10 +20076,10 @@ index 1f27ae8abd5891a0b8057b454f2210b088b4e95a..a978a6130f5f6fdd1dab194e753cbe24 return true; } else { diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -index b5a71fd4e2f55bf036c2c697da5d50cc90fc657c..7f33db05284a957690eac6eb6f5b3b05586727bb 100644 +index c131734cad123a35456d18f8a161f77a4ac9ac99..c4471342eea4f9e2b0916fc1c5f1b24bc07757fd 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -69,7 +69,7 @@ public class RedStoneWireBlock extends Block { +@@ -68,7 +68,7 @@ public class RedStoneWireBlock extends Block { }); private static final float PARTICLE_DENSITY = 0.2F; private final BlockState crossState; @@ -20084,7 +20088,7 @@ index b5a71fd4e2f55bf036c2c697da5d50cc90fc657c..7f33db05284a957690eac6eb6f5b3b05 @Override public MapCodec codec() { -@@ -261,7 +261,11 @@ public class RedStoneWireBlock extends Block { +@@ -260,7 +260,11 @@ public class RedStoneWireBlock extends Block { // Paper start - Optimize redstone (Eigencraft) // The bulk of the new functionality is found in RedstoneWireTurbo.java @@ -20097,7 +20101,7 @@ index b5a71fd4e2f55bf036c2c697da5d50cc90fc657c..7f33db05284a957690eac6eb6f5b3b05 /* * Modified version of pre-existing updateSurroundingRedstone, which is called from -@@ -270,7 +274,7 @@ public class RedStoneWireBlock extends Block { +@@ -269,7 +273,7 @@ public class RedStoneWireBlock extends Block { */ private void updateSurroundingRedstone(Level worldIn, BlockPos pos, BlockState state, BlockPos source) { if (worldIn.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.EIGENCRAFT) { @@ -20106,7 +20110,7 @@ index b5a71fd4e2f55bf036c2c697da5d50cc90fc657c..7f33db05284a957690eac6eb6f5b3b05 return; } updatePowerStrength(worldIn, pos, state); -@@ -289,9 +293,9 @@ public class RedStoneWireBlock extends Block { +@@ -288,9 +292,9 @@ public class RedStoneWireBlock extends Block { int i = state.getValue(POWER); int j = 0; j = this.getPower(j, worldIn.getBlockState(pos2)); @@ -20118,7 +20122,7 @@ index b5a71fd4e2f55bf036c2c697da5d50cc90fc657c..7f33db05284a957690eac6eb6f5b3b05 if (worldIn.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.VANILLA) { // This code is totally redundant to if statements just below the loop. -@@ -361,7 +365,7 @@ public class RedStoneWireBlock extends Block { +@@ -360,7 +364,7 @@ public class RedStoneWireBlock extends Block { // [Space Walker] suppress shape updates and emit those manually to // bypass the new neighbor update stack. if (worldIn.setBlock(pos1, state, Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_CLIENTS)) @@ -20127,7 +20131,7 @@ index b5a71fd4e2f55bf036c2c697da5d50cc90fc657c..7f33db05284a957690eac6eb6f5b3b05 } } -@@ -410,10 +414,10 @@ public class RedStoneWireBlock extends Block { +@@ -409,10 +413,10 @@ public class RedStoneWireBlock extends Block { } private int calculateTargetStrength(Level world, BlockPos pos) { @@ -20140,25 +20144,25 @@ index b5a71fd4e2f55bf036c2c697da5d50cc90fc657c..7f33db05284a957690eac6eb6f5b3b05 int j = 0; if (i < 15) { -@@ -552,12 +556,12 @@ public class RedStoneWireBlock extends Block { +@@ -551,12 +555,12 @@ public class RedStoneWireBlock extends Block { @Override - public int getDirectSignal(BlockState state, BlockGetter world, BlockPos pos, Direction direction) { + protected int getDirectSignal(BlockState state, BlockGetter world, BlockPos pos, Direction direction) { - return !this.shouldSignal ? 0 : state.getSignal(world, pos, direction); + return !io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegionizedWorldData().shouldSignal ? 0 : state.getSignal(world, pos, direction); // Folia - region threading } @Override - public int getSignal(BlockState state, BlockGetter world, BlockPos pos, Direction direction) { + protected int getSignal(BlockState state, BlockGetter world, BlockPos pos, Direction direction) { - if (this.shouldSignal && direction != Direction.DOWN) { + if (io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegionizedWorldData().shouldSignal && direction != Direction.DOWN) { // Folia - region threading int i = (Integer) state.getValue(RedStoneWireBlock.POWER); return i == 0 ? 0 : (direction != Direction.UP && !((RedstoneSide) this.getConnectionState(world, state, pos).getValue((Property) RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(direction.getOpposite()))).isConnected() ? 0 : i); -@@ -584,7 +588,10 @@ public class RedStoneWireBlock extends Block { +@@ -583,7 +587,10 @@ public class RedStoneWireBlock extends Block { @Override - public boolean isSignalSource(BlockState state) { + protected boolean isSignalSource(BlockState state) { - return this.shouldSignal; + // Folia start - region threading + io.papermc.paper.threadedregions.RegionizedWorldData worldData = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegionizedWorldData(); @@ -20168,11 +20172,11 @@ index b5a71fd4e2f55bf036c2c697da5d50cc90fc657c..7f33db05284a957690eac6eb6f5b3b05 public static int getColorForPower(int powerLevel) { diff --git a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java -index 1dbfda52a4423fb031eecad24e5766f49ecf6050..332f606d9a41ab19707f2f11bd43d2880b410180 100644 +index ceba9617748a8b4f3a9bd459475952c9c6c9ed7c..525d3b4c0b91b87399748fceda61c4046fa6bef2 100644 --- a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java @@ -81,10 +81,10 @@ public class RedstoneTorchBlock extends BaseTorchBlock { - public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { boolean flag = this.hasNeighborSignal(world, pos, state); // Paper start - Faster redstone torch rapid clock removal - java.util.ArrayDeque redstoneUpdateInfos = world.redstoneUpdateInfos; @@ -20224,7 +20228,7 @@ index 1dbfda52a4423fb031eecad24e5766f49ecf6050..332f606d9a41ab19707f2f11bd43d288 } } diff --git a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java b/src/main/java/net/minecraft/world/level/block/SaplingBlock.java -index 3ff0d08e4964aae82d8e51d3b8bf9aa002096f81..d4e86aa35a36ce0ef2cac3567e044b78fa58c87e 100644 +index d262a5a6da57ef9ba9a6fe0dfbc88f577105e74f..e842c05cfe5991ba33582b9399610affbd02913f 100644 --- a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SaplingBlock.java @@ -35,7 +35,7 @@ public class SaplingBlock extends BushBlock implements BonemealableBlock { @@ -20265,23 +20269,23 @@ index 3ff0d08e4964aae82d8e51d3b8bf9aa002096f81..d4e86aa35a36ce0ef2cac3567e044b78 if (treeType != null) { event = new StructureGrowEvent(location, treeType, false, null, blocks); diff --git a/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java b/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java -index f3003a3832deff7724d28b4b3a091f4802a4cb29..d628cee1f72ee973bc10a49f2dd65becab85e28c 100644 +index b7165ec19bef1a07f6618fc0429d86cda1b08da4..ad44708d19d216ed57c664940ccd1c8ecb78877c 100644 --- a/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java -@@ -55,7 +55,7 @@ public abstract class SpreadingSnowyDirtBlock extends SnowyDirtBlock { +@@ -54,7 +54,7 @@ public abstract class SpreadingSnowyDirtBlock extends SnowyDirtBlock { @Override - public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { -- if (this instanceof GrassBlock && world.paperConfig().tickRates.grassSpread != 1 && (world.paperConfig().tickRates.grassSpread < 1 || (MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.grassSpread != 0)) { return; } // Paper - Configurable random tick rates for blocks + protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { +- if (this instanceof GrassBlock && world.paperConfig().tickRates.grassSpread != 1 && (world.paperConfig().tickRates.grassSpread < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.grassSpread != 0)) { return; } // Paper - Configurable random tick rates for blocks + if (this instanceof GrassBlock && world.paperConfig().tickRates.grassSpread != 1 && (world.paperConfig().tickRates.grassSpread < 1 || (io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() + pos.hashCode()) % world.paperConfig().tickRates.grassSpread != 0)) { return; } // Paper - Configurable random tick rates for blocks // Folia - regionised ticking // Paper start - Perf: optimize dirt and snow spreading - net.minecraft.world.level.chunk.ChunkAccess cachedBlockChunk = world.getChunkIfLoaded(pos); + final net.minecraft.world.level.chunk.ChunkAccess cachedBlockChunk = world.getChunkIfLoaded(pos); if (cachedBlockChunk == null) { // Is this needed? diff --git a/src/main/java/net/minecraft/world/level/block/WitherSkullBlock.java b/src/main/java/net/minecraft/world/level/block/WitherSkullBlock.java -index fb180f0bcd20e51d41cfc924029c0b23d3d26258..3db0727cd8d835e8d1b7b3fab93613d2e97b95ab 100644 +index bbf59b2577812e74ffd45f694b83a42e043273c0..9d4ecf409098adbf4d47b08d7ef10c6d9c3de113 100644 --- a/src/main/java/net/minecraft/world/level/block/WitherSkullBlock.java +++ b/src/main/java/net/minecraft/world/level/block/WitherSkullBlock.java -@@ -58,7 +58,7 @@ public class WitherSkullBlock extends SkullBlock { +@@ -61,7 +61,7 @@ public class WitherSkullBlock extends SkullBlock { } public static void checkSpawn(Level world, BlockPos pos, SkullBlockEntity blockEntity) { @@ -20291,10 +20295,10 @@ index fb180f0bcd20e51d41cfc924029c0b23d3d26258..3db0727cd8d835e8d1b7b3fab93613d2 BlockState iblockdata = blockEntity.getBlockState(); boolean flag = iblockdata.is(Blocks.WITHER_SKELETON_SKULL) || iblockdata.is(Blocks.WITHER_SKELETON_WALL_SKULL); diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -index 4b81b0180dfc96fc6a88646838a886ca5b5d301b..d973ac7d15ee087deb6c6c55a5d10beeedcca8e0 100644 +index a6ffbbc1b5021564864e42c0756342352c2b8290..28d0dbb81a68ecf2dfba6744093e26bbba291966 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -211,7 +211,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name +@@ -215,7 +215,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name } i1 = blockEntity.levels; @@ -20304,10 +20308,10 @@ index 4b81b0180dfc96fc6a88646838a886ca5b5d301b..d973ac7d15ee087deb6c6c55a5d10bee blockEntity.levels = BeaconBlockEntity.updateBase(world, i, j, k); } diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -index 9ea74d37cd951e0dc76d20ed8234b5871035566c..5be70de980d8b475d64dfbb029d11ba30894b880 100644 +index 6349f2e0a5ba30d250f5ffe43771f325c0999a76..a3aa4a567c15cb3ac124caa17fd16fdf1f7d37b7 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -26,7 +26,7 @@ import co.aikar.timings.MinecraftTimings; // Paper +@@ -38,7 +38,7 @@ import co.aikar.timings.MinecraftTimings; // Paper import co.aikar.timings.Timing; // Paper public abstract class BlockEntity { @@ -20316,9 +20320,9 @@ index 9ea74d37cd951e0dc76d20ed8234b5871035566c..5be70de980d8b475d64dfbb029d11ba3 public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper // CraftBukkit start - data containers -@@ -41,6 +41,12 @@ public abstract class BlockEntity { - protected boolean remove; +@@ -54,6 +54,12 @@ public abstract class BlockEntity { private BlockState blockState; + private DataComponentMap components; + // Folia start - region ticking + public void updateTicks(final long fromTickOffset, final long fromRedstoneTimeOffset) { @@ -20327,9 +20331,9 @@ index 9ea74d37cd951e0dc76d20ed8234b5871035566c..5be70de980d8b475d64dfbb029d11ba3 + // Folia end - region ticking + public BlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { + this.components = DataComponentMap.EMPTY; this.type = type; - this.worldPosition = pos.immutable(); -@@ -162,7 +168,7 @@ public abstract class BlockEntity { +@@ -217,7 +223,7 @@ public abstract class BlockEntity { public void setChanged() { if (this.level != null) { @@ -20339,10 +20343,10 @@ index 9ea74d37cd951e0dc76d20ed8234b5871035566c..5be70de980d8b475d64dfbb029d11ba3 } diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -index 9bb542ce3a8c52e1688bb1f66fc916dd23a5fd10..23ebbc58f8f7eeb6398d21b3e96772971d02bcac 100644 +index 887957ce1ddc2f32569405642f35df468c08271f..a1cd6dcabe480c1714bdc15d53aadc828e041f6d 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -@@ -56,7 +56,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -54,7 +54,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements public int fuel; protected final ContainerData dataAccess; // CraftBukkit start - add fields and methods @@ -20351,7 +20355,7 @@ index 9bb542ce3a8c52e1688bb1f66fc916dd23a5fd10..23ebbc58f8f7eeb6398d21b3e9677297 public List transaction = new java.util.ArrayList(); private int maxStack = MAX_STACK; -@@ -173,11 +173,10 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -170,11 +170,10 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements ItemStack itemstack1 = (ItemStack) blockEntity.items.get(3); // CraftBukkit start - Use wall time instead of ticks for brewing @@ -20366,10 +20370,10 @@ index 9bb542ce3a8c52e1688bb1f66fc916dd23a5fd10..23ebbc58f8f7eeb6398d21b3e9677297 // CraftBukkit end diff --git a/src/main/java/net/minecraft/world/level/block/entity/CommandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/CommandBlockEntity.java -index f08c77e20462bada221b5ed395ceb2f7d39ee7c0..8422e4fb36342555937002afcb3611d604a60c07 100644 +index 6c484f3f8f37a19992ebbfe30aba399cac21acfe..733a3d17b8e06b1c078ccf9e533fdaad89f110cc 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/CommandBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/CommandBlockEntity.java -@@ -57,6 +57,13 @@ public class CommandBlockEntity extends BlockEntity { +@@ -61,6 +61,13 @@ public class CommandBlockEntity extends BlockEntity { return new CommandSourceStack(this, Vec3.atCenterOf(CommandBlockEntity.this.worldPosition), new Vec2(0.0F, enumdirection.toYRot()), this.getLevel(), this.getLevel().paperConfig().commandBlocks.permissionsLevel, this.getName().getString(), this.getName(), this.getLevel().getServer(), (Entity) null); // Paper - configurable command block perm level } @@ -20384,10 +20388,10 @@ index f08c77e20462bada221b5ed395ceb2f7d39ee7c0..8422e4fb36342555937002afcb3611d6 public boolean isValid() { return !CommandBlockEntity.this.isRemoved(); diff --git a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -index 37e0b762b86e74f607a4541ecb7b24ad7a591d0e..4ddc3b3dc704610bf1fb7082e1c89a284c245fce 100644 +index 73e532dc998e5701c1a73da846da3d3a79871b81..5e4cb998554791cdfc2e32ae7115f87e9e23feff 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -@@ -83,7 +83,7 @@ public class ConduitBlockEntity extends BlockEntity { +@@ -84,7 +84,7 @@ public class ConduitBlockEntity extends BlockEntity { public static void clientTick(Level world, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity) { ++blockEntity.tickCount; @@ -20396,7 +20400,7 @@ index 37e0b762b86e74f607a4541ecb7b24ad7a591d0e..4ddc3b3dc704610bf1fb7082e1c89a28 List list = blockEntity.effectBlocks; if (i % 40L == 0L) { -@@ -101,7 +101,7 @@ public class ConduitBlockEntity extends BlockEntity { +@@ -102,7 +102,7 @@ public class ConduitBlockEntity extends BlockEntity { public static void serverTick(Level world, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity) { ++blockEntity.tickCount; @@ -20406,18 +20410,18 @@ index 37e0b762b86e74f607a4541ecb7b24ad7a591d0e..4ddc3b3dc704610bf1fb7082e1c89a28 if (i % 40L == 0L) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e42ef55201 100644 +index 8310d132006043e93c612890514c4c7f3eb1c74d..1280c358748bbb08f0361acd4ebc095bf6bc3496 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -50,7 +50,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - public static final int HOPPER_CONTAINER_SIZE = 5; +@@ -49,7 +49,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + private static final int[][] CACHED_SLOTS = new int[54][]; private NonNullList items; public int cooldownTime; - private long tickedGameTime; + private long tickedGameTime = Long.MIN_VALUE; // Folia - region threading + private Direction facing; // CraftBukkit start - add fields and methods - public List transaction = new java.util.ArrayList(); @@ -82,6 +82,16 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } // CraftBukkit end @@ -20435,7 +20439,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e4 public HopperBlockEntity(BlockPos pos, BlockState state) { super(BlockEntityType.HOPPER, pos, state); this.items = NonNullList.withSize(5, ItemStack.EMPTY); -@@ -137,7 +147,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -141,7 +151,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen public static void pushItemsTick(Level world, BlockPos pos, BlockState state, HopperBlockEntity blockEntity) { --blockEntity.cooldownTime; @@ -20444,7 +20448,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e4 if (!blockEntity.isOnCooldown()) { blockEntity.setCooldown(0); // Spigot start -@@ -234,12 +244,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -237,12 +247,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } // Paper start - Perf: Optimize Hoppers @@ -20460,7 +20464,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e4 boolean foundItem = false; for (int i = 0; i < hopper.getContainerSize(); ++i) { final ItemStack item = hopper.getItem(i); -@@ -254,7 +263,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -257,7 +266,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen // We only need to fire the event once to give protection plugins a chance to cancel this event // Because nothing uses getItem, every event call should end up the same result. @@ -20469,7 +20473,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e4 movedItem = callPushMoveEvent(destination, movedItem, hopper); if (movedItem == null) { // cancelled origItemStack.setCount(originalItemCount); -@@ -284,13 +293,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -287,13 +296,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } private static boolean hopperPull(final Level level, final Hopper hopper, final Container container, ItemStack origItemStack, final int i) { @@ -20485,7 +20489,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e4 movedItem = callPullMoveEvent(hopper, container, movedItem); if (movedItem == null) { // cancelled origItemStack.setCount(originalItemCount); -@@ -310,9 +320,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -313,9 +323,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen origItemStack.setCount(originalItemCount - movedItemCount + remainingItemCount); } @@ -20497,7 +20501,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e4 container.setChanged(); return true; } -@@ -327,12 +337,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -330,12 +340,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Nullable private static ItemStack callPushMoveEvent(Container iinventory, ItemStack itemstack, HopperBlockEntity hopper) { @@ -20512,7 +20516,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e4 } if (!result) { cooldownHopper(hopper); -@@ -348,6 +359,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -351,6 +362,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Nullable private static ItemStack callPullMoveEvent(final Hopper hopper, final Container container, final ItemStack itemstack) { @@ -20520,7 +20524,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e4 final Inventory sourceInventory = getInventory(container); final Inventory destination = getInventory(hopper); -@@ -355,7 +367,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -358,7 +370,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen final io.papermc.paper.event.inventory.PaperInventoryMoveItemEvent event = new io.papermc.paper.event.inventory.PaperInventoryMoveItemEvent(sourceInventory, CraftItemStack.asCraftMirror(itemstack), destination, false); final boolean result = event.callEvent(); if (!event.calledGetItem && !event.calledSetItem) { @@ -20529,23 +20533,23 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e4 } if (!result) { cooldownHopper(hopper); -@@ -518,13 +530,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -541,13 +553,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } public static boolean suckInItems(Level world, Hopper hopper) { + io.papermc.paper.threadedregions.RegionizedWorldData worldData = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegionizedWorldData(); // Folia - region threading - Container iinventory = HopperBlockEntity.getSourceContainer(world, hopper); + BlockPos blockposition = BlockPos.containing(hopper.getLevelX(), hopper.getLevelY() + 1.0D, hopper.getLevelZ()); + BlockState iblockdata = world.getBlockState(blockposition); + Container iinventory = HopperBlockEntity.getSourceContainer(world, hopper, blockposition, iblockdata); if (iinventory != null) { Direction enumdirection = Direction.DOWN; +- skipPullModeEventFire = skipHopperEvents; // Paper - Perf: Optimize Hoppers ++ worldData.skipPullModeEventFire = worldData.skipHopperEvents; // Paper - Perf: Optimize Hoppers // Folia - region threading + int[] aint = HopperBlockEntity.getSlots(iinventory, enumdirection); + int i = aint.length; - // Paper start - Perf: Optimize Hoppers -- skipPullModeEventFire = skipHopperEvents; -+ worldData.skipPullModeEventFire = worldData.skipHopperEvents; // Folia - region threading - // merge container isEmpty check and move logic into one loop - if (iinventory instanceof WorldlyContainer worldlyContainer) { - for (final int slot : worldlyContainer.getSlotsForFace(enumdirection)) { -@@ -724,9 +737,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -733,9 +746,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen stack = stack.split(to.getMaxStackSize()); } // Spigot end @@ -20558,10 +20562,10 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e4 flag = true; } else if (HopperBlockEntity.canMergeItems(itemstack1, stack)) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java -index 83481539e058e5f428d9951e409fed62ef159e5c..48260dce982181e2ee4e92614f8ed3af4bf83af0 100644 +index 81dd0aa6a90fd9dda9e7752f85b9cf4568e3b575..a56804cd7ba9197993d1c3f83f7c3e054bd08bb0 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java -@@ -43,9 +43,9 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi +@@ -45,9 +45,9 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi // Paper end - Fix NPE in SculkBloomEvent world access public static void serverTick(Level world, BlockPos pos, BlockState state, SculkCatalystBlockEntity blockEntity) { @@ -20574,10 +20578,10 @@ index 83481539e058e5f428d9951e409fed62ef159e5c..48260dce982181e2ee4e92614f8ed3af @Override diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java -index 098fde8200a11f91f934ddab6b1486dac4014dfe..412fa8a03be7215fa2695f07ac4f2334d1e70903 100644 +index 93bd70c1dc2ba8b893a6087730071c81fb1132f4..04743a3e8546655e769442744c32a4c54425fc55 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java -@@ -51,9 +51,12 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { +@@ -52,9 +52,12 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { public long age; private int teleportCooldown; @Nullable @@ -20591,7 +20595,7 @@ index 098fde8200a11f91f934ddab6b1486dac4014dfe..412fa8a03be7215fa2695f07ac4f2334 public TheEndGatewayBlockEntity(BlockPos pos, BlockState state) { super(BlockEntityType.END_GATEWAY, pos, state); } -@@ -121,7 +124,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { +@@ -117,7 +120,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { } public static boolean canEntityTeleport(Entity entity) { @@ -20600,7 +20604,7 @@ index 098fde8200a11f91f934ddab6b1486dac4014dfe..412fa8a03be7215fa2695f07ac4f2334 } public boolean isSpawning() { -@@ -169,8 +172,136 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { +@@ -165,8 +168,136 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { } } @@ -20727,17 +20731,17 @@ index 098fde8200a11f91f934ddab6b1486dac4014dfe..412fa8a03be7215fa2695f07ac4f2334 + // Folia end - region threading + public static void teleportEntity(Level world, BlockPos pos, BlockState state, Entity entity, TheEndGatewayBlockEntity blockEntity) { - if (world instanceof ServerLevel && !blockEntity.isCoolingDown()) { + if (world instanceof ServerLevel worldserver && !blockEntity.isCoolingDown()) { + // Folia start - region threading + if (true) { + teleportRegionThreading(world, pos, state, entity, blockEntity); + return; + } + // Folia end - region threading - ServerLevel worldserver = (ServerLevel) world; - blockEntity.teleportCooldown = 100; -@@ -275,6 +406,129 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { + BlockPos blockposition1; + +@@ -269,6 +400,129 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { return TheEndGatewayBlockEntity.findTallestBlock(world, blockposition1, 16, true); } @@ -20840,7 +20844,7 @@ index 098fde8200a11f91f934ddab6b1486dac4014dfe..412fa8a03be7215fa2695f07ac4f2334 + world.chunkTaskScheduler.scheduleChunkLoad( + io.papermc.paper.util.CoordinateUtils.getChunkX(vars.currPos), + io.papermc.paper.util.CoordinateUtils.getChunkZ(vars.currPos), -+ net.minecraft.world.level.chunk.ChunkStatus.FULL, ++ net.minecraft.world.level.chunk.status.ChunkStatus.FULL, + true, + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, + (chunk) -> { @@ -20854,7 +20858,7 @@ index 098fde8200a11f91f934ddab6b1486dac4014dfe..412fa8a03be7215fa2695f07ac4f2334 + world.chunkTaskScheduler.scheduleChunkLoad( + io.papermc.paper.util.CoordinateUtils.getChunkX(posDirExtruded), + io.papermc.paper.util.CoordinateUtils.getChunkZ(posDirExtruded), -+ net.minecraft.world.level.chunk.ChunkStatus.FULL, ++ net.minecraft.world.level.chunk.status.ChunkStatus.FULL, + true, + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, + (chunk) -> { @@ -20879,10 +20883,10 @@ index 28e3b73507b988f7234cbf29c4024c88180d0aef..c8facee29ee08e0975528083f89b64f0 + BlockEntity getTileEntity(); // Folia - region threading } diff --git a/src/main/java/net/minecraft/world/level/block/grower/TreeGrower.java b/src/main/java/net/minecraft/world/level/block/grower/TreeGrower.java -index 8cb822fed0cda4268f288feae1079a3dc4dc103e..3f53d51960ded5df3b8be12362110f22b3c495b8 100644 +index 5803a6731d1d35afc3df316546519fa0d423af6e..576c5aba2209cbeccd09a7ba5803b3780178f39b 100644 --- a/src/main/java/net/minecraft/world/level/block/grower/TreeGrower.java +++ b/src/main/java/net/minecraft/world/level/block/grower/TreeGrower.java -@@ -175,51 +175,53 @@ public final class TreeGrower { +@@ -174,51 +174,53 @@ public final class TreeGrower { // CraftBukkit start private void setTreeType(Holder> holder) { ResourceKey> worldgentreeabstract = holder.unwrapKey().get(); @@ -20958,10 +20962,10 @@ index 8cb822fed0cda4268f288feae1079a3dc4dc103e..3f53d51960ded5df3b8be12362110f22 // CraftBukkit end diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java -index be74adc86f0ca467f3b59e7b57fd47a8f381d86e..363a712d6b9e717b075aa52643c6cf91497e7c3b 100644 +index e0c62227b279a5fe0f3868fbf9ce8c78c515a09c..bf9a6f40998144ba7dbdfafc8dbdbb84168d1edb 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java -@@ -152,7 +152,7 @@ public class PistonBaseBlock extends DirectionalBlock { +@@ -153,7 +153,7 @@ public class PistonBaseBlock extends DirectionalBlock { if (tileentity instanceof PistonMovingBlockEntity) { PistonMovingBlockEntity tileentitypiston = (PistonMovingBlockEntity) tileentity; @@ -20971,10 +20975,10 @@ index be74adc86f0ca467f3b59e7b57fd47a8f381d86e..363a712d6b9e717b075aa52643c6cf91 } } diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index 9f45dda6ff45ac1ffb7ac99575b7d09bdc61c56a..9a0d66b48470a6bef70b6643ff05812da519adfa 100644 +index b35f476e26a020cf75e53a5eb488717d996a6935..58b570cfdd52b414752b5a117946d59031eafe94 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -39,9 +39,19 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -40,9 +40,19 @@ public class PistonMovingBlockEntity extends BlockEntity { private static final ThreadLocal NOCLIP = ThreadLocal.withInitial(() -> null); private float progress; private float progressO; @@ -20995,7 +20999,7 @@ index 9f45dda6ff45ac1ffb7ac99575b7d09bdc61c56a..9a0d66b48470a6bef70b6643ff05812d public PistonMovingBlockEntity(BlockPos pos, BlockState state) { super(BlockEntityType.PISTON, pos, state); } -@@ -148,8 +158,8 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -149,8 +159,8 @@ public class PistonMovingBlockEntity extends BlockEntity { entity.setDeltaMovement(e, g, h); // Paper - EAR items stuck in in slime pushed by a piston @@ -21006,7 +21010,7 @@ index 9f45dda6ff45ac1ffb7ac99575b7d09bdc61c56a..9a0d66b48470a6bef70b6643ff05812d // Paper end break; } -@@ -289,7 +299,7 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -290,7 +300,7 @@ public class PistonMovingBlockEntity extends BlockEntity { } public static void tick(Level world, BlockPos pos, BlockState state, PistonMovingBlockEntity blockEntity) { @@ -21016,7 +21020,7 @@ index 9f45dda6ff45ac1ffb7ac99575b7d09bdc61c56a..9a0d66b48470a6bef70b6643ff05812d if (blockEntity.progressO >= 1.0F) { if (world.isClientSide && blockEntity.deathTicks < 5) { diff --git a/src/main/java/net/minecraft/world/level/border/WorldBorder.java b/src/main/java/net/minecraft/world/level/border/WorldBorder.java -index 350aabd20329f429248c84d73ab8b5eb145943a7..bdb864f5e7a1bacde88be632442c9de000ce7729 100644 +index 6c6eb7deed281678c05ef27f933e1693b11dae7c..e1572c7d5409bde5e73905d8814d2d1defcfc227 100644 --- a/src/main/java/net/minecraft/world/level/border/WorldBorder.java +++ b/src/main/java/net/minecraft/world/level/border/WorldBorder.java @@ -33,19 +33,19 @@ public class WorldBorder { @@ -21045,10 +21049,10 @@ index 350aabd20329f429248c84d73ab8b5eb145943a7..bdb864f5e7a1bacde88be632442c9de0 // Paper end - Bound treasure maps to world border diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java -index 4c03297fb523ef59cd9d11edbed437398e562a00..484cd058ca3cd317d2c82e502c064edca4293e74 100644 +index 927bdebdb8ae01613f0cea074b3367bd7ffe9ab1..9a17f3d0b53b2ab0358012e4238164f8af0a6c6e 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -320,7 +320,7 @@ public abstract class ChunkGenerator { +@@ -326,7 +326,7 @@ public abstract class ChunkGenerator { } private static boolean tryAddReference(StructureManager structureAccessor, StructureStart start) { @@ -21058,10 +21062,10 @@ index 4c03297fb523ef59cd9d11edbed437398e562a00..484cd058ca3cd317d2c82e502c064edc 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 465458e8a7dbaf9afb32709a71c7b2620d1e1fd2..ff1a7b78fa010857daab7a306cb9483c98560b79 100644 +index 2a8609e33716949ff1877b6d10f64a9d7a7c81e9..f1f0391b5e5b808b1176bc76e7c49fc7ecd141a4 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 { +@@ -61,6 +61,13 @@ public class LevelChunk extends ChunkAccess { @Override public void tick() {} @@ -21126,7 +21130,7 @@ index 465458e8a7dbaf9afb32709a71c7b2620d1e1fd2..ff1a7b78fa010857daab7a306cb9483c if (this.blockTicks.isDirty(gameTime) || this.fluidTicks.isDirty(gameTime)) { return true; } -@@ -1117,6 +1125,13 @@ public class LevelChunk extends ChunkAccess { +@@ -1115,6 +1123,13 @@ public class LevelChunk extends ChunkAccess { this.ticker = wrapped; } @@ -21140,7 +21144,7 @@ index 465458e8a7dbaf9afb32709a71c7b2620d1e1fd2..ff1a7b78fa010857daab7a306cb9483c @Override public void tick() { this.ticker.tick(); -@@ -1153,6 +1168,13 @@ public class LevelChunk extends ChunkAccess { +@@ -1151,6 +1166,13 @@ public class LevelChunk extends ChunkAccess { this.ticker = blockentityticker; } @@ -21155,10 +21159,10 @@ index 465458e8a7dbaf9afb32709a71c7b2620d1e1fd2..ff1a7b78fa010857daab7a306cb9483c public void tick() { if (!this.blockEntity.isRemoved() && this.blockEntity.hasLevel()) { diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -index d312ce27364f84d32dec8d58a2b37a8a6ad756af..c1629db60017acccc0cf246941afa02c03048bbb 100644 +index 26431a814f6472689484dcc7cd8183fe1676e17e..de1a916c5034a8886bf16ee6ab235185d48a8a2c 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -@@ -645,7 +645,7 @@ public class ChunkSerializer { +@@ -633,7 +633,7 @@ public class ChunkSerializer { } private static void saveTicks(ServerLevel world, CompoundTag nbt, ChunkAccess.TicksToSave tickSchedulers) { @@ -21168,7 +21172,7 @@ index d312ce27364f84d32dec8d58a2b37a8a6ad756af..c1629db60017acccc0cf246941afa02c nbt.put("block_ticks", tickSchedulers.blocks().save(i, (block) -> { return BuiltInRegistries.BLOCK.getKey(block).toString(); diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java -index d4f903c402765c6e8e1db99e148613748f530726..9568ec33e2b0efdb536930edb44d46e082b86152 100644 +index 18a1b4325cac81b040596071dab99ef9bf6f3142..23b8776fb5379a3cbe5ee95a953cbf7cbd904f94 100644 --- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java @@ -76,7 +76,7 @@ public class EndDragonFight { @@ -21236,10 +21240,10 @@ index d4f903c402765c6e8e1db99e148613748f530726..9568ec33e2b0efdb536930edb44d46e0 if (blockposition == null) { diff --git a/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java -index 1c4dafdfb3898b5efe06d66792b1b0841ec5724d..8115eb2b632f6aa8d624bddc83c23e281727407f 100644 +index 1741360aa3f2409b1a8ddf1d4602ffe57651a586..0788c67a09e67b9775c0d073efc72547f90df94a 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java +++ b/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java -@@ -19,7 +19,7 @@ import net.minecraft.world.level.block.state.BlockState; +@@ -18,7 +18,7 @@ import net.minecraft.world.level.block.state.BlockState; public class PatrolSpawner implements CustomSpawner { @@ -21248,7 +21252,7 @@ index 1c4dafdfb3898b5efe06d66792b1b0841ec5724d..8115eb2b632f6aa8d624bddc83c23e28 public PatrolSpawner() {} -@@ -32,15 +32,16 @@ public class PatrolSpawner implements CustomSpawner { +@@ -31,15 +31,16 @@ public class PatrolSpawner implements CustomSpawner { return 0; } else { RandomSource randomsource = world.random; @@ -21267,7 +21271,7 @@ index 1c4dafdfb3898b5efe06d66792b1b0841ec5724d..8115eb2b632f6aa8d624bddc83c23e28 if (entityhuman.isSpectator()) { return 0; } -@@ -50,8 +51,8 @@ public class PatrolSpawner implements CustomSpawner { +@@ -49,8 +50,8 @@ public class PatrolSpawner implements CustomSpawner { --entityhuman.patrolSpawnDelay; patrolSpawnDelay = entityhuman.patrolSpawnDelay; } else { @@ -21278,7 +21282,7 @@ index 1c4dafdfb3898b5efe06d66792b1b0841ec5724d..8115eb2b632f6aa8d624bddc83c23e28 } if (patrolSpawnDelay > 0) { -@@ -66,7 +67,7 @@ public class PatrolSpawner implements CustomSpawner { +@@ -65,7 +66,7 @@ public class PatrolSpawner implements CustomSpawner { if (world.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.perPlayer) { entityhuman.patrolSpawnDelay += world.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.ticks + randomsource.nextInt(1200); } else { @@ -21288,10 +21292,10 @@ index 1c4dafdfb3898b5efe06d66792b1b0841ec5724d..8115eb2b632f6aa8d624bddc83c23e28 if (days >= world.paperConfig().entities.behavior.pillagerPatrols.start.day && world.isDay()) { diff --git a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java -index ed80960777b18faca2d6a99783e53daf5fa19e09..b52455178290dd27478da4c062863562942ae2ba 100644 +index 1b1b475ca27e799e251d6f8a8c9fe1a4fd8bae83..3085658976345d095e7c38a0edab42cb92fe5d03 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java +++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java -@@ -22,7 +22,7 @@ import net.minecraft.world.level.material.FluidState; +@@ -21,7 +21,7 @@ import net.minecraft.world.level.material.FluidState; public class PhantomSpawner implements CustomSpawner { @@ -21300,7 +21304,7 @@ index ed80960777b18faca2d6a99783e53daf5fa19e09..b52455178290dd27478da4c062863562 public PhantomSpawner() {} -@@ -40,20 +40,22 @@ public class PhantomSpawner implements CustomSpawner { +@@ -39,20 +39,22 @@ public class PhantomSpawner implements CustomSpawner { // Paper end - Ability to control player's insomnia and phantoms RandomSource randomsource = world.random; @@ -21392,7 +21396,7 @@ index 1695cff01932d435848e230921d1680b69a41d73..71658657fdaa858ffd388bb19218c30d protected int getMaxReferences() { diff --git a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java -index 5d4c18b068f41f349bdccec14e08ca6ca7cb0c6c..4945bf03176e1842ae3e1bdd4708e39b0a3bdc07 100644 +index 2407d93c11b806701fc7d192f39d535128281e80..e251935b89799046e82228f49ea7a7737078892b 100644 --- a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java +++ b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java @@ -89,10 +89,10 @@ public class PortalForcer { @@ -21421,27 +21425,27 @@ index 106af2b2c7ff72c7549975aef75cdcff8d9a7d97..67be58de9f684e440b62541365c079cf boolean bl2 = this.maxChainedNeighborUpdates >= 0 && this.count >= this.maxChainedNeighborUpdates; this.count++; diff --git a/src/main/java/net/minecraft/world/level/saveddata/SavedData.java b/src/main/java/net/minecraft/world/level/saveddata/SavedData.java -index 0655a26a58b3df19d81b18abf6b8ab81fd000ef7..d222b102abdd71b9487e11b4b7637be0d129bb2b 100644 +index 4cbb943b702baaeb8bfd2b558cc848e719cf095d..6869144a2c1bb37d15f3fec622497b8d20ab2c68 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/SavedData.java +++ b/src/main/java/net/minecraft/world/level/saveddata/SavedData.java -@@ -13,7 +13,7 @@ import org.slf4j.Logger; +@@ -14,7 +14,7 @@ import org.slf4j.Logger; public abstract class SavedData { private static final Logger LOGGER = LogUtils.getLogger(); - private boolean dirty; + private volatile boolean dirty; // Folia - make map data thread-safe - public abstract CompoundTag save(CompoundTag nbt); + public abstract CompoundTag save(CompoundTag nbt, HolderLookup.Provider registryLookup); -@@ -36,6 +36,7 @@ public abstract class SavedData { - - public java.util.concurrent.CompletableFuture save(File file, @org.jetbrains.annotations.Nullable java.util.concurrent.ExecutorService ioExecutor) { // Paper - Write SavedData IO async +@@ -39,6 +39,7 @@ public abstract class SavedData { + public java.util.concurrent.CompletableFuture save(File file, HolderLookup.Provider registryLookup, @org.jetbrains.annotations.Nullable java.util.concurrent.ExecutorService ioExecutor) { + // Paper end - Write SavedData IO async if (this.isDirty()) { + this.setDirty(false); // Folia - make map data thread-safe - move before save, so that any changes after are not lost CompoundTag compoundTag = new CompoundTag(); - compoundTag.put("data", this.save(new CompoundTag())); + compoundTag.put("data", this.save(new CompoundTag(), registryLookup)); NbtUtils.addCurrentDataVersion(compoundTag); -@@ -48,7 +49,7 @@ public abstract class SavedData { +@@ -51,7 +52,7 @@ public abstract class SavedData { } }; // Paper - Write SavedData IO async @@ -21451,13 +21455,13 @@ index 0655a26a58b3df19d81b18abf6b8ab81fd000ef7..d222b102abdd71b9487e11b4b7637be0 if (ioExecutor == null) { return java.util.concurrent.CompletableFuture.runAsync(writeRunnable); // No executor, just use common pool diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapIndex.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapIndex.java -index 7640752188b9cb62f19e20b832f39d009cbcb62f..b158e9f2f3a97d2f88f1fb43825f1192650c0924 100644 +index 763b315b1d761bc3bd82d9b847ed3f64fd5ce991..7a044d337df8a14150a695d539a8e5c8799c4032 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapIndex.java +++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapIndex.java -@@ -33,17 +33,21 @@ public class MapIndex extends SavedData { +@@ -34,17 +34,21 @@ public class MapIndex extends SavedData { @Override - public CompoundTag save(CompoundTag nbt) { + public CompoundTag save(CompoundTag nbt, HolderLookup.Provider registryLookup) { + synchronized (this.usedAuxIds) { // Folia - make map data thread-safe for (Entry entry : this.usedAuxIds.object2IntEntrySet()) { nbt.putInt(entry.getKey(), entry.getIntValue()); @@ -21467,29 +21471,29 @@ index 7640752188b9cb62f19e20b832f39d009cbcb62f..b158e9f2f3a97d2f88f1fb43825f1192 return nbt; } - public int getFreeAuxValueForMap() { + public MapId getFreeAuxValueForMap() { + synchronized (this.usedAuxIds) { // Folia - make map data thread-safe int i = this.usedAuxIds.getInt("map") + 1; this.usedAuxIds.put("map", i); this.setDirty(); - return i; + return new MapId(i); + } // Folia - make map data thread-safe } } diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -index 45269115e63cfc3bd7dc740a5694e2cc7c35bcb1..df799198d4d77a1827002d6d192ebaea3007d5b8 100644 +index cf8ae635fce7ea66d4e1ab1dc05575f035fa95ef..6b131c112ca227f9f910d5d88cf8314cc088be03 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -@@ -192,7 +192,7 @@ public class MapItemSavedData extends SavedData { +@@ -211,7 +211,7 @@ public class MapItemSavedData extends SavedData { } @Override -- public CompoundTag save(CompoundTag nbt) { -+ public synchronized CompoundTag save(CompoundTag nbt) { // Folia - make map data thread-safe +- public CompoundTag save(CompoundTag nbt, HolderLookup.Provider registryLookup) { ++ public synchronized CompoundTag save(CompoundTag nbt, HolderLookup.Provider registryLookup) { // Folia - make map data thread-safe DataResult dataresult = ResourceLocation.CODEC.encodeStart(NbtOps.INSTANCE, this.dimension.location()); // CraftBukkit - decompile error Logger logger = MapItemSavedData.LOGGER; -@@ -249,7 +249,7 @@ public class MapItemSavedData extends SavedData { +@@ -261,7 +261,7 @@ public class MapItemSavedData extends SavedData { return nbt; } @@ -21498,13 +21502,17 @@ index 45269115e63cfc3bd7dc740a5694e2cc7c35bcb1..df799198d4d77a1827002d6d192ebaea MapItemSavedData worldmap = new MapItemSavedData(this.centerX, this.centerZ, this.scale, this.trackingPosition, this.unlimitedTracking, true, this.dimension); worldmap.bannerMarkers.putAll(this.bannerMarkers); -@@ -260,11 +260,12 @@ public class MapItemSavedData extends SavedData { +@@ -272,7 +272,7 @@ public class MapItemSavedData extends SavedData { return worldmap; } -- public MapItemSavedData scaled(int zoomOutScale) { -+ public synchronized MapItemSavedData scaled(int zoomOutScale) { // Folia - make map data thread-safe - return MapItemSavedData.createFresh((double) this.centerX, (double) this.centerZ, (byte) Mth.clamp(this.scale + zoomOutScale, 0, 4), this.trackingPosition, this.unlimitedTracking, this.dimension); +- public MapItemSavedData scaled() { ++ public synchronized MapItemSavedData scaled() { // Folia - make map data thread-safe + return MapItemSavedData.createFresh((double) this.centerX, (double) this.centerZ, (byte) Mth.clamp(this.scale + 1, 0, 4), this.trackingPosition, this.unlimitedTracking, this.dimension); + } + +@@ -284,7 +284,8 @@ public class MapItemSavedData extends SavedData { + }; } - public void tickCarriedBy(Player player, ItemStack stack) { @@ -21513,7 +21521,7 @@ index 45269115e63cfc3bd7dc740a5694e2cc7c35bcb1..df799198d4d77a1827002d6d192ebaea if (!this.carriedByPlayers.containsKey(player)) { MapItemSavedData.HoldingPlayer worldmap_worldmaphumantracker = new MapItemSavedData.HoldingPlayer(player); -@@ -373,7 +374,7 @@ public class MapItemSavedData extends SavedData { +@@ -378,7 +379,7 @@ public class MapItemSavedData extends SavedData { rotation += rotation < 0.0D ? -8.0D : 8.0D; b2 = (byte) ((int) (rotation * 16.0D / 360.0D)); if (this.dimension == Level.NETHER && world != null) { @@ -21522,15 +21530,15 @@ index 45269115e63cfc3bd7dc740a5694e2cc7c35bcb1..df799198d4d77a1827002d6d192ebaea b2 = (byte) (j * j * 34187121 + j * 121 >> 15 & 15); } -@@ -432,14 +433,14 @@ public class MapItemSavedData extends SavedData { +@@ -437,14 +438,14 @@ public class MapItemSavedData extends SavedData { } @Nullable -- public Packet getUpdatePacket(int id, Player player) { -+ public synchronized Packet getUpdatePacket(int id, Player player) { // Folia - make map data thread-safe +- public Packet getUpdatePacket(MapId mapId, Player player) { ++ public synchronized Packet getUpdatePacket(MapId mapId, Player player) { // Folia - make map data thread-safe MapItemSavedData.HoldingPlayer worldmap_worldmaphumantracker = (MapItemSavedData.HoldingPlayer) this.carriedByPlayers.get(player); - return worldmap_worldmaphumantracker == null ? null : worldmap_worldmaphumantracker.nextUpdatePacket(id); + return worldmap_worldmaphumantracker == null ? null : worldmap_worldmaphumantracker.nextUpdatePacket(mapId); } - public void setColorsDirty(int x, int z) { @@ -21540,7 +21548,7 @@ index 45269115e63cfc3bd7dc740a5694e2cc7c35bcb1..df799198d4d77a1827002d6d192ebaea Iterator iterator = this.carriedBy.iterator(); while (iterator.hasNext()) { -@@ -447,15 +448,16 @@ public class MapItemSavedData extends SavedData { +@@ -452,15 +453,16 @@ public class MapItemSavedData extends SavedData { worldmap_worldmaphumantracker.markColorsDirty(x, z); } @@ -21561,7 +21569,7 @@ index 45269115e63cfc3bd7dc740a5694e2cc7c35bcb1..df799198d4d77a1827002d6d192ebaea MapItemSavedData.HoldingPlayer worldmap_worldmaphumantracker = (MapItemSavedData.HoldingPlayer) this.carriedByPlayers.get(player); if (worldmap_worldmaphumantracker == null) { -@@ -467,7 +469,7 @@ public class MapItemSavedData extends SavedData { +@@ -472,7 +474,7 @@ public class MapItemSavedData extends SavedData { return worldmap_worldmaphumantracker; } @@ -21570,7 +21578,7 @@ index 45269115e63cfc3bd7dc740a5694e2cc7c35bcb1..df799198d4d77a1827002d6d192ebaea double d0 = (double) pos.getX() + 0.5D; double d1 = (double) pos.getZ() + 0.5D; int i = 1 << this.scale; -@@ -476,7 +478,7 @@ public class MapItemSavedData extends SavedData { +@@ -481,7 +483,7 @@ public class MapItemSavedData extends SavedData { boolean flag = true; if (d2 >= -63.0D && d3 >= -63.0D && d2 <= 63.0D && d3 <= 63.0D) { @@ -21579,16 +21587,16 @@ index 45269115e63cfc3bd7dc740a5694e2cc7c35bcb1..df799198d4d77a1827002d6d192ebaea if (mapiconbanner == null) { return false; -@@ -497,7 +499,7 @@ public class MapItemSavedData extends SavedData { +@@ -502,7 +504,7 @@ public class MapItemSavedData extends SavedData { return false; } - public void checkBanners(BlockGetter world, int x, int z) { + public synchronized void checkBanners(BlockGetter world, int x, int z) { // Folia - make map data thread-safe - Iterator iterator = this.bannerMarkers.values().iterator(); + Iterator iterator = this.bannerMarkers.values().iterator(); while (iterator.hasNext()) { -@@ -519,12 +521,12 @@ public class MapItemSavedData extends SavedData { +@@ -524,12 +526,12 @@ public class MapItemSavedData extends SavedData { return this.bannerMarkers.values(); } @@ -21603,7 +21611,7 @@ index 45269115e63cfc3bd7dc740a5694e2cc7c35bcb1..df799198d4d77a1827002d6d192ebaea byte b1 = this.colors[x + z * 128]; if (b1 != color) { -@@ -535,12 +537,12 @@ public class MapItemSavedData extends SavedData { +@@ -540,12 +542,12 @@ public class MapItemSavedData extends SavedData { } } @@ -21618,16 +21626,16 @@ index 45269115e63cfc3bd7dc740a5694e2cc7c35bcb1..df799198d4d77a1827002d6d192ebaea Iterator iterator = this.decorations.values().iterator(); MapDecoration mapicon; -@@ -575,7 +577,7 @@ public class MapItemSavedData extends SavedData { +@@ -580,7 +582,7 @@ public class MapItemSavedData extends SavedData { return this.decorations.values(); } -- public boolean isTrackedCountOverLimit(int iconCount) { -+ public synchronized boolean isTrackedCountOverLimit(int iconCount) { // Folia - make map data thread-safe - return this.trackedDecorationCount >= iconCount; +- public boolean isTrackedCountOverLimit(int decorationCount) { ++ public synchronized boolean isTrackedCountOverLimit(int decorationCount) { // Folia - make map data thread-safe + return this.trackedDecorationCount >= decorationCount; } -@@ -701,11 +703,13 @@ public class MapItemSavedData extends SavedData { +@@ -724,11 +726,13 @@ public class MapItemSavedData extends SavedData { } public void applyToMap(MapItemSavedData mapState) { @@ -21642,10 +21650,10 @@ index 45269115e63cfc3bd7dc740a5694e2cc7c35bcb1..df799198d4d77a1827002d6d192ebaea } } diff --git a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java -index b89bd2d046e99d0c4848579a5ab4385453358b89..2c000f830ca3b99b13546ae2edd7e90059290543 100644 +index 6e23e69abd56eeda3b52a22019e1b74ae10682e7..2c086f1d4cbfc29a759a77e5c5f9f39d177e81ba 100644 --- a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -39,6 +39,7 @@ public class DimensionDataStorage implements java.io.Closeable { // Paper - Writ +@@ -43,6 +43,7 @@ public class DimensionDataStorage implements java.io.Closeable { // Paper - Writ } public T computeIfAbsent(SavedData.Factory type, String id) { @@ -21653,7 +21661,7 @@ index b89bd2d046e99d0c4848579a5ab4385453358b89..2c000f830ca3b99b13546ae2edd7e900 T savedData = this.get(type, id); if (savedData != null) { return savedData; -@@ -47,10 +48,12 @@ public class DimensionDataStorage implements java.io.Closeable { // Paper - Writ +@@ -51,10 +52,12 @@ public class DimensionDataStorage implements java.io.Closeable { // Paper - Writ this.set(id, savedData2); return savedData2; } @@ -21666,7 +21674,7 @@ index b89bd2d046e99d0c4848579a5ab4385453358b89..2c000f830ca3b99b13546ae2edd7e900 SavedData savedData = this.cache.get(id); if (savedData == null && !this.cache.containsKey(id)) { savedData = this.readSavedData(type.deserializer(), type.type(), id); -@@ -58,6 +61,7 @@ public class DimensionDataStorage implements java.io.Closeable { // Paper - Writ +@@ -62,6 +65,7 @@ public class DimensionDataStorage implements java.io.Closeable { // Paper - Writ } return (T)savedData; @@ -21674,7 +21682,7 @@ index b89bd2d046e99d0c4848579a5ab4385453358b89..2c000f830ca3b99b13546ae2edd7e900 } @Nullable -@@ -76,7 +80,9 @@ public class DimensionDataStorage implements java.io.Closeable { // Paper - Writ +@@ -80,7 +84,9 @@ public class DimensionDataStorage implements java.io.Closeable { // Paper - Writ } public void set(String id, SavedData state) { @@ -21815,11 +21823,11 @@ index 7a69564572357a7acc043e35b9c113beeb738951..f71661ef4250d3b668fffeea7cd74a28 LevelChunkTicks levelChunkTicks = this.allContainers.get(l); if (levelChunkTicks == null) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index b63effd92be5a8a75db6c37e5a1b91541020ec75..350fc61fd709453a86c9f7f6e4bccc434065cc35 100644 +index 2fa5507aa2153a05208077f9547c165a1099b5bb..08e374191b474a1300a70096f2b0138b309e4b80 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -309,7 +309,7 @@ public final class CraftServer implements Server { - private final CraftPotionBrewer potionBrewer = new CraftPotionBrewer(); // Paper - Custom Potion Mixes +@@ -307,7 +307,7 @@ public final class CraftServer implements Server { + private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer; // Paper - Custom Potion Mixes // Paper start - Folia region threading API - private final io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler(); @@ -21827,7 +21835,7 @@ index b63effd92be5a8a75db6c37e5a1b91541020ec75..350fc61fd709453a86c9f7f6e4bccc43 private final io.papermc.paper.threadedregions.scheduler.FoliaAsyncScheduler asyncScheduler = new io.papermc.paper.threadedregions.scheduler.FoliaAsyncScheduler(); private final io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler globalRegionScheduler = new io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler(); -@@ -377,6 +377,12 @@ public final class CraftServer implements Server { +@@ -375,6 +375,12 @@ public final class CraftServer implements Server { return io.papermc.paper.util.TickThread.isTickThreadFor(((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandleRaw()); } // Paper end - Folia reagion threading API @@ -21840,7 +21848,7 @@ index b63effd92be5a8a75db6c37e5a1b91541020ec75..350fc61fd709453a86c9f7f6e4bccc43 static { ConfigurationSerialization.registerClass(CraftOfflinePlayer.class); -@@ -971,6 +977,9 @@ public final class CraftServer implements Server { +@@ -936,6 +942,9 @@ public final class CraftServer implements Server { // NOTE: Should only be called from DedicatedServer.ah() public boolean dispatchServerCommand(CommandSender sender, ConsoleInput serverCommand) { @@ -21850,7 +21858,7 @@ index b63effd92be5a8a75db6c37e5a1b91541020ec75..350fc61fd709453a86c9f7f6e4bccc43 if (sender instanceof Conversable) { Conversable conversable = (Conversable) sender; -@@ -990,12 +999,46 @@ public final class CraftServer implements Server { +@@ -955,12 +964,46 @@ public final class CraftServer implements Server { } } @@ -21897,7 +21905,7 @@ index b63effd92be5a8a75db6c37e5a1b91541020ec75..350fc61fd709453a86c9f7f6e4bccc43 if (this.commandMap.dispatch(sender, commandLine)) { return true; } -@@ -3234,7 +3277,7 @@ public final class CraftServer implements Server { +@@ -3240,7 +3283,7 @@ public final class CraftServer implements Server { @Override public int getCurrentTick() { @@ -21907,7 +21915,7 @@ 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 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db57371eacc 100644 +index f2b20ed5063a293f0b464548f590d652170cd1d8..0e549bfbecc15befc129a0382e189ba8cdd74c87 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -193,7 +193,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -21919,7 +21927,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 } @Override -@@ -255,7 +255,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -263,7 +263,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper start - per world spawn limits for (SpawnCategory spawnCategory : SpawnCategory.values()) { if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { @@ -21928,7 +21936,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 } } // Paper end - per world spawn limits -@@ -342,6 +342,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -350,6 +350,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Chunk getChunkAt(int x, int z) { @@ -21936,7 +21944,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 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); -@@ -365,7 +366,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -373,7 +374,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper start private void addTicket(int x, int z) { @@ -21945,7 +21953,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 } // Paper end -@@ -384,10 +385,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -392,10 +393,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean isChunkGenerated(int x, int z) { // Paper start - Fix this method @@ -21958,7 +21966,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 } ChunkAccess chunk = world.getChunkSource().getChunkAtImmediately(x, z); if (chunk == null) { -@@ -441,7 +442,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -449,7 +450,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { } private boolean unloadChunk0(int x, int z, boolean save) { @@ -21967,7 +21975,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 if (!this.isChunkLoaded(x, z)) { return true; } -@@ -456,7 +457,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -464,7 +465,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean regenerateChunk(int x, int z) { @@ -21976,7 +21984,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 warnUnsafeChunk("regenerating a faraway chunk", x, z); // Paper // Paper start - implement regenerateChunk method final ServerLevel serverLevel = this.world; -@@ -519,6 +520,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -529,6 +530,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean refreshChunk(int x, int z) { @@ -21984,7 +21992,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z)); if (playerChunk == null) return false; -@@ -554,7 +556,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -564,7 +566,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean loadChunk(int x, int z, boolean generate) { @@ -21993,7 +22001,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 warnUnsafeChunk("loading a faraway chunk", x, z); // Paper // Paper start - Optimize this method ChunkPos chunkPos = new ChunkPos(x, z); -@@ -623,7 +625,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -633,7 +635,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 @@ -22002,7 +22010,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 return true; } -@@ -833,13 +835,15 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -843,13 +845,15 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { @@ -22023,7 +22031,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 BlockPos position = ((CraftBlockState) blockstate).getPosition(); net.minecraft.world.level.block.state.BlockState oldBlock = this.world.getBlockState(position); int flag = ((CraftBlockState) blockstate).getFlag(); -@@ -847,10 +851,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -857,10 +861,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); } @@ -22036,7 +22044,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 return false; } } -@@ -884,6 +888,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -894,6 +898,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setTime(long time) { @@ -22044,7 +22052,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 long margin = (time - this.getFullTime()) % 24000; if (margin < 0) margin += 24000; this.setFullTime(this.getFullTime() + margin); -@@ -896,6 +901,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -906,6 +911,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setFullTime(long time) { @@ -22052,7 +22060,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 // Notify anyone who's listening TimeSkipEvent event = new TimeSkipEvent(this, TimeSkipEvent.SkipReason.CUSTOM, time - this.world.getDayTime()); this.server.getPluginManager().callEvent(event); -@@ -923,7 +929,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -933,7 +939,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public long getGameTime() { @@ -22061,21 +22069,21 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 } @Override -@@ -943,11 +949,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -962,11 +968,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { + explosionType = net.minecraft.world.level.Level.ExplosionInteraction.MOB; // Respect mobGriefing gamerule + } - @Override - public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) { -+ io.papermc.paper.util.TickThread.ensureTickThread(this.world, x, z, "Cannot create explosion asynchronously"); - return !this.world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? net.minecraft.world.level.Level.ExplosionInteraction.MOB : net.minecraft.world.level.Level.ExplosionInteraction.NONE).wasCanceled; ++ io.papermc.paper.util.TickThread.ensureTickThread(this.world, x, z, "Cannot create explosion asynchronously"); // Folia - region threading + return !this.world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, explosionType).wasCanceled; } // Paper start @Override public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks) { -+ io.papermc.paper.util.TickThread.ensureTickThread(this.world, loc.getX(), loc.getZ(), "Cannot create explosion asynchronously"); ++ io.papermc.paper.util.TickThread.ensureTickThread(this.world, loc.getX(), loc.getZ(), "Cannot create explosion asynchronously"); // Folia - region threading 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 -@@ -1024,6 +1032,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1043,6 +1051,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) { @@ -22083,7 +22091,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 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); -@@ -1054,6 +1063,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1073,6 +1082,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); @@ -22091,7 +22099,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 if (this.world.hasChunkAt(pos)) { net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkAt(pos); -@@ -1364,6 +1374,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1383,6 +1393,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setStorm(boolean hasStorm) { @@ -22099,7 +22107,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 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) -@@ -1376,6 +1387,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1395,6 +1406,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setWeatherDuration(int duration) { @@ -22107,7 +22115,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.world.serverLevelData.setRainTime(duration); } -@@ -1386,6 +1398,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1405,6 +1417,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setThundering(boolean thundering) { @@ -22115,7 +22123,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 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) -@@ -1398,6 +1411,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1417,6 +1430,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setThunderDuration(int duration) { @@ -22123,7 +22131,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.world.serverLevelData.setThunderTime(duration); } -@@ -1408,6 +1422,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1427,6 +1441,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setClearWeatherDuration(int duration) { @@ -22131,15 +22139,15 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.world.serverLevelData.setClearWeatherTime(duration); } -@@ -1602,6 +1617,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1621,6 +1636,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setKeepSpawnInMemory(boolean keepLoaded) { + io.papermc.paper.threadedregions.RegionizedServer.ensureGlobalTickThread("Cannot modify keep spawn in memory off of the global region"); // Folia - region threading - // Paper start - Configurable spawn radius - if (keepLoaded == this.world.keepSpawnInMemory) { - // do nothing, nothing has changed -@@ -1680,6 +1696,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { + if (keepLoaded) { + this.setGameRule(GameRule.SPAWN_CHUNK_RADIUS, this.getGameRuleDefault(GameRule.SPAWN_CHUNK_RADIUS)); + } else { +@@ -1689,6 +1705,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setHardcore(boolean hardcore) { @@ -22147,7 +22155,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.world.serverLevelData.settings.hardcore = hardcore; } -@@ -1692,6 +1709,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1701,6 +1718,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns) { @@ -22155,7 +22163,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.setTicksPerSpawns(SpawnCategory.ANIMAL, ticksPerAnimalSpawns); } -@@ -1704,6 +1722,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1713,6 +1731,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns) { @@ -22163,7 +22171,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.setTicksPerSpawns(SpawnCategory.MONSTER, ticksPerMonsterSpawns); } -@@ -1716,6 +1735,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1725,6 +1744,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterSpawns(int ticksPerWaterSpawns) { @@ -22171,7 +22179,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.setTicksPerSpawns(SpawnCategory.WATER_ANIMAL, ticksPerWaterSpawns); } -@@ -1728,6 +1748,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1737,6 +1757,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterAmbientSpawns(int ticksPerWaterAmbientSpawns) { @@ -22179,7 +22187,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.setTicksPerSpawns(SpawnCategory.WATER_AMBIENT, ticksPerWaterAmbientSpawns); } -@@ -1740,6 +1761,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1749,6 +1770,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterUndergroundCreatureSpawns(int ticksPerWaterUndergroundCreatureSpawns) { @@ -22187,7 +22195,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.setTicksPerSpawns(SpawnCategory.WATER_UNDERGROUND_CREATURE, ticksPerWaterUndergroundCreatureSpawns); } -@@ -1752,11 +1774,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1761,11 +1783,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerAmbientSpawns(int ticksPerAmbientSpawns) { @@ -22201,7 +22209,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 Preconditions.checkArgument(spawnCategory != null, "SpawnCategory cannot be null"); Preconditions.checkArgument(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory.%s are not supported", spawnCategory); -@@ -1773,21 +1797,25 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1782,21 +1806,25 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { @@ -22227,7 +22235,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.server.getWorldMetadata().removeMetadata(this, metadataKey, owningPlugin); } -@@ -1800,6 +1828,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1809,6 +1837,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setMonsterSpawnLimit(int limit) { @@ -22235,7 +22243,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.setSpawnLimit(SpawnCategory.MONSTER, limit); } -@@ -1812,6 +1841,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1821,6 +1850,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setAnimalSpawnLimit(int limit) { @@ -22243,7 +22251,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.setSpawnLimit(SpawnCategory.ANIMAL, limit); } -@@ -1824,6 +1854,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1833,6 +1863,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterAnimalSpawnLimit(int limit) { @@ -22251,7 +22259,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.setSpawnLimit(SpawnCategory.WATER_ANIMAL, limit); } -@@ -1836,6 +1867,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1845,6 +1876,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterAmbientSpawnLimit(int limit) { @@ -22259,7 +22267,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.setSpawnLimit(SpawnCategory.WATER_AMBIENT, limit); } -@@ -1848,6 +1880,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1857,6 +1889,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterUndergroundCreatureSpawnLimit(int limit) { @@ -22267,7 +22275,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.setSpawnLimit(SpawnCategory.WATER_UNDERGROUND_CREATURE, limit); } -@@ -1860,6 +1893,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1869,6 +1902,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setAmbientSpawnLimit(int limit) { @@ -22275,7 +22283,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 this.setSpawnLimit(SpawnCategory.AMBIENT, limit); } -@@ -1882,6 +1916,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1891,6 +1925,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setSpawnLimit(SpawnCategory spawnCategory, int limit) { @@ -22283,7 +22291,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 Preconditions.checkArgument(spawnCategory != null, "SpawnCategory cannot be null"); Preconditions.checkArgument(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory.%s are not supported", spawnCategory); -@@ -1964,7 +1999,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1973,7 +2008,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); @@ -22292,7 +22300,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 if (entityTracker != null) { entityTracker.broadcastAndSend(packet); } -@@ -1976,7 +2011,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1985,7 +2020,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); @@ -22301,7 +22309,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 if (entityTracker != null) { entityTracker.broadcastAndSend(packet); } -@@ -2065,6 +2100,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2074,6 +2109,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean setGameRuleValue(String rule, String value) { @@ -22309,7 +22317,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 // No null values allowed if (rule == null || value == null) return false; -@@ -2107,6 +2143,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2116,6 +2152,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean setGameRule(GameRule rule, T newValue) { @@ -22317,7 +22325,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 Preconditions.checkArgument(rule != null, "GameRule cannot be null"); Preconditions.checkArgument(newValue != null, "GameRule value cannot be null"); -@@ -2359,6 +2396,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2367,6 +2404,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) { @@ -22327,10 +22335,10 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 + } + io.papermc.paper.util.TickThread.ensureTickThread(this.world, position.getX(), position.getZ(), "Cannot send game event asynchronously"); + // Folia end - region threading - 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)); + getHandle().gameEvent(sourceEntity != null ? ((CraftEntity) sourceEntity).getHandle(): null, net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.getHolder(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(gameEvent.getKey())).orElseThrow(), org.bukkit.craftbukkit.util.CraftVector.toBlockPos(position)); } // Paper end -@@ -2487,7 +2530,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2495,7 +2538,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 @@ -22339,7 +22347,7 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 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)); -@@ -2504,7 +2547,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2512,7 +2555,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) -> { @@ -22348,18 +22356,6 @@ index 00357d78182b3ff87e3d9a45705b072af56739c8..f325532b326fd7fe8c36003833890db5 net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk)c; if (chunk != null) this.addTicket(x, z); // Paper ret.complete(chunk == null ? null : new CraftChunk(chunk)); -diff --git a/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java -index dfe5fa29a29af06640382456ef59aed794f5362b..ba5e47037f4dc3eb3efe86cd31183b39eab823fe 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java -@@ -64,6 +64,7 @@ public final class CapturedBlockState extends CraftBlockState { - - for (int k = 0; k < j; ++k) { - Bee entitybee = new Bee(EntityType.BEE, generatoraccessseed.getMinecraftWorld()); -+ entitybee.setPosRaw(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()); // Folia - region threading - set position so that thread checks do not fail - - tileentitybeehive.addOccupantWithPresetTicks(entitybee, false, random.nextInt(599)); - } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index ac11f18690434922179b61ffcc3036dea025b0cb..9efe9fce59a0b4fe7315dc41d1e21615b97e5cf6 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -22564,10 +22560,10 @@ index ac11f18690434922179b61ffcc3036dea025b0cb..9efe9fce59a0b4fe7315dc41d1e21615 this.getNMS().randomTick(level, this.position, level.random); } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java -index 2cfaa59a0bb6b5253b5a8dcc38ae65e0f085fd3f..5cf33427847068fc589ada9f731b985f791ac013 100644 +index fa63a6cfcfcc4eee4503a82d85333c139c8c8b2b..1afd553624613a7af276fd81770ba9af131eca93 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 { +@@ -215,6 +215,12 @@ public class CraftBlockState implements BlockState { LevelAccessor access = this.getWorldHandle(); CraftBlock block = this.getBlock(); @@ -22580,7 +22576,7 @@ index 2cfaa59a0bb6b5253b5a8dcc38ae65e0f085fd3f..5cf33427847068fc589ada9f731b985f if (block.getType() != this.getType()) { if (!force) { return false; -@@ -340,6 +346,9 @@ public class CraftBlockState implements BlockState { +@@ -350,6 +356,9 @@ public class CraftBlockState implements BlockState { @Override public java.util.Collection getDrops(org.bukkit.inventory.ItemStack item, org.bukkit.entity.Entity entity) { @@ -22613,7 +22609,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 e8e4489bcd64fde1b3226bdc7a7cc612508bda3f..1cfe604573000fa9b32237313aa467875a891f3c 100644 +index a2d336ceb52b63db5c03432ee7bc94dc6a742b82..cf9282a46534319308e9ccf69f332a5c8c1745cf 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 { @@ -22637,7 +22633,7 @@ index e8e4489bcd64fde1b3226bdc7a7cc612508bda3f..1cfe604573000fa9b32237313aa46787 if (entityTracker != null) { for (ServerPlayerConnection connection : entityTracker.seenBy) { -@@ -994,7 +999,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -1004,7 +1009,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } ServerLevel world = ((CraftWorld) this.getWorld()).getHandle(); @@ -22646,7 +22642,7 @@ index e8e4489bcd64fde1b3226bdc7a7cc612508bda3f..1cfe604573000fa9b32237313aa46787 if (entityTracker == null) { return; -@@ -1032,29 +1037,43 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -1042,29 +1047,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. @@ -22710,10 +22706,10 @@ index e8e4489bcd64fde1b3226bdc7a7cc612508bda3f..1cfe604573000fa9b32237313aa46787 // Paper end - more teleport API / async chunk API diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 44f4665db613c558078df5bb49106e4ca5679dfe..232490c970d67e6bc77a35d5ccfef8fa95646ffe 100644 +index 7e6116963d835d4606ef3d93b69d3e44b61288e1..c03015738313ba802436ed8a047623c02e94a06e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -562,7 +562,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -647,7 +647,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void kickPlayer(String message) { @@ -22722,7 +22718,7 @@ index 44f4665db613c558078df5bb49106e4ca5679dfe..232490c970d67e6bc77a35d5ccfef8fa if (this.getHandle().connection == null) return; this.getHandle().connection.disconnect(message == null ? "" : message, org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); // Paper - kick event cause -@@ -1309,6 +1309,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1394,6 +1394,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean teleport(Location location, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause, io.papermc.paper.entity.TeleportFlag... flags) { @@ -22734,7 +22730,7 @@ index 44f4665db613c558078df5bb49106e4ca5679dfe..232490c970d67e6bc77a35d5ccfef8fa Set relativeArguments; Set allFlags; if (flags.length == 0) { -@@ -1955,7 +1960,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2040,7 +2045,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { private void unregisterEntity(Entity other) { // Paper end ChunkMap tracker = ((ServerLevel) this.getHandle().level()).getChunkSource().chunkMap; @@ -22743,7 +22739,7 @@ index 44f4665db613c558078df5bb49106e4ca5679dfe..232490c970d67e6bc77a35d5ccfef8fa if (entry != null) { entry.removePlayer(this.getHandle()); } -@@ -2052,7 +2057,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2137,7 +2142,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (original != null) otherPlayer.setUUID(original); // Paper - uuid override } @@ -22753,10 +22749,10 @@ index 44f4665db613c558078df5bb49106e4ca5679dfe..232490c970d67e6bc77a35d5ccfef8fa 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 c0823c612de9dc2a64cc797f061eef25c5f31359..ccab0ec21a6827475d97654f1b54c166ccb99085 100644 +index 34b91eff3190848bae38b20e1d956ece497b1473..9aa832a851b78197759c6d8d5c5159f33e3870f8 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -943,7 +943,7 @@ public class CraftEventFactory { +@@ -942,7 +942,7 @@ public class CraftEventFactory { return CraftEventFactory.handleBlockSpreadEvent(world, source, target, block, 2); } @@ -22765,7 +22761,7 @@ index c0823c612de9dc2a64cc797f061eef25c5f31359..ccab0ec21a6827475d97654f1b54c166 public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState block, int flag) { // Suppress during worldgen -@@ -955,7 +955,7 @@ public class CraftEventFactory { +@@ -954,7 +954,7 @@ public class CraftEventFactory { CraftBlockState state = CraftBlockStates.getBlockState(world, target, flag); state.setData(block); @@ -22774,7 +22770,7 @@ index c0823c612de9dc2a64cc797f061eef25c5f31359..ccab0ec21a6827475d97654f1b54c166 Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { -@@ -2146,7 +2146,7 @@ public class CraftEventFactory { +@@ -2140,7 +2140,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)); @@ -22796,12 +22792,12 @@ 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 3c7a771c48cc2732cc038ca11bb93ec5f8c2d667..d365e26799822f39af2d5a27761bb8b41308297e 100644 +index 5a382907285a288f2a223189e690d3dbdf45594c..8248cd6c908c82b6b7a18df7410a9a4a46a91959 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 { - String minimumVersion = MinecraftServer.getServer().server.minimumAPI; - int minimumIndex = CraftMagicNumbers.SUPPORTED_API.indexOf(minimumVersion); +@@ -387,6 +387,12 @@ public final class CraftMagicNumbers implements UnsafeValues { + throw new InvalidPluginException("Unsupported API version " + pdf.getAPIVersion()); + } + // Folia start - block plugins not marked as supported + if (!pdf.isFoliaSupported()) { @@ -22809,14 +22805,14 @@ index 3c7a771c48cc2732cc038ca11bb93ec5f8c2d667..d365e26799822f39af2d5a27761bb8b4 + } + // Folia end - block plugins not marked as supported + - if (pdf.getAPIVersion() != null) { - int pluginIndex = CraftMagicNumbers.SUPPORTED_API.indexOf(pdf.getAPIVersion()); - + if (toCheck.isOlderThan(minimumVersion)) { + // Older than supported + throw new InvalidPluginException("Plugin API version " + pdf.getAPIVersion() + " is lower than the minimum allowed version. Please update or replace it."); diff --git a/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java -index 86a20c91beff6b27e6ec886e49ba902b216106f2..96007426144b78f91c12614f04350855530cc70d 100644 +index 41a291d42667c38d3e5bbe47236772761e85929b..1c0e4f11d4d0be568ed38a02bf9e8f857fca69fc 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java +++ b/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java -@@ -69,6 +69,13 @@ public abstract class DelegatedGeneratorAccess implements WorldGenLevel { +@@ -68,6 +68,13 @@ public abstract class DelegatedGeneratorAccess implements WorldGenLevel { this.handle = worldAccess; } @@ -23042,7 +23038,7 @@ index ac0fd418fcb437896dfdff53ab3eff19833d25fb..130220977477a5d8d51e17dcb989ae0c return true; diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java -index 6c260403d91d640da0473a3df56e1c5582459fde..f685fd53ef631b32b6c51dfc7f0d847ed2dc9658 100644 +index 6c2a3813e7d63d57f07a8fa2edbb9d231221d818..97ee030af8d5328611e3c0ed2ca1eb59d1907f7b 100644 --- a/src/main/java/org/spigotmc/SpigotConfig.java +++ b/src/main/java/org/spigotmc/SpigotConfig.java @@ -228,7 +228,7 @@ public class SpigotConfig diff --git a/patches/server/0004-Max-pending-logins.patch b/patches/server/0004-Max-pending-logins.patch index 4008a6e3c..9a402de78 100644 --- a/patches/server/0004-Max-pending-logins.patch +++ b/patches/server/0004-Max-pending-logins.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Max pending logins Should help the floodgates on launch diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 58cdb65083134680230d7070f9f6209f2d32873b..aa4b461bbb2c8c4753f7c9057bab1740de2c0284 100644 +index 734f745ce383c8398fdedeb6fd71277e1482a4a6..83b09feec13a00c35e6f8d4f0ccdae1c8da9c0e5 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -89,7 +89,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -110,7 +110,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, if (this.server.getPlayerList().pushPendingJoin(name, uniqueId, this.connection)) { // Folia end - region threading - rewrite login process this.verifyLoginAndFinishConnectionSetup((GameProfile) Objects.requireNonNull(this.authenticatedProfile)); @@ -17,12 +17,12 @@ index 58cdb65083134680230d7070f9f6209f2d32873b..aa4b461bbb2c8c4753f7c9057bab1740 + } else { --this.tick; } // Paper - prevent logins to be processed even though disconnect was called // Folia - max concurrent logins } - if (this.state == ServerLoginPacketListenerImpl.State.WAITING_FOR_DUPE_DISCONNECT && !this.isPlayerAlreadyInWorld((GameProfile) Objects.requireNonNull(this.authenticatedProfile))) { + // CraftBukkit start diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 08daa5ed0b4b599836b97eef1e53e630e7659443..a390227e5af1232f2090d2be72f7789805025f76 100644 +index 67b832c9a36f8af245e381c7fa3c56a7e9becd1e..db2903276c694d395f62afdc7c71344466ae505f 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -173,6 +173,17 @@ public abstract class PlayerList { +@@ -175,6 +175,17 @@ public abstract class PlayerList { conflictingId = this.connectionById.get(byId); if (conflictingName == null && conflictingId == null) { diff --git a/patches/server/0005-Add-chunk-system-throughput-counters-to-tps.patch b/patches/server/0005-Add-chunk-system-throughput-counters-to-tps.patch index 397358778..bfdbffc7f 100644 --- a/patches/server/0005-Add-chunk-system-throughput-counters-to-tps.patch +++ b/patches/server/0005-Add-chunk-system-throughput-counters-to-tps.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add chunk system throughput counters to /tps diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkFullTask.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkFullTask.java -index 679ed4d53269e1113035b462cf74ab16a231e22e..8a48238fac0949cfddcdd9ccf179d16befe9c4d4 100644 +index c307b084f59f7bb94dc02f25bbcd3e01e01d2306..b53d15a3979f42cb1b9a4cba24147c32f9a1a676 100644 --- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkFullTask.java +++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkFullTask.java @@ -22,6 +22,9 @@ public final class ChunkFullTask extends ChunkProgressionTask implements Runnabl 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 ca2a490ef..86e1a0769 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,10 +29,10 @@ 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 fe07f0881f5835974f00c65498a31a19c8ead97c..0e71fa29ebfa649bc23899046396a6b01c4bd131 100644 +index 8d3737dc1381cb0c179912c7cb215e1585cf772f..d8be7c8dca41b6ad6d9a28590be9e33ef9045bdb 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 +@@ -2992,6 +2992,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -40,7 +40,7 @@ index fe07f0881f5835974f00c65498a31a19c8ead97c..0e71fa29ebfa649bc23899046396a6b0 // CraftBukkit start if (entity.getBukkitEntity() instanceof Vehicle && this.getBukkitEntity() instanceof LivingEntity) { VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.getBukkitEntity()); -@@ -2951,6 +2952,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3013,6 +3014,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return false; } // CraftBukkit end @@ -48,7 +48,7 @@ index fe07f0881f5835974f00c65498a31a19c8ead97c..0e71fa29ebfa649bc23899046396a6b0 if (this.isPassenger()) { this.stopRiding(); } -@@ -3028,6 +3030,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3090,6 +3092,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { // CraftBukkit start @@ -56,7 +56,7 @@ index fe07f0881f5835974f00c65498a31a19c8ead97c..0e71fa29ebfa649bc23899046396a6b0 CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); Entity orig = craft == null ? null : craft.getHandle(); if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { -@@ -3055,6 +3058,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3117,6 +3120,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return false; } // CraftBukkit end @@ -65,7 +65,7 @@ index fe07f0881f5835974f00c65498a31a19c8ead97c..0e71fa29ebfa649bc23899046396a6b0 this.passengers = ImmutableList.of(); } else { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java -index 236f94348ff8da661e23e3e17b7fc1b143680da9..7d4cdb0c5cd24aee4c831e59836c5bdd0b9ea800 100644 +index 591af9d0d2fdc9953415979fc97a4a00afd85885..4d4c88b2464bd1a65082a3377fac8a5ec90fdeae 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java @@ -1,5 +1,6 @@ @@ -97,8 +97,20 @@ index 236f94348ff8da661e23e3e17b7fc1b143680da9..7d4cdb0c5cd24aee4c831e59836c5bdd return (net.minecraft.world.entity.projectile.Projectile) entity; } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java +index d4e0170694409e674d488f913e61c205f6483712..328b0609491fe11b1e46574807cea3bc8992a068 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java +@@ -120,6 +120,7 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr + + @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 + return (net.minecraft.world.entity.projectile.AbstractArrow) this.entity; + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java -index f9cd595ec28f0284d11bae6bfc5bf92d56526ef9..a8479fa2839c77399be83dbf20051b33900044bb 100644 +index 9bcc0931510607b8fbd01233e2b3c346369b214d..74aeff7b47b1f5325e5ac676d9aed3c94a2a843c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -17,8 +17,16 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac @@ -161,6 +173,18 @@ index 34e4c763c7ec971885147ab2509281fad56e1ca6..a0a83e9111523a8080f30d0fdd35b9c9 return (Villager) this.entity; } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java +index 5e6bbeeea0cbf53180fd1260fc53f843469d6588..cb3c3c3294f0760956b6c5643e69afe0e9562f23 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractWindCharge.java +@@ -17,6 +17,7 @@ public abstract class CraftAbstractWindCharge extends CraftFireball implements A + + @Override + public net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge getHandle() { ++ io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading + return (net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) this.entity; + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java index ae16e8d1bfe8e9315391510eddb367a3fbdc9e03..bdbb54cc60c9afa8a7b89419563fcbe502554aac 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java @@ -246,10 +270,10 @@ index ab42bc721d5b6c17c2ca6c7153b757571aea05e8..2887699c16b9452ce948f8b945c595ca } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java -index a46b2dfb2f1c0c7c3b55d81fc881e481348f98b8..17f1d4bdd3ee642e5fa5e0d9f5a61348d9ee1e1d 100644 +index 81f5e1d866128af8fb2acc13aca715580fdf9886..a1485f913ee824620083f9726fdf5812f9d2dc5f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java -@@ -27,8 +27,16 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud +@@ -28,8 +28,16 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud super(server, entity); } @@ -266,6 +290,18 @@ index a46b2dfb2f1c0c7c3b55d81fc881e481348f98b8..17f1d4bdd3ee642e5fa5e0d9f5a61348 return (net.minecraft.world.entity.AreaEffectCloud) super.getHandle(); } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmadillo.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmadillo.java +index e7f2d8de25a489d7f52c78c750e6f7f9b8fee177..99f331b555cb6c55af4e0d7785d282645f92a570 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmadillo.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmadillo.java +@@ -11,6 +11,7 @@ public class CraftArmadillo extends CraftAnimals implements Armadillo { + + @Override + public net.minecraft.world.entity.animal.armadillo.Armadillo getHandle() { ++ io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading + return (net.minecraft.world.entity.animal.armadillo.Armadillo) super.getHandle(); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java index ccda0d7a96c201905f0f62dcb0e5b278a51dee9f..3ba6c46e0f5bc5f6b5994d41aaa9c4dd8276df9b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java @@ -288,11 +324,19 @@ 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 0fd2677181d741e553b9825c8c319a209194ec46..a3a5c77b264a40911ddcee9b8c593fd07b3041d7 100644 +index 5232fbef0d014edd32a5d18d4a1500ab215313f5..461419d42cc7fe47311d798a637cf2f2c0025364 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java -@@ -135,6 +135,13 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { - this.getHandle().setShotFromCrossbow(shotFromCrossbow); +@@ -26,6 +26,7 @@ public class CraftArrow extends CraftAbstractArrow implements Arrow { + + @Override + public net.minecraft.world.entity.projectile.Arrow getHandle() { ++ io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading + return (net.minecraft.world.entity.projectile.Arrow) this.entity; + } + +@@ -90,6 +91,13 @@ public class CraftArrow extends CraftAbstractArrow implements Arrow { + return true; } + // Folia start - region threading @@ -303,16 +347,8 @@ index 0fd2677181d741e553b9825c8c319a209194ec46..a3a5c77b264a40911ddcee9b8c593fd0 + // 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 - return (net.minecraft.world.entity.projectile.AbstractArrow) this.entity; - } - + public void setBasePotionData(PotionData data) { + this.setBasePotionType(CraftPotionUtil.fromBukkit(data)); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java index cbfca242f820d238b112f8ce64e9de8398c48a1c..c5f0cd5e69a20f1fffcd017385bf9fab59630ffc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java @@ -439,6 +475,42 @@ index e33b1b6fd50a4eea57500cc00dba20d6edcab75d..f9a8e684a04c4ffdf566b29252e18dbf return (net.minecraft.world.entity.vehicle.Boat) this.entity; } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java +index b252236369315502278e9b7c93709a347ec16636..a6baa179d43495f71c4dcece8b50556e7217261b 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBogged.java +@@ -12,6 +12,7 @@ public class CraftBogged extends CraftAbstractSkeleton implements Bogged { + + @Override + public net.minecraft.world.entity.monster.Bogged getHandle() { ++ io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading + return (net.minecraft.world.entity.monster.Bogged) this.entity; + } + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBreeze.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBreeze.java +index 3f3d087387d3169f352d7377c0e5a24668c3d17e..23f6eac9cec63da625c6328895702bc26c9c8ada 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBreeze.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBreeze.java +@@ -11,6 +11,7 @@ public class CraftBreeze extends CraftMonster implements Breeze { + + @Override + public net.minecraft.world.entity.monster.breeze.Breeze getHandle() { ++ io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading + return (net.minecraft.world.entity.monster.breeze.Breeze) this.entity; + } + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java +index e88e52a9b8a4d2d750101b0529cbe2a9976e91dd..8ba5a80bb4847cf33e2618cf5122f1fcffc2453d 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBreezeWindCharge.java +@@ -10,6 +10,7 @@ public class CraftBreezeWindCharge extends CraftAbstractWindCharge implements Br + + @Override + public net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge getHandle() { ++ io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading + return (net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge) this.entity; + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java index 80e571c977db5cdf43bfbfce035f37a3fa325c95..6fafba37dd7128a397ba046be7b33067c9e88f25 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java @@ -461,10 +533,10 @@ index 80e571c977db5cdf43bfbfce035f37a3fa325c95..6fafba37dd7128a397ba046be7b33067 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java -index 42342628227742aa7ee6b84caa0e1f13b498babe..8fa5a33a32ea0c9e5e7f941011612060db8ea826 100644 +index a565ac47b3dc9a27e043fc9cb00b6dea950f08cf..d753d481d84f3c6cabef79752b8164ebbb02e605 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java -@@ -16,8 +16,16 @@ public class CraftCat extends CraftTameableAnimal implements Cat { +@@ -17,8 +17,16 @@ public class CraftCat extends CraftTameableAnimal implements Cat { super(server, entity); } @@ -503,10 +575,10 @@ index 4f661fbdb860cf550da0d952b775fe6f990b43b3..4a8b2b6bf80d43bba551c34a1a03fd5c } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java -index f1844d697b91e61878ade5b922cf2a3a538365c7..c07479ea6eca28e47bb618b420e57814c861ef8d 100644 +index c0f6939ed782dd3151ebd7ee9d3d7e292154e76c..0e87d66a4c5da38bdf12b657adaf56711483f0fa 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java -@@ -18,8 +18,16 @@ public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.Chest +@@ -15,8 +15,16 @@ public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.Chest this.inventory = new CraftInventory(entity); } @@ -902,7 +974,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 1cfe604573000fa9b32237313aa467875a891f3c..8c7e01972888df4ccbaccc4eebceeeb5ab357f4c 100644 +index cf9282a46534319308e9ccf69f332a5c8c1745cf..9e883ff5ffd1298edc682873be248b8319061bb8 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 { @@ -1007,10 +1079,10 @@ index 1359d25a32b4a5d5e8e68ce737bd19f7b5afaf69..0be7f84a50b7568d0c639f5906b5ca76 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java -index a8699b274b51c5f6691557c3c3db88436f05e304..45e900cd12c5615149c99a5dc85e8f78edb5483b 100644 +index 2124b31ca4d994ad159556d47a315004b7246265..17773f2629f372b671898640ac87021593452407 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java -@@ -60,8 +60,16 @@ public class CraftFireball extends AbstractProjectile implements Fireball { +@@ -75,8 +75,16 @@ public class CraftFireball extends AbstractProjectile implements Fireball { } // Paper end - Expose power on fireball projectiles @@ -1133,10 +1205,10 @@ index c455deb4fd2a7684bcc01a8212c362a2375c190b..50ee6d3c3aa157fe69a483e02f33f231 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java -index 65131d153b78a0787b977b9f65c15cfcbd395d11..e7501d8ec8f920939ef7599d5a88bd6ce7ab4f53 100644 +index 4b0aac4362b773f30dfe7c1867fad98fc30b414c..e83fae32769cc4f258011aa7d15f7b2b64674c1c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java -@@ -16,8 +16,16 @@ public class CraftFrog extends CraftAnimals implements org.bukkit.entity.Frog { +@@ -17,8 +17,16 @@ public class CraftFrog extends CraftAnimals implements org.bukkit.entity.Frog { super(server, entity); } @@ -1343,7 +1415,7 @@ index 37007775d27598e319c0c78929c6a808b697724a..17265ad2eaa38259f3c311c1c73576a7 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java -index 8746f80d08df5501b32958eb123aa7d814573ddf..c6c6eb55f4649e18beef9832c2ea7b9d1515666f 100644 +index 9b6ff0f64966c78a3233860bb0840182b52f01bc..a9b9bebee183992d0abd4de78efae078f41fe4ec 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java @@ -13,8 +13,16 @@ public class CraftHorse extends CraftAbstractHorse implements Horse { @@ -1364,10 +1436,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 7984365c8290ac9e526a413b56e1c8c0841e330c..0c468a1324996137eba5d1927d38a39859b705f0 100644 +index 41f3cdec7deabf34358b8087df77169f85a5b919..51752a1ef885295e2c50832da1c1550ac0a8fb90 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -@@ -292,8 +292,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { +@@ -290,8 +290,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { this.mode = mode; } @@ -1595,10 +1667,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 c4a166a0c226c6083c25c58145d9631d4296e615..ee1d3f33cf5f3cfc7909dbc33178df69bd656ab8 100644 +index aa351df679f300018367244c7ccb3e5a59e9276f..9a24e70d574c854fa48510603bee7b0e5f7371e3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -@@ -470,6 +470,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { +@@ -469,6 +469,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { this.getHandle().invulnerableTime = ticks; } @@ -1612,7 +1684,7 @@ index c4a166a0c226c6083c25c58145d9631d4296e615..ee1d3f33cf5f3cfc7909dbc33178df69 @Override public int getNoActionTicks() { return this.getHandle().getNoActionTime(); -@@ -483,6 +490,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { +@@ -482,6 +489,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public net.minecraft.world.entity.LivingEntity getHandle() { @@ -1621,7 +1693,7 @@ index c4a166a0c226c6083c25c58145d9631d4296e615..ee1d3f33cf5f3cfc7909dbc33178df69 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java -index 0ad16ee7b33582d214dab41eeee378d52c8e38ed..874c6690ec46d482757093296bbcf1864382e13b 100644 +index 351f42842b780d053cd2e5bad9ae299449141b10..6329f0b069fc03eef14e2c85525c93b47b8d3945 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -14,8 +14,16 @@ public class CraftLlama extends CraftChestedHorse implements Llama, com.destroys @@ -1726,7 +1798,7 @@ index 8920af5a0dfe737c1f38d906b53e6a278456d2aa..8bc87cfe29d61b09eee8ecfccda319b5 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java -index 0ee159d488b15e571f9b19ec852fe279755696fa..356ac7fcea71f173d8698f3de33bfe9616c08312 100644 +index f34fa6715e477936097367a7aefd1a2bf87d3d90..40ecce7b710650a893ff5d4e5fac99cfa1b06cf9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java @@ -20,8 +20,16 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca @@ -1747,10 +1819,10 @@ index 0ee159d488b15e571f9b19ec852fe279755696fa..356ac7fcea71f173d8698f3de33bfe96 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java -index 313ee5c8737b2e57f9b5db6512c1871766b2ccd4..a0a136893a09185577cb46dfe8426fdb3a9a6ccd 100644 +index 4388cd0303b45faf21631e7644baebb63baaba10..7bd3722e86b9da74d5e8476d189ba28f8f10956e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java -@@ -16,8 +16,16 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo +@@ -13,8 +13,16 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo super(server, entity); } @@ -1832,10 +1904,10 @@ index 79b608e89d4d1f76a58868c585bb87c82e2689b1..7767a342b3d8bf9c07fbd73ad4ccacd8 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -index 31f62fbb54ec7b270fbd8afba7bd7c4bfafa09e3..0c89084eae131ae91d6c6aa910b1e0d2fc47747d 100644 +index e155501fb3a88edf3ddac3aa0aae1b6a5a84962e..c17d5f6e60c4e2e0266e5c4288418d127e0ccdc8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -@@ -55,8 +55,16 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { +@@ -53,8 +53,16 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { return (sound != null) ? CraftSound.minecraftToBukkit(sound) : null; } @@ -1852,7 +1924,7 @@ index 31f62fbb54ec7b270fbd8afba7bd7c4bfafa09e3..0c89084eae131ae91d6c6aa910b1e0d2 return (net.minecraft.world.entity.Mob) this.entity; } -@@ -64,7 +72,7 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { +@@ -62,7 +70,7 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { @Override public void setHandle(net.minecraft.world.entity.Entity entity) { super.setHandle(entity); @@ -1883,7 +1955,7 @@ index 706c74c832f6893df3797023f68add31139c7d57..80a612f16669e571e336dd6369a968b4 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java -index 983e0cdbd1bd950807967a36cba49859fb956f31..7dc7e382d63cd5c42bb0ef72d4766d24be99c3a6 100644 +index 5c5b64bd058684520fa175bfd10622ff57856b7c..ab8d6052c7f11b0563ea49a4766aa1cac93a5c1b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java @@ -19,6 +19,13 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow, io.paperm @@ -1899,8 +1971,8 @@ index 983e0cdbd1bd950807967a36cba49859fb956f31..7dc7e382d63cd5c42bb0ef72d4766d24 + @Override public boolean hasEffectsForNextStew() { - return this.getHandle().stewEffects != null && !this.getHandle().stewEffects.isEmpty(); -@@ -100,6 +107,7 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow, io.paperm + SuspiciousStewEffects stewEffects = this.getHandle().stewEffects; +@@ -94,6 +101,7 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow, io.paperm @Override public net.minecraft.world.entity.animal.MushroomCow getHandle() { @@ -1929,6 +2001,18 @@ index 5c60a30e80448fbf04b5fa4b1ef12fb2ee99bfd5..77eefdff4a5102fbc3abba7d7037fa7a return (net.minecraft.world.entity.animal.Ocelot) this.entity; } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftOminousItemSpawner.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftOminousItemSpawner.java +index ecdac2cf74e99f0d69e053dece11ab891973dc2b..14a1c58aacf7e07ffc254b5f02b6eb6dfc1a6277 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftOminousItemSpawner.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftOminousItemSpawner.java +@@ -13,6 +13,7 @@ public class CraftOminousItemSpawner extends CraftEntity implements OminousItemS + + @Override + public net.minecraft.world.entity.OminousItemSpawner getHandle() { ++ io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading + return (net.minecraft.world.entity.OminousItemSpawner) this.entity; + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index bcac1359c667ef1ee46384f9c7a5adf4010d2b08..f131a80df94a9f0d42a64a86424451fb06755b12 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -2140,10 +2224,10 @@ 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 232490c970d67e6bc77a35d5ccfef8fa95646ffe..0ece776a1e281a328e28dc07fb4dc882b19d029c 100644 +index c03015738313ba802436ed8a047623c02e94a06e..96201b5b458d8e0cbebf586062fac1ec2d81fdd0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -582,7 +582,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -667,7 +667,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void kick(net.kyori.adventure.text.Component message, org.bukkit.event.player.PlayerKickEvent.Cause cause) { @@ -2152,7 +2236,7 @@ index 232490c970d67e6bc77a35d5ccfef8fa95646ffe..0ece776a1e281a328e28dc07fb4dc882 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 { +@@ -2291,9 +2291,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this; } @@ -2170,7 +2254,7 @@ index 232490c970d67e6bc77a35d5ccfef8fa95646ffe..0ece776a1e281a328e28dc07fb4dc882 } public void setHandle(final ServerPlayer entity) { -@@ -3266,7 +3273,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -3329,7 +3336,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { { if ( CraftPlayer.this.getHealth() <= 0 && CraftPlayer.this.isOnline() ) { @@ -2412,7 +2496,7 @@ index 7c75d78e5e28d7320c6dbe979bcd576658fb310b..83de93bd751b1c15ad763819e4fe87ec } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java -index 824638b3428fd480419f559c07d1fc7fbd434a24..278ad88925fb5530fdeef35cb19002a0cdab68a0 100644 +index de3327812c08b3bb8f5907ae657f67962d1e4e8b..d2452b8efdd066df985e4a55f80f09275a589a9c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java @@ -27,8 +27,16 @@ public class CraftSizedFireball extends CraftFireball implements SizedFireball { @@ -2580,10 +2664,10 @@ index 4ce2373ff71c3c1b8951646e057587a3ab09e145..9041c121b9bc41152640c8e2ed983b9e } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java -index 6dff6db2e6a3a4fb2ada257041b168347d33bc6a..62b9c7fce1e3f7e17e9a1be999cf94760c057445 100644 +index 70f1f8740091d5a3d5983227ef2e6e166bb6ce7e..eed30dd92b9741718f7b9f2446ec0e45d21fead6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java -@@ -9,8 +9,16 @@ public class CraftSpectralArrow extends CraftArrow implements SpectralArrow { +@@ -9,8 +9,16 @@ public class CraftSpectralArrow extends CraftAbstractArrow implements SpectralAr super(server, entity); } @@ -2727,7 +2811,7 @@ index d7c6a0bbc5671ea8f2488230c94df5146a1e98b9..71faf263dd5ac43ab9b89b5a152dd0d1 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java -index a06679e1e5686d9bd601b3dcf8492add58918bc4..389ba1c170014f9d5b7e4acf10b494338f46efcb 100644 +index cedb8e67e208cdf954d052a4f0a100c1c07a962b..cb6bb7ce434dd72e5f23da0a257958dbffdc0547 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java @@ -12,8 +12,16 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat @@ -2769,7 +2853,7 @@ index 9ef939b76d06874b856e0c850addb364146f5a00..d3975a461778d9815f68f323e616e25c } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java -index 2a57a2ce8c21d2ab2376d34d1343315209715579..04a28b8bcd449d312dcb495e496913f470705c10 100644 +index bf7b111abdf42969218a3608d86a3313432bc0a0..51bfd27170e8aceb2274918d9c8ff71cbc2625a5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java @@ -26,8 +26,16 @@ public abstract class CraftThrowableProjectile extends CraftProjectile implement @@ -2811,10 +2895,10 @@ index 5e7fef664c56d6087502e56a0eb4fc07d34ade9f..7538d449e24a8d680628f31b22924e7d } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java -index d3aeb4b614b2b17d9613aa3ffa34ebfc81666f79..a8eba002d3620192781abcccd1b5172b77cdd1c5 100644 +index 42462fac097aeb1cfd367f8c240da63f513ec5a8..bee84fee81eb8fca431d982ea88df71b3136c182 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java -@@ -60,8 +60,17 @@ public class CraftThrownPotion extends CraftThrowableProjectile implements Throw +@@ -61,8 +61,17 @@ public class CraftThrownPotion extends CraftThrowableProjectile implements Throw this.getHandle().splash(null); } // Paper end @@ -2832,27 +2916,6 @@ index d3aeb4b614b2b17d9613aa3ffa34ebfc81666f79..a8eba002d3620192781abcccd1b5172b return (net.minecraft.world.entity.projectile.ThrownPotion) this.entity; } } -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java -index b2747e37600cadc385e2e9e1115ba1d4ec22f5da..11f7c05740e68fdc171aa5cbf6f8b3f71026948f 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java -@@ -23,8 +23,16 @@ public class CraftTippedArrow extends CraftArrow implements Arrow { - super(server, entity); - } - -+ // Folia start - region threading -+ @Override -+ public net.minecraft.world.entity.projectile.Arrow getHandleRaw() { -+ return (net.minecraft.world.entity.projectile.Arrow)this.entity; -+ } -+ // Folia end - region threading -+ - @Override - public net.minecraft.world.entity.projectile.Arrow getHandle() { -+ io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.projectile.Arrow) this.entity; - } - diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java index 4b3a764114c8372e1549dadeeced26dc7727f2d1..04cbe165b99d348a864da5d342225fc929b2bfd0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java @@ -2875,10 +2938,10 @@ index 4b3a764114c8372e1549dadeeced26dc7727f2d1..04cbe165b99d348a864da5d342225fc9 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java -index 8a6af0db8e0aa0cffbf19584be747076c2c8ee44..b7c639a027001a064333fb4e8feb0e049e8cabbd 100644 +index 4fc893378fb0568ddcffc7593d66df6bfe23f659..fe730d081e93ea6b2854b246389fde9ed8b40a94 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java -@@ -12,8 +12,16 @@ public class CraftTrident extends CraftArrow implements Trident { +@@ -12,8 +12,16 @@ public class CraftTrident extends CraftAbstractArrow implements Trident { super(server, entity); } @@ -3084,6 +3147,18 @@ index 1b347deb6eb0b39c4a23936f7cd387421f06350d..4e5d311e10736f84964c22cb01a9fafe return (WaterAnimal) this.entity; } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java +index 46447b9651dc48181916ce1306ee5deec397be12..37d205c3186ea6fa8a6ca78812b4c310ce553992 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWindCharge.java +@@ -10,6 +10,7 @@ public class CraftWindCharge extends CraftAbstractWindCharge implements WindChar + + @Override + public net.minecraft.world.entity.projectile.windcharge.WindCharge getHandle() { ++ io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading + return (net.minecraft.world.entity.projectile.windcharge.WindCharge) this.entity; + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java index 4b3d783cabcb2de1a67d7fbfb6f525bfb493aed1..b8d1fe35b9c0b00389b2aaca229f31a6d0de85c6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java @@ -3148,10 +3223,10 @@ index bc978391255c9414e06ff393f2e6707d329d020a..5af2d0f7c496d49dcb66b888047836c0 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java -index 38b6d2c377800134de592a780b737b45c8096a11..ca35b9bdabc456b64272046cb069b8d7477aa1b2 100644 +index 86574da257731de7646a712ed73384955fe35aa3..0e81a82f92934ceb03dae6908b321c9b15caa15b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java -@@ -23,8 +23,16 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf { +@@ -31,8 +31,16 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf { } } diff --git a/patches/server/0007-Disable-mid-tick-task-execution.patch b/patches/server/0007-Disable-mid-tick-task-execution.patch index 0cb632d16..0334aff29 100644 --- a/patches/server/0007-Disable-mid-tick-task-execution.patch +++ b/patches/server/0007-Disable-mid-tick-task-execution.patch @@ -10,10 +10,10 @@ 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 4e94de4a3184fd36119bf39beccff62ac561c1e4..2bd923c61642edf67338471d0578609039a51822 100644 +index cd63ccf69ce701079d780afaff0d784ec0e4f535..b28c82e4a49ae5ae58bdb43e012afd5ef4a839f3 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> dependencies = new EnumMap<>(PluginDependencyLifeCycle.class); -@@ -228,6 +229,13 @@ public class PaperPluginMeta implements PluginMeta { - return this.apiVersion; +@@ -251,6 +252,13 @@ public class PaperPluginMeta implements PluginMeta { + return this.apiVersion.getVersionString(); } + // Folia start @@ -47,10 +47,10 @@ index 0a27b468560ccf4b9588cd12d50c02e442f3024f..6369b13e1fcdbdb25dd9d6e4d3bffded ComponentLogger logger = ComponentLogger.logger(jul.getName()); PluginProviderContext context = PluginProviderContextImpl.create(configuration, logger, source); diff --git a/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java b/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java -index bdd9bc8a414719b9f1d6f01f90539ddb8603a878..bf1856316aa45d2de061e6f4268dd9c63deb1ced 100644 +index fdb52ad85cfaa1d53aadcad72cec3d3c8c12c058..1b2964d5a3d839950e6831b7542e9587187bd375 100644 --- a/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java +++ b/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java -@@ -17,6 +17,11 @@ class SpigotPluginProviderFactory implements PluginTypeFactory> optional = getLodestoneDimension(compoundTag); - if (optional.isPresent() && optional.get() == world.dimension() && compoundTag.contains("LodestonePos")) { - BlockPos blockPos = NbtUtils.readBlockPos(compoundTag.getCompound("LodestonePos")); -- if (!world.isInWorldBounds(blockPos) || (world.hasChunkAt(blockPos) && !((ServerLevel)world).getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos))) { // Paper - Prevent compass from loading chunks -+ // Folia start - do not access the POI data off-region -+ net.minecraft.world.level.chunk.LevelChunk chunk = world.getChunkIfLoaded(blockPos); -+ if (!world.isInWorldBounds(blockPos) || chunk != null && chunk.getBlockState(blockPos).getBlock() != Blocks.LODESTONE) { // Paper - Prevent compass from loading chunks -+ // Folia end - do not access the POI data off-region - compoundTag.remove("LodestonePos"); - } - } +diff --git a/src/main/java/net/minecraft/world/item/component/LodestoneTracker.java b/src/main/java/net/minecraft/world/item/component/LodestoneTracker.java +index cdd1f6939ce33e62f6609f7eb3a5dff59bf12675..5d92251dc5a53eb6b2f5ecfef1261ad6edd0e2a9 100644 +--- a/src/main/java/net/minecraft/world/item/component/LodestoneTracker.java ++++ b/src/main/java/net/minecraft/world/item/component/LodestoneTracker.java +@@ -29,7 +29,10 @@ public record LodestoneTracker(Optional target, boolean tracked) { + return this; + } else { + BlockPos blockPos = this.target.get().pos(); +- return world.isInWorldBounds(blockPos) && (!world.hasChunkAt(blockPos) || world.getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos)) // Paper - Prevent compass from loading chunks ++ // Folia start - do not access the POI data off-region ++ net.minecraft.world.level.chunk.LevelChunk chunk = world.getChunkIfLoaded(blockPos); ++ return world.isInWorldBounds(blockPos) && (chunk == null || chunk.getBlockState(blockPos).getBlock() == net.minecraft.world.level.block.Blocks.LODESTONE) // Paper - Prevent compass from loading chunks ++ // Folia end - do not access the POI data off-region + ? this + : new LodestoneTracker(Optional.empty(), true); + } diff --git a/patches/server/0016-Fix-off-region-raid-heroes.patch b/patches/server/0016-Fix-off-region-raid-heroes.patch index 3960ef212..1a61009db 100644 --- a/patches/server/0016-Fix-off-region-raid-heroes.patch +++ b/patches/server/0016-Fix-off-region-raid-heroes.patch @@ -9,15 +9,15 @@ raid before it's completion, it would throw an exception due to not being on the same region thread anymore. diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java -index 2905dab1f9b3dd846261c5b0777d073927882825..488ff78fd704b8a87b7012c3c4f66814dff97e1b 100644 +index 7c9d63c94f36c1702fc48570b07393375c77bd21..9339f7b3c4c856fc32abbca0959a961c4fe7e09b 100644 --- a/src/main/java/net/minecraft/world/entity/raid/Raid.java +++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java -@@ -420,14 +420,22 @@ public class Raid { +@@ -432,14 +432,22 @@ public class Raid { LivingEntity entityliving = (LivingEntity) entity; if (!entity.isSpectator()) { -- entityliving.addEffect(new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE, 48000, this.badOmenLevel - 1, false, false, true)); -+ //entityliving.addEffect(new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE, 48000, this.badOmenLevel - 1, false, false, true)); // Folia - Fix off region raid heroes - move down +- entityliving.addEffect(new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE, 48000, this.raidOmenLevel - 1, false, false, true)); ++ //entityliving.addEffect(new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE, 48000, this.raidOmenLevel - 1, false, false, true)); // Folia - Fix off region raid heroes - move down if (entityliving instanceof ServerPlayer) { ServerPlayer entityplayer = (ServerPlayer) entityliving; @@ -28,7 +28,7 @@ index 2905dab1f9b3dd846261c5b0777d073927882825..488ff78fd704b8a87b7012c3c4f66814 } + // Folia start - Fix off region raid heroes + entityliving.getBukkitEntity().taskScheduler.schedule((LivingEntity lv) -> { -+ lv.addEffect(new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE, 48000, this.badOmenLevel - 1, false, false, true)); ++ lv.addEffect(new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE, 48000, this.raidOmenLevel - 1, false, false, true)); + if (lv instanceof ServerPlayer entityplayer) { + entityplayer.awardStat(Stats.RAID_WIN); + CriteriaTriggers.RAID_WIN.trigger(entityplayer); diff --git a/patches/server/0017-Sync-vehicle-position-to-player-position-on-player-d.patch b/patches/server/0017-Sync-vehicle-position-to-player-position-on-player-d.patch index 1edea4874..d714e3e1e 100644 --- a/patches/server/0017-Sync-vehicle-position-to-player-position-on-player-d.patch +++ b/patches/server/0017-Sync-vehicle-position-to-player-position-on-player-d.patch @@ -7,20 +7,20 @@ This allows the player to be re-positioned before logging into the world without causing thread checks to trip on Folia. diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index a390227e5af1232f2090d2be72f7789805025f76..bbf43b5844a75a25c1757cfb1c3c9dbe9b1fadde 100644 +index db2903276c694d395f62afdc7c71344466ae505f..5f9c89dbbfa9b3e4d2b68c0d8628cf223c1f7aa0 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -522,7 +522,13 @@ public abstract class PlayerList { - CompoundTag nbttagcompound1 = nbttagcompound.getCompound("RootVehicle"); - // CraftBukkit start - ServerLevel finalWorldServer = worldserver1; + if (optional.isPresent() && ((CompoundTag) optional.get()).contains("RootVehicle", 10)) { + CompoundTag nbttagcompound = ((CompoundTag) optional.get()).getCompound("RootVehicle"); + ServerLevel finalWorldServer = worldserver1; // CraftBukkit - decompile error + Vec3 playerPos = player.position(); // Paper - force sync root vehicle to player position - Entity entity = EntityType.loadEntityRecursive(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> { + Entity entity = EntityType.loadEntityRecursive(nbttagcompound.getCompound("Entity"), worldserver1, (entity1) -> { + // Paper start - force sync root vehicle to player position + if (entity1.distanceToSqr(player) > (5.0 * 5.0)) { + entity1.setPosRaw(playerPos.x, playerPos.y, playerPos.z, true); + } + // Paper end - force sync root vehicle to player position - return !finalWorldServer.addWithUUID(entity1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity1; // Paper - Entity#getEntitySpawnReason - // CraftBukkit end + return !finalWorldServer.addWithUUID(entity1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity1; // CraftBukkit - decompile error // Paper - Entity#getEntitySpawnReason }); + diff --git a/patches/server/0018-Region-profiler.patch b/patches/server/0018-Region-profiler.patch index bf19f80e0..00397c23b 100644 --- a/patches/server/0018-Region-profiler.patch +++ b/patches/server/0018-Region-profiler.patch @@ -942,7 +942,7 @@ index 67bf841878eb8e3703782caeb16db4803d13f0d9..0d8b2a4127e8c8e4970d220b8a224049 } diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java -index 08075b8895f816420c2a940bf551dfada3c0cd9e..2c688d886b14679d7ab4a485da2675e97c2bac43 100644 +index 014cacbcb537a30566ab756bd884a20c256f9c4c..e46def6929f95828abc9b0e16e4c98c142490433 100644 --- a/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java +++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java @@ -1750,6 +1750,8 @@ public final class NewChunkHolder { @@ -1361,10 +1361,10 @@ index 0000000000000000000000000000000000000000..e36fd244f71a92d11c6ee45944948be5 + } +} diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -index 1192503d2729b3f14aa2936c2060df9884870cb4..632c5ba694a37159d5297f6af885408a5cb76330 100644 +index 9f07a1a5e2c082d16de068de6f47bf8fb06ba99a..662a9e4f48cfc314b9d619a813122b1ac67273fd 100644 --- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java +++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -@@ -51,7 +51,10 @@ public class PacketUtils { +@@ -52,7 +52,10 @@ public class PacketUtils { if (listener.shouldHandleMessage(packet)) { co.aikar.timings.Timing timing = co.aikar.timings.MinecraftTimings.getPacketTiming(packet); // Paper - timings try (co.aikar.timings.Timing ignored = timing.startTiming()) { // Paper - timings @@ -1373,13 +1373,13 @@ index 1192503d2729b3f14aa2936c2060df9884870cb4..632c5ba694a37159d5297f6af885408a packet.handle(listener); + } finally { profiler.stopTimer(packetTimerId); } // Folia - profiler } catch (Exception exception) { - label25: - { + if (exception instanceof ReportedException) { + ReportedException reportedexception = (ReportedException) exception; diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 2bd923c61642edf67338471d0578609039a51822..bcc8a0171f981e2b2e24dd57834701c1899ab4c9 100644 +index b28c82e4a49ae5ae58bdb43e012afd5ef4a839f3..4c9c227c1395744128f347e9303f8a13667a4aa3 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1592,6 +1592,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 && io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() % autosavePeriod == 0; // Folia - region threading @@ -1424,7 +1424,7 @@ index 2bd923c61642edf67338471d0578609039a51822..bcc8a0171f981e2b2e24dd57834701c1 try { this.isSaving = true; if (playerSaveInterval > 0) { -@@ -1671,6 +1682,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { // Folia - region threading entityplayer.connection.suspendFlushing(); -@@ -1801,12 +1814,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop iterator = this.level.needsChangeBroadcasting.iterator(); iterator.hasNext();) { ChunkHolder holder = iterator.next(); if (!io.papermc.paper.util.TickThread.isTickThreadFor(holder.newChunkHolder.world, holder.pos)) { -@@ -627,6 +648,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -625,6 +646,7 @@ public class ServerChunkCache extends ChunkSource { iterator.remove(); } } @@ -1635,10 +1638,10 @@ index d532043f33825ce2971d9e53f290cdead22d6916..74483543836d9ed042cc7b9cbbde8d58 // Folia end - region threading // Paper end - optimise chunk tick iteration diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfbf573ceac 100644 +index 559b6d0e3611b506ff10e5ae7c42b35f0d710173..b194f3448b5199e1204da31e1408f2e80803a77d 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -891,6 +891,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -898,6 +898,7 @@ public class ServerLevel extends Level implements WorldGenLevel { public void tick(BooleanSupplier shouldKeepTicking, io.papermc.paper.threadedregions.TickRegions.TickRegionData region) { // Folia - regionised ticking final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = this.getCurrentWorldData(); // Folia - regionised ticking @@ -1646,7 +1649,7 @@ index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfb ProfilerFiller gameprofilerfiller = this.getProfiler(); regionizedWorldData.setHandlingTick(true); // Folia - regionised ticking -@@ -919,9 +920,13 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -926,9 +927,13 @@ public class ServerLevel extends Level implements WorldGenLevel { if (!this.isDebug() && flag) { j = regionizedWorldData.getRedstoneGameTime(); // Folia - region threading gameprofilerfiller.push("blockTicks"); @@ -1660,7 +1663,7 @@ index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfb gameprofilerfiller.pop(); } this.timings.scheduledBlocks.stopTiming(); // Paper -@@ -929,18 +934,24 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -936,18 +941,24 @@ public class ServerLevel extends Level implements WorldGenLevel { gameprofilerfiller.popPush("raid"); if (flag) { this.timings.raids.startTiming(); // Paper - timings @@ -1685,7 +1688,7 @@ index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfb this.timings.doSounds.stopTiming(); // Spigot } -@@ -956,6 +967,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -963,6 +974,7 @@ public class ServerLevel extends Level implements WorldGenLevel { gameprofilerfiller.push("entities"); this.timings.tickEntities.startTiming(); // Spigot if (this.dragonFight != null && flag) { @@ -1693,7 +1696,7 @@ index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfb if (io.papermc.paper.util.TickThread.isTickThreadFor(this, this.dragonFight.origin)) { // Folia - region threading gameprofilerfiller.push("dragonFight"); this.dragonFight.tick(); -@@ -968,10 +980,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -975,10 +987,12 @@ public class ServerLevel extends Level implements WorldGenLevel { fightCenter ); } // Folia end - region threading @@ -1706,7 +1709,7 @@ index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfb regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking if (!entity.isRemoved()) { if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed -@@ -999,10 +1013,13 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1006,10 +1020,13 @@ public class ServerLevel extends Level implements WorldGenLevel { } } }); @@ -1720,7 +1723,7 @@ index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfb } gameprofilerfiller.push("entityManagement"); -@@ -1062,12 +1079,15 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1069,12 +1086,15 @@ public class ServerLevel extends Level implements WorldGenLevel { } public void tickCustomSpawners(boolean spawnMonsters, boolean spawnAnimals) { @@ -1736,7 +1739,7 @@ index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfb } } -@@ -1517,6 +1537,11 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1524,6 +1544,11 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper start- timings final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); timer = isActive ? entity.getType().tickTimer.startTiming() : entity.getType().inactiveTickTimer.startTiming(); // Paper @@ -1748,7 +1751,7 @@ index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfb try { // Paper end - timings entity.setOldPosAndRot(); -@@ -1542,7 +1567,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1549,7 +1574,7 @@ public class ServerLevel extends Level implements WorldGenLevel { // Folia end - region threading } else { entity.inactiveTick(); } // Paper - EAR 2 this.getProfiler().pop(); @@ -1757,7 +1760,7 @@ index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfb Iterator iterator = entity.getPassengers().iterator(); while (iterator.hasNext()) { -@@ -1566,6 +1591,11 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1573,6 +1598,11 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper - EAR 2 final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(passenger); co.aikar.timings.Timing timer = isActive ? passenger.getType().passengerTickTimer.startTiming() : passenger.getType().passengerInactiveTickTimer.startTiming(); // Paper @@ -1769,7 +1772,7 @@ index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfb try { // Paper end passenger.setOldPosAndRot(); -@@ -1605,7 +1635,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1612,7 +1642,7 @@ public class ServerLevel extends Level implements WorldGenLevel { this.tickPassenger(passenger, entity2); } @@ -1779,10 +1782,10 @@ index 2f799ead36f0f22afe7dc4b688e59ef25fe2f9b8..36f1af9ef5fca7c45f250470d21a4dfb } else { passenger.stopRiding(); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index bbf43b5844a75a25c1757cfb1c3c9dbe9b1fadde..90be312057221a5a78066d89783c5e22008d797d 100644 +index 5f9c89dbbfa9b3e4d2b68c0d8628cf223c1f7aa0..771b259ce930d2c857a08ca9150a243679c88c80 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -1335,6 +1335,7 @@ public abstract class PlayerList { +@@ -1334,6 +1334,7 @@ public abstract class PlayerList { public void saveAll(int interval) { io.papermc.paper.util.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main @@ -1790,7 +1793,7 @@ index bbf43b5844a75a25c1757cfb1c3c9dbe9b1fadde..90be312057221a5a78066d89783c5e22 MinecraftTimings.savePlayers.startTiming(); // Paper int numSaved = 0; long now = System.nanoTime(); // Folia - region threading -@@ -1346,7 +1347,9 @@ public abstract class PlayerList { +@@ -1345,7 +1346,9 @@ public abstract class PlayerList { } // Folia end - region threading if (interval == -1 || now - entityplayer.lastSave >= timeInterval) { // Folia - region threading @@ -1801,10 +1804,10 @@ index bbf43b5844a75a25c1757cfb1c3c9dbe9b1fadde..90be312057221a5a78066d89783c5e22 if (interval != -1 && max != -1 && ++numSaved >= max) { break; diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index 09e8445a3f8c6b3ebc852a75a9a25b41a51ba659..f921c159c4f7556daf3c8405241de3607ba251ad 100644 +index a46bf73c608641bf1f00fd55242de71a0f2ee06e..a2f0fb8b4057bd3a84d18298e49c4d02955240d3 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -326,6 +326,13 @@ public class EntityType implements FeatureElement, EntityTypeT +@@ -338,6 +338,13 @@ public class EntityType implements FeatureElement, EntityTypeT return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(id)); } @@ -1815,10 +1818,10 @@ index 09e8445a3f8c6b3ebc852a75a9a25b41a51ba659..f921c159c4f7556daf3c8405241de360 + public final int passengerInactiveTickTimerId; + // Folia end - profiler + - public EntityType(EntityType.EntityFactory factory, MobCategory spawnGroup, boolean saveable, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet canSpawnInside, EntityDimensions dimensions, int maxTrackDistance, int trackTickInterval, FeatureFlagSet requiredFeatures) { + public EntityType(EntityType.EntityFactory factory, MobCategory spawnGroup, boolean saveable, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet canSpawnInside, EntityDimensions dimensions, float spawnBoxScale, int maxTrackDistance, int trackTickInterval, FeatureFlagSet requiredFeatures) { // Paper start - this(factory, spawnGroup, saveable, summonable, fireImmune, spawnableFarFromPlayer, canSpawnInside, dimensions, maxTrackDistance, trackTickInterval, requiredFeatures, "custom"); -@@ -336,6 +343,12 @@ public class EntityType implements FeatureElement, EntityTypeT + this(factory, spawnGroup, saveable, summonable, fireImmune, spawnableFarFromPlayer, canSpawnInside, dimensions, spawnBoxScale, maxTrackDistance, trackTickInterval, requiredFeatures, "custom"); +@@ -348,6 +355,12 @@ public class EntityType implements FeatureElement, EntityTypeT this.passengerTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerTick"); this.passengerInactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerInactiveTick"); // Paper end @@ -1832,10 +1835,10 @@ index 09e8445a3f8c6b3ebc852a75a9a25b41a51ba659..f921c159c4f7556daf3c8405241de360 this.factory = factory; this.category = spawnGroup; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 38ff839aa25fa2b7397f6fc6e3eadda7ae600d48..3cd8573db9dadb2e32f3c107f4812b525db014b1 100644 +index 3a1f9598c3e25a061ac934102bd86b8c9c8332a1..8c124cb3d1238c9f3297f9f2d2345399055147fe 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -232,6 +232,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -229,6 +229,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return this.getCurrentWorldData().getLocalPlayers(); } // Folia end - region ticking @@ -1845,7 +1848,7 @@ index 38ff839aa25fa2b7397f6fc6e3eadda7ae600d48..3cd8573db9dadb2e32f3c107f4812b52 protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config; Async-Anti-Xray: Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot -@@ -324,6 +327,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -317,6 +320,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.minSection = io.papermc.paper.util.WorldUtil.getMinSection(this); this.maxSection = io.papermc.paper.util.WorldUtil.getMaxSection(this); // Paper end - optimise collisions @@ -1855,7 +1858,7 @@ index 38ff839aa25fa2b7397f6fc6e3eadda7ae600d48..3cd8573db9dadb2e32f3c107f4812b52 } // Paper start - Cancel hit for vanished players -@@ -1308,17 +1314,21 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1299,17 +1305,21 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } protected void tickBlockEntities() { @@ -1877,7 +1880,7 @@ index 38ff839aa25fa2b7397f6fc6e3eadda7ae600d48..3cd8573db9dadb2e32f3c107f4812b52 // Spigot start // Iterator iterator = this.blockEntityTickers.iterator(); boolean flag = this.tickRateManager().runsNormally(); -@@ -1345,6 +1355,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1336,6 +1346,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } } blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 // Folia - regionised ticking @@ -1886,10 +1889,10 @@ index 38ff839aa25fa2b7397f6fc6e3eadda7ae600d48..3cd8573db9dadb2e32f3c107f4812b52 this.timings.tileEntityTick.stopTiming(); // Spigot regionizedWorldData.seTtickingBlockEntities(false); // Folia - regionised ticking diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java -index 86b661de30e134258b6b74a78e8ea05fd8224aed..37938d0e116982915f470b3d2b233c74d501bb0f 100644 +index 96b99aab3720e5bdf293fd4a95944c7218ce43c0..e7691f856f85469c06f2b5a2a3db3120ec6f193d 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java -@@ -281,10 +281,17 @@ public class BlockEntityType { +@@ -283,10 +283,17 @@ public class BlockEntityType { } Type type = Util.fetchChoiceType(References.BLOCK_ENTITY, id); @@ -1908,7 +1911,7 @@ index 86b661de30e134258b6b74a78e8ea05fd8224aed..37938d0e116982915f470b3d2b233c74 this.factory = factory; this.validBlocks = blocks; this.dataType = type; -@@ -329,7 +336,12 @@ public class BlockEntityType { +@@ -331,7 +338,12 @@ public class BlockEntityType { } public BlockEntityType build(Type type) { @@ -1923,10 +1926,10 @@ index 86b661de30e134258b6b74a78e8ea05fd8224aed..37938d0e116982915f470b3d2b233c74 } } 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 ff1a7b78fa010857daab7a306cb9483c98560b79..8c6ade7cf14e367d6390849ef1b2a1bfef0d52ac 100644 +index f1f0391b5e5b808b1176bc76e7c49fc7ecd141a4..0c3f095854396da0e5f38234060ba9a190a572de 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -1181,11 +1181,14 @@ public class LevelChunk extends ChunkAccess { +@@ -1179,11 +1179,14 @@ public class LevelChunk extends ChunkAccess { BlockPos blockposition = this.blockEntity.getBlockPos(); if (LevelChunk.this.isTicking(blockposition)) { @@ -1941,7 +1944,7 @@ index ff1a7b78fa010857daab7a306cb9483c98560b79..8c6ade7cf14e367d6390849ef1b2a1bf BlockState iblockdata = LevelChunk.this.getBlockState(blockposition); if (this.blockEntity.getType().isValid(iblockdata)) { -@@ -1200,6 +1203,7 @@ public class LevelChunk extends ChunkAccess { +@@ -1198,6 +1201,7 @@ public class LevelChunk extends ChunkAccess { } // Paper end - Remove the Block Entity if it's invalid } diff --git a/patches/server/0019-Fix-entity-tracker-desync-when-new-players-are-added.patch b/patches/server/0019-Fix-entity-tracker-desync-when-new-players-are-added.patch deleted file mode 100644 index 9f59fd1e7..000000000 --- a/patches/server/0019-Fix-entity-tracker-desync-when-new-players-are-added.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf -Date: Tue, 20 Feb 2024 18:24:16 -0800 -Subject: [PATCH] Fix entity tracker desync when new players are added to the - tracker - -The delta position packet instructs the client to update -the entity position by a position difference. However, this position -difference is relative to the last position in the entity tracker -state, not the last position which has been sent to the player. As -a result, if the last position the player has recorded is different -than the one stored in the entity tracker (which occurs when a new -player is added to an existing entity tracker state) then the sent -position difference will cause a position desync for the client. - -We can resolve this problem by either tracking the last position -sent per-player, or by simply resetting the last sent position -in the entity tracker state every time a new player is added. -Resetting the last sent position every time a new player is -added to the tracker is just easier to do, so that is what -this patch does. - -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 30aa7891292da87092724e0e046a08e500dd22ca..6ab9f83786dcfbd3156d2f2bd6da57baed1399f4 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1419,6 +1419,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - this.serverEntity.addPairing(player); - } - // Paper end - entity tracking events -+ this.serverEntity.onPlayerAdd(); // Paper - fix desync when a player is added to the tracker - } - } else if (this.seenBy.remove(player.connection)) { - this.serverEntity.removePairing(player); -diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 529ab44baaf573b97cf7e89560c548642733188f..16373e0c5ea38199fab3eb289bf2a5fcf0dd7439 100644 ---- a/src/main/java/net/minecraft/server/level/ServerEntity.java -+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -93,6 +93,13 @@ public class ServerEntity { - this.trackedDataValues = entity.getEntityData().getNonDefaultValues(); - } - -+ // Paper start - fix desync when a player is added to the tracker -+ private boolean forceStateResync; -+ public void onPlayerAdd() { -+ this.forceStateResync = true; -+ } -+ // Paper end - fix desync when a player is added to the tracker -+ - public void sendChanges() { - List list = this.entity.getPassengers(); - -@@ -141,7 +148,7 @@ public class ServerEntity { - } - } - -- if (this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { -+ if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker - int i; - int j; - -@@ -177,13 +184,13 @@ public class ServerEntity { - boolean flag4 = false; - boolean flag5 = false; - -- if (!(this.entity instanceof net.minecraft.world.entity.decoration.HangingEntity) || this.tickCount > 0 || this.entity instanceof AbstractArrow) { // Paper - Always update position to fix first-tick teleports -+ if (this.forceStateResync || !(this.entity instanceof net.minecraft.world.entity.decoration.HangingEntity) || this.tickCount > 0 || this.entity instanceof AbstractArrow) { // Paper - Always update position to fix first-tick teleports - long k = this.positionCodec.encodeX(vec3d); - long l = this.positionCodec.encodeY(vec3d); - long i1 = this.positionCodec.encodeZ(vec3d); - boolean flag6 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L; - -- if (!flag6 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()&& !(io.papermc.paper.configuration.GlobalConfiguration.get().collisions.sendFullPosForHardCollidingEntities && this.entity.hardCollides())) { // Paper - send full pos for hard colliding entities to prevent collision problems due to desync -+ if (!this.forceStateResync && !flag6 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()&& !(io.papermc.paper.configuration.GlobalConfiguration.get().collisions.sendFullPosForHardCollidingEntities && this.entity.hardCollides())) { // Paper - send full pos for hard colliding entities to prevent collision problems due to desync - if ((!flag2 || !flag3) && !(this.entity instanceof AbstractArrow)) { - if (flag2) { - packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) k), (short) ((int) l), (short) ((int) i1), this.entity.onGround()); -@@ -240,6 +247,7 @@ public class ServerEntity { - } - - this.entity.hasImpulse = false; -+ this.forceStateResync = false; // Paper - fix desync when a player is added to the tracker - } - - ++this.tickCount;