diff --git a/build.gradle.kts b/build.gradle.kts index 5101f5e..e8e83df 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,10 @@ -import io.papermc.paperweight.patcher.tasks.SimpleRebuildGitPatches +import io.papermc.paperweight.tasks.RebuildGitPatches plugins { java `maven-publish` - id("com.github.johnrengelman.shadow") version "7.1.2" apply false - id("io.papermc.paperweight.patcher") version "1.4.0" + id("com.github.johnrengelman.shadow") version "8.1.0" apply false + id("io.papermc.paperweight.patcher") version "1.5.3" } val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" @@ -18,8 +18,8 @@ repositories { dependencies { remapper("net.fabricmc:tiny-remapper:0.8.6:fat") - decompiler("net.minecraftforge:forgeflower:2.0.605.1") - paperclip("io.papermc:paperclip:3.0.2") + decompiler("net.minecraftforge:forgeflower:2.0.627.2") + paperclip("io.papermc:paperclip:3.0.3") } allprojects { @@ -113,6 +113,6 @@ publishing { } -tasks.withType { +tasks.withType { filterPatches.set(false) } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ed67948..dd9b568 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ group=dev.folia -version=1.19.3-R0.1-SNAPSHOT -mcVersion=1.19.3 -paperRef=4da844f1e3e375a24a0e518b0787ae909fa0e247 +version=1.19.4-R0.1-SNAPSHOT +mcVersion=1.19.4 +paperRef=e8b82590d0c3dd57ac1728b236117d2fcd531c4f org.gradle.caching=true org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cb..ccebba7 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f398c33..bdc9a83 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68..79a61d4 100755 --- a/gradlew +++ b/gradlew @@ -144,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac diff --git a/patches/api/0002-Region-scheduler-API.patch b/patches/api/0002-Region-scheduler-API.patch index a947176..ec89016 100644 --- a/patches/api/0002-Region-scheduler-API.patch +++ b/patches/api/0002-Region-scheduler-API.patch @@ -509,10 +509,10 @@ index 2204336d8800311b65e894739ab1b27273e7c6f2..ea4d93680066295de9fd447eda58b930 + // Folia end - region threading API } diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java -index cdbc7329cf5f67d66e31eb31e83b9e7997040f72..90451ed12b2c95bb372ac2e3cbb57b8b83cc6a82 100644 +index 365350d38b2eee00d22bad09ab95c6054f11d536..86a86ad5555c5f9f6ed1938615f1cae9149b2805 100644 --- a/src/main/java/org/bukkit/entity/Entity.java +++ b/src/main/java/org/bukkit/entity/Entity.java -@@ -970,4 +970,13 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent +@@ -953,4 +953,13 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent */ boolean wouldCollideUsing(@NotNull BoundingBox boundingBox); // Paper End - Collision API @@ -527,10 +527,10 @@ index cdbc7329cf5f67d66e31eb31e83b9e7997040f72..90451ed12b2c95bb372ac2e3cbb57b8b + // Folia end - region threading API } diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -index b012ce40d82389c29d1b841ff685425ac10a7f9e..057fa5dc78734520224af5031250b6be101ce3cb 100644 +index 2b8308989fce7f8a16907f8711b362e671fdbfb6..800f954161886ca4f6332f8e0cbc4d4e8f9cbb74 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -@@ -585,9 +585,9 @@ public final class SimplePluginManager implements PluginManager { +@@ -544,9 +544,9 @@ public final class SimplePluginManager implements PluginManager { } try { diff --git a/patches/api/0003-Require-plugins-to-be-explicitly-marked-as-Folia-sup.patch b/patches/api/0003-Require-plugins-to-be-explicitly-marked-as-Folia-sup.patch index 26c6db2..4db28cc 100644 --- a/patches/api/0003-Require-plugins-to-be-explicitly-marked-as-Folia-sup.patch +++ b/patches/api/0003-Require-plugins-to-be-explicitly-marked-as-Folia-sup.patch @@ -14,45 +14,60 @@ more helpful than some random error log caused by a breakage. diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java -index 0c9f4d1e9104fa6951114c1f9ec954dfcc749196..fc11577083672f127335613459436167d339efa4 100644 +index 028805bcdb1d2bb0d11387db165b7376579e5f60..51bc04571f75a4ccf05c3d080531a29fe35817d1 100644 --- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java -@@ -254,6 +254,17 @@ public final class PluginDescriptionFile { +@@ -255,6 +255,20 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf private Set awareness = ImmutableSet.of(); private String apiVersion = null; private List libraries = ImmutableList.of(); ++ + // Folia start - block plugins not marked as supported -+ private boolean foliaSupported; ++ private String foliaSupported; ++ private static final String FOLIA_SUPPORTED_KEY = "folia-supported"; + + /** + * Returns whether the plugin has been marked to be compatible with regionised threading as provided + * by Folia + */ + public boolean isFoliaSupported() { -+ return foliaSupported; ++ return this.foliaSupported != null && this.foliaSupported.equalsIgnoreCase("true"); + } + // Folia end - block plugins not marked as supported - - public PluginDescriptionFile(@NotNull final InputStream stream) throws InvalidDescriptionException { - loadMap(asMap(YAML.get().load(stream))); -@@ -1173,6 +1184,11 @@ public final class PluginDescriptionFile { ++ + // Paper start - oh my goddddd + /** + * Don't use this. +@@ -1238,6 +1252,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf if (map.get("prefix") != null) { prefix = map.get("prefix").toString(); } + // Folia start - block plugins not marked as supported -+ if (map.get("folia-supported") != null) { -+ foliaSupported = map.get("folia-supported").toString().equalsIgnoreCase("true"); ++ if (map.get(FOLIA_SUPPORTED_KEY) != null) { ++ foliaSupported = map.get(FOLIA_SUPPORTED_KEY).toString(); + } + // Folia end - block plugins not marked as supported } @NotNull +@@ -1314,6 +1333,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf + if (prefix != null) { + map.put("prefix", prefix); + } ++ // Folia start - block plugins not marked as supported ++ if (foliaSupported != null) { ++ map.put(FOLIA_SUPPORTED_KEY, foliaSupported); ++ } ++ // Folia end - block plugins not marked as supported + + return map; + } diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -index 057fa5dc78734520224af5031250b6be101ce3cb..ec838d1c7850f0d07980b051dff7c88db0aa6dbf 100644 +index 800f954161886ca4f6332f8e0cbc4d4e8f9cbb74..e0026c938aa369d6d9797852324437456d3c4ed9 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -@@ -163,6 +163,12 @@ public final class SimplePluginManager implements PluginManager { - server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + file.getParentFile().getPath() + "': uses the space-character (0x20) in its name"); // Paper +@@ -173,6 +173,12 @@ public final class SimplePluginManager implements PluginManager { + server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "': uses the space-character (0x20) in its name"); continue; } + // Folia start - block plugins not marked as supported @@ -62,5 +77,5 @@ index 057fa5dc78734520224af5031250b6be101ce3cb..ec838d1c7850f0d07980b051dff7c88d + } + // Folia end - block plugins not marked as supported } catch (InvalidDescriptionException ex) { - server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + file.getParentFile().getPath() + "'", ex); // Paper + server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "'", ex); continue; diff --git a/patches/server/0001-Build-changes.patch b/patches/server/0001-Build-changes.patch index ea27b28..d414c6f 100644 --- a/patches/server/0001-Build-changes.patch +++ b/patches/server/0001-Build-changes.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Build changes diff --git a/build.gradle.kts b/build.gradle.kts -index 781609605d25283009e5f3e61649ecde9ea9a4cb..b0542179837067492334ceccc20286db2bd8727a 100644 +index 9cf389defdaeb887e9cad4f0fed3f3b95667b238..dd53b1ffaff8dbaea0cf21c489a90162a496a026 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,8 +7,12 @@ plugins { @@ -23,7 +23,7 @@ index 781609605d25283009e5f3e61649ecde9ea9a4cb..b0542179837067492334ceccc20286db // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -61,7 +65,7 @@ tasks.jar { +@@ -62,7 +66,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", @@ -32,7 +32,7 @@ index 781609605d25283009e5f3e61649ecde9ea9a4cb..b0542179837067492334ceccc20286db "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, -@@ -133,7 +137,7 @@ fun TaskContainer.registerRunTask( +@@ -134,7 +138,7 @@ fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit ): TaskProvider = register(name) { @@ -57,10 +57,10 @@ index bf42969859545a8a520923ef1836ffa4a5cc24a0..719b0e318a85d4a1fb8f616deeb31193 return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage; diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 710ca7d3a5659953f64bc6dccdd93b43300961cc..2ee4e5e8d17a3a1e6a342c74b13135df030ffef6 100644 +index 4450d825a5474da211f0e83f845d8c7129fa08aa..8ccc92836bfda8e00eea649430174dcd5664af70 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1654,7 +1654,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 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, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { - // Holder holder = worlddimension.type(); // CraftBukkit - decompile error + // IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 7d6d3c8556033d289fdadc489e73fba478fce41a..869daafbc236b3ff63f878e5fe28427fde75afe5 100644 +index ca5291a9573a62cb5c19539cf5c7aceff11f9829..8a80b222456c2e4818cada3a9248ab2f9b76a983 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -269,6 +269,48 @@ public class ServerPlayer extends Player { +@@ -275,6 +275,48 @@ public class ServerPlayer extends Player { public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event @@ -2060,10 +2060,10 @@ index 7d6d3c8556033d289fdadc489e73fba478fce41a..869daafbc236b3ff63f878e5fe28427f super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); this.chatVisibility = ChatVisiblity.FULL; diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 4b754f6eae683248d7fe11d6d6cb168d5dd696a2..3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26 100644 +index c0c14766adaac855112f85a203a6163b8adfdded..0dbe182fbae5ce5ba182176eb5d5e3f1897e77f2 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -270,7 +270,7 @@ public abstract class PlayerList { +@@ -271,7 +271,7 @@ public abstract class PlayerList { boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); // Spigot - view distance @@ -2072,7 +2072,7 @@ index 4b754f6eae683248d7fe11d6d6cb168d5dd696a2..3c9d08c37a44a60bc70387d8d0dbd0a3 player.getBukkitEntity().sendSupportedChannels(); // CraftBukkit playerconnection.send(new ClientboundUpdateEnabledFeaturesPacket(FeatureFlags.REGISTRY.toNames(worldserver1.enabledFeatures()))); playerconnection.send(new ClientboundCustomPayloadPacket(ClientboundCustomPayloadPacket.BRAND, (new FriendlyByteBuf(Unpooled.buffer())).writeUtf(this.getServer().getServerModName()))); -@@ -898,8 +898,8 @@ public abstract class PlayerList { +@@ -905,8 +905,8 @@ public abstract class PlayerList { // CraftBukkit start LevelData worlddata = worldserver1.getLevelData(); entityplayer1.connection.send(new ClientboundRespawnPacket(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), (byte) i, entityplayer1.getLastDeathLocation())); @@ -2084,10 +2084,10 @@ index 4b754f6eae683248d7fe11d6d6cb168d5dd696a2..3c9d08c37a44a60bc70387d8d0dbd0a3 entityplayer1.unsetRemoved(); entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot())); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 3cbf801b2e5420c0e870f73788deb550e49ad54d..60003ff929f7ac6b34f9230c53ccbd54dc9e176b 100644 +index 973ecd50f9cb6b86c353586e84d15dcb118ccb60..944da18bcc993ab0488a34cbbe9df134c355301a 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -627,7 +627,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -635,7 +635,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i); // Paper start - per player view distance - allow block updates for non-ticking chunks in player view distance // if copied from above @@ -2097,7 +2097,7 @@ index 3cbf801b2e5420c0e870f73788deb550e49ad54d..60003ff929f7ac6b34f9230c53ccbd54 // Paper end - per player view distance } 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 28e4b302284f955a73e75d0f4276d55fb51826f5..e776eb8afef978938da084f9ae29d611181b43fe 100644 +index 206dc04086a218b510930739a6c573f2653ab0fa..9599af33c683ec47e28b1c8e4dc965d30d9081a7 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -184,43 +184,6 @@ public class LevelChunk extends ChunkAccess { @@ -2152,7 +2152,7 @@ index 28e4b302284f955a73e75d0f4276d55fb51826f5..e776eb8afef978938da084f9ae29d611 if (server != null) { /* * If it's a new world, the first few chunks are generated inside -@@ -1074,6 +1036,7 @@ public class LevelChunk extends ChunkAccess { +@@ -1086,6 +1048,7 @@ public class LevelChunk extends ChunkAccess { BlockState iblockdata1 = Block.updateFromNeighbourShapes(iblockdata, this.level, blockposition); this.level.setBlock(blockposition, iblockdata1, 20); @@ -2160,7 +2160,7 @@ index 28e4b302284f955a73e75d0f4276d55fb51826f5..e776eb8afef978938da084f9ae29d611 } } -@@ -1093,7 +1056,6 @@ public class LevelChunk extends ChunkAccess { +@@ -1105,7 +1068,6 @@ public class LevelChunk extends ChunkAccess { this.upgradeData.upgrade(this); } finally { // Paper start - replace chunk loader system this.isPostProcessingDone = true; @@ -2169,10 +2169,10 @@ index 28e4b302284f955a73e75d0f4276d55fb51826f5..e776eb8afef978938da084f9ae29d611 // Paper end - replace chunk loader system } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 4cb0307935aa63d44aac55c80ee50be074d7913c..d33476ffa49d7f6388bb227f8a57cf115a74698f 100644 +index 5e9055fdf411029ea2fed91acd6b981f79156418..ff6559bf563f2fdcc0f2843d4f4aa24d7ddfb6db 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -2257,12 +2257,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2273,12 +2273,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Spigot start @Override public int getViewDistance() { @@ -2187,7 +2187,7 @@ index 4cb0307935aa63d44aac55c80ee50be074d7913c..d33476ffa49d7f6388bb227f8a57cf11 } // Spigot end // Paper start - view distance api -@@ -2296,12 +2296,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2312,12 +2312,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getSendViewDistance() { @@ -2203,10 +2203,10 @@ index 4cb0307935aa63d44aac55c80ee50be074d7913c..d33476ffa49d7f6388bb227f8a57cf11 // Paper end - view distance api diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 7c43de6ad6bd7259c6bcb2a55e312e8abfcf546b..0351eb67bac6ce257f820af60aa3bba9f45da687 100644 +index 1bada55af5d16437da4d16f9ded55f88a6121eb4..100f057f98b2f15972afe32fade22a7a320cf300 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -188,44 +188,22 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -189,44 +189,22 @@ public class CraftPlayer extends CraftHumanEntity implements Player { // Paper start - implement view distances @Override public int getViewDistance() { @@ -2255,7 +2255,7 @@ index 7c43de6ad6bd7259c6bcb2a55e312e8abfcf546b..0351eb67bac6ce257f820af60aa3bba9 } @Override -@@ -240,23 +218,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -241,23 +219,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public int getSendViewDistance() { diff --git a/patches/server/0003-Make-ChunkStatus.EMPTY-not-rely-on-the-main-thread-f.patch b/patches/server/0003-Make-ChunkStatus.EMPTY-not-rely-on-the-main-thread-f.patch index 0238da0..1456459 100644 --- a/patches/server/0003-Make-ChunkStatus.EMPTY-not-rely-on-the-main-thread-f.patch +++ b/patches/server/0003-Make-ChunkStatus.EMPTY-not-rely-on-the-main-thread-f.patch @@ -70,7 +70,7 @@ index fb42d776f15f735fb59e972e00e2b512c23a8387..300700477ee34bc22b31315825c0e40f chunk = wrappedFull.getWrapped(); } else { diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java -index 3df793f7e6bb67f40e7387a72fdafb912a7b1373..31657c387156f789d5c04ad3413d049bc32f1359 100644 +index be6f3f6a57668a9bd50d0ea5f2dd2335355b69d6..d52f68d0302d581b9bbe30fe0680fb8108e3da85 100644 --- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java +++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java @@ -25,6 +25,7 @@ import org.slf4j.Logger; @@ -330,7 +330,7 @@ index 8950b220b9a3512cd4667beb7bdec0e82e07edc6..9be85eb0abec02bc0e0eded71c34ab1c public void checkConsistencyWithBlocks(ChunkPos chunkPos, LevelChunkSection chunkSection) { 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 d4c4d37bcef14e392739d9aae9e20b7d69b05c12..256642f2e2aa66f7e8c00cae91a75060a8817c9c 100644 +index 0ec80b83a99bfdb1f985045d98a81905a8a5a3ac..9d6f4749ed72fe319754ccea28f20fa97286527d 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 @@ -122,13 +122,11 @@ public class ChunkSerializer { diff --git a/patches/server/0004-Threaded-Regions.patch b/patches/server/0004-Threaded-Regions.patch index f28079f..9e9810c 100644 --- a/patches/server/0004-Threaded-Regions.patch +++ b/patches/server/0004-Threaded-Regions.patch @@ -1744,7 +1744,7 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..897cb94abf7b53da8ba7cda5135b6580 metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> { Map> map = new HashMap<>(); diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java -index 4f3670b2bdb8b1b252e9f074a6af56a018a8c465..5c1ea572a97b130c3ff77624189b4acf3e9e9ece 100644 +index cab91880a08c6fdc545804911d295e0f24f4d983..8f2bff24256f0946f38e1d8b0ae9c8c921b0a2db 100644 --- a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java @@ -179,11 +179,7 @@ public final class ChunkPacketBlockControllerAntiXray extends ChunkPacketBlockCo @@ -1782,10 +1782,10 @@ index 22a2547810d0c029f29685faddf7ac21cde2df0b..30370ad31056437fa3b5bd65357e2e07 // The variable 'k' holds the maximum redstone power value of any adjacent blocks. // If 'k' has the highest level of all neighbors, then the power level of this diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -index 309fe1162db195c7c3c94d785d6aa2700e42b08a..27f8c9b1c56cbf9af400a9ae15c2076a2db8b284 100644 +index 4d9bc4a62ebae0f3707900503576c64733de639f..9ba89a4bf4ae4e42418eca18f9d8a109e6c56a14 100644 --- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -@@ -97,7 +97,7 @@ public final class ChatProcessor { +@@ -98,7 +98,7 @@ public final class ChatProcessor { final CraftPlayer player = this.player.getBukkitEntity(); final AsyncPlayerChatEvent ae = new AsyncPlayerChatEvent(this.async, player, this.craftbukkit$originalMessage, new LazyPlayerSet(this.server)); this.post(ae); @@ -1794,7 +1794,7 @@ index 309fe1162db195c7c3c94d785d6aa2700e42b08a..27f8c9b1c56cbf9af400a9ae15c2076a final PlayerChatEvent se = new PlayerChatEvent(player, ae.getMessage(), ae.getFormat(), ae.getRecipients()); se.setCancelled(ae.isCancelled()); // propagate cancelled state this.queueIfAsyncOrRunImmediately(new Waitable() { -@@ -177,7 +177,7 @@ public final class ChatProcessor { +@@ -178,7 +178,7 @@ public final class ChatProcessor { ae.setCancelled(cancelled); // propagate cancelled state this.post(ae); final boolean listenersOnSyncEvent = canYouHearMe(ChatEvent.getHandlerList()); @@ -3204,10 +3204,10 @@ index 8013dd333e27aa5fd0beb431fa32491eec9f5246..3b70ccd8e0b1ada943f57faf99c23b29 return true; diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java -index 92154550b41b2e1d03deb1271b71bb3baa735e0a..bc97ad0ae019edb52e189e44d0d698973c8792a0 100644 +index 7ba60b4b4f29a42c58d98aafc5ea0fa3214f554c..dc1820e1231c15a7244883731a86f04fa8d20aa1 100644 --- a/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java -@@ -50,7 +50,7 @@ public final class PaperCommand extends Command { +@@ -43,7 +43,7 @@ public final class PaperCommand extends Command { commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand()); commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand()); commands.put(Set.of("dumpitem"), new DumpItemCommand()); @@ -3217,7 +3217,7 @@ index 92154550b41b2e1d03deb1271b71bb3baa735e0a..bc97ad0ae019edb52e189e44d0d69897 return commands.entrySet().stream() diff --git a/src/main/java/io/papermc/paper/command/PaperCommands.java b/src/main/java/io/papermc/paper/command/PaperCommands.java -index d31b5ed47cffc61c90c926a0cd2005b72ebddfc5..0bc4ba2b8718d399223fdf10b970c0fcf4cf28b7 100644 +index bbb8b1933ef33a3b91f69545f69dd3cfb84b27f5..b23b76a598731da8feef53c370b341233afdbea7 100644 --- a/src/main/java/io/papermc/paper/command/PaperCommands.java +++ b/src/main/java/io/papermc/paper/command/PaperCommands.java @@ -17,7 +17,7 @@ public final class PaperCommands { @@ -3346,7 +3346,7 @@ index 9f5f0d8ddc8f480b48079c70e38c9c08eff403f6..3b83f25a24d6f9cdbf131d5a4432fb4a public class ChunkLoadingBasic extends ConfigurationPart { diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java -index 4532f3a0d74feae0a1249b53e1bfbc18a8808b32..f06681b3e66234b8805e6aa2d26fd535fbdb0aff 100644 +index 51cf0014c4229fc8671804d885b6381996810130..ee7b26d80ad3b4f76196492b9ffc11b33f15b9ad 100644 --- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java @@ -128,7 +128,7 @@ public class WorldConfiguration extends ConfigurationPart { @@ -3968,10 +3968,10 @@ index 0000000000000000000000000000000000000000..3549e5f3359f38b207e189d895954420 +} diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionisedServer.java b/src/main/java/io/papermc/paper/threadedregions/RegionisedServer.java new file mode 100644 -index 0000000000000000000000000000000000000000..796421515e3c41e3ff86c5fda844771909114f36 +index 0000000000000000000000000000000000000000..b40d3834fbaa032fb5ee3a9423e1b4a7d3123c29 --- /dev/null +++ b/src/main/java/io/papermc/paper/threadedregions/RegionisedServer.java -@@ -0,0 +1,375 @@ +@@ -0,0 +1,352 @@ +package io.papermc.paper.threadedregions; + +import ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue; @@ -4196,39 +4196,16 @@ index 0000000000000000000000000000000000000000..796421515e3c41e3ff86c5fda8447719 + + private void tickPlayerSample() { + final MinecraftServer mcServer = MinecraftServer.getServer(); -+ final ServerStatus status = mcServer.getStatus(); -+ final PlayerList playerList = mcServer.getPlayerList(); + -+ final long i = System.nanoTime(); ++ final long currtime = System.nanoTime(); + + // player ping sample + // copied from MinecraftServer#tickServer + // note: we need to reorder setPlayers to be the last operation it does, rather than the first to avoid publishing + // an uncomplete status -+ if (i - this.lastServerStatus >= 5000000000L) { -+ this.lastServerStatus = i; -+ List players = new ArrayList<>(playerList.players); -+ ServerStatus.Players newPlayers = new ServerStatus.Players(mcServer.getMaxPlayers(), players.size()); -+ -+ if (!mcServer.hidesOnlinePlayers()) { -+ GameProfile[] agameprofile = new GameProfile[Math.min(players.size(), org.spigotmc.SpigotConfig.playerSample)]; // Paper -+ int j = Mth.nextInt(new LegacyRandomSource(i), 0, players.size() - agameprofile.length); -+ -+ for (int k = 0; k < agameprofile.length; ++k) { -+ ServerPlayer entityplayer = (ServerPlayer) players.get(j + k); -+ -+ if (entityplayer.allowsListing()) { -+ agameprofile[k] = entityplayer.getGameProfile(); -+ } else { -+ agameprofile[k] = MinecraftServer.ANONYMOUS_PLAYER_PROFILE; -+ } -+ } -+ -+ Collections.shuffle(Arrays.asList(agameprofile)); -+ newPlayers.setSample(agameprofile); -+ } -+ // TODO make players field volatile -+ status.setPlayers(newPlayers); ++ if (currtime - this.lastServerStatus >= 5000000000L) { ++ this.lastServerStatus = currtime; ++ mcServer.rebuildServerStatus(); + } + } + @@ -10338,10 +10315,10 @@ 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 6898c704e60d89d53c8ed114e5e12f73ed63605a..594ada3cdec25784c7bd6abb9ad42d3f1e2bd733 100644 +index c856a9a0d085b278da416c59996fc131811f790c..915cbf8c02c4bba0c62e5589229ee27e30535c07 100644 --- a/src/main/java/io/papermc/paper/util/MCUtil.java +++ b/src/main/java/io/papermc/paper/util/MCUtil.java -@@ -28,6 +28,7 @@ import net.minecraft.world.level.ClipContext; +@@ -29,6 +29,7 @@ import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkStatus; @@ -10349,7 +10326,7 @@ index 6898c704e60d89d53c8ed114e5e12f73ed63605a..594ada3cdec25784c7bd6abb9ad42d3f import org.apache.commons.lang.exception.ExceptionUtils; import com.mojang.authlib.GameProfile; import org.bukkit.Location; -@@ -332,6 +333,7 @@ public final class MCUtil { +@@ -333,6 +334,7 @@ public final class MCUtil { */ public static void ensureMain(String reason, Runnable run) { if (!isMainThread()) { @@ -10357,7 +10334,7 @@ index 6898c704e60d89d53c8ed114e5e12f73ed63605a..594ada3cdec25784c7bd6abb9ad42d3f if (reason != null) { MinecraftServer.LOGGER.warn("Asynchronous " + reason + "!", new IllegalStateException()); } -@@ -472,6 +474,30 @@ public final class MCUtil { +@@ -473,6 +475,30 @@ public final class MCUtil { return new Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()); } @@ -10832,7 +10809,7 @@ index 0000000000000000000000000000000000000000..cf9b66afc1762dbe2c625f09f9e804ca + } +} diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java -index ae5dd08de75a7ed231295f306fd0974da3988249..0674c69e7180c482bcace9797af877e09263e88b 100644 +index 7b6b51392b123d34382233adcf4c3d4867bdaa32..c6a28a1ff59a352b647f5f6c1e04f62349e2e428 100644 --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java @@ -66,7 +66,7 @@ public class CommandSourceStack implements SharedSuggestionProvider, com.destroy @@ -10845,10 +10822,10 @@ index ae5dd08de75a7ed231295f306fd0974da3988249..0674c69e7180c482bcace9797af877e0 protected CommandSourceStack(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, int level, String name, Component displayName, MinecraftServer server, @Nullable Entity entity, boolean silent, @Nullable ResultConsumer consumer, EntityAnchorArgument.Anchor entityAnchor, CommandSigningContext signedArguments, TaskChainer messageChainTaskQueue) { diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 330f6c79417378da855326b4da665f9d240e748d..22f06033a731c3ba1b815842be7a9d575fa820f2 100644 +index 87cc7562e4a166d078fe11b7f6980497fc0bd33e..2ad80b9afdebfd40a8ed542480b60dc4eed758f7 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -139,12 +139,12 @@ public class Commands { +@@ -143,13 +143,13 @@ public class Commands { AdvancementCommands.register(this.dispatcher); AttributeCommand.register(this.dispatcher, commandRegistryAccess); ExecuteCommand.register(this.dispatcher, commandRegistryAccess); @@ -10856,17 +10833,18 @@ index 330f6c79417378da855326b4da665f9d240e748d..22f06033a731c3ba1b815842be7a9d57 + //BossBarCommands.register(this.dispatcher); // Folia - region threading - TODO ClearInventoryCommands.register(this.dispatcher, commandRegistryAccess); - CloneCommands.register(this.dispatcher, commandRegistryAccess); ++ //CloneCommands.register(this.dispatcher, commandRegistryAccess); // Folia - region threading - TODO + DamageCommand.register(this.dispatcher, commandRegistryAccess); - DataCommands.register(this.dispatcher); - DataPackCommand.register(this.dispatcher); - DebugCommand.register(this.dispatcher); -+ //CloneCommands.register(this.dispatcher, commandRegistryAccess); // Folia - region threading - TODO + //DataCommands.register(this.dispatcher); // Folia - region threading - TODO + //DataPackCommand.register(this.dispatcher); // Folia - region threading - TODO + //DebugCommand.register(this.dispatcher); // Folia - region threading - TODO DefaultGameModeCommands.register(this.dispatcher); DifficultyCommand.register(this.dispatcher); EffectCommands.register(this.dispatcher, commandRegistryAccess); -@@ -154,44 +154,44 @@ public class Commands { +@@ -159,45 +159,45 @@ public class Commands { FillCommand.register(this.dispatcher, commandRegistryAccess); FillBiomeCommand.register(this.dispatcher, commandRegistryAccess); ForceLoadCommand.register(this.dispatcher); @@ -10891,6 +10869,7 @@ index 330f6c79417378da855326b4da665f9d240e748d..22f06033a731c3ba1b815842be7a9d57 - ReloadCommand.register(this.dispatcher); + //ReloadCommand.register(this.dispatcher); // Folia - region threading RecipeCommand.register(this.dispatcher); + RideCommand.register(this.dispatcher); SayCommand.register(this.dispatcher); - ScheduleCommand.register(this.dispatcher); - ScoreboardCommand.register(this.dispatcher); @@ -10924,7 +10903,7 @@ index 330f6c79417378da855326b4da665f9d240e748d..22f06033a731c3ba1b815842be7a9d57 if (JvmProfiler.INSTANCE.isAvailable()) { JfrCommand.register(this.dispatcher); } -@@ -208,8 +208,8 @@ public class Commands { +@@ -215,8 +215,8 @@ public class Commands { OpCommand.register(this.dispatcher); PardonCommand.register(this.dispatcher); PardonIpCommand.register(this.dispatcher); @@ -10935,7 +10914,7 @@ index 330f6c79417378da855326b4da665f9d240e748d..22f06033a731c3ba1b815842be7a9d57 SaveOffCommand.register(this.dispatcher); SaveOnCommand.register(this.dispatcher); SetPlayerIdleTimeoutCommand.register(this.dispatcher); -@@ -417,9 +417,12 @@ public class Commands { +@@ -446,9 +446,12 @@ public class Commands { } // Paper start - Async command map building new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper @@ -10991,10 +10970,10 @@ index 1e6ba6d9cceda1d4867b183c3dbc03d317ed287f..de8cf0f0d34708b960f1c81cb10d813a } diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bcf0672dc9 100644 +index 9598aa381978194fee859721731196f0e6ee08fc..6977cdee91cc0c0635adce66d9d9ebf94bb5aa94 100644 --- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -221,7 +221,7 @@ public interface DispenseItemBehavior { +@@ -222,7 +222,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -11003,7 +10982,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -276,7 +276,7 @@ public interface DispenseItemBehavior { +@@ -277,7 +277,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -11012,7 +10991,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -329,7 +329,7 @@ public interface DispenseItemBehavior { +@@ -333,7 +333,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()); @@ -11021,7 +11000,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc world.getCraftServer().getPluginManager().callEvent(event); } -@@ -385,7 +385,7 @@ public interface DispenseItemBehavior { +@@ -389,7 +389,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorseabstract.getBukkitEntity()); @@ -11030,7 +11009,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc world.getCraftServer().getPluginManager().callEvent(event); } -@@ -459,7 +459,7 @@ public interface DispenseItemBehavior { +@@ -463,7 +463,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorsechestedabstract.getBukkitEntity()); @@ -11039,7 +11018,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc world.getCraftServer().getPluginManager().callEvent(event); } -@@ -498,7 +498,7 @@ public interface DispenseItemBehavior { +@@ -502,7 +502,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())); @@ -11048,7 +11027,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -556,7 +556,7 @@ public interface DispenseItemBehavior { +@@ -560,7 +560,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5)); @@ -11057,7 +11036,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -628,7 +628,7 @@ public interface DispenseItemBehavior { +@@ -634,7 +634,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)); @@ -11066,7 +11045,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -701,7 +701,7 @@ public interface DispenseItemBehavior { +@@ -707,7 +707,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())); @@ -11075,7 +11054,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -748,7 +748,7 @@ public interface DispenseItemBehavior { +@@ -754,7 +754,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)); @@ -11084,7 +11063,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -809,7 +809,7 @@ public interface DispenseItemBehavior { +@@ -815,7 +815,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)); @@ -11093,7 +11072,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -827,7 +827,8 @@ public interface DispenseItemBehavior { +@@ -833,7 +833,8 @@ public interface DispenseItemBehavior { } } @@ -11103,7 +11082,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc // CraftBukkit end if (!BoneMealItem.growCrop(stack, worldserver, blockposition) && !BoneMealItem.growWaterPlant(stack, worldserver, blockposition, (Direction) null)) { -@@ -836,13 +837,13 @@ public interface DispenseItemBehavior { +@@ -842,13 +843,13 @@ public interface DispenseItemBehavior { worldserver.levelEvent(1505, blockposition, 0); } // CraftBukkit start @@ -11123,7 +11102,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc StructureGrowEvent structureEvent = null; if (treeType != null) { structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks); -@@ -877,7 +878,7 @@ public interface DispenseItemBehavior { +@@ -883,7 +884,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)); @@ -11132,7 +11111,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -934,7 +935,7 @@ public interface DispenseItemBehavior { +@@ -940,7 +941,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())); @@ -11141,7 +11120,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -983,7 +984,7 @@ public interface DispenseItemBehavior { +@@ -989,7 +990,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())); @@ -11150,7 +11129,7 @@ index 58fa7b99dc7a9745afe6faf31c1804e95ed27dbe..979871b342317b5cbc3d71b3147243bc worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -1056,7 +1057,7 @@ public interface DispenseItemBehavior { +@@ -1062,7 +1063,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())); @@ -11186,10 +11165,10 @@ index 0159ed9cbc644c39fa79e62327f13375193fdc98..a930c8eb64d6c7044646d6b0156e202e } diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 38c09c65dfa4a7a0c80d36f726c1fd028cbe05f8..5e74408bbdcc9b434447e3d9cf7523ef122ec03e 100644 +index fa1d325034dafdb9f1da546a6f9c5e88d2b67749..61bcbcacc1718b66f5b93548b1777c536cf3916b 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -73,7 +73,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -75,7 +75,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 }); private final PacketFlow receiving; @@ -11198,7 +11177,7 @@ index 38c09c65dfa4a7a0c80d36f726c1fd028cbe05f8..5e74408bbdcc9b434447e3d9cf7523ef public Channel channel; public SocketAddress address; // Spigot Start -@@ -81,7 +81,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -83,7 +83,7 @@ public class Connection extends SimpleChannelInboundHandler> { public com.mojang.authlib.properties.Property[] spoofedProfile; public boolean preparing = true; // Spigot End @@ -11207,7 +11186,7 @@ index 38c09c65dfa4a7a0c80d36f726c1fd028cbe05f8..5e74408bbdcc9b434447e3d9cf7523ef private Component disconnectedReason; private boolean encrypted; private boolean disconnectionHandled; -@@ -177,6 +177,32 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -179,6 +179,32 @@ public class Connection extends SimpleChannelInboundHandler> { this.receiving = side; } @@ -11240,7 +11219,7 @@ index 38c09c65dfa4a7a0c80d36f726c1fd028cbe05f8..5e74408bbdcc9b434447e3d9cf7523ef public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception { super.channelActive(channelhandlercontext); this.channel = channelhandlercontext.channel(); -@@ -191,6 +217,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -193,6 +219,7 @@ public class Connection extends SimpleChannelInboundHandler> { Connection.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to change protocol to handshake", throwable); } @@ -11248,7 +11227,7 @@ index 38c09c65dfa4a7a0c80d36f726c1fd028cbe05f8..5e74408bbdcc9b434447e3d9cf7523ef } public void setProtocol(ConnectionProtocol state) { -@@ -372,13 +399,6 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -375,13 +402,6 @@ public class Connection extends SimpleChannelInboundHandler> { return; // Do nothing } packet.onPacketDispatch(getPlayer()); @@ -11262,7 +11241,7 @@ index 38c09c65dfa4a7a0c80d36f726c1fd028cbe05f8..5e74408bbdcc9b434447e3d9cf7523ef // write the packets to the queue, then flush - antixray hooks there already java.util.List extraPackets = InnerUtil.buildExtraPackets(packet); boolean hasExtraPackets = extraPackets != null && !extraPackets.isEmpty(); -@@ -496,66 +516,58 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -503,66 +523,58 @@ public class Connection extends SimpleChannelInboundHandler> { // Paper start - rewrite this to be safer if ran off main thread private boolean flushQueue() { // void -> boolean @@ -11368,7 +11347,7 @@ index 38c09c65dfa4a7a0c80d36f726c1fd028cbe05f8..5e74408bbdcc9b434447e3d9cf7523ef } // Paper end -@@ -564,21 +576,41 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -571,21 +583,41 @@ public class Connection extends SimpleChannelInboundHandler> { private static int currTick; // Paper public void tick() { this.flushQueue(); @@ -11418,7 +11397,7 @@ index 38c09c65dfa4a7a0c80d36f726c1fd028cbe05f8..5e74408bbdcc9b434447e3d9cf7523ef // Paper start - detailed watchdog information net.minecraft.network.protocol.PacketUtils.packetProcessing.push(this.packetListener); try { // Paper end - detailed watchdog information -@@ -618,13 +650,21 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -625,13 +657,21 @@ public class Connection extends SimpleChannelInboundHandler> { // Paper start public void clearPacketQueue() { net.minecraft.server.level.ServerPlayer player = getPlayer(); @@ -11443,7 +11422,7 @@ index 38c09c65dfa4a7a0c80d36f726c1fd028cbe05f8..5e74408bbdcc9b434447e3d9cf7523ef } // Paper end public void disconnect(Component disconnectReason) { -@@ -636,6 +676,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -643,6 +683,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; } @@ -11451,7 +11430,7 @@ index 38c09c65dfa4a7a0c80d36f726c1fd028cbe05f8..5e74408bbdcc9b434447e3d9cf7523ef } -@@ -784,13 +825,27 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -802,13 +843,27 @@ public class Connection extends SimpleChannelInboundHandler> { final net.minecraft.server.network.ServerGamePacketListenerImpl playerConnection = (net.minecraft.server.network.ServerGamePacketListenerImpl) packetListener; new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(playerConnection.player.getUUID(), playerConnection.player.getScoreboardName(), ((java.net.InetSocketAddress)address).getAddress(), false).callEvent(); @@ -11484,7 +11463,7 @@ index 38c09c65dfa4a7a0c80d36f726c1fd028cbe05f8..5e74408bbdcc9b434447e3d9cf7523ef new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(profile.getId(), profile.getName(), ((java.net.InetSocketAddress)address).getAddress(), false).callEvent(); diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -index 27d4aa45e585842c04491839826d405d6f447f0e..e6ef0691588fbb33d47692db4269c56557814c9b 100644 +index d2f0a0755317f5fa9a1ccf7db346aa77fd287d80..b07df826a3028c14b48b09dbaeccc9078d7cc992 100644 --- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java +++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java @@ -2,6 +2,7 @@ package net.minecraft.network.protocol; @@ -11504,7 +11483,7 @@ index 27d4aa45e585842c04491839826d405d6f447f0e..e6ef0691588fbb33d47692db4269c565 packetProcessing.push(listener); // Paper - detailed watchdog information try { // Paper - detailed watchdog information if (MinecraftServer.getServer().hasStopped() || (listener instanceof ServerGamePacketListenerImpl && ((ServerGamePacketListenerImpl) listener).processedDisconnect)) return; // CraftBukkit, MC-142590 -@@ -71,7 +72,17 @@ public class PacketUtils { +@@ -66,7 +67,17 @@ public class PacketUtils { } // Paper end - detailed watchdog information @@ -11524,10 +11503,10 @@ index 27d4aa45e585842c04491839826d405d6f447f0e..e6ef0691588fbb33d47692db4269c565 // CraftBukkit start - SPIGOT-5477, MC-142590 } else if (MinecraftServer.getServer().hasStopped() || (listener instanceof ServerGamePacketListenerImpl && ((ServerGamePacketListenerImpl) listener).processedDisconnect)) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 2ee4e5e8d17a3a1e6a342c74b13135df030ffef6..fb2f7cde13ef96334a42448798a4902e8c1e06a3 100644 +index 8ccc92836bfda8e00eea649430174dcd5664af70..58eee2965ce3e92b0f90eb7e908c6eee40052670 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -291,7 +291,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); public int autosavePeriod; public Commands vanillaCommandDispatcher; -@@ -304,12 +304,40 @@ 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 -@@ -602,7 +630,21 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop= 5000000000L) { // Folia - region threading - moved to global tick this.lastServerStatus = i; - this.status.setPlayers(new ServerStatus.Players(this.getMaxPlayers(), this.getPlayerCount())); - if (!this.hidesOnlinePlayers()) { -@@ -1429,9 +1574,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { this.playerList.saveAll(playerSaveInterval); } @@ -11879,7 +11858,7 @@ index 2ee4e5e8d17a3a1e6a342c74b13135df030ffef6..fb2f7cde13ef96334a42448798a4902e } } } finally { -@@ -1441,16 +1586,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop list = this.playerList.getPlayers(); ++ List list = new java.util.ArrayList<>(this.playerList.getPlayers()); // Folia - region threading + int i = this.getMaxPlayers(); + + if (this.hidesOnlinePlayers()) { +@@ -1477,14 +1630,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper -- worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper +- worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper + // Folia - region threading this.profiler.push(() -> { return worldserver + " " + worldserver.dimension().location(); -@@ -1532,7 +1677,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop biome, Predicate> filter) throws CommandSyntaxException { BlockPos blockPos = quantize(from); BlockPos blockPos2 = quantize(to); -@@ -78,29 +84,43 @@ public class FillBiomeCommand { - throw ERROR_VOLUME_TOO_LARGE.create(32768, i); +@@ -79,8 +85,19 @@ public class FillBiomeCommand { + throw ERROR_VOLUME_TOO_LARGE.create(j, i); } else { ServerLevel serverLevel = source.getLevel(); -- List list = new ArrayList<>(); + // Folia start - region threading + int buffer = 0; + // no buffer, we do not touch neighbours @@ -12500,54 +12501,27 @@ index 6c29947dc9259f453782de3c973c1cabb87e3de5..c8e60578f15a358223ed056460d3ea2c + net.minecraft.world.level.chunk.ChunkStatus.FULL, + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, + (chunks) -> { -+ List list = new ArrayList<>(); ++ try { // Folia end - region threading + List list = new ArrayList<>(); +- + for(int k = SectionPos.blockToSectionCoord(boundingBox.minZ()); k <= SectionPos.blockToSectionCoord(boundingBox.maxZ()); ++k) { + for(int l = SectionPos.blockToSectionCoord(boundingBox.minX()); l <= SectionPos.blockToSectionCoord(boundingBox.maxX()); ++l) { + ChunkAccess chunkAccess = serverLevel.getChunk(l, k, ChunkStatus.FULL, false); +@@ -101,7 +118,11 @@ public class FillBiomeCommand { -- for(int j = SectionPos.blockToSectionCoord(boundingBox.minZ()); j <= SectionPos.blockToSectionCoord(boundingBox.maxZ()); ++j) { -- for(int k = SectionPos.blockToSectionCoord(boundingBox.minX()); k <= SectionPos.blockToSectionCoord(boundingBox.maxX()); ++k) { -- ChunkAccess chunkAccess = serverLevel.getChunk(k, j, ChunkStatus.FULL, false); -- if (chunkAccess == null) { -- throw ERROR_NOT_LOADED.create(); -- } -+ for(int j = SectionPos.blockToSectionCoord(boundingBox.minZ()); j <= SectionPos.blockToSectionCoord(boundingBox.maxZ()); ++j) { -+ for(int k = SectionPos.blockToSectionCoord(boundingBox.minX()); k <= SectionPos.blockToSectionCoord(boundingBox.maxX()); ++k) { -+ ChunkAccess chunkAccess = serverLevel.getChunk(k, j, ChunkStatus.FULL, false); -+ if (chunkAccess == null) { -+ sendMessage(source, ERROR_NOT_LOADED.create()); return; -+ } - -- list.add(chunkAccess); -- } -- } -+ list.add(chunkAccess); -+ } -+ } - -- MutableInt mutableInt = new MutableInt(0); -+ MutableInt mutableInt = new MutableInt(0); - -- for(ChunkAccess chunkAccess2 : list) { -- chunkAccess2.fillBiomesFromNoise(makeResolver(mutableInt, chunkAccess2, boundingBox, biome, filter), serverLevel.getChunkSource().randomState().sampler()); -- chunkAccess2.setUnsaved(true); -- serverLevel.getChunkSource().chunkMap.resendChunk(chunkAccess2); -- } -+ for(ChunkAccess chunkAccess2 : list) { -+ chunkAccess2.fillBiomesFromNoise(makeResolver(mutableInt, chunkAccess2, boundingBox, biome, filter), serverLevel.getChunkSource().randomState().sampler()); -+ chunkAccess2.setUnsaved(true); -+ serverLevel.getChunkSource().chunkMap.resendChunk(chunkAccess2); -+ } - -- source.sendSuccess(Component.translatable("commands.fillbiome.success.count", mutableInt.getValue(), boundingBox.minX(), boundingBox.minY(), boundingBox.minZ(), boundingBox.maxX(), boundingBox.maxY(), boundingBox.maxZ()), true); + serverLevel.getChunkSource().chunkMap.resendBiomesForChunks(list); + source.sendSuccess(Component.translatable("commands.fillbiome.success.count", mutableInt.getValue(), boundingBox.minX(), boundingBox.minY(), boundingBox.minZ(), boundingBox.maxX(), boundingBox.maxY(), boundingBox.maxZ()), true); - return mutableInt.getValue(); -+ source.sendSuccess(Component.translatable("commands.fillbiome.success.count", mutableInt.getValue(), boundingBox.minX(), boundingBox.minY(), boundingBox.minZ(), boundingBox.maxX(), boundingBox.maxY(), boundingBox.maxZ()), true); -+ } -+ ); -+ return 0; -+ // Folia end - region threading ++ // Folia start - region threading ++ } catch (CommandSyntaxException ex) { ++ sendMessage(source, ex); ++ } ++ }); return 0; // Folia end - region threading } } } diff --git a/src/main/java/net/minecraft/server/commands/FillCommand.java b/src/main/java/net/minecraft/server/commands/FillCommand.java -index 99fbb24dabe867ed4956a2996543107f58a57193..01360d24522a877bf7c3524f17ec65ef2b514b0c 100644 +index b25b2ed0eb3c6716a7c92cb1f1066a1447d88bcf..3b55e806204cbe2df2cadcec91fbc84eed5f15b0 100644 --- a/src/main/java/net/minecraft/server/commands/FillCommand.java +++ b/src/main/java/net/minecraft/server/commands/FillCommand.java @@ -57,6 +57,12 @@ public class FillCommand { @@ -12562,22 +12536,11 @@ index 99fbb24dabe867ed4956a2996543107f58a57193..01360d24522a877bf7c3524f17ec65ef + private static int fillBlocks(CommandSourceStack source, BoundingBox range, BlockInput block, FillCommand.Mode mode, @Nullable Predicate filter) throws CommandSyntaxException { int i = range.getXSpan() * range.getYSpan() * range.getZSpan(); - if (i > 32768) { -@@ -64,33 +70,50 @@ public class FillCommand { + int j = source.getLevel().getGameRules().getInt(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT); +@@ -65,6 +71,18 @@ public class FillCommand { } else { List list = Lists.newArrayList(); ServerLevel serverLevel = source.getLevel(); -- int j = 0; - -- for(BlockPos blockPos : BlockPos.betweenClosed(range.minX(), range.minY(), range.minZ(), range.maxX(), range.maxY(), range.maxZ())) { -- if (filter == null || filter.test(new BlockInWorld(serverLevel, blockPos, true))) { -- BlockInput blockInput = mode.filter.filter(range, blockPos, block, serverLevel); -- if (blockInput != null) { -- BlockEntity blockEntity = serverLevel.getBlockEntity(blockPos); -- Clearable.tryClear(blockEntity); -- if (blockInput.place(serverLevel, blockPos, 2)) { -- list.add(blockPos.immutable()); -- ++j; + // Folia start - region threading + int buffer = 32; + // physics may spill into neighbour chunks, so use a buffer @@ -12589,50 +12552,22 @@ index 99fbb24dabe867ed4956a2996543107f58a57193..01360d24522a877bf7c3524f17ec65ef + net.minecraft.world.level.chunk.ChunkStatus.FULL, + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.NORMAL, + (chunks) -> { -+ int j = 0; -+ -+ for(BlockPos blockPos : BlockPos.betweenClosed(range.minX(), range.minY(), range.minZ(), range.maxX(), range.maxY(), range.maxZ())) { -+ if (filter == null || filter.test(new BlockInWorld(serverLevel, blockPos, true))) { -+ BlockInput blockInput = mode.filter.filter(range, blockPos, block, serverLevel); -+ if (blockInput != null) { -+ BlockEntity blockEntity = serverLevel.getBlockEntity(blockPos); -+ Clearable.tryClear(blockEntity); -+ if (blockInput.place(serverLevel, blockPos, 2)) { -+ list.add(blockPos.immutable()); -+ ++j; -+ } -+ } - } - } -- } -- } ++ try { // Folia end - region threading + int k = 0; -- for(BlockPos blockPos2 : list) { -- Block block2 = serverLevel.getBlockState(blockPos2).getBlock(); -- serverLevel.blockUpdated(blockPos2, block2); -- } -+ for(BlockPos blockPos2 : list) { -+ Block block2 = serverLevel.getBlockState(blockPos2).getBlock(); -+ serverLevel.blockUpdated(blockPos2, block2); -+ } -+ -+ if (j == 0) { -+ sendMessage(source, ERROR_FAILED.create()); return; // Folia - region threading -+ } else { -+ source.sendSuccess(Component.translatable("commands.fill.success", j), true); -+ return; // Folia - region threading -+ } -+ } -+ ); - -- if (j == 0) { -- throw ERROR_FAILED.create(); -- } else { -- source.sendSuccess(Component.translatable("commands.fill.success", j), true); -- return j; -- } -+ return 0; -+ // Folia end - region threading + for(BlockPos blockPos : BlockPos.betweenClosed(range.minX(), range.minY(), range.minZ(), range.maxX(), range.maxY(), range.maxZ())) { +@@ -90,8 +108,13 @@ public class FillCommand { + throw ERROR_FAILED.create(); + } else { + source.sendSuccess(Component.translatable("commands.fill.success", k), true); +- return k; ++ return; // Folia - region threading + } ++ // Folia start - region threading ++ } catch (CommandSyntaxException ex) { ++ sendMessage(source, ex); ++ } ++ }); return 0; // Folia end - region threading } } @@ -12850,7 +12785,7 @@ index 27c0aaf123c3e945eb24e8a3892bd8ac42115733..2f9f73e75b6c730a9cf327767ba1c34e 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 06e3a868e922f1b7a586d0ca28f64a67ae463b68..8f4a7b6ed27e97c22153dadf837e521a75bb6940 100644 +index ee7d29d85c8b024c9b23cba8ecd4192aa7e8aa7b..9fc4e60750552dae8412ed07982ea025f934af61 100644 --- a/src/main/java/net/minecraft/server/commands/GiveCommand.java +++ b/src/main/java/net/minecraft/server/commands/GiveCommand.java @@ -55,6 +55,7 @@ public class GiveCommand { @@ -12862,7 +12797,7 @@ index 06e3a868e922f1b7a586d0ca28f64a67ae463b68..8f4a7b6ed27e97c22153dadf837e521a ItemEntity entityitem; @@ -74,6 +75,7 @@ public class GiveCommand { - entityitem.setOwner(entityplayer.getUUID()); + entityitem.setTarget(entityplayer.getUUID()); } } + }, null, 1L); // Folia - region threading @@ -12885,7 +12820,7 @@ index a6e4bd9243dab7feaed1bd968108a324d6c37ed7..4637e60292128e8c4053fb3a5fed48e5 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 6835072c6b30ee0b79c43e05526fd6d605bf7139..0a6baec737ef847fc84723176c7f267d3999ad4c 100644 +index c9ee0b8a0f72c21f29448c3a8fd53a7007c740f8..f92a2bd92201264c8d38ef4dd663955188fb5ecc 100644 --- a/src/main/java/net/minecraft/server/commands/PlaceCommand.java +++ b/src/main/java/net/minecraft/server/commands/PlaceCommand.java @@ -83,82 +83,130 @@ public class PlaceCommand { @@ -13174,7 +13109,7 @@ index ad435815e56ca5a8d5ea6046ee4a3ed4d3673a48..2e53969ae222c13a7ef034f96a7014f9 public interface Filter { diff --git a/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java b/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java -index 1e41de9523c5fa3b9cfced798a5c35a24ec9d349..aa2c3d3161d01c87cd88e3311907e6559e81aa4e 100644 +index b0ed00b95b273f0916cbade0e3bac47aa464d3fd..ebabc7919562acc1e43014aa702e65765567175f 100644 --- a/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java +++ b/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java @@ -35,7 +35,12 @@ public class SetSpawnCommand { @@ -13192,7 +13127,7 @@ index 1e41de9523c5fa3b9cfced798a5c35a24ec9d349..aa2c3d3161d01c87cd88e3311907e655 } // Paper end diff --git a/src/main/java/net/minecraft/server/commands/SummonCommand.java b/src/main/java/net/minecraft/server/commands/SummonCommand.java -index ade2626bc63f986a53277378cdc19f5366f9372f..b2081239f13d3a001bbfa467933518ec400baea7 100644 +index 108b8ddbb724c6a2aca97bd7d5b29bea87662e70..4b3e7e744b99b3b2b1cf957f4f5f6051ab20a52b 100644 --- a/src/main/java/net/minecraft/server/commands/SummonCommand.java +++ b/src/main/java/net/minecraft/server/commands/SummonCommand.java @@ -63,11 +63,18 @@ public class SummonCommand { @@ -13217,21 +13152,21 @@ index ade2626bc63f986a53277378cdc19f5366f9372f..b2081239f13d3a001bbfa467933518ec + if (false) { // CraftBukkit - pass a spawn reason of "COMMAND" // Folia - region threading throw SummonCommand.ERROR_DUPLICATE_UUID.create(); } else { - source.sendSuccess(Component.translatable("commands.summon.success", entity.getDisplayName()), true); + 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 027ca5b67c544048815ddef4bb36d0a8fc3d038c..f7981cc27aa62cf0935d6ce027cd73c50b837c04 100644 +index 6511af08d8db1f8fc62bdb4a8f357941f524886d..8dee4f9a408194f2bbbd9028517d33504cbe188d 100644 --- a/src/main/java/net/minecraft/server/commands/TeleportCommand.java +++ b/src/main/java/net/minecraft/server/commands/TeleportCommand.java -@@ -78,7 +78,7 @@ public class TeleportCommand { +@@ -77,7 +77,7 @@ public class TeleportCommand { while (iterator.hasNext()) { Entity entity1 = (Entity) iterator.next(); -- TeleportCommand.performTeleport(source, entity1, (ServerLevel) destination.level, destination.getX(), destination.getY(), destination.getZ(), EnumSet.noneOf(ClientboundPlayerPositionPacket.RelativeArgument.class), destination.getYRot(), destination.getXRot(), (TeleportCommand.LookAt) null); +- TeleportCommand.performTeleport(source, entity1, (ServerLevel) destination.level, destination.getX(), destination.getY(), destination.getZ(), EnumSet.noneOf(RelativeMovement.class), destination.getYRot(), destination.getXRot(), (TeleportCommand.LookAt) null); + io.papermc.paper.threadedregions.TeleportUtils.teleport(entity1, false, destination, Float.valueOf(destination.getYRot()), Float.valueOf(destination.getXRot()), Entity.TELEPORT_FLAG_LOAD_CHUNK, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND, null); // Folia - region threading } if (targets.size() == 1) { -@@ -154,6 +154,24 @@ public class TeleportCommand { +@@ -153,6 +153,24 @@ public class TeleportCommand { float f2 = Mth.wrapDegrees(yaw); float f3 = Mth.wrapDegrees(pitch); @@ -13248,14 +13183,14 @@ index 027ca5b67c544048815ddef4bb36d0a8fc3d038c..f7981cc27aa62cf0935d6ce027cd73c5 + org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND, + Entity.TELEPORT_FLAG_LOAD_CHUNK, + null -+ ); ++ ); + }, null, 1L); + return; + } + // Folia end - region threading - if (target instanceof ServerPlayer) { - ChunkPos chunkcoordintpair = new ChunkPos(new BlockPos(x, y, z)); - + // CraftBukkit start - Teleport event + boolean result; + if (target instanceof ServerPlayer player) { diff --git a/src/main/java/net/minecraft/server/commands/TimeCommand.java b/src/main/java/net/minecraft/server/commands/TimeCommand.java index f0a7a8df3caa2ea765bb0a87cfede71d0995d276..00f63992885c16ea01384fc00e1325f389cc1a0f 100644 --- a/src/main/java/net/minecraft/server/commands/TimeCommand.java @@ -13301,15 +13236,15 @@ index f0a7a8df3caa2ea765bb0a87cfede71d0995d276..00f63992885c16ea01384fc00e1325f3 } } diff --git a/src/main/java/net/minecraft/server/commands/WeatherCommand.java b/src/main/java/net/minecraft/server/commands/WeatherCommand.java -index 71fd7887a4fa174d3f74c4bbe24497b156cbd3c8..b8e1054cd5c906fd425fe5987c10db963cb32c62 100644 +index 471e9a2d8ad92c8f45856487a2919e4113ed4468..d2a8f27a2f169d0df81e4959ca103c1401b4231d 100644 --- a/src/main/java/net/minecraft/server/commands/WeatherCommand.java +++ b/src/main/java/net/minecraft/server/commands/WeatherCommand.java -@@ -28,20 +28,26 @@ public class WeatherCommand { +@@ -35,20 +35,26 @@ public class WeatherCommand { } private static int setClear(CommandSourceStack source, int duration) { + io.papermc.paper.threadedregions.RegionisedServer.getInstance().addTask(() -> { // Folia - region threading - source.getLevel().setWeatherParameters(duration, 0, false, false); + source.getLevel().setWeatherParameters(getDuration(source, duration, ServerLevel.RAIN_DELAY), 0, false, false); source.sendSuccess(Component.translatable("commands.weather.set.clear"), true); + }); // Folia - region threading return duration; @@ -13317,7 +13252,7 @@ index 71fd7887a4fa174d3f74c4bbe24497b156cbd3c8..b8e1054cd5c906fd425fe5987c10db96 private static int setRain(CommandSourceStack source, int duration) { + io.papermc.paper.threadedregions.RegionisedServer.getInstance().addTask(() -> { // Folia - region threading - source.getLevel().setWeatherParameters(0, duration, true, false); + source.getLevel().setWeatherParameters(0, getDuration(source, duration, ServerLevel.RAIN_DURATION), true, false); source.sendSuccess(Component.translatable("commands.weather.set.rain"), true); + }); // Folia - region threading return duration; @@ -13325,17 +13260,17 @@ index 71fd7887a4fa174d3f74c4bbe24497b156cbd3c8..b8e1054cd5c906fd425fe5987c10db96 private static int setThunder(CommandSourceStack source, int duration) { + io.papermc.paper.threadedregions.RegionisedServer.getInstance().addTask(() -> { // Folia - region threading - source.getLevel().setWeatherParameters(0, duration, true, true); + source.getLevel().setWeatherParameters(0, getDuration(source, duration, ServerLevel.THUNDER_DURATION), true, true); source.sendSuccess(Component.translatable("commands.weather.set.thunder"), true); + }); // Folia - region threading return duration; } } diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 51b3db0b6c2cede95b584268e035c0fb36d38094..48718c37e96821576f0d6bf0e510cd5806a23d4c 100644 +index a7e133f3495e9132a5fdae2c24f225e7b026295a..7abd4f38ae59a6019137345af960fd60a3c7adf0 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -436,9 +436,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -443,9 +443,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } @Override @@ -13348,7 +13283,7 @@ index 51b3db0b6c2cede95b584268e035c0fb36d38094..48718c37e96821576f0d6bf0e510cd58 } @Override -@@ -741,6 +741,12 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -748,6 +748,12 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @Override public String runCommand(String command) { @@ -13362,7 +13297,7 @@ index 51b3db0b6c2cede95b584268e035c0fb36d38094..48718c37e96821576f0d6bf0e510cd58 this.rconConsoleSource.prepareForCommand(); this.executeBlocking(() -> { diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java -index 0b9cb85c063f913ad9245bafb8587d2f06c0ac6e..179e142e7012eebbe636f65804f5ac6b8fb72abe 100644 +index 6fce2a9bce051e21eba8f331007a9752607f69f2..f899ba0580418895f534b8751e31a36915499a7c 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -85,18 +85,18 @@ public class ChunkHolder { @@ -13414,10 +13349,10 @@ index 0b9cb85c063f913ad9245bafb8587d2f06c0ac6e..179e142e7012eebbe636f65804f5ac6b // 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 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d7e634a80 100644 +index 2d133ae656f7420d6ceec14bc591721cff815479..6f12d91f73e04c25fb0bc9054dc7d49de16e614a 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -146,21 +146,21 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -149,21 +149,21 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider private final AtomicInteger tickingGenerated; public final StructureTemplateManager structureTemplateManager; // Paper - rewrite chunk system private final String storageName; @@ -13444,7 +13379,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d // Paper end - optimise checkDespawn // Paper start - distance maps -@@ -174,8 +174,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -177,8 +177,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // obviously this means a spawn range > 8 cannot be implemented // these maps are named after spigot's uses @@ -13455,7 +13390,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d // Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning // Paper start - use distance map to optimise tracker public static boolean isLegacyTrackingEntity(Entity entity) { -@@ -184,11 +184,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -187,11 +187,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // inlined EnumMap, TrackingRange.TrackingRangeType static final org.spigotmc.TrackingRange.TrackingRangeType[] TRACKING_RANGE_TYPES = org.spigotmc.TrackingRange.TrackingRangeType.values(); @@ -13468,7 +13403,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d private int convertSpigotRangeToVanilla(final int vanilla) { return MinecraftServer.getServer().getScaledTrackingDistance(vanilla); -@@ -200,40 +196,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -203,40 +199,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider int chunkX = MCUtil.getChunkCoordinate(player.getX()); int chunkZ = MCUtil.getChunkCoordinate(player.getZ()); // Note: players need to be explicitly added to distance maps before they can be updated @@ -13518,7 +13453,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d // Paper end - use distance map to optimise tracker } -@@ -242,21 +227,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -245,21 +230,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider int chunkZ = MCUtil.getChunkCoordinate(player.getZ()); // Note: players need to be explicitly added to distance maps before they can be updated this.level.playerChunkLoader.updatePlayer(player); // Paper - replace chunk loader @@ -13544,7 +13479,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d } // Paper end // Paper start -@@ -294,8 +272,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -297,8 +275,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync); // Paper - rewrite chunk system this.tickingGenerated = new AtomicInteger(); @@ -13555,7 +13490,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d this.chunkTypeCache = new Long2ByteOpenHashMap(); this.chunkSaveCooldowns = new Long2LongOpenHashMap(); this.unloadQueue = Queues.newConcurrentLinkedQueue(); -@@ -340,96 +318,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -343,96 +321,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.setViewDistance(viewDistance); // Paper start this.dataRegionManager = new io.papermc.paper.chunk.SingleThreadChunkRegionManager(this.level, 2, (1.0 / 3.0), 1, 6, "Data", DataRegionData::new, DataRegionSectionData::new); @@ -13658,7 +13593,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d // Paper end - optimise checkDespawn } -@@ -457,28 +357,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -460,28 +360,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } // Paper start @@ -13688,7 +13623,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d // Paper end private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) { -@@ -747,6 +626,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -750,6 +629,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper start // rets true if to prevent the entity from being added public static boolean checkDupeUUID(ServerLevel level, Entity entity) { @@ -13701,7 +13636,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d 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 -@@ -1007,6 +892,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1010,6 +895,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } final boolean anyPlayerCloseEnoughForSpawning(ChunkHolder playerchunk, ChunkPos chunkcoordintpair, boolean reducedRange) { @@ -13740,7 +13675,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d // this function is so hot that removing the map lookup call can have an order of magnitude impact on its performance // tested and confirmed via System.nanoTime() com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet playersInRange = reducedRange ? playerchunk.playersInMobSpawnRange : playerchunk.playersInChunkTickRange; -@@ -1052,7 +969,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1055,7 +972,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return List.of(); } else { Builder builder = ImmutableList.builder(); @@ -13749,7 +13684,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d while (iterator.hasNext()) { ServerPlayer entityplayer = (ServerPlayer) iterator.next(); -@@ -1081,25 +998,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1084,25 +1001,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } void updatePlayerStatus(ServerPlayer player, boolean added) { @@ -13780,7 +13715,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d this.removePlayerFromDistanceMaps(player); // Paper - distance maps } -@@ -1118,43 +1028,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1121,43 +1031,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public void move(ServerPlayer player) { // Paper - delay this logic for the entity tracker tick, no need to duplicate it @@ -13825,7 +13760,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d // Paper - replaced by PlayerChunkLoader -@@ -1177,9 +1051,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1180,9 +1054,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 @@ -13837,7 +13772,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d return; } if (entity instanceof ServerPlayer && ((ServerPlayer) entity).supressTrackerForLogin) return; // Delay adding to tracker until after list packets -@@ -1192,27 +1066,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1195,27 +1069,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (i != 0) { int j = entitytypes.updateInterval(); @@ -13873,7 +13808,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d } } -@@ -1226,16 +1098,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1229,16 +1101,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider ServerPlayer entityplayer = (ServerPlayer) entity; this.updatePlayerStatus(entityplayer, false); @@ -13897,7 +13832,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d if (playerchunkmap_entitytracker1 != null) { playerchunkmap_entitytracker1.broadcastRemoved(); -@@ -1245,25 +1117,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1248,25 +1120,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper start - optimised tracker private final void processTrackQueue() { @@ -13933,7 +13868,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d } // Paper end - optimised tracker -@@ -1274,51 +1139,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1277,51 +1142,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return; } // Paper end - optimized tracker @@ -13987,7 +13922,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d if (playerchunkmap_entitytracker != null) { playerchunkmap_entitytracker.broadcast(packet); -@@ -1327,7 +1153,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1330,7 +1156,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } protected void broadcastAndSend(Entity entity, Packet packet) { @@ -13996,7 +13931,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d if (playerchunkmap_entitytracker != null) { playerchunkmap_entitytracker.broadcastAndSend(packet); -@@ -1504,41 +1330,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1517,41 +1343,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.lastSectionPos = SectionPos.of((EntityAccess) entity); } @@ -14039,7 +13974,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d public boolean equals(Object object) { return object instanceof ChunkMap.TrackedEntity ? ((ChunkMap.TrackedEntity) object).entity.getId() == this.entity.getId() : false; -@@ -1585,6 +1377,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1598,6 +1390,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } } @@ -14068,7 +14003,7 @@ index 870f4d6fae8c14502b4653f246a2df9e345ccca3..e23d752fcf6fea08d3ec114b065ada9d public void updatePlayer(ServerPlayer player) { org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot -@@ -1600,10 +1414,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1613,10 +1427,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player); // CraftBukkit start - respect vanish API @@ -14480,10 +14415,10 @@ index 736f37979c882e41e7571202df38eb6a2923fcb0..09a6a74f9bbcbbfba8bfc0424cde6000 } diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e932673e48 100644 +index e57cf6a74a129ea0919a4ad5e84b615cd5aa141e..5c20a7c090baed582a3351163520d37b4e1a4424 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -192,35 +192,34 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -190,35 +190,34 @@ public class ServerLevel extends Level implements WorldGenLevel { public final ServerChunkCache chunkSource; private final MinecraftServer server; public final PrimaryLevelData serverLevelData; // CraftBukkit - type @@ -14528,7 +14463,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 private final alternate.current.wire.WireHandler wireHandler = new alternate.current.wire.WireHandler(this); // Paper - optimize redstone (Alternate Current) public static Throwable getAddToWorldStackTrace(Entity entity) { final Throwable thr = new Throwable(entity + " Added to world at " + new java.util.Date()); -@@ -256,6 +255,13 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -254,6 +253,13 @@ public class ServerLevel extends Level implements WorldGenLevel { ServerChunkCache chunkProvider = this.getChunkSource(); @@ -14542,7 +14477,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 for (int cx = minChunkX; cx <= maxChunkX; ++cx) { for (int cz = minChunkZ; cz <= maxChunkZ; ++cz) { if (chunkProvider.getChunkAtIfLoadedImmediately(cx, cz) == null) { -@@ -267,50 +273,64 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -265,50 +271,64 @@ public class ServerLevel extends Level implements WorldGenLevel { return true; } @@ -14634,7 +14569,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 chunkProvider.addTicketAtLevel(TicketType.UNKNOWN, chunkPos, ticketLevel, chunkPos); chunkProvider.removeTicketAtLevel(TicketType.FUTURE_AWAIT, chunkPos, ticketLevel, holderIdentifier); -@@ -322,11 +342,31 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -320,11 +340,31 @@ public class ServerLevel extends Level implements WorldGenLevel { for (int cx = minChunkX; cx <= maxChunkX; ++cx) { for (int cz = minChunkZ; cz <= maxChunkZ; ++cz) { io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad( @@ -14667,7 +14602,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 // Paper start - rewrite chunk system public final io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler chunkTaskScheduler; -@@ -446,81 +486,16 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -444,81 +484,16 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper end // Paper start - optimise checkDespawn @@ -14754,7 +14689,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 // Paper end - optimise get nearest players for entity AI public final io.papermc.paper.chunk.system.RegionisedPlayerChunkLoader playerChunkLoader = new io.papermc.paper.chunk.system.RegionisedPlayerChunkLoader(this); -@@ -565,6 +540,59 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -563,6 +538,59 @@ public class ServerLevel extends Level implements WorldGenLevel { }); } @@ -14813,7 +14748,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 + // 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, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { - // Holder holder = worlddimension.type(); // CraftBukkit - decompile error + // IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error @@ -574,13 +602,13 @@ public class ServerLevel extends Level implements WorldGenLevel { this.convertable = convertable_conversionsession; this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); @@ -15052,7 +14987,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - disable thunder blockposition.set(this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15))); // Paper -@@ -941,7 +996,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -940,7 +995,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(); @@ -15061,7 +14996,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 if (index >= tickingBlocks) { continue; } -@@ -955,7 +1010,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -954,7 +1009,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); @@ -15070,7 +15005,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 // We drop the fluid tick since LAVA is ALREADY TICKED by the above method (See LiquidBlock). // TODO CHECK ON UPDATE (ping the Canadian) } -@@ -1009,7 +1064,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1008,7 +1063,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } public boolean isHandlingTick() { @@ -15079,7 +15014,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 } public boolean canSleepThroughNights() { -@@ -1041,6 +1096,14 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1040,6 +1095,14 @@ public class ServerLevel extends Level implements WorldGenLevel { } public void updateSleepingPlayerList() { @@ -15094,7 +15029,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 if (!this.players.isEmpty() && this.sleepStatus.update(this.players)) { this.announceSleepStatus(); } -@@ -1052,7 +1115,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1051,7 +1114,7 @@ public class ServerLevel extends Level implements WorldGenLevel { return this.server.getScoreboard(); } @@ -15103,7 +15038,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 boolean flag = this.isRaining(); if (this.dimensionType().hasSkyLight()) { -@@ -1138,23 +1201,24 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1137,23 +1200,24 @@ public class ServerLevel extends Level implements WorldGenLevel { this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } // */ @@ -15137,7 +15072,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 } } // CraftBukkit end -@@ -1218,7 +1282,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1217,7 +1281,7 @@ public class ServerLevel extends Level implements WorldGenLevel { public void tickNonPassenger(Entity entity) { // Paper start - log detailed entity tick information @@ -15146,7 +15081,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 try { if (currentlyTickingEntity.get() == null) { currentlyTickingEntity.lazySet(entity); -@@ -1251,7 +1315,16 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1250,7 +1314,16 @@ public class ServerLevel extends Level implements WorldGenLevel { if (isActive) { // Paper - EAR 2 TimingHistory.activatedEntityTicks++; entity.tick(); @@ -15164,7 +15099,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 } else { entity.inactiveTick(); } // Paper - EAR 2 this.getProfiler().pop(); } finally { timer.stopTiming(); } // Paper - timings -@@ -1274,7 +1347,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1273,7 +1346,7 @@ public class ServerLevel extends Level implements WorldGenLevel { private void tickPassenger(Entity vehicle, Entity passenger) { if (!passenger.isRemoved() && passenger.getVehicle() == vehicle) { @@ -15173,7 +15108,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 // 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 -@@ -1291,7 +1364,16 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1290,7 +1363,16 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper start - EAR 2 if (isActive) { passenger.rideTick(); @@ -15191,7 +15126,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 } else { passenger.setDeltaMovement(Vec3.ZERO); passenger.inactiveTick(); -@@ -1379,7 +1461,15 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1378,7 +1460,15 @@ public class ServerLevel extends Level implements WorldGenLevel { // Paper - rewrite chunk system - entity saving moved into ChunkHolder } else if (close) { chunkproviderserver.close(false); } // Paper - rewrite chunk system @@ -15207,7 +15142,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 // CraftBukkit start - moved from MinecraftServer.saveChunks ServerLevel worldserver1 = this; -@@ -1387,12 +1477,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1386,12 +1476,7 @@ public class ServerLevel extends Level implements WorldGenLevel { this.serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save()); this.convertable.saveDataTag(this.server.registryAccess(), this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); // CraftBukkit end @@ -15221,7 +15156,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 this.getChunkSource().getDataStorage().save(); } -@@ -1447,6 +1532,19 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1446,6 +1531,19 @@ public class ServerLevel extends Level implements WorldGenLevel { return list; } @@ -15241,7 +15176,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 @Nullable public ServerPlayer getRandomPlayer() { List list = this.getPlayers(LivingEntity::isAlive); -@@ -1548,8 +1646,8 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1547,8 +1645,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 @@ -15252,7 +15187,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 return true; } // Paper end -@@ -1688,7 +1786,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1687,7 +1785,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public void sendBlockUpdated(BlockPos pos, BlockState oldState, BlockState newState, int flags) { @@ -15261,7 +15196,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 String s = "recursive call to sendBlockUpdated"; Util.logAndPauseIfInIde("recursive call to sendBlockUpdated", new IllegalStateException("recursive call to sendBlockUpdated")); -@@ -1701,7 +1799,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1700,7 +1798,7 @@ public class ServerLevel extends Level implements WorldGenLevel { if (Shapes.joinIsNotEmpty(voxelshape, voxelshape1, BooleanOp.NOT_SAME)) { List list = new ObjectArrayList(); @@ -15270,7 +15205,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 while (iterator.hasNext()) { // CraftBukkit start - fix SPIGOT-6362 -@@ -1724,7 +1822,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1723,7 +1821,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } try { @@ -15279,7 +15214,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 iterator = list.iterator(); while (iterator.hasNext()) { -@@ -1733,7 +1831,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1732,7 +1830,7 @@ public class ServerLevel extends Level implements WorldGenLevel { navigationabstract1.recomputePath(); } } finally { @@ -15288,7 +15223,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 } } -@@ -1742,23 +1840,23 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1741,23 +1839,23 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public void updateNeighborsAt(BlockPos pos, Block sourceBlock) { @@ -15317,7 +15252,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 } @Override -@@ -1784,7 +1882,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1788,7 +1886,7 @@ public class ServerLevel extends Level implements WorldGenLevel { explosion.clearToBlow(); } @@ -15326,7 +15261,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 while (iterator.hasNext()) { ServerPlayer entityplayer = (ServerPlayer) iterator.next(); -@@ -1799,25 +1897,28 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1803,25 +1901,28 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public void blockEvent(BlockPos pos, Block block, int type, int data) { @@ -15361,7 +15296,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 } private boolean doBlockEvent(BlockEventData event) { -@@ -1828,12 +1929,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1832,12 +1933,12 @@ public class ServerLevel extends Level implements WorldGenLevel { @Override public LevelTicks getBlockTicks() { @@ -15376,7 +15311,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 } @Nonnull -@@ -1857,7 +1958,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1861,7 +1962,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 Expansion @@ -15385,7 +15320,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 } public int sendParticles(List receivers, ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) { // Paper end -@@ -1910,7 +2011,14 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1914,7 +2015,14 @@ public class ServerLevel extends Level implements WorldGenLevel { public Entity getEntityOrPart(int id) { Entity entity = (Entity) this.getEntities().get(id); @@ -15401,7 +15336,7 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 } @Nullable -@@ -1918,6 +2026,61 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1922,6 +2030,61 @@ public class ServerLevel extends Level implements WorldGenLevel { return (Entity) this.getEntities().get(uuid); } @@ -15712,10 +15647,10 @@ index 714637cdd9dcdbffa344b19e77944fb3c7541ff7..80ff2f28521f3d6d00ff21fbe76ab4e9 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 869daafbc236b3ff63f878e5fe28427fde75afe5..c9ffb72c5d39a46ce9cbd41cd49da92ece1ddfce 100644 +index 8a80b222456c2e4818cada3a9248ab2f9b76a983..c49e1e15e6878b1a5670988b89e2e50fe2d7aca8 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -181,7 +181,7 @@ import org.bukkit.inventory.MainHand; +@@ -187,7 +187,7 @@ import org.bukkit.inventory.MainHand; public class ServerPlayer extends Player { private static final Logger LOGGER = LogUtils.getLogger(); @@ -15724,7 +15659,7 @@ index 869daafbc236b3ff63f878e5fe28427fde75afe5..c9ffb72c5d39a46ce9cbd41cd49da92e private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32; private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10; public ServerGamePacketListenerImpl connection; -@@ -242,11 +242,7 @@ public class ServerPlayer extends Player { +@@ -248,11 +248,7 @@ public class ServerPlayer extends Player { public boolean queueHealthUpdatePacket = false; public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; // Paper end @@ -15737,17 +15672,7 @@ index 869daafbc236b3ff63f878e5fe28427fde75afe5..c9ffb72c5d39a46ce9cbd41cd49da92e // CraftBukkit start public String displayName; -@@ -311,6 +307,9 @@ public class ServerPlayer extends Player { - }); - } - -+ // Folia start - region threading -+ // Folia end - region threading -+ - public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile) { - super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); - this.chatVisibility = ChatVisiblity.FULL; -@@ -408,7 +407,7 @@ public class ServerPlayer extends Player { +@@ -414,7 +410,7 @@ public class ServerPlayer extends Player { this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper this.bukkitPickUpLoot = true; this.maxHealthCache = this.getMaxHealth(); @@ -15756,7 +15681,7 @@ index 869daafbc236b3ff63f878e5fe28427fde75afe5..c9ffb72c5d39a46ce9cbd41cd49da92e } // Yes, this doesn't match Vanilla, but it's the best we can do for now. -@@ -450,11 +449,11 @@ public class ServerPlayer extends Player { +@@ -456,11 +452,11 @@ public class ServerPlayer extends Player { } // CraftBukkit end @@ -15771,7 +15696,7 @@ index 869daafbc236b3ff63f878e5fe28427fde75afe5..c9ffb72c5d39a46ce9cbd41cd49da92e int j = Mth.floor(world.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); if (j < i) { -@@ -468,33 +467,76 @@ public class ServerPlayer extends Player { +@@ -474,33 +470,76 @@ public class ServerPlayer extends Player { long k = (long) (i * 2 + 1); long l = k * k; int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; @@ -15867,7 +15792,7 @@ index 869daafbc236b3ff63f878e5fe28427fde75afe5..c9ffb72c5d39a46ce9cbd41cd49da92e return horizontalSpawnArea <= 16 ? horizontalSpawnArea - 1 : 17; } -@@ -1147,6 +1189,343 @@ public class ServerPlayer extends Player { +@@ -1159,6 +1198,343 @@ public class ServerPlayer extends Player { } } @@ -16211,29 +16136,20 @@ index 869daafbc236b3ff63f878e5fe28427fde75afe5..c9ffb72c5d39a46ce9cbd41cd49da92e @Nullable @Override public Entity changeDimension(ServerLevel destination) { -@@ -2098,6 +2477,12 @@ public class ServerPlayer extends Player { - - if (entity1 == entity) return; // new spec target is the current spec target +@@ -2098,6 +2474,12 @@ public class ServerPlayer extends Player { + public void setCamera(@Nullable Entity entity) { + Entity entity1 = this.getCamera(); + // Folia start - region threading -+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(entity)) { ++ if (entity != null && !io.papermc.paper.util.TickThread.isTickThreadFor(entity)) { + return; + } + // Folia end - region threading + - if (entity == this) { - com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent playerStopSpectatingEntityEvent = new com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent(this.getBukkitEntity(), entity1.getBukkitEntity()); - -@@ -2132,7 +2517,7 @@ public class ServerPlayer extends Player { - this.getBukkitEntity().teleport(new Location(entity.getCommandSenderWorld().getWorld(), entity.getX(), entity.getY(), entity.getZ(), this.getYRot(), this.getXRot()), TeleportCause.SPECTATE); // Correctly handle cross-world entities from api calls by using CB teleport - - // Make sure we're tracking the entity before sending -- ChunkMap.TrackedEntity tracker = ((ServerLevel)entity.level).getChunkSource().chunkMap.entityMap.get(entity.getId()); -+ ChunkMap.TrackedEntity tracker = entity.tracker; // Folia - region threading - if (tracker != null) { // dumb plugins... - tracker.updatePlayer(this); - } -@@ -2567,7 +2952,7 @@ public class ServerPlayer extends Player { + this.camera = (Entity) (entity == null ? this : entity); + if (entity1 != this.camera) { + // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Event +@@ -2559,7 +2941,7 @@ public class ServerPlayer extends Player { this.experienceLevel = this.newLevel; this.totalExperience = this.newTotalExp; this.experienceProgress = 0; @@ -16243,7 +16159,7 @@ index 869daafbc236b3ff63f878e5fe28427fde75afe5..c9ffb72c5d39a46ce9cbd41cd49da92e 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 58b093bb1de78ee3b3b2ea364aa50474883f443a..dd6a45f88d69e892e57cbb862b978b08d404a3e9 100644 +index 0a3eb5e929c605d9eb7369de8ade8b49951f5d37..6b7b44ad8cb7ece5cfbf69bc54ed589a34f448a2 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java @@ -123,11 +123,11 @@ public class ServerPlayerGameMode { @@ -16419,16 +16335,16 @@ index 877498729c66de9aa6a27c9148f7494d7895615c..d8af2d59fb1f112f2f1a9fdbb3517fc7 this.generatingStatus = status; this.writeRadiusCutoff = placementRadius; diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java -index abcc3266d18f34d160eac87fdea153dce24c60b8..7cf0619883577a0f21ed75ba70ece90d5c316c21 100644 +index 44d99e89226adb6234b9405f25ac9dab9bd84297..c04e275658cf77d774027ac3a8ca26e12f9cedd5 100644 --- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java +++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java -@@ -155,10 +155,13 @@ public class ServerConnectionListener { +@@ -154,10 +154,13 @@ public class ServerConnectionListener { // Paper end - // ServerConnectionListener.this.connections.add((Connection) object); // CraftBukkit - decompile error -- pending.add((Connection) object); // Paper + //ServerConnectionListener.this.connections.add(object); +- pending.add(object); // Paper + // Folia - connection fixes - move down - channel.pipeline().addLast("packet_handler", (ChannelHandler) object); + channelpipeline.addLast("packet_handler", (ChannelHandler) object); ((Connection) object).setListener(new ServerHandshakePacketListenerImpl(ServerConnectionListener.this.server, (Connection) object)); io.papermc.paper.network.ChannelInitializeListenerHolder.callListeners(channel); // Paper + // Folia start - regionised threading @@ -16437,7 +16353,7 @@ index abcc3266d18f34d160eac87fdea153dce24c60b8..7cf0619883577a0f21ed75ba70ece90d } }).group((EventLoopGroup) lazyinitvar.get()).localAddress(address)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit // Paper } -@@ -217,7 +220,7 @@ public class ServerConnectionListener { +@@ -218,7 +221,7 @@ public class ServerConnectionListener { // Spigot Start this.addPending(); // Paper // This prevents players from 'gaming' the server, and strategically relogging to increase their position in the tick order @@ -16447,10 +16363,10 @@ index abcc3266d18f34d160eac87fdea153dce24c60b8..7cf0619883577a0f21ed75ba70ece90d 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 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c57f08f019 100644 +index 2d8488b9aa088b6d5f0c7e557b8ad0b29bc4cd88..aa8da680ed91e9a7695bd07f3cb88ae962f5b176 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -320,10 +320,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -322,10 +322,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic private final org.bukkit.craftbukkit.CraftServer cserver; public boolean processedDisconnect; @@ -16464,7 +16380,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 private int dropCount = 0; // Get position of last block hit for BlockDamageLevel.STOPPED -@@ -340,8 +340,40 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -342,8 +342,40 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic } // CraftBukkit end @@ -16505,7 +16421,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 if (this.ackBlockChangesUpTo > -1) { this.send(new ClientboundBlockChangedAckPacket(this.ackBlockChangesUpTo)); this.ackBlockChangesUpTo = -1; -@@ -393,22 +425,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -395,22 +427,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic this.server.getProfiler().push("keepAlive"); // Paper Start - give clients a longer time to respond to pings as per pre 1.12.2 timings // This should effectively place the keepalive handling back to "as it was" before 1.12.2 @@ -16529,7 +16445,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 // Paper end this.server.getProfiler().pop(); -@@ -441,6 +458,19 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -443,6 +460,19 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic this.lastGoodX = this.player.getX(); this.lastGoodY = this.player.getY(); this.lastGoodZ = this.player.getZ(); @@ -16549,7 +16465,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 } @Override -@@ -477,24 +507,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -479,24 +509,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic if (this.processedDisconnect) { return; } @@ -16576,7 +16492,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 return; } -@@ -525,7 +539,6 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -527,7 +541,6 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic Objects.requireNonNull(this.connection); // CraftBukkit - Don't wait @@ -16584,7 +16500,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 } private CompletableFuture filterTextPacket(T text, BiFunction> filterer) { -@@ -608,9 +621,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -610,9 +623,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic // Paper end - fix large move vectors killing the server // CraftBukkit start - handle custom speeds and skipped ticks @@ -16597,7 +16513,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 ++this.receivedMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount; -@@ -864,13 +878,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -866,13 +880,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // Paper - 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 start - split and make configurable @@ -16613,7 +16529,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 return; } // Paper end -@@ -895,7 +909,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -897,7 +911,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic if (!event.isHandled()) { if (!event.isCancelled()) { @@ -16622,7 +16538,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { -@@ -906,7 +920,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -908,7 +922,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic this.connection.send(new ClientboundCommandSuggestionsPacket(packet.getId(), suggestEvent.getSuggestions())); // Paper end - Brigadier API }); @@ -16631,7 +16547,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 } } else if (!completions.isEmpty()) { final com.mojang.brigadier.suggestion.SuggestionsBuilder builder0 = new com.mojang.brigadier.suggestion.SuggestionsBuilder(command, stringreader.getTotalLength()); -@@ -1215,7 +1229,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1217,7 +1231,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic 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!"); @@ -16640,7 +16556,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 return; } byteTotal += byteLength; -@@ -1238,17 +1252,17 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1240,17 +1254,17 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic 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()); @@ -16662,7 +16578,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 // CraftBukkit end int i = packet.getSlot(); -@@ -1435,9 +1449,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1437,9 +1451,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic int i = this.receivedMovePacketCount - this.knownMovePacketCount; // CraftBukkit start - handle custom speeds and skipped ticks @@ -16675,7 +16591,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 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); -@@ -1829,9 +1844,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1819,9 +1834,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic 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. @@ -16687,7 +16603,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 } else { // Else we increment the drop count and check the amount. this.dropCount++; -@@ -1859,7 +1874,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1849,7 +1864,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic case ABORT_DESTROY_BLOCK: case STOP_DESTROY_BLOCK: // Paper start - Don't allow digging in unloaded chunks @@ -16696,7 +16612,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 this.player.connection.ackBlockChangesUpTo(packet.getSequence()); return; } -@@ -1943,7 +1958,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1933,7 +1948,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic BlockPos blockposition = movingobjectpositionblock.getBlockPos(); Vec3 vec3d1 = Vec3.atCenterOf(blockposition); @@ -16705,7 +16621,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 Vec3 vec3d2 = vec3d.subtract(vec3d1); double d0 = 1.0000001D; -@@ -2056,7 +2071,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2046,7 +2061,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic Entity entity = packet.getEntity(worldserver); if (entity != null) { @@ -16714,7 +16630,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 return; } } -@@ -2117,6 +2132,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2109,6 +2124,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic 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 @@ -16723,7 +16639,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) { this.server.getPlayerList().broadcastSystemMessage(PaperAdventure.asVanilla(quitMessage), false); // Paper end -@@ -2201,9 +2218,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2193,9 +2210,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic } // CraftBukkit end if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.message())) { @@ -16735,7 +16651,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 } else { Optional optional = this.tryHandleChat(packet.message(), packet.timeStamp(), packet.lastSeenMessages()); -@@ -2237,17 +2254,17 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2229,17 +2246,17 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @Override public void handleChatCommand(ServerboundChatCommandPacket packet) { if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.command())) { @@ -16757,7 +16673,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 } } -@@ -2321,9 +2338,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2313,9 +2330,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic private Optional tryHandleChat(String message, Instant timestamp, LastSeenMessages.Update acknowledgment) { if (!this.updateChatOrder(timestamp)) { ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}': {} > {}", this.player.getName().getString(), message, this.lastChatTimeStamp.get().getEpochSecond(), timestamp.getEpochSecond()); // Paper @@ -16767,9 +16683,9 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 - }); // Paper - push to main + // Folia - region threading return Optional.empty(); - } else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales - this.send(new ClientboundSystemChatPacket(Component.translatable("chat.disabled.options").withStyle(ChatFormatting.RED), false)); -@@ -2396,7 +2413,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic + } else { + Optional optional = this.unpackAndApplyLastSeen(acknowledgment); +@@ -2390,7 +2407,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic String originalFormat = event.getFormat(), originalMessage = event.getMessage(); this.cserver.getPluginManager().callEvent(event); @@ -16778,7 +16694,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 // Evil plugins still listening to deprecated event final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), event.getRecipients()); queueEvent.setCancelled(event.isCancelled()); -@@ -2474,6 +2491,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2468,6 +2485,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic public void handleCommand(String s) { // Paper - private -> public // Paper Start if (!org.spigotmc.AsyncCatcher.shuttingDown && !org.bukkit.Bukkit.isPrimaryThread()) { @@ -16786,7 +16702,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 LOGGER.error("Command Dispatched Async: " + s); LOGGER.error("Please notify author of plugin causing this execution to fix this bug! see: http://bit.ly/1oSiM6C", new Throwable()); Waitable wait = new Waitable<>() { -@@ -2534,6 +2552,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2528,6 +2546,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic if (s.isEmpty()) { ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message"); } else if (this.getCraftPlayer().isConversing()) { @@ -16794,7 +16710,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 final String conversationInput = s; this.server.processQueue.add(new Runnable() { @Override -@@ -2751,7 +2770,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2769,7 +2788,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic this.player.resetLastActionTime(); this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); @@ -16803,7 +16719,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 if (!worldserver.getWorldBorder().isWithinBounds(entity.blockPosition())) { return; } -@@ -2889,6 +2908,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2909,6 +2928,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic switch (packetplayinclientcommand_enumclientcommand) { case PERFORM_RESPAWN: if (this.player.wonGame) { @@ -16816,7 +16732,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 this.player.wonGame = false; this.player = this.server.getPlayerList().respawn(this.player, this.server.getLevel(this.player.getRespawnDimension()), true, null, true, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag.END_PORTAL); // Paper - add isEndCreditsRespawn argument CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); -@@ -2897,6 +2922,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2917,6 +2942,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic return; } @@ -16835,7 +16751,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 this.player = this.server.getPlayerList().respawn(this.player, false); if (this.server.isHardcore()) { this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper -@@ -3249,7 +3286,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3269,7 +3306,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic // Paper start if (!org.bukkit.Bukkit.isPrimaryThread()) { if (recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) { @@ -16844,7 +16760,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 return; } } -@@ -3391,7 +3428,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3411,7 +3448,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic this.filterTextPacket(list).thenAcceptAsync((list1) -> { this.updateSignText(packet, list1); @@ -16859,7 +16775,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 } private void updateSignText(ServerboundSignUpdatePacket packet, List signText) { -@@ -3461,9 +3504,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -3481,9 +3524,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic this.keepAlivePending = false; } else if (!this.isSingleplayerOwner()) { // Paper start - This needs to be handled on the main thread for plugins @@ -16872,7 +16788,7 @@ index 3472f7f9b98d6d9c9f6465872803ef17fa67486d..19b7bcb7a773d48580842cbd33e022c5 } diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index a25306fe8a35bb70a490e6a0c01d0340bbc0d781..626d99c785d2886bce605ba468ee24ce1710beb2 100644 +index 2ff578e4a953ffcf5176815ba8e3f06f73499989..48223b78dd7ea2f065a259ad071f101398f40cfd 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -53,7 +53,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @@ -17015,10 +16931,10 @@ index a25306fe8a35bb70a490e6a0c01d0340bbc0d781..626d99c785d2886bce605ba468ee24ce private State() {} } diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60ccab0272 100644 +index 0dbe182fbae5ce5ba182176eb5d5e3f1897e77f2..e49e9cc31a9e05422fd1f48616c5a452011d66e1 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -138,7 +138,7 @@ public abstract class PlayerList { +@@ -139,7 +139,7 @@ public abstract class PlayerList { private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); private final MinecraftServer server; public final List players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety @@ -17027,7 +16943,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 private final UserBanList bans; private final IpBanList ipBans; private final ServerOpList ops; -@@ -160,9 +160,56 @@ public abstract class PlayerList { +@@ -161,9 +161,56 @@ public abstract class PlayerList { // CraftBukkit start private CraftServer cserver; @@ -17085,7 +17001,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 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 -@@ -184,7 +231,7 @@ public abstract class PlayerList { +@@ -185,7 +232,7 @@ public abstract class PlayerList { } abstract public void loadAndSaveFiles(); // Paper - moved from DedicatedPlayerList constructor @@ -17094,7 +17010,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 player.isRealPlayer = true; // Paper player.loginTime = System.currentTimeMillis(); // Paper GameProfile gameprofile = player.getGameProfile(); -@@ -234,8 +281,28 @@ public abstract class PlayerList { +@@ -235,8 +282,28 @@ public abstract class PlayerList { worldserver1 = worldserver; } @@ -17125,7 +17041,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 player.setLevel(worldserver1); String s1 = "local"; -@@ -246,7 +313,7 @@ public abstract class PlayerList { +@@ -247,7 +314,7 @@ public abstract class PlayerList { // Spigot start - spawn location event Player spawnPlayer = player.getBukkitEntity(); org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new com.destroystokyo.paper.event.player.PlayerInitialSpawnEvent(spawnPlayer, spawnPlayer.getLocation()); // Paper use our duplicate event @@ -17134,7 +17050,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 Location loc = ev.getSpawnLocation(); worldserver1 = ((CraftWorld) loc.getWorld()).getHandle(); -@@ -265,6 +332,7 @@ public abstract class PlayerList { +@@ -266,6 +333,7 @@ public abstract class PlayerList { player.loadGameTypes(nbttagcompound); ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player); @@ -17142,7 +17058,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 GameRules gamerules = worldserver1.getGameRules(); boolean flag = gamerules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN); boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); -@@ -282,7 +350,7 @@ public abstract class PlayerList { +@@ -283,7 +351,7 @@ public abstract class PlayerList { this.sendPlayerPermissionLevel(player); player.getStats().markAllDirty(); player.getRecipeBook().sendInitialRecipeBook(player); @@ -17151,16 +17067,16 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 this.server.invalidateStatus(); MutableComponent ichatmutablecomponent; -@@ -319,7 +387,7 @@ public abstract class PlayerList { +@@ -325,7 +393,7 @@ public abstract class PlayerList { this.cserver.getPluginManager().callEvent(playerJoinEvent); - if (!player.connection.connection.isConnected()) { + if (!player.connection.isAcceptingMessages()) { - return; + //return; // Folia - region threading - must still allow the player to connect, as we must add to chunk map before handling disconnect } final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); -@@ -334,8 +402,7 @@ public abstract class PlayerList { +@@ -340,8 +408,7 @@ public abstract class PlayerList { ClientboundPlayerInfoUpdatePacket packet = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player)); final List onlinePlayers = Lists.newArrayListWithExpectedSize(this.players.size() - 1); // Paper - use single player info update packet @@ -17170,7 +17086,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 if (entityplayer1.getBukkitEntity().canSee(bukkitPlayer)) { entityplayer1.connection.send(packet); -@@ -451,7 +518,7 @@ public abstract class PlayerList { +@@ -458,7 +525,7 @@ public abstract class PlayerList { // Paper start - Add to collideRule team if needed final Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard(); final PlayerTeam collideRuleTeam = scoreboard.getPlayerTeam(this.collideRuleTeamName); @@ -17179,7 +17095,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam); } // Paper end -@@ -542,7 +609,7 @@ public abstract class PlayerList { +@@ -549,7 +616,7 @@ public abstract class PlayerList { protected void save(ServerPlayer player) { if (!player.getBukkitEntity().isPersistent()) return; // CraftBukkit @@ -17188,7 +17104,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 this.playerIo.save(player); ServerStatsCounter serverstatisticmanager = (ServerStatsCounter) player.getStats(); // CraftBukkit -@@ -582,7 +649,7 @@ public abstract class PlayerList { +@@ -589,7 +656,7 @@ public abstract class PlayerList { // CraftBukkit end // Paper start - Remove from collideRule team if needed @@ -17197,7 +17113,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 final Scoreboard scoreBoard = this.server.getLevel(Level.OVERWORLD).getScoreboard(); final PlayerTeam team = scoreBoard.getPlayersTeam(this.collideRuleTeamName); if (entityplayer.getTeam() == team && team != null) { -@@ -622,6 +689,7 @@ public abstract class PlayerList { +@@ -629,6 +696,7 @@ public abstract class PlayerList { entityplayer.unRide(); worldserver.removePlayerImmediately(entityplayer, Entity.RemovalReason.UNLOADED_WITH_PLAYER); @@ -17205,7 +17121,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 entityplayer.getAdvancements().stopListening(); this.players.remove(entityplayer); this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot -@@ -640,8 +708,7 @@ public abstract class PlayerList { +@@ -647,8 +715,7 @@ public abstract class PlayerList { // CraftBukkit start // this.broadcastAll(new ClientboundPlayerInfoRemovePacket(List.of(entityplayer.getUUID()))); ClientboundPlayerInfoRemovePacket packet = new ClientboundPlayerInfoRemovePacket(List.of(entityplayer.getUUID())); @@ -17215,7 +17131,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { entityplayer2.connection.send(packet); -@@ -666,19 +733,13 @@ public abstract class PlayerList { +@@ -673,19 +740,13 @@ public abstract class PlayerList { ServerPlayer entityplayer; @@ -17237,7 +17153,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 } // Instead of kicking then returning, we need to store the kick reason -@@ -717,7 +778,7 @@ public abstract class PlayerList { +@@ -724,7 +785,7 @@ public abstract class PlayerList { event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(ichatmutablecomponent)); // Paper - Adventure } else { // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null; @@ -17246,7 +17162,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 event.disallow(PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure } } -@@ -967,10 +1028,10 @@ public abstract class PlayerList { +@@ -976,10 +1037,10 @@ public abstract class PlayerList { public void tick() { if (++this.sendAllPlayerInfoIn > 600) { // CraftBukkit start @@ -17260,7 +17176,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 @Override public boolean test(ServerPlayer input) { return target.getBukkitEntity().canSee(input.getBukkitEntity()); -@@ -996,18 +1057,17 @@ public abstract class PlayerList { +@@ -1005,18 +1066,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) { @@ -17283,7 +17199,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 } } -@@ -1051,8 +1111,7 @@ public abstract class PlayerList { +@@ -1060,8 +1120,7 @@ public abstract class PlayerList { if (scoreboardteambase == null) { this.broadcastSystemMessage(message, false); } else { @@ -17293,7 +17209,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 if (entityplayer.getTeam() != scoreboardteambase) { entityplayer.sendSystemMessage(message); -@@ -1063,10 +1122,12 @@ public abstract class PlayerList { +@@ -1072,10 +1131,12 @@ public abstract class PlayerList { } public String[] getPlayerNamesArray() { @@ -17309,7 +17225,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 } return astring; -@@ -1085,7 +1146,9 @@ public abstract class PlayerList { +@@ -1094,7 +1155,9 @@ public abstract class PlayerList { ServerPlayer entityplayer = this.getPlayer(profile.getId()); if (entityplayer != null) { @@ -17319,7 +17235,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 } } -@@ -1095,7 +1158,10 @@ public abstract class PlayerList { +@@ -1104,7 +1167,10 @@ public abstract class PlayerList { ServerPlayer entityplayer = this.getPlayer(profile.getId()); if (entityplayer != null) { @@ -17330,7 +17246,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 } } -@@ -1156,8 +1222,7 @@ public abstract class PlayerList { +@@ -1165,8 +1231,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) { @@ -17340,7 +17256,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 // CraftBukkit start - Test if player receiving packet can see the source of the packet if (player != null && !entityplayer.getBukkitEntity().canSee(player.getBukkitEntity())) { -@@ -1187,9 +1252,12 @@ public abstract class PlayerList { +@@ -1196,9 +1261,12 @@ public abstract class PlayerList { io.papermc.paper.util.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main MinecraftTimings.savePlayers.startTiming(); // Paper int numSaved = 0; @@ -17356,7 +17272,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 if (interval == -1 || now - entityplayer.lastSave >= interval) { this.save(entityplayer); if (interval != -1 && ++numSaved <= io.papermc.paper.configuration.GlobalConfiguration.get().playerAutoSave.maxPerTick()) { break; } -@@ -1309,6 +1377,20 @@ public abstract class PlayerList { +@@ -1318,6 +1386,20 @@ public abstract class PlayerList { } public void removeAll(boolean isRestarting) { @@ -17377,7 +17293,7 @@ index 3c9d08c37a44a60bc70387d8d0dbd0a39ea98a26..f60feb0b9101afa24363c438949e1d60 // Paper end // CraftBukkit start - disconnect safely for (ServerPlayer player : this.players) { -@@ -1318,7 +1400,7 @@ public abstract class PlayerList { +@@ -1327,7 +1409,7 @@ public abstract class PlayerList { // CraftBukkit end // Paper start - Remove collideRule team if it exists @@ -17486,10 +17402,10 @@ index 83ef8cb27db685cceb5c2b7c9674e17b93ba081c..2d87c16420a97b9142d4ea76ceb6013d } } diff --git a/src/main/java/net/minecraft/world/damagesource/CombatTracker.java b/src/main/java/net/minecraft/world/damagesource/CombatTracker.java -index ba96589aab8be0a90144f73f7779769146c7a37e..08dc87506686434d2e53e748ead9d05c35f470cd 100644 +index a454aa44acddd668c96a17da44ccccb1bbac4546..0e6112a7dbeb17b088e3585b0d284ec36e48ca80 100644 --- a/src/main/java/net/minecraft/world/damagesource/CombatTracker.java +++ b/src/main/java/net/minecraft/world/damagesource/CombatTracker.java -@@ -34,7 +34,7 @@ public class CombatTracker { +@@ -40,7 +40,7 @@ public class CombatTracker { public void prepareForDamage() { this.resetPreparedStatus(); Optional optional = this.mob.getLastClimbablePos(); @@ -17498,50 +17414,37 @@ index ba96589aab8be0a90144f73f7779769146c7a37e..08dc87506686434d2e53e748ead9d05c BlockState blockState = this.mob.level.getBlockState(optional.get()); if (!blockState.is(Blocks.LADDER) && !blockState.is(BlockTags.TRAPDOORS)) { if (blockState.is(Blocks.VINE)) { -@@ -85,6 +85,7 @@ public class CombatTracker { - CombatEntry combatEntry2 = this.entries.get(this.entries.size() - 1); +@@ -92,6 +92,7 @@ public class CombatTracker { Component component = combatEntry2.getAttackerName(); - Entity entity = combatEntry2.getSource().getEntity(); + DamageSource damageSource = combatEntry2.getSource(); + Entity entity = damageSource.getEntity(); + if (!io.papermc.paper.util.TickThread.isTickThreadFor(entity)) entity = null; // Folia - region threading - not safe to access other entity data + DeathMessageType deathMessageType = damageSource.type().deathMessageType(); Component component4; - if (combatEntry != null && combatEntry2.getSource() == DamageSource.FALL) { - Component component2 = combatEntry.getAttackerName(); -@@ -126,6 +127,7 @@ public class CombatTracker { - float g = 0.0F; + if (combatEntry != null && deathMessageType == DeathMessageType.FALL_VARIANTS) { +@@ -158,6 +159,7 @@ public class CombatTracker { for(CombatEntry combatEntry : this.entries) { -+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(combatEntry.getSource().getEntity())) { continue; } // Folia - region threading - skip entities we do not own - if (combatEntry.getSource().getEntity() instanceof Player && (player == null || combatEntry.getDamage() > g)) { - g = combatEntry.getDamage(); - player = (Player)combatEntry.getSource().getEntity(); -diff --git a/src/main/java/net/minecraft/world/damagesource/EntityDamageSource.java b/src/main/java/net/minecraft/world/damagesource/EntityDamageSource.java -index b53e04854f960682fae94bb2ef5a12e4274fcebf..01469deddce99a736e661ce9bca8e20e88bb6c1e 100644 ---- a/src/main/java/net/minecraft/world/damagesource/EntityDamageSource.java -+++ b/src/main/java/net/minecraft/world/damagesource/EntityDamageSource.java -@@ -35,7 +35,7 @@ public class EntityDamageSource extends DamageSource { - public Component getLocalizedDeathMessage(LivingEntity entity) { - Entity var4 = this.entity; - ItemStack var10000; -- if (var4 instanceof LivingEntity livingEntity) { -+ if (var4 instanceof LivingEntity livingEntity && io.papermc.paper.util.TickThread.isTickThreadFor(livingEntity)) { // Folia - region threading - var10000 = livingEntity.getMainHandItem(); - } else { - var10000 = ItemStack.EMPTY; -diff --git a/src/main/java/net/minecraft/world/damagesource/IndirectEntityDamageSource.java b/src/main/java/net/minecraft/world/damagesource/IndirectEntityDamageSource.java -index 6b5fd3e2e19c2d3d694df94f90fce0d310a1a86c..a7a48cf40db1e31ab03e0f42028b617b4f87c8ad 100644 ---- a/src/main/java/net/minecraft/world/damagesource/IndirectEntityDamageSource.java -+++ b/src/main/java/net/minecraft/world/damagesource/IndirectEntityDamageSource.java -@@ -34,7 +34,7 @@ public class IndirectEntityDamageSource extends EntityDamageSource { - Entity entity1 = this.cause; - ItemStack itemstack; + Entity var8 = combatEntry.getSource().getEntity(); ++ if (!io.papermc.paper.util.TickThread.isTickThreadFor(var8)) { continue; } // Folia - region threading - skip entities we do not own + if (var8 instanceof Player player2) { + if (player == null || combatEntry.getDamage() > g) { + g = combatEntry.getDamage(); +diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java +index 93a1e990b0a6caae4143c2f9d09bfb368fa1d6db..ad3166481dd37f4b5380f8bf28653bb4fd5c4933 100644 +--- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java ++++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java +@@ -112,7 +112,7 @@ public class DamageSource { + Entity entity = this.causingEntity; + ItemStack itemstack; -- if (entity1 instanceof LivingEntity) { -+ if (entity1 instanceof LivingEntity && io.papermc.paper.util.TickThread.isTickThreadFor(entity1)) { // Folia - region threading - LivingEntity entityliving1 = (LivingEntity) entity1; +- if (entity instanceof LivingEntity) { ++ if (entity instanceof LivingEntity livingEntity && io.papermc.paper.util.TickThread.isTickThreadFor(livingEntity)) { // Folia - region threading + LivingEntity entityliving2 = (LivingEntity) entity; - itemstack = entityliving1.getMainHandItem(); + itemstack = entityliving2.getMainHandItem(); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8d6ac06e7 100644 +index 9a1e8589e6b371869b2199650172d61ae186c907..0f958731923c7ac7093b47c11ceb1eda7c79e0de 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -165,7 +165,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -17585,7 +17488,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 @Override public CommandSender getBukkitSender(CommandSourceStack wrapper) { return this.getBukkitEntity(); -@@ -488,28 +500,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -489,28 +501,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.isLegacyTrackingEntity = isLegacyTrackingEntity; } @@ -17615,7 +17518,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 // Paper end - optimise entity tracking // Paper start - make end portalling safe public BlockPos portalBlock; -@@ -541,6 +532,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -542,6 +533,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.teleportTo(worldserver, null); } // Paper end - make end portalling safe @@ -17641,7 +17544,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -656,6 +666,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -657,6 +667,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public final void discard() { @@ -17653,7 +17556,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 this.remove(Entity.RemovalReason.DISCARDED); } -@@ -780,6 +795,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -781,6 +796,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // CraftBukkit start public void postTick() { @@ -17666,7 +17569,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 // 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(); -@@ -802,7 +823,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -803,7 +824,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.walkDistO = this.walkDist; this.xRotO = this.getXRot(); this.yRotO = this.getYRot(); @@ -17675,13 +17578,13 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -903,11 +924,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -904,11 +925,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // This will be called every single tick the entity is in lava, so don't throw an event this.setSecondsOnFire(15, false); } - CraftEventFactory.blockDamage = (this.lastLavaContact) == null ? null : org.bukkit.craftbukkit.block.CraftBlock.at(level, lastLavaContact); + CraftEventFactory.blockDamageRT.set((this.lastLavaContact) == null ? null : org.bukkit.craftbukkit.block.CraftBlock.at(level, lastLavaContact)); // Folia - region threading - if (this.hurt(DamageSource.LAVA, 4.0F)) { + if (this.hurt(this.damageSources().lava(), 4.0F)) { this.playSound(SoundEvents.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F); } - CraftEventFactory.blockDamage = null; @@ -17689,7 +17592,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls } -@@ -1015,8 +1036,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1016,8 +1037,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } else { this.wasOnFire = this.isOnFire(); if (movementType == MoverType.PISTON) { @@ -17700,7 +17603,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 movement = this.limitPistonMovement(movement); if (movement.equals(Vec3.ZERO)) { return; -@@ -3071,6 +3092,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3090,6 +3111,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @Nullable public Team getTeam() { @@ -17712,19 +17615,19 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 if (!this.level.paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper return this.level.getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -3186,9 +3212,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3205,9 +3231,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (this.fireImmune()) { return; } - CraftEventFactory.entityDamage = lightning; + CraftEventFactory.entityDamageRT.set(lightning); // Folia - region threading - if (!this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F)) { + if (!this.hurt(this.damageSources().lightningBolt(), 5.0F)) { - CraftEventFactory.entityDamage = null; + CraftEventFactory.entityDamageRT.set(null); // Folia - region threading return; } // CraftBukkit end -@@ -3361,6 +3387,750 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3380,6 +3406,750 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.portalEntrancePos = original.portalEntrancePos; } @@ -18475,7 +18378,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 @Nullable public Entity changeDimension(ServerLevel destination) { // CraftBukkit start -@@ -3859,17 +4629,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3904,17 +4674,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // Paper start public void startSeenByPlayer(ServerPlayer player) { @@ -18495,7 +18398,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 } // Paper end -@@ -4341,7 +5107,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4405,7 +5171,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } } // Paper end - fix MC-4 @@ -18505,7 +18408,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 synchronized (this.posLock) { // Paper this.position = new Vec3(x, y, z); } // Paper -@@ -4362,7 +5129,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4426,7 +5193,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // Paper start - never allow AABB to become desynced from position // hanging has its own special logic @@ -18514,7 +18417,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 this.setBoundingBox(this.makeBoundingBox()); } // Paper end -@@ -4437,6 +5204,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4513,6 +5280,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return this.removalReason != null; } @@ -18527,7 +18430,7 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 @Nullable public Entity.RemovalReason getRemovalReason() { return this.removalReason; -@@ -4461,7 +5234,23 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4537,7 +5310,23 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (reason != RemovalReason.UNLOADED_TO_CHUNK) this.getPassengers().forEach(Entity::stopRiding); // Paper - chunk system - don't adjust passenger state when unloading, it's just not safe (and messes with our logic in entity chunk unload) this.levelCallback.onRemove(reason); @@ -18552,10 +18455,10 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..58d39268a2608901a14696d36f3c59d8 public void unsetRemoved() { this.removalReason = null; diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 42eb78830855d7282b7f3f1bdbe85e632d489784..1e36d889edb6b68d52eae9eee3c13802496af864 100644 +index dcfb71b5a53df789e366fea2080921d677549a2e..485e5c3f1348f9e79f48f6ec3fad34fa58dcfe73 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -469,7 +469,7 @@ public abstract class LivingEntity extends Entity { +@@ -464,7 +464,7 @@ public abstract class LivingEntity extends Entity implements Attackable { if (this.isDeadOrDying() && this.level.shouldTickDeath(this)) { this.tickDeath(); @@ -18564,8 +18467,8 @@ index 42eb78830855d7282b7f3f1bdbe85e632d489784..1e36d889edb6b68d52eae9eee3c13802 if (this.lastHurtByPlayerTime > 0) { --this.lastHurtByPlayerTime; -@@ -620,11 +620,14 @@ public abstract class LivingEntity extends Entity { - return false; +@@ -610,11 +610,14 @@ public abstract class LivingEntity extends Entity implements Attackable { + return true; } + public boolean broadcastedDeath = false; // Folia - region threading @@ -18581,7 +18484,7 @@ index 42eb78830855d7282b7f3f1bdbe85e632d489784..1e36d889edb6b68d52eae9eee3c13802 } } -@@ -841,9 +844,9 @@ public abstract class LivingEntity extends Entity { +@@ -835,9 +838,9 @@ public abstract class LivingEntity extends Entity implements Attackable { } this.hurtTime = nbt.getShort("HurtTime"); @@ -18593,7 +18496,7 @@ index 42eb78830855d7282b7f3f1bdbe85e632d489784..1e36d889edb6b68d52eae9eee3c13802 String s = nbt.getString("Team"); PlayerTeam scoreboardteam = this.level.getScoreboard().getPlayerTeam(s); if (!level.paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof net.minecraft.world.entity.player.Player)) { scoreboardteam = null; } // Paper -@@ -2264,7 +2267,7 @@ public abstract class LivingEntity extends Entity { +@@ -2266,7 +2269,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @Nullable public LivingEntity getKillCredit() { @@ -18602,7 +18505,7 @@ index 42eb78830855d7282b7f3f1bdbe85e632d489784..1e36d889edb6b68d52eae9eee3c13802 } public final float getMaxHealth() { -@@ -3432,7 +3435,7 @@ public abstract class LivingEntity extends Entity { +@@ -3394,7 +3397,7 @@ public abstract class LivingEntity extends Entity implements Attackable { this.pushEntities(); this.level.getProfiler().pop(); // Paper start @@ -18611,8 +18514,8 @@ index 42eb78830855d7282b7f3f1bdbe85e632d489784..1e36d889edb6b68d52eae9eee3c13802 if (this.xo != 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()); -@@ -4096,7 +4099,7 @@ public abstract class LivingEntity extends Entity { - BlockPos blockposition = new BlockPos(d0, d1, d2); +@@ -4054,7 +4057,7 @@ public abstract class LivingEntity extends Entity implements Attackable { + BlockPos blockposition = BlockPos.containing(d0, d1, d2); Level world = this.level; - if (world.hasChunkAt(blockposition)) { @@ -18621,10 +18524,10 @@ index 42eb78830855d7282b7f3f1bdbe85e632d489784..1e36d889edb6b68d52eae9eee3c13802 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 49b983064ea810382b6112f5dc7f93ba4e5710bd..90c81bd2ed00450a9b2188e92011e6e4873d0619 100644 +index 02cb6b8c1d59855ff4a8aad3024fe12007eca0ee..88e2d818264450e63e0f5693fdc7940d072e50a6 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -135,6 +135,14 @@ public abstract class Mob extends LivingEntity { +@@ -135,6 +135,14 @@ public abstract class Mob extends LivingEntity implements Targeting { public boolean aware = true; // CraftBukkit @@ -18639,9 +18542,9 @@ index 49b983064ea810382b6112f5dc7f93ba4e5710bd..90c81bd2ed00450a9b2188e92011e6e4 protected Mob(EntityType type, Level world) { super(type, world); this.handItems = NonNullList.withSize(2, ItemStack.EMPTY); -@@ -253,9 +261,21 @@ public abstract class Mob extends LivingEntity { - +@@ -283,9 +291,21 @@ public abstract class Mob extends LivingEntity implements Targeting { @Nullable + @Override public LivingEntity getTarget() { + // Folia start - region threading + if (!io.papermc.paper.util.TickThread.isTickThreadFor(this.target)) { @@ -18661,7 +18564,7 @@ index 49b983064ea810382b6112f5dc7f93ba4e5710bd..90c81bd2ed00450a9b2188e92011e6e4 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 -@@ -263,7 +283,7 @@ public abstract class Mob extends LivingEntity { +@@ -293,7 +313,7 @@ public abstract class Mob extends LivingEntity implements Targeting { } public boolean setTarget(LivingEntity entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) { @@ -18670,7 +18573,7 @@ index 49b983064ea810382b6112f5dc7f93ba4e5710bd..90c81bd2ed00450a9b2188e92011e6e4 if (fireEvent) { if (reason == EntityTargetEvent.TargetReason.UNKNOWN && this.getTarget() != null && entityliving == null) { reason = this.getTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; -@@ -826,12 +846,7 @@ public abstract class Mob extends LivingEntity { +@@ -855,12 +875,7 @@ public abstract class Mob extends LivingEntity implements Targeting { if (this.level.getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { this.discard(); } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { @@ -18702,28 +18605,28 @@ index 8ec07578c1e41997a2e5ef158885ad3f4c2a31b6..6dcacfca6eb4a8a6425f1aaeb57733d2 context.>get(mobs).stream().filter((mob) -> { return mob instanceof Villager && mob != entity; 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 11a101e8ff05fbda5e84018358be02014ca01854..8cfa70e9b07e0f993d172d3e4d3804490a4d9fd5 100644 +index 4fe177c950c769f5c6e76b522019b5d5b78259a5..624a4cc8a03880b74fb44bf16e0e35e4398eb1f9 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 { @Override public boolean canContinueToUse() { -- return this.navigation.isDone() ? false : (this.tamable.isOrderedToSit() ? false : this.tamable.distanceToSqr((Entity) this.owner) > (double) (this.stopDistance * this.stopDistance)); -+ return this.navigation.isDone() ? false : (this.tamable.isOrderedToSit() ? false : (this.owner.level == this.level && this.tamable.distanceToSqr((Entity) this.owner) > (double) (this.stopDistance * this.stopDistance))); // Folia - region threading - check level +- return this.navigation.isDone() ? false : (this.unableToMove() ? false : this.tamable.distanceToSqr((Entity) this.owner) > (double) (this.stopDistance * this.stopDistance)); ++ return this.navigation.isDone() ? false : (this.unableToMove() ? false : (this.owner.level == this.level && this.tamable.distanceToSqr((Entity) this.owner) > (double) (this.stopDistance * this.stopDistance))); // Folia - region threading - check level } - @Override -@@ -93,7 +93,7 @@ public class FollowOwnerGoal extends Goal { + private boolean unableToMove() { +@@ -96,7 +96,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 if (--this.timeToRecalcPath <= 0) { this.timeToRecalcPath = this.adjustedTickDelay(10); - if (!this.tamable.isLeashed() && !this.tamable.isPassenger()) { -- if (this.tamable.distanceToSqr((Entity) this.owner) >= 144.0D) { -+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(this.owner) || this.tamable.distanceToSqr((Entity) this.owner) >= 144.0D) { // Folia - region threading - required in case the player suddenly moves into another dimension - this.teleportToOwner(); - } else { - this.navigation.moveTo((Entity) this.owner, this.speedModifier); -@@ -105,6 +105,11 @@ public class FollowOwnerGoal extends Goal { +- if (this.tamable.distanceToSqr((Entity) this.owner) >= 144.0D) { ++ if (!io.papermc.paper.util.TickThread.isTickThreadFor(this.owner) || this.tamable.distanceToSqr((Entity) this.owner) >= 144.0D) { // Folia - region threading - required in case the player suddenly moves into another dimension + this.teleportToOwner(); + } else { + this.navigation.moveTo((Entity) this.owner, this.speedModifier); +@@ -107,6 +107,11 @@ public class FollowOwnerGoal extends Goal { private void teleportToOwner() { BlockPos blockposition = this.owner.blockPosition(); @@ -18735,7 +18638,7 @@ index 11a101e8ff05fbda5e84018358be02014ca01854..8cfa70e9b07e0f993d172d3e4d380449 for (int i = 0; i < 10; ++i) { int j = this.randomIntInclusive(-3, 3); -@@ -135,7 +140,21 @@ public class FollowOwnerGoal extends Goal { +@@ -137,7 +142,21 @@ public class FollowOwnerGoal extends Goal { } to = event.getTo(); @@ -18759,10 +18662,10 @@ index 11a101e8ff05fbda5e84018358be02014ca01854..8cfa70e9b07e0f993d172d3e4d380449 this.navigation.stop(); return true; 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 97257b450e848f53fdb9b5b7affa57b03ea5f459..5485eba13ae544a3e5b7ff5e416c369db8f9c7bc 100644 +index 7ffe5bef3778d5971ea4ceadf3102725fd0d08cd..bd6910c279a3a319744d3c7c889a889b892a8f76 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 -@@ -79,11 +79,11 @@ public abstract class PathNavigation { +@@ -80,11 +80,11 @@ public abstract class PathNavigation { } public void recomputePath() { @@ -18776,7 +18679,7 @@ index 97257b450e848f53fdb9b5b7affa57b03ea5f459..5485eba13ae544a3e5b7ff5e416c369d this.hasDelayedRecomputation = false; } } else { -@@ -198,7 +198,7 @@ public abstract class PathNavigation { +@@ -199,7 +199,7 @@ public abstract class PathNavigation { public boolean moveTo(Entity entity, double speed) { // Paper start - Pathfinding optimizations @@ -18785,7 +18688,7 @@ index 97257b450e848f53fdb9b5b7affa57b03ea5f459..5485eba13ae544a3e5b7ff5e416c369d return false; } // Paper end -@@ -210,7 +210,7 @@ public abstract class PathNavigation { +@@ -211,7 +211,7 @@ public abstract class PathNavigation { return true; } else { this.pathfindFailures++; @@ -18977,10 +18880,10 @@ index 9be85eb0abec02bc0e0eded71c34ab1c565c63e7..9c56304476b4fc841b5d769423261758 @Override 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 0114c1cf3b6b0500149a77ebc190cb7fa2832184..1189465e79005c99204f873ca7768171218d6399 100644 +index 72b30a5cdeb8a43702d9ab5f198311929761fad1..3951a1f740839f286a190f3fda66132fc4e7ead5 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Cat.java +++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java -@@ -366,7 +366,7 @@ public class Cat extends TamableAnimal implements VariantHolder { +@@ -363,7 +363,7 @@ public class Cat extends TamableAnimal implements VariantHolder { }); ServerLevel worldserver = world.getLevel(); @@ -18990,26 +18893,26 @@ index 0114c1cf3b6b0500149a77ebc190cb7fa2832184..1189465e79005c99204f873ca7768171 this.setPersistenceRequired(); } diff --git a/src/main/java/net/minecraft/world/entity/animal/Turtle.java b/src/main/java/net/minecraft/world/entity/animal/Turtle.java -index 25503678e7d049a8b3172cfad8a5606958c32302..13d60258c6c491a7d0ba5cc93934f0c9b2abd35b 100644 +index 81dab77f525ae667614f940c4ff5ec308a9579a2..5fdb9ab7c6c0ae6bb948a44c5578c4304e8d6c3f 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Turtle.java +++ b/src/main/java/net/minecraft/world/entity/animal/Turtle.java -@@ -336,9 +336,9 @@ public class Turtle extends Animal { +@@ -337,9 +337,9 @@ public class Turtle extends Animal { @Override public void thunderHit(ServerLevel world, LightningBolt lightning) { - org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = lightning; // CraftBukkit + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamageRT.set(lightning); // CraftBukkit // Folia - region threading - this.hurt(DamageSource.LIGHTNING_BOLT, Float.MAX_VALUE); + this.hurt(this.damageSources().lightningBolt(), Float.MAX_VALUE); - org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamageRT.set(null); // CraftBukkit // Folia - region threading } private static class TurtleMoveControl extends MoveControl { diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java -index 428523feaa4f30260e32ba03937e88200246c693..5722f1dd949c8ef59379bf4499ec2d77a40df847 100644 +index 30aec9dff249ae629b22318e52902361a9fa4099..b452b566693558fa714eca2db08ca775e73d48a0 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java -@@ -290,8 +290,10 @@ public class ItemFrame extends HangingEntity { +@@ -294,8 +294,10 @@ public class ItemFrame extends HangingEntity { MapItemSavedData worldmap = MapItem.getSavedData(i, this.level); if (worldmap != null) { @@ -19021,10 +18924,10 @@ index 428523feaa4f30260e32ba03937e88200246c693..5722f1dd949c8ef59379bf4499ec2d77 }); diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -index eacb8a407fe99af2c13f23c12b5544696bda8890..723d5f44c59a8073040669549d9cab88b45e9a3e 100644 +index ce2c3c146ef64400e00084bd2245d2b87a67fbc2..c8d125955754e27da54d95fb5b1cea39ca54b618 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -292,9 +292,9 @@ public class FallingBlockEntity extends Entity { +@@ -293,9 +293,9 @@ public class FallingBlockEntity extends Entity { float f2 = (float) Math.min(Mth.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax); this.level.getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> { @@ -19037,19 +18940,19 @@ index eacb8a407fe99af2c13f23c12b5544696bda8890..723d5f44c59a8073040669549d9cab88 boolean flag = this.blockState.is(BlockTags.ANVIL); diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index f0ccdfbd7d7be8c6e302609accf8fe9cac8885c4..d07060fb35df66e77ebdd404444c58564fdb9402 100644 +index d47b3ac633e7936d30abfda6fc46c2c7412d76fe..4245973677f1e2a3a75dce74c3e010330d0a9a41 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -50,7 +50,7 @@ public class ItemEntity extends Entity { +@@ -51,7 +51,7 @@ public class ItemEntity extends Entity implements TraceableEntity { @Nullable - private UUID owner; + public UUID target; public final float bobOffs; - private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit + //private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit // Folia - region threading public boolean canMobPickup = true; // Paper private int despawnRate = -1; // Paper public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper -@@ -116,13 +116,11 @@ public class ItemEntity extends Entity { +@@ -125,13 +125,11 @@ public class ItemEntity extends Entity implements TraceableEntity { this.discard(); } else { super.tick(); @@ -19068,7 +18971,7 @@ index f0ccdfbd7d7be8c6e302609accf8fe9cac8885c4..d07060fb35df66e77ebdd404444c5856 this.xo = this.getX(); this.yo = this.getY(); -@@ -176,11 +174,11 @@ public class ItemEntity extends Entity { +@@ -185,11 +183,11 @@ public class ItemEntity extends Entity implements TraceableEntity { this.mergeWithNeighbours(); } @@ -19082,7 +18985,7 @@ index f0ccdfbd7d7be8c6e302609accf8fe9cac8885c4..d07060fb35df66e77ebdd404444c5856 this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing(); if (!this.level.isClientSide) { -@@ -207,13 +205,14 @@ public class ItemEntity extends Entity { +@@ -216,13 +214,14 @@ public class ItemEntity extends Entity implements TraceableEntity { // Spigot start - copied from above @Override public void inactiveTick() { @@ -19104,7 +19007,7 @@ index f0ccdfbd7d7be8c6e302609accf8fe9cac8885c4..d07060fb35df66e77ebdd404444c5856 if (!this.level.isClientSide && this.age >= this.despawnRate) { // Spigot // Paper // CraftBukkit start - fire ItemDespawnEvent -@@ -514,14 +513,20 @@ public class ItemEntity extends Entity { +@@ -520,14 +519,20 @@ public class ItemEntity extends Entity implements TraceableEntity { return false; } @@ -19129,10 +19032,10 @@ index f0ccdfbd7d7be8c6e302609accf8fe9cac8885c4..d07060fb35df66e77ebdd404444c5856 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 bedee2c93bd0aff148f93dcf111e0fc3d9bce4a0..718701a39d0c5369600119330cec7f8015fd95b0 100644 +index dfdf7e7fc1070975ec18fd215c724f4fc84d3705..52150e27294fcd51ae23ea3ff06673fb1ca3d113 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -59,7 +59,7 @@ public class PrimedTnt extends Entity { +@@ -60,7 +60,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { @Override public void tick() { @@ -19141,7 +19044,7 @@ index bedee2c93bd0aff148f93dcf111e0fc3d9bce4a0..718701a39d0c5369600119330cec7f80 if (!this.isNoGravity()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D)); } -@@ -101,7 +101,7 @@ public class PrimedTnt extends Entity { +@@ -102,7 +102,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. // This does pretty well at keeping their clients in sync with the server. @@ -19280,10 +19183,10 @@ index 5f407535298a31a34cfe114dd863fd6a9b977707..1f1e3d6e5e94b985a5c929ab266a9964 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 18eac340386a396c9850f53f30d20a41c1437788..81efaadf67f7bcc6097c19c05ba2fdb6b34d8218 100644 +index 6023b9eb3001e1a98ab8b970d853c4e7c7603f4d..02cf29f089adeec2ba93aabb5778f7c2e4c380af 100644 --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java +++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java -@@ -710,6 +710,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) { @@ -19292,7 +19195,7 @@ index 18eac340386a396c9850f53f30d20a41c1437788..81efaadf67f7bcc6097c19c05ba2fdb6 PoiManager villageplace = worldserver.getPoiManager(); Optional> optional = villageplace.getType(globalpos.pos()); BiPredicate> bipredicate = (BiPredicate) Villager.POI_MEMORIES.get(pos); -@@ -718,6 +720,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()); } @@ -19301,7 +19204,7 @@ index 18eac340386a396c9850f53f30d20a41c1437788..81efaadf67f7bcc6097c19c05ba2fdb6 } }); 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 0ae8e9134a3671cdf2a480cd4dd6598653e261ab..d9d832b7978d03417912408564f6e21bb5e52dc3 100644 +index ae9f9112ce9bec82e7571f679017f1723d9eb982..d9d832b7978d03417912408564f6e21bb5e52dc3 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 { @@ -19324,7 +19227,7 @@ index 0ae8e9134a3671cdf2a480cd4dd6598653e261ab..d9d832b7978d03417912408564f6e21b //this.spawnDelay = properties.getWanderingTraderSpawnDelay(); // Paper - This value is read from the world file only for the first spawn, after which vanilla uses a hardcoded value //this.spawnChance = properties.getWanderingTraderSpawnChance(); // Paper - This value is read from the world file only for the first spawn, after which vanilla uses a hardcoded value //if (this.spawnDelay == 0 && this.spawnChance == 0) { -@@ -56,36 +54,37 @@ public class WanderingTraderSpawner implements CustomSpawner { +@@ -56,37 +54,37 @@ public class WanderingTraderSpawner implements CustomSpawner { @Override public int tick(ServerLevel world, boolean spawnMonsters, boolean spawnAnimals) { @@ -19364,6 +19267,7 @@ index 0ae8e9134a3671cdf2a480cd4dd6598653e261ab..d9d832b7978d03417912408564f6e21b - int i = this.spawnChance; + int i = worldData.wanderingTraderSpawnChance; // Folia - region threading +- this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance); - this.spawnChance = Mth.clamp(i + world.paperConfig().entities.spawning.wanderingTrader.spawnChanceFailureIncrement, world.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin, world.paperConfig().entities.spawning.wanderingTrader.spawnChanceMax); + worldData.wanderingTraderSpawnChance = Mth.clamp(i + world.paperConfig().entities.spawning.wanderingTrader.spawnChanceFailureIncrement, world.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin, world.paperConfig().entities.spawning.wanderingTrader.spawnChanceMax); // Folia - region threading //this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance); // Paper - We don't need to save this value to disk if it gets set back to a hardcoded value anyways @@ -19375,7 +19279,7 @@ index 0ae8e9134a3671cdf2a480cd4dd6598653e261ab..d9d832b7978d03417912408564f6e21b // Paper end return 1; } else { -@@ -97,7 +96,7 @@ public class WanderingTraderSpawner implements CustomSpawner { +@@ -98,7 +96,7 @@ public class WanderingTraderSpawner implements CustomSpawner { } private boolean spawn(ServerLevel world) { @@ -19384,7 +19288,7 @@ index 0ae8e9134a3671cdf2a480cd4dd6598653e261ab..d9d832b7978d03417912408564f6e21b if (entityplayer == null) { return true; -@@ -127,7 +126,7 @@ public class WanderingTraderSpawner implements CustomSpawner { +@@ -128,7 +126,7 @@ public class WanderingTraderSpawner implements CustomSpawner { this.tryToSpawnLlamaFor(world, entityvillagertrader, 4); } @@ -19394,7 +19298,7 @@ index 0ae8e9134a3671cdf2a480cd4dd6598653e261ab..d9d832b7978d03417912408564f6e21b entityvillagertrader.setWanderTarget(blockposition1); entityvillagertrader.restrictTo(blockposition1, 16); 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 9788e477ff1446ad2ea3669922cc7dfc09900ce8..b3ff974a8e77810b79b179e5f46d5b8b14cf1ae0 100644 +index 5d6d26cfe8f0ab68a3145214b3fc126ca7a71a66..c8be8b54859e39967ede5c53ce940da39a68563e 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java @@ -149,6 +149,11 @@ public abstract class AbstractArrow extends Projectile { @@ -19410,7 +19314,7 @@ index 9788e477ff1446ad2ea3669922cc7dfc09900ce8..b3ff974a8e77810b79b179e5f46d5b8b 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 97231f7328f0eebffcacdae5469027be8aeec3ae..6c3d7118b08445a430e200688234d5d4230a94fd 100644 +index 2096e8a0bdbcfc865f175f3a01ab688542481531..8e072c1ae653258722fce7b50cd27076988d9666 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java @@ -77,6 +77,11 @@ public abstract class AbstractHurtingProjectile extends Projectile { @@ -19426,62 +19330,63 @@ index 97231f7328f0eebffcacdae5469027be8aeec3ae..6c3d7118b08445a430e200688234d5d4 this.setSecondsOnFire(1); } diff --git a/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java b/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java -index c7265a650a5d6bdc42d41c5c90cad401d7f1c99d..c95d80ee142dc056874af6baf2d058cc932985e9 100644 +index d8a2b5e0e0ff640bcc827f1b1310bd19b9154cc2..2a4542a9bcb990e276796fb042d9f780cc7b63dd 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java +++ b/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java -@@ -128,9 +128,9 @@ public class EvokerFangs extends Entity { +@@ -129,9 +129,9 @@ public class EvokerFangs extends Entity implements TraceableEntity { if (target.isAlive() && !target.isInvulnerable() && target != entityliving1) { if (entityliving1 == null) { - org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = this; // CraftBukkit + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamageRT.set(this); // CraftBukkit // Folia - region threading - target.hurt(DamageSource.MAGIC, 6.0F); + target.hurt(this.damageSources().magic(), 6.0F); - org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamageRT.set(null); // CraftBukkit // Folia - region threading } else { if (entityliving1.isAlliedTo((Entity) target)) { return; 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 5406925cd66f46ab8744123c670d72cea7bfc3a1..d0fa197283a3bf14ead356e832500430ecae3f86 100644 +index fca27f98989bf106060ba08196255fe32f850df5..98c9eda4056093d8d230ac56ac407c39556ba2cb 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -130,6 +130,10 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { +@@ -129,6 +129,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { }); } -+ if (this.attachedToEntity != null && !io.papermc.paper.util.TickThread.isTickThreadFor(this.attachedToEntity)) { // Folia start - region threading ++ // Folia start - region threading ++ if (this.attachedToEntity != null && !io.papermc.paper.util.TickThread.isTickThreadFor(this.attachedToEntity)) { + this.attachedToEntity = null; + } + // Folia end - region threading if (this.attachedToEntity != null) { if (this.attachedToEntity.isFallFlying()) { -@@ -241,9 +245,9 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { +@@ -240,9 +245,9 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { if (f > 0.0F) { if (this.attachedToEntity != null) { - CraftEventFactory.entityDamage = this; // CraftBukkit + CraftEventFactory.entityDamageRT.set(this); // CraftBukkit // Folia - region threading - this.attachedToEntity.hurt(DamageSource.fireworks(this, this.getOwner()), 5.0F + (float) (nbttaglist.size() * 2)); + this.attachedToEntity.hurt(this.damageSources().fireworks(this, this.getOwner()), 5.0F + (float) (nbttaglist.size() * 2)); - CraftEventFactory.entityDamage = null; // CraftBukkit + CraftEventFactory.entityDamageRT.set(null); // CraftBukkit // Folia - region threading } double d0 = 5.0D; -@@ -270,9 +274,9 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { +@@ -269,9 +274,9 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { if (flag) { float f1 = f * (float) Math.sqrt((5.0D - (double) this.distanceTo(entityliving)) / 5.0D); - CraftEventFactory.entityDamage = this; // CraftBukkit + CraftEventFactory.entityDamageRT.set(this); // CraftBukkit // Folia - region threading - entityliving.hurt(DamageSource.fireworks(this, this.getOwner()), f1); + entityliving.hurt(this.damageSources().fireworks(this, this.getOwner()), f1); - CraftEventFactory.entityDamage = null; // CraftBukkit + CraftEventFactory.entityDamageRT.set(null); // CraftBukkit // Folia - region threading } } } 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 7f3a7a769afec8449547c26453112064b9bcb04a..5429cd3f6ee08609c91a25751acedc5936d3e49f 100644 +index d77410588a1c10d8ac902f21a8bd7e35f74fecd2..675a01ec82b31140594beace0f0b651be096f90e 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java @@ -98,7 +98,7 @@ public class FishingHook extends Projectile { @@ -19502,10 +19407,10 @@ index 7f3a7a769afec8449547c26453112064b9bcb04a..5429cd3f6ee08609c91a25751acedc59 double d3 = vec3d.length(); 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 4132c1113f5437a776e5e3c1cb306904775aed88..a756a7373985152eceaa03255e3f0fb39c53d081 100644 +index c4f4a26e016eea744f587461af80461074d48303..42f6481eb92a3aa91010c235f08ea6581e36573e 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/LlamaSpit.java +++ b/src/main/java/net/minecraft/world/entity/projectile/LlamaSpit.java -@@ -31,6 +31,11 @@ public class LlamaSpit extends Projectile { +@@ -30,6 +30,11 @@ public class LlamaSpit extends Projectile { public void tick() { super.tick(); Vec3 vec3d = this.getDeltaMovement(); @@ -19518,10 +19423,10 @@ index 4132c1113f5437a776e5e3c1cb306904775aed88..a756a7373985152eceaa03255e3f0fb3 this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event 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 66476b33cede1e44db5ec166a0cea81f82ffe47a..26a17e3098317f6f623cdcab59dceb9d213c7f63 100644 +index 8b2a3a8482018b7db7de81bc295862f783e17ce5..ad8cff8bc7f12a48e2b5c9bbc30b33676d61853b 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -52,8 +52,19 @@ public abstract class Projectile extends Entity { +@@ -53,9 +53,20 @@ public abstract class Projectile extends Entity implements TraceableEntity { } @@ -19529,6 +19434,7 @@ index 66476b33cede1e44db5ec166a0cea81f82ffe47a..26a17e3098317f6f623cdcab59dceb9d + // In general, this is an entire mess. At the time of writing, there are fifty usages of getOwner. + // Usage of this function is to avoid concurrency issues, even if it sacrifices behavior. @Nullable + @Override public Entity getOwner() { + Entity ret = this.getOwnerRaw(); + return io.papermc.paper.util.TickThread.isTickThreadFor(ret) ? ret : null; @@ -19541,7 +19447,7 @@ index 66476b33cede1e44db5ec166a0cea81f82ffe47a..26a17e3098317f6f623cdcab59dceb9d if (this.cachedOwner != null && !this.cachedOwner.isRemoved()) { return this.cachedOwner; } else if (this.ownerUUID != null && this.level instanceof ServerLevel) { -@@ -273,6 +284,6 @@ public abstract class Projectile extends Entity { +@@ -277,6 +288,6 @@ public abstract class Projectile extends Entity implements TraceableEntity { public boolean mayInteract(Level world, BlockPos pos) { Entity entity = this.getOwner(); @@ -19550,7 +19456,7 @@ index 66476b33cede1e44db5ec166a0cea81f82ffe47a..26a17e3098317f6f623cdcab59dceb9d } } 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 00ac1cdc4734cc57f15433c5c6e7a3a545739d33..39b0034b7c612759fed87b6a5fff1819583f3f85 100644 +index b9e4955fecabbad8d6762f3d933ea1402e932d9b..e026f2517a0714bba0f51aa2bf087c1babb55990 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/SmallFireball.java +++ b/src/main/java/net/minecraft/world/entity/projectile/SmallFireball.java @@ -23,7 +23,7 @@ public class SmallFireball extends Fireball { @@ -19579,11 +19485,11 @@ index 88181c59e604ba3b132b9e695cef5eaf5b836029..0146b150b6cb70a7272e8d9781e100a0 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 f224ebbc0efefddede43d87f0300c014077b9931..2627610b77e779722bb33eeb1096d862aa9639d2 100644 +index 39ab9a283d856ba8d578d1378285758e32a24cf0..2b35495df87614c3578727598ebf1b4469829154 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -44,6 +44,62 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { - entityHitResult.getEntity().hurt(DamageSource.thrown(this, this.getOwner()), 0.0F); +@@ -43,6 +43,62 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { + entityHitResult.getEntity().hurt(this.damageSources().thrown(this, this.getOwner()), 0.0F); } + // Folia start - region threading @@ -19622,16 +19528,16 @@ index f224ebbc0efefddede43d87f0300c014077b9931..2627610b77e779722bb33eeb1096d862 + + // endermite spawn chance + if (world.random.nextFloat() < 0.05F && world.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { -+ Endermite entityendermite = EntityType.ENDERMITE.create(world); ++ Endermite entityendermite = (Endermite) EntityType.ENDERMITE.create(world); + + if (entityendermite != null) { -+ entityendermite.moveTo(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot()); ++ entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot()); + world.addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); + } + } + + // damage player -+ player.hurt(DamageSource.FALL, 5.0F); ++ player.hurt(player.damageSources().fall(), 5.0F); + } + } + ); @@ -19645,7 +19551,7 @@ index f224ebbc0efefddede43d87f0300c014077b9931..2627610b77e779722bb33eeb1096d862 @Override protected void onHit(HitResult hitResult) { super.onHit(hitResult); -@@ -53,6 +109,20 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -52,6 +108,20 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { } if (!this.level.isClientSide && !this.isRemoved()) { @@ -19666,19 +19572,19 @@ index f224ebbc0efefddede43d87f0300c014077b9931..2627610b77e779722bb33eeb1096d862 Entity entity = this.getOwner(); if (entity instanceof ServerPlayer) { -@@ -84,9 +154,9 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -83,9 +153,9 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { entityplayer.connection.teleport(teleEvent.getTo()); entity.resetFallDistance(); - CraftEventFactory.entityDamage = this; + CraftEventFactory.entityDamageRT.set(this); // Folia - region threading - entity.hurt(DamageSource.FALL, 5.0F); + entity.hurt(this.damageSources().fall(), 5.0F); - CraftEventFactory.entityDamage = null; + CraftEventFactory.entityDamageRT.set(null); // Folia - region threading } // CraftBukkit end } -@@ -112,6 +182,14 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -111,6 +181,14 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { } @@ -19694,7 +19600,7 @@ index f224ebbc0efefddede43d87f0300c014077b9931..2627610b77e779722bb33eeb1096d862 @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 08b18428e867baf14f551beb72e3875b0c420639..941e74fe6f66a1e7d1a909e2dcf494eba0704058 100644 +index 879c3bb661e24b9682b654def57c2800f4f8ca92..359f1690497eac00899eb26c17308e0a6fe943ad 100644 --- a/src/main/java/net/minecraft/world/entity/raid/Raid.java +++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java @@ -108,6 +108,13 @@ public class Raid { @@ -19730,7 +19636,7 @@ index 08b18428e867baf14f551beb72e3875b0c420639..941e74fe6f66a1e7d1a909e2dcf494eb 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 e5ccbaf72f29731f1d1aa939b9297b644a408cd4..1792655d2f0357b388b3c83886cac4bc109e1aa9 100644 +index 99e9d46d42ddd0b451c6aeb847f1b295ebe5c697..9bc6b5a0b476e019e719709e68314d8e84d55a59 100644 --- a/src/main/java/net/minecraft/world/entity/raid/Raider.java +++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java @@ -91,7 +91,7 @@ public abstract class Raider extends PatrollingMonster { @@ -19743,7 +19649,7 @@ index e5ccbaf72f29731f1d1aa939b9297b644a408cd4..1792655d2f0357b388b3c83886cac4bc 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 feb89eb69994bdd1d2f95d2b9992e69251b2bee7..39cdb5c0080613662eaefc4f94d17fa1bd25ed30 100644 +index fabce3bc592b1b172b227395a07febdbb66ec3c9..ebdbadc1dba41f47ba4795ea43020b80102f5ccb 100644 --- a/src/main/java/net/minecraft/world/entity/raid/Raids.java +++ b/src/main/java/net/minecraft/world/entity/raid/Raids.java @@ -28,14 +28,14 @@ import net.minecraft.world.phys.Vec3; @@ -19862,10 +19768,10 @@ index feb89eb69994bdd1d2f95d2b9992e69251b2bee7..39cdb5c0080613662eaefc4f94d17fa1 if (raid1.isActive() && d1 < d0) { 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 70f1916185b79bbb9f033f4ef8119d7b17a13ef8..54d55e8827f4ab286fca722f199aac42cddab8d2 100644 +index 1b8f22805af87dc08e0dea9fd93a5f93c0b05107..9c265574f02616c924c0de1b82f4499816b53b94 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java -@@ -155,7 +155,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +@@ -128,7 +128,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper // Paper start public void immunize() { @@ -19875,10 +19781,10 @@ index 70f1916185b79bbb9f033f4ef8119d7b17a13ef8..54d55e8827f4ab286fca722f199aac42 // 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 9c8604376228c02f8bbd9a15673fbdf5097e7cb2..40410ce889ef18344291f04d29938b4d1d3c9766 100644 +index d7a0cbde8f8c99276307502674c71463fbe7e89c..2a501b3fa8d69f627b279fd035fd2cb11d590f06 100644 --- a/src/main/java/net/minecraft/world/item/ArmorItem.java +++ b/src/main/java/net/minecraft/world/item/ArmorItem.java -@@ -63,7 +63,7 @@ public class ArmorItem extends Item implements Wearable { +@@ -68,7 +68,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()); @@ -19888,10 +19794,10 @@ index 9c8604376228c02f8bbd9a15673fbdf5097e7cb2..40410ce889ef18344291f04d29938b4d } diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 6860096cb8c0deecc9c1d87543d1128fb95fd2d4..9e11c7310ad83a2550affe2dc84721f4ab70db96 100644 +index a6253272205337b3b855679b3057c2519a807a4c..291d55866a4f5da3409a96675cc71e153ce3e5fd 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -333,6 +333,7 @@ public final class ItemStack { +@@ -334,6 +334,7 @@ public final class ItemStack { } public InteractionResult useOn(UseOnContext itemactioncontext, InteractionHand enumhand) { // CraftBukkit - add hand @@ -19899,7 +19805,7 @@ index 6860096cb8c0deecc9c1d87543d1128fb95fd2d4..9e11c7310ad83a2550affe2dc84721f4 net.minecraft.world.entity.player.Player entityhuman = itemactioncontext.getPlayer(); BlockPos blockposition = itemactioncontext.getClickedPos(); BlockInWorld shapedetectorblock = new BlockInWorld(itemactioncontext.getLevel(), blockposition, false); -@@ -344,12 +345,13 @@ public final class ItemStack { +@@ -345,12 +346,13 @@ public final class ItemStack { CompoundTag oldData = this.getTagClone(); int oldCount = this.getCount(); ServerLevel world = (ServerLevel) itemactioncontext.getLevel(); @@ -19915,7 +19821,7 @@ index 6860096cb8c0deecc9c1d87543d1128fb95fd2d4..9e11c7310ad83a2550affe2dc84721f4 } } Item item = this.getItem(); -@@ -358,14 +360,14 @@ public final class ItemStack { +@@ -359,14 +361,14 @@ public final class ItemStack { int newCount = this.getCount(); this.setCount(oldCount); this.setTagClone(oldData); @@ -19928,16 +19834,16 @@ index 6860096cb8c0deecc9c1d87543d1128fb95fd2d4..9e11c7310ad83a2550affe2dc84721f4 Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); - TreeType treeType = SaplingBlock.treeType; - SaplingBlock.treeType = null; -- List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); +- List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); - world.capturedBlockStates.clear(); + TreeType treeType = SaplingBlock.treeTypeRT.get(); // Folia - region threading + SaplingBlock.treeTypeRT.set(null); // Folia - region threading -+ List blocks = new java.util.ArrayList<>(worldData.capturedBlockStates.values()); // Folia - region threading ++ List blocks = new java.util.ArrayList<>(worldData.capturedBlockStates.values()); // Folia - region threading + worldData.capturedBlockStates.clear(); // Folia - region threading StructureGrowEvent structureEvent = null; if (treeType != null) { boolean isBonemeal = this.getItem() == Items.BONE_MEAL; -@@ -392,12 +394,12 @@ public final class ItemStack { +@@ -393,12 +395,12 @@ public final class ItemStack { SignItem.openSign = null; // SPIGOT-6758 - Reset on early return return enuminteractionresult; } @@ -19953,7 +19859,7 @@ index 6860096cb8c0deecc9c1d87543d1128fb95fd2d4..9e11c7310ad83a2550affe2dc84721f4 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 - don't call event twice for snow buckets -@@ -408,13 +410,13 @@ public final class ItemStack { +@@ -409,13 +411,13 @@ public final class ItemStack { enuminteractionresult = InteractionResult.FAIL; // cancel placement // PAIL: Remove this when MC-99075 fixed placeEvent.getPlayer().updateInventory(); @@ -19970,7 +19876,7 @@ index 6860096cb8c0deecc9c1d87543d1128fb95fd2d4..9e11c7310ad83a2550affe2dc84721f4 // Brute force all possible updates BlockPos placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition(); -@@ -429,7 +431,7 @@ public final class ItemStack { +@@ -430,7 +432,7 @@ public final class ItemStack { this.setCount(newCount); } @@ -19979,7 +19885,7 @@ index 6860096cb8c0deecc9c1d87543d1128fb95fd2d4..9e11c7310ad83a2550affe2dc84721f4 world.setBlockEntity(e.getValue()); } -@@ -490,8 +492,8 @@ public final class ItemStack { +@@ -504,8 +506,8 @@ public final class ItemStack { entityhuman.awardStat(Stats.ITEM_USED.get(item)); } } @@ -20173,7 +20079,7 @@ index 3b959f42d958bf0f426853aee56753d6c455fcdb..b1a6a66ed02706c1adc36dcedfa415f5 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 a213f4098859858a73ddd601bbe8c7511972e0d5..07aa859ccfd3283097c172672c5d80130187cd4c 100644 +index 59837144c2c0460aca6e8c349eb3d6528111d1dc..7f32d5d5b709e8bb0395ccbeada2322c6e89cea3 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java @@ -246,7 +246,7 @@ public class Explosion { @@ -20185,7 +20091,7 @@ index a213f4098859858a73ddd601bbe8c7511972e0d5..07aa859ccfd3283097c172672c5d8013 entity.lastDamageCancelled = false; if (entity instanceof EnderDragon) { -@@ -259,7 +259,7 @@ public class Explosion { +@@ -262,7 +262,7 @@ public class Explosion { entity.hurt(this.getDamageSource(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f2 + 1.0D))); } @@ -20194,7 +20100,7 @@ index a213f4098859858a73ddd601bbe8c7511972e0d5..07aa859ccfd3283097c172672c5d8013 if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled continue; } -@@ -503,17 +503,10 @@ public class Explosion { +@@ -515,17 +515,10 @@ public class Explosion { } // Paper start - Optimize explosions private float getBlockDensity(Vec3 vec3d, Entity entity) { @@ -20215,10 +20121,10 @@ index a213f4098859858a73ddd601bbe8c7511972e0d5..07aa859ccfd3283097c172672c5d8013 static class CacheKey { diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a3b8b63c8 100644 +index 944da18bcc993ab0488a34cbbe9df134c355301a..54e5b4eb2cc0d77e20edcf677b0ffed10cd27a4c 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -116,10 +116,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -118,10 +118,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; @@ -20233,7 +20139,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a public final Thread thread; private final boolean isDebug; private int skyDarken; -@@ -129,7 +129,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -131,7 +131,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public float rainLevel; protected float oThunderLevel; public float thunderLevel; @@ -20242,16 +20148,16 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a /** @deprecated */ @Deprecated private final RandomSource threadSafeRandom = RandomSource.createThreadSafe(); -@@ -141,7 +141,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - private final WorldBorder worldBorder; - private final BiomeManager biomeManager; +@@ -145,7 +145,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { private final ResourceKey dimension; + private final RegistryAccess registryAccess; + private final DamageSources damageSources; - private long subTickCount; + private final java.util.concurrent.atomic.AtomicLong subTickCount = new java.util.concurrent.atomic.AtomicLong(); //private long subTickCount; // Folia - region threading // CraftBukkit start Added the following private final CraftWorld world; -@@ -150,20 +150,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -154,20 +154,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public org.bukkit.generator.ChunkGenerator generator; public static final boolean DEBUG_ENTITIES = Boolean.getBoolean("debug.entities"); // Paper @@ -20275,7 +20181,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot // Paper start private final io.papermc.paper.configuration.WorldConfiguration paperConfig; -@@ -177,9 +167,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -181,9 +171,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public static BlockPos lastPhysicsProblem; // Spigot private org.spigotmc.TickLimiter entityLimiter; private org.spigotmc.TickLimiter tileLimiter; @@ -20288,7 +20194,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a // Paper start - fix and optimise world upgrading // copied from below -@@ -223,7 +213,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -227,7 +217,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { List ret = new java.util.ArrayList<>(); double maxRangeSquared = maxRange * maxRange; @@ -20297,7 +20203,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a if ((maxRange < 0.0 || player.distanceToSqr(sourceX, sourceY, sourceZ) < maxRangeSquared)) { if (predicate == null || predicate.test(player)) { ret.add(player); -@@ -239,7 +229,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -243,7 +233,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { net.minecraft.server.level.ServerPlayer closest = null; double closestRangeSquared = maxRange < 0.0 ? Double.MAX_VALUE : maxRange * maxRange; @@ -20306,15 +20212,15 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a double distanceSquared = player.distanceToSqr(sourceX, sourceY, sourceZ); if (distanceSquared < closestRangeSquared && (predicate == null || predicate.test(player))) { closest = player; -@@ -270,6 +260,24 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -274,6 +264,24 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public abstract ResourceKey getTypeKey(); + // Folia start - region ticking + public final io.papermc.paper.threadedregions.RegionisedData worldRegionData + = new io.papermc.paper.threadedregions.RegionisedData<>( -+ (ServerLevel)this, () -> new io.papermc.paper.threadedregions.RegionisedWorldData((ServerLevel)Level.this), -+ io.papermc.paper.threadedregions.RegionisedWorldData.REGION_CALLBACK ++ (ServerLevel)this, () -> new io.papermc.paper.threadedregions.RegionisedWorldData((ServerLevel)Level.this), ++ io.papermc.paper.threadedregions.RegionisedWorldData.REGION_CALLBACK + ); + public volatile io.papermc.paper.threadedregions.RegionisedServer.WorldLevelData tickData; + @@ -20328,30 +20234,30 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a + } + // Folia end - region ticking + - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, 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 - Async-Anti-Xray - Pass executor + 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 - 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 -@@ -313,7 +321,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -317,7 +325,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { this.thread = Thread.currentThread(); this.biomeManager = new BiomeManager(this, i); this.isDebug = flag1; - this.neighborUpdater = new CollectingNeighborUpdater(this, j); + this.neighbourUpdateMax = j; // Folia - region threading + this.registryAccess = iregistrycustom; + this.damageSources = new DamageSources(iregistrycustom); // CraftBukkit start - this.getWorldBorder().world = (ServerLevel) this; - // From PlayerList.setPlayerFileData -@@ -452,8 +460,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -458,8 +466,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Nullable - public final BlockState getBlockStateIfLoaded(BlockPos blockposition) { + public final BlockState getBlockStateIfLoaded(BlockPos pos) { // CraftBukkit start - tree generation -- if (captureTreeGeneration) { -- CraftBlockState previous = capturedBlockStates.get(blockposition); +- if (this.captureTreeGeneration) { +- CraftBlockState previous = this.capturedBlockStates.get(pos); + if (this.getCurrentWorldData().captureTreeGeneration) { // Folia - region threading -+ CraftBlockState previous = this.getCurrentWorldData().capturedBlockStates.get(blockposition); // Folia - region threading ++ CraftBlockState previous = this.getCurrentWorldData().capturedBlockStates.get(pos); // Folia - region threading if (previous != null) { return previous.getHandle(); } -@@ -514,16 +522,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -521,16 +529,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) { @@ -20370,9 +20276,9 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a - this.capturedBlockStates.put(pos.immutable(), blockstate); + worldData.capturedBlockStates.put(pos.immutable(), blockstate); // Folia - region threading } + blockstate.setFlag(flags); // Paper - update the flag also blockstate.setData(state); - return true; -@@ -539,10 +548,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -547,10 +556,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // CraftBukkit start - capture blockstates boolean captured = false; @@ -20385,7 +20291,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a captured = true; } // CraftBukkit end -@@ -552,8 +561,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -560,8 +569,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (iblockdata1 == null) { // CraftBukkit start - remove blockstate if failed (or the same) @@ -20396,7 +20302,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a } // CraftBukkit end return false; -@@ -596,7 +605,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -604,7 +613,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { */ // CraftBukkit start @@ -20405,7 +20311,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a // Modularize client and physic updates // Spigot start try { -@@ -645,7 +654,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -653,7 +662,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // CraftBukkit start 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(); @@ -20414,7 +20320,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata)); this.getCraftServer().getPluginManager().callEvent(event); -@@ -659,7 +668,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -667,7 +676,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } // CraftBukkit start - SPIGOT-5710 @@ -20423,7 +20329,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); } // CraftBukkit end -@@ -738,7 +747,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -746,7 +755,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public void neighborShapeChanged(Direction direction, BlockState neighborState, BlockPos pos, BlockPos neighborPos, int flags, int maxUpdateDepth) { @@ -20432,7 +20338,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a } @Override -@@ -763,11 +772,24 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -771,11 +780,24 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return this.getChunkSource().getLightEngine(); } @@ -20459,7 +20365,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a if (previous != null) { return previous.getHandle(); } -@@ -858,7 +880,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -866,7 +888,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } public void addBlockEntityTicker(TickingBlockEntity ticker) { @@ -20468,7 +20374,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a } protected void tickBlockEntities() { -@@ -866,11 +888,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -874,11 +896,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { gameprofilerfiller.push("blockEntities"); timings.tileEntityPending.startTiming(); // Spigot @@ -20484,7 +20390,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a timings.tileEntityPending.stopTiming(); // Spigot timings.tileEntityTick.startTiming(); // Spigot -@@ -879,9 +900,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -887,9 +908,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { int tilesThisCycle = 0; var toRemove = new it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet(net.minecraft.Util.identityStrategy()); // Paper - use removeAll toRemove.add(null); @@ -20496,7 +20402,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a // Spigot start if (tickingblockentity == null) { this.getCraftServer().getLogger().severe("Spigot has detected a null entity and has removed it, preventing a crash"); -@@ -898,19 +918,19 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -906,19 +926,19 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) { tickingblockentity.tick(); // Paper start - execute chunk tasks during tick @@ -20521,7 +20427,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a } public void guardEntityTick(Consumer tickConsumer, T entity) { -@@ -1006,9 +1026,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1014,9 +1034,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Nullable public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) { @@ -20537,7 +20443,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a return blockEntity; } // Paper end -@@ -1021,8 +1046,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1029,8 +1054,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (!this.isOutsideBuildHeight(blockposition)) { // CraftBukkit start @@ -20548,7 +20454,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a return; } // CraftBukkit end -@@ -1226,13 +1251,30 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1234,13 +1259,30 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public void disconnect() {} @@ -20581,7 +20487,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a public boolean mayInteract(Player player, BlockPos pos) { return true; -@@ -1438,8 +1480,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1442,8 +1484,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 @@ -20591,7 +20497,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a out.set(x + (i1 & 15), y + (i1 >> 16 & l), z + (i1 >> 8 & 15)); // Paper - change to setValues call return out; // Paper -@@ -1470,7 +1511,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1474,7 +1515,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @Override public long nextSubTickCount() { @@ -20599,7 +20505,7 @@ index 60003ff929f7ac6b34f9230c53ccbd54dc9e176b..467e51fd2cb695ecf282757da82e133a + return this.subTickCount.getAndIncrement(); // Folia - region threading } - public static enum ExplosionInteraction { + @Override diff --git a/src/main/java/net/minecraft/world/level/LevelAccessor.java b/src/main/java/net/minecraft/world/level/LevelAccessor.java index 73d1adc5ddf0363966eac0c77c8dfbbb20a2b6a3..375a2b57bcb29458443c1a4e2be3c0e5f4e6019c 100644 --- a/src/main/java/net/minecraft/world/level/LevelAccessor.java @@ -20676,7 +20582,7 @@ index 7fe1b8856bf916796fa6d2a984f0a07a2331e23b..07802d0a25e49519c3c9b33c217e0500 @Deprecated default boolean hasChunksAt(int minX, int minZ, int maxX, int maxZ) { diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 01b21f520ef1c834b9bafc3de85c1fa4fcf539d6..99bc2e30e3a35929de7cff65bf0a69f25d93d5c2 100644 +index 15d266fc97eb73338f4f6fb2cfe25d6861e79810..52a7d5ef4a25bee618d9c9a784df95a2341fe015 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java @@ -115,11 +115,7 @@ public final class NaturalSpawner { @@ -20759,7 +20665,7 @@ 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 bad7031426ae6c750ae4376beb238186e7d65270..070d8fe9e016ad03be2c1fb5f22379f80ad3f155 100644 +index 09c85ed428b8eaf51f8b3c6e45cce925f05ab354..3d797880b5964dd07f3757495ea1255a034aad89 100644 --- a/src/main/java/net/minecraft/world/level/StructureManager.java +++ b/src/main/java/net/minecraft/world/level/StructureManager.java @@ -44,11 +44,8 @@ public class StructureManager { @@ -20807,10 +20713,10 @@ index bad7031426ae6c750ae4376beb238186e7d65270..070d8fe9e016ad03be2c1fb5f22379f8 } 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 7b71073027f4cf79736546500ededdfbb83d968e..6c6b7b94e875dce36619461e3994b148148e7f8a 100644 +index 4f91e4832a94c3facbc711fcae4cb5ad540a5ca0..e5ca38b375becfb3a10fb94739bdaed354c426c6 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 { +@@ -394,8 +394,8 @@ public class Block extends BlockBehaviour implements ItemLike { entityitem.setDefaultPickUpDelay(); // CraftBukkit start @@ -20835,39 +20741,39 @@ index 03fde6e47c4a347c62fe9b4a3351769aedf874f6..d2e3e1d20d60f5edd0d93709b808f812 } } diff --git a/src/main/java/net/minecraft/world/level/block/CactusBlock.java b/src/main/java/net/minecraft/world/level/block/CactusBlock.java -index 1ec242205b82a5a1f10deb2312795cc5dc157a76..ae08011006851493ad315f2490a4374877b2a02d 100644 +index 7579946ce222b6ab3685a7fd9821bcd5a4babe33..08f0360e12087cdce0671a0f3f782b62a75bac47 100644 --- a/src/main/java/net/minecraft/world/level/block/CactusBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CactusBlock.java -@@ -118,9 +118,9 @@ public class CactusBlock extends Block { +@@ -117,9 +117,9 @@ public class CactusBlock extends Block { @Override public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - CraftEventFactory.blockDamage = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); // CraftBukkit + CraftEventFactory.blockDamageRT.set(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); // CraftBukkit // Folia - region threading - entity.hurt(DamageSource.CACTUS, 1.0F); + entity.hurt(world.damageSources().cactus(), 1.0F); - CraftEventFactory.blockDamage = null; // CraftBukkit + CraftEventFactory.blockDamageRT.set(null); // CraftBukkit // Folia - region threading } @Override diff --git a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java b/src/main/java/net/minecraft/world/level/block/CampfireBlock.java -index a4c44cb59dee29cf227dbb51bfc1576d89dfb2e3..3d3f85e10c56dc95a0b6e576bd4b8d33a9daa8a3 100644 +index 219c87dcf065e86512f330fbeec59e55f4675083..90e56394554b2b6d5dd12fa7f1f5279dc9a38478 100644 --- a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CampfireBlock.java -@@ -95,9 +95,9 @@ public class CampfireBlock extends BaseEntityBlock implements SimpleWaterloggedB +@@ -94,9 +94,9 @@ public class CampfireBlock extends BaseEntityBlock implements SimpleWaterloggedB public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper if ((Boolean) state.getValue(CampfireBlock.LIT) && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity) entity)) { - org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = CraftBlock.at(world, pos); // CraftBukkit + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamageRT.set(CraftBlock.at(world, pos)); // CraftBukkit // Folia - region threading - entity.hurt(DamageSource.IN_FIRE, (float) this.fireDamage); + entity.hurt(world.damageSources().inFire(), (float) this.fireDamage); - org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamageRT.set(null); // CraftBukkit // Folia - region threading } super.entityInside(state, world, pos, entity); 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 16504b8be08064e61b013fa943f692816612cbd0..076c6209725bac9268c19c7bfec7b5a94f2ea9a1 100644 +index 81376e725151f723dad8a7b5c1a4bd597e60294e..a9876256edd5354015e83d943a83d1c0e4060d4e 100644 --- a/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java @@ -113,7 +113,7 @@ public class DaylightDetectorBlock extends BaseEntityBlock { @@ -20902,7 +20808,7 @@ index 8f55d0753fa26924235c943595f0d1a06a933a6f..a195d37847e3278d7721641b5db85891 } 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 e234ae13fe9793db237adb6f6216fa32638cfc4f..9447bc16dcd7ecfa941081197d5e4c34f78c79d4 100644 +index 9db66b393e057d93a8025b803ae0ad2a1bca61f6..bace9a699aa6aeaec417434730a7ca6dd9983946 100644 --- a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java @@ -95,7 +95,7 @@ public class DoublePlantBlock extends BushBlock { @@ -20931,10 +20837,10 @@ index 9d0fc6b5b8d8fb31cacf7e8b346b9babf1a3e8a2..85701eba8dea71c64f92d5eaf99cb232 // 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 683f24251baf8ef3bef8f32ba83dc7f0e8ed7d70..b0352a9f05ad1ec49314d505dc99ed7b29ed09c3 100644 +index 29efe50dd3911a1d7ef5175034e82191130b8fd1..83810585125403a8ed1f85ff3dfc0f2d6ec40c75 100644 --- a/src/main/java/net/minecraft/world/level/block/HoneyBlock.java +++ b/src/main/java/net/minecraft/world/level/block/HoneyBlock.java -@@ -81,7 +81,7 @@ public class HoneyBlock extends HalfTransparentBlock { +@@ -80,7 +80,7 @@ public class HoneyBlock extends HalfTransparentBlock { } private void maybeDoSlideAchievement(Entity entity, BlockPos pos) { @@ -20957,16 +20863,16 @@ index da3b301a42a93c891d083a6e02d1be8ed35adf1d..f354981843868bf938be0b5ac1ef2ce3 } } diff --git a/src/main/java/net/minecraft/world/level/block/MagmaBlock.java b/src/main/java/net/minecraft/world/level/block/MagmaBlock.java -index d3540a4daaa8021ae009bfd4d9ef4f1172ab4c56..336a4797d114ccfad319086c68e3546bdf3f6fe1 100644 +index 12ffb5714f088f4aeafa1ad6a36f5b64a86c4c96..57eceff3fd313449c6db02c7719ad9f74ed15b17 100644 --- a/src/main/java/net/minecraft/world/level/block/MagmaBlock.java +++ b/src/main/java/net/minecraft/world/level/block/MagmaBlock.java -@@ -29,9 +29,9 @@ public class MagmaBlock extends Block { +@@ -28,9 +28,9 @@ public class MagmaBlock extends Block { @Override public void stepOn(Level world, BlockPos pos, BlockState state, Entity entity) { if (!entity.isSteppingCarefully() && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity) entity)) { - org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); // CraftBukkit + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamageRT.set(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); // CraftBukkit // Folia - region threading - entity.hurt(DamageSource.HOT_FLOOR, 1.0F); + entity.hurt(world.damageSources().hotFloor(), 1.0F); - org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamageRT.set(null); // CraftBukkit // Folia - region threading } @@ -20986,7 +20892,7 @@ index f6f8e155223cba10c4073ddca602d1aa3aa872d7..bc42faf2f5cf54197849b1ad133a8851 return true; } else { diff --git a/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java b/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java -index e78fdd317d59cfca6a28deb6e0bd02aabe91e930..c2cb07426d22ff0c14dfa24cc2ead785eaaf1903 100644 +index 6b909d41ccdf6c1ac3ac0c4e673ff52f0d14a238..e7079e164f5943f21aff487c22c525f7bf98911f 100644 --- a/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java @@ -143,9 +143,9 @@ public class PointedDripstoneBlock extends Block implements Fallable, SimpleWate @@ -20995,7 +20901,7 @@ index e78fdd317d59cfca6a28deb6e0bd02aabe91e930..c2cb07426d22ff0c14dfa24cc2ead785 if (state.getValue(PointedDripstoneBlock.TIP_DIRECTION) == Direction.UP && state.getValue(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) { - CraftEventFactory.blockDamage = CraftBlock.at(world, pos); // CraftBukkit + CraftEventFactory.blockDamageRT.set(CraftBlock.at(world, pos)); // CraftBukkit // Folia - region threading - entity.causeFallDamage(fallDistance + 2.0F, 2.0F, DamageSource.STALAGMITE); + entity.causeFallDamage(fallDistance + 2.0F, 2.0F, world.damageSources().stalagmite()); - CraftEventFactory.blockDamage = null; // CraftBukkit + CraftEventFactory.blockDamageRT.set(null); // CraftBukkit // Folia - region threading } else { @@ -21231,16 +21137,16 @@ index af46c05a34292d271fd4a809398e6b299e10b12b..49a8d37b9c77dbc869c03e9f495efeee 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/SweetBerryBushBlock.java b/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java -index c926cd3ebb916115a608e86b389ffe7e15d48cd7..5375f79c6d5e05f4202a6363eaf50e6e6548a789 100644 +index 08a11888133b97e52535cb49cad218a1b6c6ac97..9d9564d603d5b05e60dc48d85039c384157a0dad 100644 --- a/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java -@@ -86,9 +86,9 @@ public class SweetBerryBushBlock extends BushBlock implements BonemealableBlock +@@ -85,9 +85,9 @@ public class SweetBerryBushBlock extends BushBlock implements BonemealableBlock double d1 = Math.abs(entity.getZ() - entity.zOld); if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { - CraftEventFactory.blockDamage = CraftBlock.at(world, pos); // CraftBukkit + CraftEventFactory.blockDamageRT.set(CraftBlock.at(world, pos)); // CraftBukkit // Folia - region threading - entity.hurt(DamageSource.SWEET_BERRY_BUSH, 1.0F); + entity.hurt(world.damageSources().sweetBerryBush(), 1.0F); - CraftEventFactory.blockDamage = null; // CraftBukkit + CraftEventFactory.blockDamageRT.set(null); // CraftBukkit // Folia - region threading } @@ -21260,7 +21166,7 @@ index b91effe91dad2e1aeea0ea31140f7432833b343f..46979b4ee8c24b499577aa64167c7596 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 928625b5ab054ffa412be8a438f58291cc7a3cc0..bbc051be1c3a2697e33cc316e328760b838af243 100644 +index ef740d1ad6352ca4af299001a081b720bc472d2e..cf41ff83b1465b89e96d029b72530cdba10f3d99 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 @@ -202,7 +202,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name @@ -21273,14 +21179,14 @@ index 928625b5ab054ffa412be8a438f58291cc7a3cc0..bbc051be1c3a2697e33cc316e328760b 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 58986bc0677c5ea1ad54d7d6d4efa5c2ea233aea..ac1f6d5c78c1970b3242c017031679fb9a906fb0 100644 +index 1b248db497500aa6bd346b306dcb908af77626f3..ac1f6d5c78c1970b3242c017031679fb9a906fb0 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 import co.aikar.timings.Timing; // Paper public abstract class BlockEntity { -- static boolean IGNORE_TILE_UPDATES = false; // Paper +- static boolean ignoreTileUpdates; // Paper + static final ThreadLocal IGNORE_TILE_UPDATES = ThreadLocal.withInitial(() -> Boolean.FALSE); // Paper // Folia - region threading public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper @@ -21302,16 +21208,16 @@ index 58986bc0677c5ea1ad54d7d6d4efa5c2ea233aea..ac1f6d5c78c1970b3242c017031679fb public void setChanged() { if (this.level != null) { -- if (IGNORE_TILE_UPDATES) return; // Paper +- if (ignoreTileUpdates) return; // Paper + if (IGNORE_TILE_UPDATES.get()) return; // Paper // Folia - region threading BlockEntity.setChanged(this.level, this.worldPosition, this.blockState); } 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 55006724ccec9f3de828ec18693728e9741ff65f..9e806ba83240916d422c4a736a9cfd61e73108e4 100644 +index c57efcb9a79337ec791e4e8f6671612f0a82b441..526d1bfd5ad0de7bcfd0c2da902515f3dec94c54 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 -@@ -54,7 +54,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -56,7 +56,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements public int fuel; protected final ContainerData dataAccess; // CraftBukkit start - add fields and methods @@ -21320,7 +21226,7 @@ index 55006724ccec9f3de828ec18693728e9741ff65f..9e806ba83240916d422c4a736a9cfd61 public List transaction = new java.util.ArrayList(); private int maxStack = 64; -@@ -171,11 +171,10 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements +@@ -173,11 +173,10 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements ItemStack itemstack1 = (ItemStack) blockEntity.items.get(3); // CraftBukkit start - Use wall time instead of ticks for brewing @@ -21335,10 +21241,10 @@ index 55006724ccec9f3de828ec18693728e9741ff65f..9e806ba83240916d422c4a736a9cfd61 // CraftBukkit end 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 05eab04e4aec4151018f25b59f92ddbbb4c09f87..2a6e3eb2ec74e8b1a356b5a62ec5f8521da00380 100644 +index 963a596154091b79ca139af6274aa323518ad1ad..57b11cb78270a8094f772da497ad3264a0a67db1 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 -@@ -88,7 +88,7 @@ public class ConduitBlockEntity extends BlockEntity { +@@ -87,7 +87,7 @@ public class ConduitBlockEntity extends BlockEntity { public static void clientTick(Level world, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity) { ++blockEntity.tickCount; @@ -21347,7 +21253,7 @@ index 05eab04e4aec4151018f25b59f92ddbbb4c09f87..2a6e3eb2ec74e8b1a356b5a62ec5f852 List list = blockEntity.effectBlocks; if (i % 40L == 0L) { -@@ -106,7 +106,7 @@ public class ConduitBlockEntity extends BlockEntity { +@@ -105,7 +105,7 @@ public class ConduitBlockEntity extends BlockEntity { public static void serverTick(Level world, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity) { ++blockEntity.tickCount; @@ -21356,13 +21262,13 @@ index 05eab04e4aec4151018f25b59f92ddbbb4c09f87..2a6e3eb2ec74e8b1a356b5a62ec5f852 List list = blockEntity.effectBlocks; if (i % 40L == 0L) { -@@ -236,11 +236,11 @@ public class ConduitBlockEntity extends BlockEntity { +@@ -235,11 +235,11 @@ public class ConduitBlockEntity extends BlockEntity { if (blockEntity.destroyTarget != null) { // CraftBukkit start - CraftEventFactory.blockDamage = CraftBlock.at(world, pos); + CraftEventFactory.blockDamageRT.set(CraftBlock.at(world, pos)); // Folia - region threading - if (blockEntity.destroyTarget.hurt(DamageSource.MAGIC, 4.0F)) { + if (blockEntity.destroyTarget.hurt(world.damageSources().magic(), 4.0F)) { world.playSound((Player) null, blockEntity.destroyTarget.getX(), blockEntity.destroyTarget.getY(), blockEntity.destroyTarget.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F); } - CraftEventFactory.blockDamage = null; @@ -21371,95 +21277,95 @@ index 05eab04e4aec4151018f25b59f92ddbbb4c09f87..2a6e3eb2ec74e8b1a356b5a62ec5f852 } 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 ccad692aba2ed77259f6814d88f01b91ed9d229b..955f6560f4c6032d375927987c9bb62561ed5034 100644 +index cba114f554644a37339c93026630c66c43f524b9..ee224ab6b8be3308f5b9f58967ae117c49e00750 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 -@@ -189,12 +189,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - return false; +@@ -194,12 +194,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } + // Paper start - Optimize Hoppers -- private static boolean skipPullModeEventFire = false; -- private static boolean skipPushModeEventFire = false; -- public static boolean skipHopperEvents = false; +- private static boolean skipPullModeEventFire; +- private static boolean skipPushModeEventFire; +- public static boolean skipHopperEvents; + // Folia - region threading - moved to RegionisedWorldData - private static boolean hopperPush(Level level, BlockPos pos, Container destination, Direction enumdirection, HopperBlockEntity hopper) { + private static boolean hopperPush(final Level level, final Container destination, final Direction direction, final HopperBlockEntity hopper) { - skipPushModeEventFire = skipHopperEvents; + io.papermc.paper.threadedregions.RegionisedWorldData worldData = level.getCurrentWorldData(); // Folia - region threading + worldData.skipPushModeEventFire = worldData.skipHopperEvents; // Folia - region threading boolean foundItem = false; for (int i = 0; i < hopper.getContainerSize(); ++i) { - ItemStack item = hopper.getItem(i); -@@ -209,7 +208,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + final ItemStack item = hopper.getItem(i); +@@ -214,7 +213,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. - if (!skipPushModeEventFire) { + if (!worldData.skipPushModeEventFire) { // Folia - region threading - itemstack = callPushMoveEvent(destination, itemstack, hopper); - if (itemstack == null) { // cancelled - origItemStack.setCount(origCount); -@@ -238,12 +237,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + movedItem = callPushMoveEvent(destination, movedItem, hopper); + if (movedItem == null) { // cancelled + origItemStack.setCount(originalItemCount); +@@ -244,12 +243,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } - private static boolean hopperPull(Level level, Hopper ihopper, Container iinventory, ItemStack origItemStack, int i) { + private static boolean hopperPull(final Level level, final Hopper hopper, final Container container, ItemStack origItemStack, final int i) { + io.papermc.paper.threadedregions.RegionisedWorldData worldData = level.getCurrentWorldData(); // Folia - region threading - ItemStack itemstack = origItemStack; - final int origCount = origItemStack.getCount(); - final int moved = Math.min(level.spigotConfig.hopperAmount, origCount); - itemstack.setCount(moved); + ItemStack movedItem = origItemStack; + final int originalItemCount = origItemStack.getCount(); + final int movedItemCount = Math.min(level.spigotConfig.hopperAmount, originalItemCount); + movedItem.setCount(movedItemCount); - if (!skipPullModeEventFire) { + if (!worldData.skipPullModeEventFire) { // Folia - region threading - itemstack = callPullMoveEvent(ihopper, iinventory, itemstack); - if (itemstack == null) { // cancelled - origItemStack.setCount(origCount); -@@ -262,9 +262,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - if (!origItemStack.isEmpty()) { - origItemStack.setCount(origCount - moved + remaining); + movedItem = callPullMoveEvent(hopper, container, movedItem); + if (movedItem == null) { // cancelled + origItemStack.setCount(originalItemCount); +@@ -269,9 +269,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + origItemStack.setCount(originalItemCount - movedItemCount + remainingItemCount); } -- IGNORE_TILE_UPDATES = true; + +- ignoreTileUpdates = true; + IGNORE_TILE_UPDATES.set(true); // Folia - region threading - iinventory.setItem(i, origItemStack); -- IGNORE_TILE_UPDATES = false; + container.setItem(i, origItemStack); +- ignoreTileUpdates = false; + IGNORE_TILE_UPDATES.set(false); // Folia - region threading - iinventory.setChanged(); + container.setChanged(); return true; } -@@ -278,12 +278,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - } +@@ -286,12 +286,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + @Nullable private static ItemStack callPushMoveEvent(Container iinventory, ItemStack itemstack, HopperBlockEntity hopper) { + io.papermc.paper.threadedregions.RegionisedWorldData worldData = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegionisedWorldData(); // Folia - region threading - Inventory destinationInventory = getInventory(iinventory); - InventoryMoveItemEvent event = new InventoryMoveItemEvent(hopper.getOwner(false).getInventory(), + final Inventory destinationInventory = getInventory(iinventory); + final InventoryMoveItemEvent event = new InventoryMoveItemEvent(hopper.getOwner(false).getInventory(), CraftItemStack.asCraftMirror(itemstack), destinationInventory, true); - boolean result = event.callEvent(); + final boolean result = event.callEvent(); if (!event.calledGetItem && !event.calledSetItem) { - skipPushModeEventFire = true; + worldData.skipPushModeEventFire = true; // Folia - region threading } if (!result) { cooldownHopper(hopper); -@@ -298,6 +299,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - } +@@ -307,6 +308,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - private static ItemStack callPullMoveEvent(Hopper hopper, Container iinventory, ItemStack itemstack) { + @Nullable + private static ItemStack callPullMoveEvent(final Hopper hopper, final Container container, final ItemStack itemstack) { + io.papermc.paper.threadedregions.RegionisedWorldData worldData = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegionisedWorldData(); // Folia - region threading - Inventory sourceInventory = getInventory(iinventory); - Inventory destination = getInventory(hopper); + final Inventory sourceInventory = getInventory(container); + final Inventory destination = getInventory(hopper); -@@ -306,7 +308,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - CraftItemStack.asCraftMirror(itemstack), destination, false); - boolean result = event.callEvent(); +@@ -314,7 +316,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + final InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, CraftItemStack.asCraftMirror(itemstack), destination, false); + final boolean result = event.callEvent(); if (!event.calledGetItem && !event.calledSetItem) { - skipPullModeEventFire = true; + worldData.skipPullModeEventFire = true; // Folia - region threading } if (!result) { cooldownHopper(hopper); -@@ -447,13 +449,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - // Paper end +@@ -459,13 +461,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + } public static boolean suckInItems(Level world, Hopper hopper) { + io.papermc.paper.threadedregions.RegionisedWorldData worldData = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegionisedWorldData(); // Folia - region threading @@ -21473,21 +21379,21 @@ index ccad692aba2ed77259f6814d88f01b91ed9d229b..955f6560f4c6032d375927987c9bb625 + worldData.skipPullModeEventFire = worldData.skipHopperEvents; // Folia - region threading return !HopperBlockEntity.isEmptyContainer(iinventory, enumdirection) && anyMatch(iinventory, enumdirection, (item, i) -> { // Logic copied from below to avoid extra getItem calls - if (!item.isEmpty() && canTakeItemFromContainer(iinventory, item, i, enumdirection)) { -@@ -592,9 +595,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + if (!item.isEmpty() && canTakeItemFromContainer(hopper, iinventory, item, i, enumdirection)) { +@@ -646,9 +649,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen stack = stack.split(to.getMaxStackSize()); } // Spigot end -- IGNORE_TILE_UPDATES = true; // Paper +- ignoreTileUpdates = true; // Paper + IGNORE_TILE_UPDATES.set(true); // Paper // Folia - region threading to.setItem(slot, stack); -- IGNORE_TILE_UPDATES = false; // Paper +- ignoreTileUpdates = false; // Paper + IGNORE_TILE_UPDATES.set(false); // Paper // Folia - region threading stack = leftover; // Paper 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 163e63e3c538c7c1c75ed634896db9d8c00416f3..740cb2858a3f78298895a463fb0fac9e88a9a4a0 100644 +index 902f2b39104bf059849228829bfe93b6dbc757d4..9a6c51652bd2dbb3d474809372df03038e34ce75 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 @@ -86,9 +86,9 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi @@ -21503,7 +21409,7 @@ index 163e63e3c538c7c1c75ed634896db9d8c00416f3..740cb2858a3f78298895a463fb0fac9e @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 f80545f80948db27d1fbde77d0505c916eb504ed..3b656e7d5e8b75f8f415d5f43ed5c91da963731b 100644 +index c73024cc62490c336ffe26313580e88d25ca7078..197f9f54fc0cf61cf55528d9215bc6001805e398 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 { @@ -21780,10 +21686,10 @@ index 28e3b73507b988f7234cbf29c4024c88180d0aef..c8facee29ee08e0975528083f89b64f0 + BlockEntity getTileEntity(); // Folia - region threading } diff --git a/src/main/java/net/minecraft/world/level/block/grower/AbstractTreeGrower.java b/src/main/java/net/minecraft/world/level/block/grower/AbstractTreeGrower.java -index df41c210a0c06a2789fe4944fe1b9c2ba9509b61..c774545cbe195b71ebf3ee86cf6450a7ced61d4b 100644 +index a743f36f2682a6b72ffa6644782fc081d1479eb7..f5263a71d97f404c6f6dbd3354a5ed2e98bb71db 100644 --- a/src/main/java/net/minecraft/world/level/block/grower/AbstractTreeGrower.java +++ b/src/main/java/net/minecraft/world/level/block/grower/AbstractTreeGrower.java -@@ -75,49 +75,51 @@ public abstract class AbstractTreeGrower { +@@ -75,51 +75,53 @@ public abstract class AbstractTreeGrower { // CraftBukkit start protected void setTreeType(Holder> holder) { ResourceKey> worldgentreeabstract = holder.unwrapKey().get(); @@ -21848,6 +21754,9 @@ index df41c210a0c06a2789fe4944fe1b9c2ba9509b61..c774545cbe195b71ebf3ee86cf6450a7 } else if (worldgentreeabstract == TreeFeatures.TALL_MANGROVE) { - SaplingBlock.treeType = TreeType.TALL_MANGROVE; + treeType = TreeType.TALL_MANGROVE; // Folia - region threading + } else if (worldgentreeabstract == TreeFeatures.CHERRY || worldgentreeabstract == TreeFeatures.CHERRY_BEES_005) { +- SaplingBlock.treeType = TreeType.CHERRY; ++ treeType = TreeType.CHERRY; // Folia - region threading } else { throw new IllegalArgumentException("Unknown tree generator " + worldgentreeabstract); } @@ -21871,7 +21780,7 @@ index 221c5d080d55326e458c1182823d6b49224ef498..29a27534e6c97b262229b51e4ea03455 break; } 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 7a12a4da4864306ec6589ca81368e84718825047..e3ef5ccad7f8a8138b1372f419680409ddeab291 100644 +index 204f008dc36212e696fba781fede88044b2f735a..1bc2b24deba7a534478184a6a3f3d41184a86734 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 { @@ -21900,10 +21809,10 @@ index 7a12a4da4864306ec6589ca81368e84718825047..e3ef5ccad7f8a8138b1372f419680409 // Paper end 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 7e9c388179c75a233d9b179ea1e00428ac65ee99..df83966cb2be368aaee95f3b8563e01ab807d816 100644 +index 42ecfc1237bfc724dc9134a6a8bae3670251449e..2fbfdf1fdba12417e2dbca041b9c7e29af27d02d 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -308,7 +308,7 @@ public abstract class ChunkGenerator { +@@ -306,7 +306,7 @@ public abstract class ChunkGenerator { return Pair.of(placement.getLocatePos(pos), holder); } @@ -21912,7 +21821,7 @@ index 7e9c388179c75a233d9b179ea1e00428ac65ee99..df83966cb2be368aaee95f3b8563e01a structurestart = structureAccessor.getStartForStructure(SectionPos.bottomOf(ichunkaccess), (Structure) holder.value(), ichunkaccess); } while (structurestart == null); -@@ -319,7 +319,7 @@ public abstract class ChunkGenerator { +@@ -317,7 +317,7 @@ public abstract class ChunkGenerator { } private static boolean tryAddReference(StructureManager structureAccessor, StructureStart start) { @@ -21922,7 +21831,7 @@ index 7e9c388179c75a233d9b179ea1e00428ac65ee99..df83966cb2be368aaee95f3b8563e01a 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 e776eb8afef978938da084f9ae29d611181b43fe..d270f6b5937e167f18c3f358c99a9f6f3cde9c7a 100644 +index 9599af33c683ec47e28b1c8e4dc965d30d9081a7..f4c4951f815062c2791531a703ed8cbe9337d574 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -61,6 +61,13 @@ public class LevelChunk extends ChunkAccess { @@ -22084,7 +21993,7 @@ index e776eb8afef978938da084f9ae29d611181b43fe..d270f6b5937e167f18c3f358c99a9f6f if (this.blockTicks.isDirty(gameTime) || this.fluidTicks.isDirty(gameTime)) { return true; } -@@ -1213,6 +1171,13 @@ public class LevelChunk extends ChunkAccess { +@@ -1225,6 +1183,13 @@ public class LevelChunk extends ChunkAccess { this.ticker = wrapped; } @@ -22098,7 +22007,7 @@ index e776eb8afef978938da084f9ae29d611181b43fe..d270f6b5937e167f18c3f358c99a9f6f @Override public void tick() { this.ticker.tick(); -@@ -1249,6 +1214,13 @@ public class LevelChunk extends ChunkAccess { +@@ -1261,6 +1226,13 @@ public class LevelChunk extends ChunkAccess { this.ticker = blockentityticker; } @@ -22113,10 +22022,10 @@ index e776eb8afef978938da084f9ae29d611181b43fe..d270f6b5937e167f18c3f358c99a9f6f 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 256642f2e2aa66f7e8c00cae91a75060a8817c9c..9fb91e3648db3ad79bb6d1fe79894a13ddc07cbb 100644 +index 9d6f4749ed72fe319754ccea28f20fa97286527d..3c9ae42290c2e0cb70bb08e97f3ea2c3fb594c7d 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 -@@ -687,7 +687,7 @@ public class ChunkSerializer { +@@ -686,7 +686,7 @@ public class ChunkSerializer { } private static void saveTicks(ServerLevel world, CompoundTag nbt, ChunkAccess.TicksToSave tickSchedulers) { @@ -22232,7 +22141,7 @@ index a908652f1ebb426d265ef614746f70cd1e538268..b2a9cd719c4968a1cde8f0b30f46f01d 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 1c3718d9244513d9fc795dceb564a81375734557..f445e1db1538fb9eda4b2f81f62748dc57fda24a 100644 +index e8ae4449696d73c8c9b8b27d4d2e20db933a72cc..cd4bac707744a98d4577f9b3f47b817f43ff15ab 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java +++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java @@ -24,7 +24,7 @@ import net.minecraft.world.level.material.FluidState; @@ -22272,10 +22181,10 @@ index 1c3718d9244513d9fc795dceb564a81375734557..f445e1db1538fb9eda4b2f81f62748dc while (iterator.hasNext()) { Player entityhuman = (Player) iterator.next(); diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java -index 4761aa772bc34dd66547dd4dd561c2e04c3229ad..ac4648773c9d6316db4915d515991219589fa473 100644 +index 1ca00340aaa201dd34e5c350d23ef53e126a0ca6..cf664ed17c6c138aed2a8680b51480ded47a2e50 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java -@@ -51,8 +51,101 @@ public class StructureCheck { +@@ -50,8 +50,101 @@ public class StructureCheck { private final BiomeSource biomeSource; private final long seed; private final DataFixer fixerUpper; @@ -22379,7 +22288,7 @@ index 4761aa772bc34dd66547dd4dd561c2e04c3229ad..ac4648773c9d6316db4915d515991219 public StructureCheck(ChunkScanAccess chunkIoWorker, RegistryAccess registryManager, StructureTemplateManager structureTemplateManager, ResourceKey worldKey, ChunkGenerator chunkGenerator, RandomState noiseConfig, LevelHeightAccessor world, BiomeSource biomeSource, long seed, DataFixer dataFixer) { // Paper - fix missing CB diff this.storageAccess = chunkIoWorker; -@@ -71,7 +164,7 @@ public class StructureCheck { +@@ -70,7 +163,7 @@ public class StructureCheck { public StructureCheckResult checkStart(ChunkPos pos, Structure type, boolean skipReferencedStructures) { long l = pos.toLong(); @@ -22388,7 +22297,7 @@ index 4761aa772bc34dd66547dd4dd561c2e04c3229ad..ac4648773c9d6316db4915d515991219 if (object2IntMap != null) { return this.checkStructureInfo(object2IntMap, type, skipReferencedStructures); } else { -@@ -79,9 +172,9 @@ public class StructureCheck { +@@ -78,9 +171,9 @@ public class StructureCheck { if (structureCheckResult != null) { return structureCheckResult; } else { @@ -22401,7 +22310,7 @@ index 4761aa772bc34dd66547dd4dd561c2e04c3229ad..ac4648773c9d6316db4915d515991219 return this.canCreateStructure(pos, type); }); return !bl ? StructureCheckResult.START_NOT_PRESENT : StructureCheckResult.CHUNK_LOAD_NEEDED; -@@ -194,17 +287,26 @@ public class StructureCheck { +@@ -193,17 +286,26 @@ public class StructureCheck { } private void storeFullResults(long pos, Object2IntMap referencesByStructure) { @@ -22527,7 +22436,7 @@ index b1c594dc6a6b8a6c737b99272acab9e7dbd0ed63..7c1768452fa0f7278ccc84470ef0965a 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 c8cdcf40e45f5c6270f9b124f0333643266e2858..b370ba924b03cc0a36666ee6ed26be06a6affaa7 100644 +index 353e602d476beea23e591ad770227c5d6c1e97fa..6f254ee89e1f2eb2b853888e2ff1259cd1f9a6db 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/SavedData.java +++ b/src/main/java/net/minecraft/world/level/saveddata/SavedData.java @@ -10,7 +10,7 @@ import org.slf4j.Logger; @@ -22546,7 +22455,7 @@ index c8cdcf40e45f5c6270f9b124f0333643266e2858..b370ba924b03cc0a36666ee6ed26be06 + 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.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion()); + NbtUtils.addCurrentDataVersion(compoundTag); @@ -38,7 +39,7 @@ public abstract class SavedData { LOGGER.error("Could not save data {}", this, var4); } @@ -22583,7 +22492,7 @@ index 9b2948b5150c8f039ca667a50765109721b93947..1b76e4edce628f2b25815e28cd4cb750 } } 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 b2845ed8d28627178589da3d2224cd9edd29c31e..5121569f389ee4a50273432a9a272a936542fa12 100644 +index 50348a5eec1e2ffabfc8405d708461376a162913..56e277f328a18e342c1adbe19660a31cbb175ba9 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 @@ -185,7 +185,7 @@ public class MapItemSavedData extends SavedData { @@ -22610,7 +22519,7 @@ index b2845ed8d28627178589da3d2224cd9edd29c31e..5121569f389ee4a50273432a9a272a93 - 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, (int) 0, (int) 4), this.trackingPosition, this.unlimitedTracking, this.dimension); + return MapItemSavedData.createFresh((double) this.centerX, (double) this.centerZ, (byte) Mth.clamp(this.scale + zoomOutScale, 0, 4), this.trackingPosition, this.unlimitedTracking, this.dimension); } - public void tickCarriedBy(Player player, ItemStack stack) { @@ -22748,7 +22657,7 @@ index b2845ed8d28627178589da3d2224cd9edd29c31e..5121569f389ee4a50273432a9a272a93 } } 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 2da78bc43af715fe399eac1d83b3bf6e8fb8afac..433a9302f496a297172c02f3fe0404174cc7a8f1 100644 +index defe31a5d3aa89a3d18b94f2ff005594e38754b3..55609e5bfb2e1d6d8d832355080f520ec7f5b7e7 100644 --- a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java @@ -36,6 +36,7 @@ public class DimensionDataStorage { @@ -22817,7 +22726,7 @@ index ac807277a6b26d140ea9873d17c7aa4fb5fe37b2..e13d8700593f1f486cfc5c96ac258942 public LevelChunkTicks() { } diff --git a/src/main/java/net/minecraft/world/ticks/LevelTicks.java b/src/main/java/net/minecraft/world/ticks/LevelTicks.java -index 7f1ac2cb29eb84833c0895442d611dfa0504527e..c79cfebc65fd04994735dabcf5bb6e6cc714aca8 100644 +index 1d7c663fa0e550bd0cfb9a4b83ccd7e2968666f0..e559b54a5d3d5f07ed6f96347a8697a21a55ede0 100644 --- a/src/main/java/net/minecraft/world/ticks/LevelTicks.java +++ b/src/main/java/net/minecraft/world/ticks/LevelTicks.java @@ -42,13 +42,70 @@ public class LevelTicks implements LevelTickAccess { @@ -22922,10 +22831,10 @@ index 7f1ac2cb29eb84833c0895442d611dfa0504527e..c79cfebc65fd04994735dabcf5bb6e6c 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 2ea3778ee1348e5d06b15a2c5dc5d9bd4136dbe3..34dd05b737ee02200c5973ad21a600b2e2434d07 100644 +index e0b6c737f9de2b6e692d6813d8dea4c35f038573..5fa6b219b90bcf3f583eb64cf5eecf09bc56a406 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -307,6 +307,81 @@ public final class CraftServer implements Server { +@@ -303,6 +303,81 @@ public final class CraftServer implements Server { CraftItemFactory.instance(); } @@ -23007,7 +22916,7 @@ index 2ea3778ee1348e5d06b15a2c5dc5d9bd4136dbe3..34dd05b737ee02200c5973ad21a600b2 public CraftServer(DedicatedServer console, PlayerList playerList) { this.console = console; this.playerList = (DedicatedPlayerList) playerList; -@@ -879,6 +954,9 @@ public final class CraftServer implements Server { +@@ -856,6 +931,9 @@ public final class CraftServer implements Server { // NOTE: Should only be called from DedicatedServer.ah() public boolean dispatchServerCommand(CommandSender sender, ConsoleInput serverCommand) { @@ -23017,7 +22926,7 @@ index 2ea3778ee1348e5d06b15a2c5dc5d9bd4136dbe3..34dd05b737ee02200c5973ad21a600b2 if (sender instanceof Conversable) { Conversable conversable = (Conversable) sender; -@@ -898,12 +976,44 @@ public final class CraftServer implements Server { +@@ -875,12 +953,44 @@ public final class CraftServer implements Server { } } @@ -23062,7 +22971,7 @@ index 2ea3778ee1348e5d06b15a2c5dc5d9bd4136dbe3..34dd05b737ee02200c5973ad21a600b2 // Paper Start if (!org.spigotmc.AsyncCatcher.shuttingDown && !Bukkit.isPrimaryThread()) { final CommandSender fSender = sender; -@@ -2913,7 +3023,7 @@ public final class CraftServer implements Server { +@@ -2894,7 +3004,7 @@ public final class CraftServer implements Server { @Override public int getCurrentTick() { @@ -23072,7 +22981,7 @@ index 2ea3778ee1348e5d06b15a2c5dc5d9bd4136dbe3..34dd05b737ee02200c5973ad21a600b2 @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index d33476ffa49d7f6388bb227f8a57cf115a74698f..6d1d49811af39e8c943404d82e8acd64f3ee297a 100644 +index ff6559bf563f2fdcc0f2843d4f4aa24d7ddfb6db..b760e7c6608f991fc1fded531778904deab32ea4 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -180,7 +180,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -23173,7 +23082,7 @@ index d33476ffa49d7f6388bb227f8a57cf115a74698f..6d1d49811af39e8c943404d82e8acd64 } @Override -@@ -1853,7 +1856,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1858,7 +1861,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(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(CraftSound.getSoundEffect(sound)), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, this.getHandle().getRandom().nextLong()); @@ -23182,7 +23091,7 @@ index d33476ffa49d7f6388bb227f8a57cf115a74698f..6d1d49811af39e8c943404d82e8acd64 if (entityTracker != null) { entityTracker.broadcastAndSend(packet); } -@@ -2339,7 +2342,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2355,7 +2358,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 @@ -23191,7 +23100,7 @@ index d33476ffa49d7f6388bb227f8a57cf115a74698f..6d1d49811af39e8c943404d82e8acd64 net.minecraft.world.level.chunk.LevelChunk immediate = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); if (immediate != null) { return java.util.concurrent.CompletableFuture.completedFuture(immediate.getBukkitChunk()); -@@ -2356,7 +2359,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2372,7 +2375,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) -> { @@ -23213,7 +23122,7 @@ index fb6454cc64ebc549f61ad7d51efb16ef15f8384d..903408d4d8f9ce5c9566ec96312281ab 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 350cbf64c17938021002d5fd67176c44b398231e..0399f8d0d5ede68ef61fb094b278e519fba9a5d3 100644 +index 962c950ca9c7e047a3aec215d4faa73676049d36..e4ff805381be84d88c11ab7643b10920cfcbcfeb 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -568,16 +568,17 @@ public class CraftBlock implements Block { @@ -23264,10 +23173,10 @@ index cd4ad8261e56365850068db1d83d6a8454026737..c098ae9f057a3dcc77c61555feb87045 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 78f53ee557276de85f0431ebcb146445b1f4fb92..91a11cfa430c63455e2d54125d6e1bd407f822ac 100644 +index 57a0dbb23a32123d30c3b3572f4d129be9d97847..3f46d9398add0e97a2b8b072f66b48b0e056d023 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -200,6 +200,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -203,6 +203,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { private EntityDamageEvent lastDamageEvent; private final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftEntity.DATA_TYPE_REGISTRY); protected net.kyori.adventure.pointer.Pointers adventure$pointers; // Paper - implement pointers @@ -23284,10 +23193,10 @@ index 78f53ee557276de85f0431ebcb146445b1f4fb92..91a11cfa430c63455e2d54125d6e1bd4 public CraftEntity(final CraftServer server, final Entity entity) { this.server = server; -@@ -556,6 +566,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -567,6 +577,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override - public boolean teleport(Location location, TeleportCause cause, boolean ignorePassengers, boolean dismount) { + public boolean teleport(Location location, TeleportCause cause, io.papermc.paper.entity.TeleportFlag... flags) { + // Folia start - region threading + if (true) { + throw new UnsupportedOperationException("Must use teleportAsync while in region threading"); @@ -23296,7 +23205,7 @@ index 78f53ee557276de85f0431ebcb146445b1f4fb92..91a11cfa430c63455e2d54125d6e1bd4 // Paper end Preconditions.checkArgument(location != null, "location cannot be null"); location.checkFinite(); -@@ -1206,7 +1221,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -1244,7 +1259,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } ServerLevel world = ((CraftWorld) this.getWorld()).getHandle(); @@ -23305,7 +23214,7 @@ index 78f53ee557276de85f0431ebcb146445b1f4fb92..91a11cfa430c63455e2d54125d6e1bd4 if (entityTracker == null) { return; -@@ -1270,30 +1285,38 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -1308,30 +1323,38 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { Preconditions.checkArgument(location != null, "location"); location.checkFinite(); Location locationClone = location.clone(); // clone so we don't need to worry about mutations after this call. @@ -23364,10 +23273,10 @@ index 78f53ee557276de85f0431ebcb146445b1f4fb92..91a11cfa430c63455e2d54125d6e1bd4 @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 0351eb67bac6ce257f820af60aa3bba9f45da687..7b29843302d7aba8e64a2533a4b2203e9f30ecca 100644 +index 100f057f98b2f15972afe32fade22a7a320cf300..9ee05436a26c73f99bb5e0eae43831d7bd385975 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -563,7 +563,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -564,7 +564,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void kickPlayer(String message) { @@ -23376,7 +23285,7 @@ index 0351eb67bac6ce257f820af60aa3bba9f45da687..7b29843302d7aba8e64a2533a4b2203e if (this.getHandle().connection == null) return; this.getHandle().connection.disconnect(message == null ? "" : message, org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); // Paper - kick event cause -@@ -1702,7 +1702,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1779,7 +1779,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { private void unregisterEntity(Entity other) { // Paper end ChunkMap tracker = ((ServerLevel) this.getHandle().level).getChunkSource().chunkMap; @@ -23385,7 +23294,7 @@ index 0351eb67bac6ce257f820af60aa3bba9f45da687..7b29843302d7aba8e64a2533a4b2203e if (entry != null) { entry.removePlayer(this.getHandle()); } -@@ -1765,7 +1765,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1858,7 +1858,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { this.getHandle().connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(otherPlayer))); } @@ -23395,21 +23304,21 @@ index 0351eb67bac6ce257f820af60aa3bba9f45da687..7b29843302d7aba8e64a2533a4b2203e 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 6a52ae70b5f7fd9953b6b2605cae722f606e7fec..2a6fe4a3fdba9d0027a2e445b694afc80a18053c 100644 +index cdb8ec04f4a19ec3dbedbd5b17a7d1f3afaa238e..49c68ee30436232663b8d4dd15991e19b5f59d09 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -228,8 +228,8 @@ import org.bukkit.event.entity.SpawnerSpawnEvent; // Spigot +@@ -227,8 +227,8 @@ import org.bukkit.potion.PotionEffect; + import org.bukkit.event.entity.SpawnerSpawnEvent; // Spigot + public class CraftEventFactory { - public static final DamageSource MELTING = CraftDamageSource.copyOf(DamageSource.ON_FIRE); - public static final DamageSource POISON = CraftDamageSource.copyOf(DamageSource.MAGIC); - public static org.bukkit.block.Block blockDamage; // For use in EntityDamageByBlockEvent - public static Entity entityDamage; // For use in EntityDamageByEntityEvent -+ public static final ThreadLocal blockDamageRT = new ThreadLocal<>(); // For use in EntityDamageByBlockEvent -+ public static final ThreadLocal entityDamageRT = new ThreadLocal<>(); // For use in EntityDamageByEntityEvent ++ public static final ThreadLocal blockDamageRT = new ThreadLocal<>(); // For use in EntityDamageByBlockEvent // Folia - region threading ++ public static final ThreadLocal entityDamageRT = new ThreadLocal<>(); // For use in EntityDamageByEntityEvent // Folia - region threading // helper methods private static boolean canBuild(ServerLevel world, Player player, int x, int z) { -@@ -842,7 +842,7 @@ public class CraftEventFactory { +@@ -841,7 +841,7 @@ public class CraftEventFactory { return CraftEventFactory.handleBlockSpreadEvent(world, source, target, block, 2); } @@ -23418,7 +23327,7 @@ index 6a52ae70b5f7fd9953b6b2605cae722f606e7fec..2a6fe4a3fdba9d0027a2e445b694afc8 public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState block, int flag) { // Suppress during worldgen if (!(world instanceof Level)) { -@@ -853,7 +853,7 @@ public class CraftEventFactory { +@@ -852,7 +852,7 @@ public class CraftEventFactory { CraftBlockState state = CraftBlockStates.getBlockState(world, target, flag); state.setData(block); @@ -23427,9 +23336,9 @@ index 6a52ae70b5f7fd9953b6b2605cae722f606e7fec..2a6fe4a3fdba9d0027a2e445b694afc8 Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { -@@ -968,8 +968,8 @@ public class CraftEventFactory { +@@ -967,8 +967,8 @@ public class CraftEventFactory { private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, Map modifiers, Map> modifierFunctions, boolean cancelled) { - if (source.isExplosion()) { + if (source.is(DamageTypeTags.IS_EXPLOSION)) { DamageCause damageCause; - Entity damager = CraftEventFactory.entityDamage; - CraftEventFactory.entityDamage = null; @@ -23438,10 +23347,10 @@ index 6a52ae70b5f7fd9953b6b2605cae722f606e7fec..2a6fe4a3fdba9d0027a2e445b694afc8 EntityDamageEvent event; if (damager == null) { event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, modifiers, modifierFunctions); -@@ -1022,13 +1022,13 @@ public class CraftEventFactory { +@@ -1024,13 +1024,13 @@ public class CraftEventFactory { } return event; - } else if (source == DamageSource.LAVA) { + } else if (source.is(DamageTypes.LAVA)) { - EntityDamageEvent event = (new EntityDamageByBlockEvent(CraftEventFactory.blockDamage, entity.getBukkitEntity(), DamageCause.LAVA, modifiers, modifierFunctions)); + EntityDamageEvent event = (new EntityDamageByBlockEvent(CraftEventFactory.blockDamageRT.get(), entity.getBukkitEntity(), DamageCause.LAVA, modifiers, modifierFunctions)); // Folia - region threading event.setCancelled(cancelled); @@ -23456,7 +23365,7 @@ index 6a52ae70b5f7fd9953b6b2605cae722f606e7fec..2a6fe4a3fdba9d0027a2e445b694afc8 if (!event.isCancelled()) { event.getEntity().setLastDamageCause(event); -@@ -1036,9 +1036,9 @@ public class CraftEventFactory { +@@ -1038,9 +1038,9 @@ public class CraftEventFactory { entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled } return event; @@ -23465,10 +23374,10 @@ index 6a52ae70b5f7fd9953b6b2605cae722f606e7fec..2a6fe4a3fdba9d0027a2e445b694afc8 DamageCause cause = null; - Block damager = CraftEventFactory.blockDamage; + Block damager = CraftEventFactory.blockDamageRT.get(); // Folia - region threading - if (source == DamageSource.CACTUS || source == DamageSource.SWEET_BERRY_BUSH || source == DamageSource.STALAGMITE || "fallingStalactite".equals(source.msgId) || "anvil".equals(source.msgId)) { + if (source.is(DamageTypes.CACTUS) || source.is(DamageTypes.SWEET_BERRY_BUSH) || source.is(DamageTypes.STALAGMITE) || source.is(DamageTypes.FALLING_STALACTITE) || source.is(DamageTypes.FALLING_ANVIL)) { cause = DamageCause.CONTACT; - } else if (source == DamageSource.HOT_FLOOR) { -@@ -1053,9 +1053,9 @@ public class CraftEventFactory { + } else if (source.is(DamageTypes.HOT_FLOOR)) { +@@ -1055,9 +1055,9 @@ public class CraftEventFactory { EntityDamageEvent event = new EntityDamageByBlockEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions); event.setCancelled(cancelled); @@ -23480,7 +23389,7 @@ index 6a52ae70b5f7fd9953b6b2605cae722f606e7fec..2a6fe4a3fdba9d0027a2e445b694afc8 if (!event.isCancelled()) { event.getEntity().setLastDamageCause(event); -@@ -1063,10 +1063,10 @@ public class CraftEventFactory { +@@ -1065,10 +1065,10 @@ public class CraftEventFactory { entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled } return event; @@ -23489,9 +23398,9 @@ index 6a52ae70b5f7fd9953b6b2605cae722f606e7fec..2a6fe4a3fdba9d0027a2e445b694afc8 DamageCause cause = null; - CraftEntity damager = CraftEventFactory.entityDamage.getBukkitEntity(); - CraftEventFactory.entityDamage = null; -+ CraftEntity damager = CraftEventFactory.entityDamageRT.get().getBukkitEntity(); ++ CraftEntity damager = CraftEventFactory.entityDamageRT.get().getBukkitEntity(); // Folia - region threading + CraftEventFactory.entityDamageRT.set(null); // Folia - region threading - if ("fallingStalactite".equals(source.msgId) || "fallingBlock".equals(source.msgId) || "anvil".equals(source.msgId)) { + if (source.is(DamageTypes.FALLING_STALACTITE) || source.is(DamageTypes.FALLING_BLOCK) || source.is(DamageTypes.FALLING_ANVIL)) { cause = DamageCause.FALLING_BLOCK; } else if (damager instanceof LightningStrike) { diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -23507,10 +23416,10 @@ index cdefb2025eedea7e204d70d568adaf1c1ec4c03c..9136fb30db749737e9f189d0901024fc 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 daeaa30cdd64f5cb775304e82f2390684c02a9d3..829c44a4a1289de5b035f405a018c9d375f44e8c 100644 +index 64c50c52c11214740de7903e5592b8b6b2c170b3..9f5e8a21de3785721897cf8cf75b17ce3968cb7e 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -372,6 +372,12 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -373,6 +373,12 @@ public final class CraftMagicNumbers implements UnsafeValues { String minimumVersion = MinecraftServer.getServer().server.minimumAPI; int minimumIndex = CraftMagicNumbers.SUPPORTED_API.indexOf(minimumVersion); diff --git a/patches/server/0007-Max-pending-logins.patch b/patches/server/0007-Max-pending-logins.patch index 1757098..6f9bfa5 100644 --- a/patches/server/0007-Max-pending-logins.patch +++ b/patches/server/0007-Max-pending-logins.patch @@ -6,7 +6,7 @@ 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 626d99c785d2886bce605ba468ee24ce1710beb2..7b529beed6c68c5bf81eca1c53b5afe916430724 100644 +index 48223b78dd7ea2f065a259ad071f101398f40cfd..30fae97d5fed9de036cc4131a09d404468c69dd4 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -85,7 +85,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @@ -19,10 +19,10 @@ index 626d99c785d2886bce605ba468ee24ce1710beb2..7b529beed6c68c5bf81eca1c53b5afe9 } // Folia - region threading - remove delayed accept diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index f60feb0b9101afa24363c438949e1d60ccab0272..5d205856037032ceb9ea753ff12c3aac01583c2d 100644 +index e49e9cc31a9e05422fd1f48616c5a452011d66e1..132e1e055a8898beb4683dbec821b1f6e4dbf1a2 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -176,6 +176,17 @@ public abstract class PlayerList { +@@ -177,6 +177,17 @@ public abstract class PlayerList { conflictingId = this.connectionById.get(byId); if (conflictingName == null && conflictingId == null) { diff --git a/patches/server/0009-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch b/patches/server/0009-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch index 083ba2f..a522222 100644 --- a/patches/server/0009-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch +++ b/patches/server/0009-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch @@ -51,10 +51,10 @@ index d9687722e02dfd4088c7030abbf5008eb0a092c8..62484ebf4550b05182f693a3180bbac5 TickThread.ensureTickThread(thisEntity, "May not tick entity scheduler asynchronously"); final List toRun; diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 58d39268a2608901a14696d36f3c59d8d6ac06e7..021177d19384ef898667b8a374cd3838f6bd311c 100644 +index 0f958731923c7ac7093b47c11ceb1eda7c79e0de..8343830ffc6f9847cba0217ae2c13377fcf90490 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2756,6 +2756,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2767,6 +2767,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // CraftBukkit start com.google.common.base.Preconditions.checkState(!entity.passengers.contains(this), "Circular entity riding! %s %s", this, entity); @@ -62,7 +62,7 @@ index 58d39268a2608901a14696d36f3c59d8d6ac06e7..021177d19384ef898667b8a374cd3838 CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); Entity orig = craft == null ? null : craft.getHandle(); if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { -@@ -2783,6 +2784,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2794,6 +2795,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (event.isCancelled()) { return false; } @@ -70,7 +70,7 @@ index 58d39268a2608901a14696d36f3c59d8d6ac06e7..021177d19384ef898667b8a374cd3838 // Spigot end if (this.passengers.isEmpty()) { this.passengers = ImmutableList.of(entity); -@@ -2810,6 +2812,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2822,6 +2824,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { // CraftBukkit start @@ -78,7 +78,7 @@ index 58d39268a2608901a14696d36f3c59d8d6ac06e7..021177d19384ef898667b8a374cd3838 CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); Entity orig = craft == null ? null : craft.getHandle(); if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { -@@ -2837,6 +2840,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2849,6 +2852,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (event.isCancelled()) { return false; } @@ -87,10 +87,10 @@ index 58d39268a2608901a14696d36f3c59d8d6ac06e7..021177d19384ef898667b8a374cd3838 if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 34dd05b737ee02200c5973ad21a600b2e2434d07..306cc8fe9a90091dadac6a9f2d984342ff798218 100644 +index 5fa6b219b90bcf3f583eb64cf5eecf09bc56a406..45afdd01af2fdc819beab648227fdd500dc33c62 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -378,7 +378,7 @@ public final class CraftServer implements Server { +@@ -374,7 +374,7 @@ public final class CraftServer implements Server { @Override public final boolean isOwnedByCurrentRegion(Entity entity) { @@ -100,7 +100,7 @@ index 34dd05b737ee02200c5973ad21a600b2e2434d07..306cc8fe9a90091dadac6a9f2d984342 // Folia end - region threading API diff --git a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java -index 825fdc6162797ade8e76e1ca3a863ed5fb48f936..f812ad4a4d6c640c3f3f2d5766ee2b5882583cc5 100644 +index 1c8d63e462f3ed3d5286659ae0d1ec04d8b55177..116341b777f898a8080cc348499159c0f01b7329 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 @@ @@ -110,16 +110,22 @@ index 825fdc6162797ade8e76e1ca3a863ed5fb48f936..f812ad4a4d6c640c3f3f2d5766ee2b58 import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Projectile; -@@ -42,8 +43,15 @@ public abstract class AbstractProjectile extends CraftEntity implements Projecti +@@ -42,6 +43,13 @@ public abstract class AbstractProjectile extends CraftEntity implements Projecti this.getHandle().hasBeenShot = beenShot; } + // Folia start - region threading ++ @Override + public net.minecraft.world.entity.projectile.Projectile getHandleRaw() { + return (net.minecraft.world.entity.projectile.Projectile)this.entity; + } + // Folia end - region threading + + @Override + public boolean canHitEntity(org.bukkit.entity.Entity entity) { + return this.getHandle().canHitEntity(((CraftEntity) entity).getHandle()); +@@ -59,6 +67,7 @@ public abstract class AbstractProjectile extends CraftEntity implements Projecti + @Override public net.minecraft.world.entity.projectile.Projectile getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading @@ -212,7 +218,7 @@ index f6d9ccc993a067e554d6a7ef98c5fff1392efaef..69118f8ff00755ba1c31845a2704dd95 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java -index 6dfb0b47bd77fa4584744b3a54267879521b540a..d1054b93f652138a581a12a8eced66864e9c1003 100644 +index a0fed289f1f6b6addd60ccbd1344ad2c1202c78b..e7bd0ab46da08facea06ae86e8d21b288fe2e117 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java @@ -16,8 +16,16 @@ public class CraftAllay extends CraftCreature implements org.bukkit.entity.Allay @@ -296,7 +302,7 @@ index fec308cbc8fb27036301fe27a1169ac7368f9732..9ef569fad87838171198ff444538a401 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java -index f80cafe3544c7e6c3c29073ba6539783adf6666c..39d3a848e139da0b6e536089b99c63967667b125 100644 +index 17d08d2c90047ebfc4098b087be091b83111a40f..f678c151938ddd3e5277a05d6d8884c12b114336 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java @@ -26,8 +26,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { @@ -421,8 +427,29 @@ index 84cd915955188492696e5948fbb1c4eca0cca039..7dfbf7f7a94eae0c62d6830d459c3478 return (net.minecraft.world.entity.monster.Blaze) entity; } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java +index 2592a838b1b1fe4db98b95327dfd4f9774a0390b..29ac4ef7d2ed35e10df539b055db087f741fe4b6 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java +@@ -13,8 +13,16 @@ public class CraftBlockDisplay extends CraftDisplay implements BlockDisplay { + super(server, entity); + } + ++ // Folia start - region threading ++ @Override ++ public net.minecraft.world.entity.Display.BlockDisplay getHandleRaw() { ++ return (net.minecraft.world.entity.Display.BlockDisplay)this.entity; ++ } ++ // Folia end - region threading ++ + @Override + public net.minecraft.world.entity.Display.BlockDisplay 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.Display.BlockDisplay) super.getHandle(); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java -index e5b16e930e12557a9a9052866cf0f431e3a5310d..4084b43ce21bab35088b9e5d5f466c7e7f3b40a4 100644 +index dd7076938b04d4b36e3360a883bae81ced455fda..6671a86496394a786034cab7defa8126b55e8d5e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -92,8 +92,16 @@ public class CraftBoat extends CraftVehicle implements Boat { @@ -443,10 +470,10 @@ index e5b16e930e12557a9a9052866cf0f431e3a5310d..4084b43ce21bab35088b9e5d5f466c7e } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java -index f49789ba5e04441bc1d5fda343bd08627d398a8e..a1ccfd214240f6747fad168cf18346dd6d890551 100644 +index 509232424f6596d0ac43ba0d59b24e2bbdcbed0f..17dc189187e343db0e91f642a2edc782c6419ab9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java -@@ -11,8 +11,16 @@ public class CraftCamel extends CraftAbstractHorse implements Camel { +@@ -12,8 +12,16 @@ public class CraftCamel extends CraftAbstractHorse implements Camel { super(server, entity); } @@ -673,6 +700,27 @@ index 63a8188010f045d5c17a1ecb63e8081ec86c2960..24c6c26f0930940f88bdd0353d660ff3 return (net.minecraft.world.entity.monster.Creeper) entity; } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java +index 864fbfef94373d7252f0e7eff4023330fa73c145..d1e7f24344ebc21fc9050e726ccf7657090451f8 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java +@@ -13,8 +13,16 @@ public class CraftDisplay extends CraftEntity implements Display { + super(server, entity); + } + ++ // Folia start - region threading ++ @Override ++ public net.minecraft.world.entity.Display getHandleRaw() { ++ return (net.minecraft.world.entity.Display)this.entity; ++ } ++ // Folia end - region threading ++ + @Override + public net.minecraft.world.entity.Display 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.Display) super.getHandle(); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java index c1db88ceb65eb81c542171fc5465224ef613ce3b..108e0bbe345075a92e133c58df0d1009fc06009d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java @@ -758,7 +806,7 @@ index 2dbc6bf56f3462028dd3c9cbc4a939c53e573c76..1c5a2168c150d6d819e238db3d7986f2 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java -index 4326dae90e70d0f2029c43b878d19c3a1ba90d8a..5af88d11290434457c3b376e3f6f33a46fcd949d 100644 +index 92bcc01b3b28062aa966a7aaca199d7a3be832f4..10b827cb126d937548cc29a1b052d5acfa244f67 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java @@ -31,8 +31,16 @@ public class CraftEnderDragon extends CraftMob implements EnderDragon, CraftEnem @@ -821,7 +869,7 @@ index 21d5d8d4becee2709295d45b4b4fd2d1edbd3910..0cc66673866bd20ef74437866765134b } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java -index 13c1188639e00cd96e00b179c4e353582bf66e64..4cc5fd45e194568fd7a4215a2a7f895e3f9dce13 100644 +index 86a5b59c2987a4faa5d29eebd978b4fb0b6cd424..26ba9f73504fc652f76b5a19baf19e3d42c4d0ac 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java @@ -16,8 +16,16 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { @@ -884,10 +932,10 @@ index 75c7645fb5732c43d1da15181cf5c7ee4c3ecd6c..6d3325436a77153438bc40aa86819562 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 91a11cfa430c63455e2d54125d6e1bd407f822ac..0ea759602a541480b4535569358d98353a7ad4dd 100644 +index 3f46d9398add0e97a2b8b072f66b48b0e056d023..59986e24adea4cecc4eb82a84eeab5755e689bf6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -813,7 +813,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -827,7 +827,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public UUID getUniqueId() { @@ -896,7 +944,7 @@ index 91a11cfa430c63455e2d54125d6e1bd407f822ac..0ea759602a541480b4535569358d9835 } @Override -@@ -829,7 +829,14 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -843,7 +843,14 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { this.getHandle().tickCount = value; } @@ -1353,10 +1401,10 @@ index 1f474ef8f9e86da383206bd50ba00c7ed8352c5d..4dd82aef0d4e37336c076f74fe01cbd4 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -index ed22e6f17f48db71cc283afc8b71d85682cd7d3a..53fd705f6351980d93881f1e9f504a589126d52a 100644 +index c8cccfcf4d572a9e65fce09621aeed2a7045003c..1fe7d7eb632adfb050e11138b2e775f6d9c1a970 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -@@ -285,8 +285,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { +@@ -292,8 +292,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { this.mode = mode; } @@ -1415,6 +1463,27 @@ index bbf7189a0fc9921e7a6007494f91229d9fba0846..3ab7929aa11584ec0f86ff8ad441f2b9 return (net.minecraft.world.entity.monster.Illusioner) super.getHandle(); } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java +index cb7183b5d72e505762cfaf5c8694406a5ef2dd3b..7b7074a9418bbcd87c18217ea78efdbc7d01528a 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java +@@ -13,8 +13,16 @@ public class CraftInteraction extends CraftEntity implements Interaction { + super(server, entity); + } + ++ // Folia start - region threading ++ @Override ++ public net.minecraft.world.entity.Interaction getHandleRaw() { ++ return (net.minecraft.world.entity.Interaction)this.entity; ++ } ++ // Folia end - region threading ++ + @Override + public net.minecraft.world.entity.Interaction 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.Interaction) super.getHandle(); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java index 2966d4d466f44751b2f02afda2273a708c12b251..8c3818e8024ee25c29929368750dc346261db5d6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java @@ -1436,6 +1505,27 @@ index 2966d4d466f44751b2f02afda2273a708c12b251..8c3818e8024ee25c29929368750dc346 return (net.minecraft.world.entity.animal.IronGolem) entity; } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java +index 9b7b98e21e757ab2caca68de20d0191d0011bc9d..06e2580653db00110b0f0a05cfda9d0e9baecdfa 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java +@@ -14,8 +14,16 @@ public class CraftItemDisplay extends CraftDisplay implements ItemDisplay { + super(server, entity); + } + ++ // Folia start - region threading ++ @Override ++ public net.minecraft.world.entity.Display.ItemDisplay getHandleRaw() { ++ return (net.minecraft.world.entity.Display.ItemDisplay)this.entity; ++ } ++ // Folia end - region threading ++ + @Override + public net.minecraft.world.entity.Display.ItemDisplay 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.Display.ItemDisplay) super.getHandle(); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index 2a297adc49129729751317817d959c2d2566fc3e..7352909a3f2b2f1dc0f96e452869014fa328fc1c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -1521,10 +1611,10 @@ index e515e819774bfb31ec03f05a5502921e66f2b0e2..80cac5d7362577e53ef5ca215ab32618 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -index 09da9d3c85e36c2a78663f58a97963dbc795a367..0557872b7fe0c17cd8f706f156c704a93cd0dd22 100644 +index aec588b41f19b2147a4e7267bafa417fbcf7abc0..bd115a08512e6f4c13bc30ce2b05c7378754754f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -@@ -413,8 +413,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { +@@ -419,8 +419,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { this.getHandle().invulnerableTime = ticks; } @@ -1710,7 +1800,7 @@ index b8378d5f3c2a08ab565dcb8cb200822b581c7dba..e7c303a0f8b4e2ca26cf28b4661b7bdf } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java -index 569763b3c9e92a4071884f139fb1263201f80e43..41cddff04ee6ce47c429e8ddddd08087a0e81a94 100644 +index 67fe56cc4c2af24f6bd883c6e14851019b0b9523..31665297fc24f6d2e86e206ef1ddf46ded51782f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java @@ -40,8 +40,17 @@ public final class CraftMinecartHopper extends CraftMinecartContainer implements @@ -1732,7 +1822,7 @@ index 569763b3c9e92a4071884f139fb1263201f80e43..41cddff04ee6ce47c429e8ddddd08087 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java -index dfd0b5e018194343ca40629db6f70c6020c2d567..6097ccf0abbcaffe178cde18b05048a99511d253 100644 +index 5e3f0180accf633aa28ae87fe07464edfde50bff..1ad6c76dd5c45b2865dfe752891906a545e920b2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java @@ -20,8 +20,17 @@ public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMi @@ -1805,10 +1895,10 @@ index 11b23670cd80a643f266c59542a380b42b17dfbd..d3b655ab5adacd60f04f912187662c57 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java -index 20eaa3424428b8b30fd15591b660983cb7fc4375..495b3e8b1fa0f3da98e2e2d978329edd1742bdbe 100644 +index 4a6aae106de5eeeb80c078c5a167ef0484b13929..f3016d316c1dcee3f5d7c7221668280c7bd9a76e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java -@@ -11,8 +11,16 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow { +@@ -11,8 +11,16 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow, io.paperm super(server, entity); } @@ -1931,7 +2021,7 @@ index 9a3734c670972ee91a0d44a1b1fa8493de854a9c..e1ae90699fdc13f6f2bb9ebf227b3803 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java -index 377099c83a47837749589429657a82a9f92a2aa0..f0d128164f9acc32b4401c54618987566e90def8 100644 +index 61613f38b39dfd4512e2d9caadaa3bb6b37d4e55..f94b45ba171fcbae718b50ab2ff60d38248e622c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -56,8 +56,16 @@ public class CraftPig extends CraftAnimals implements Pig { @@ -2057,10 +2147,10 @@ index beea227855f0b978e655efc298024120df8f4945..e1b7922ed298b6b3068c3f5fbe3b4030 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 7b29843302d7aba8e64a2533a4b2203e9f30ecca..2c1406a956a2154f04cd12a72cbb96925efc3290 100644 +index 9ee05436a26c73f99bb5e0eae43831d7bd385975..559e1fa14dcb046dcc00422db4e3c3a818b6c348 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -583,7 +583,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -584,7 +584,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) { @@ -2069,7 +2159,7 @@ index 7b29843302d7aba8e64a2533a4b2203e9f30ecca..2c1406a956a2154f04cd12a72cbb9692 final ServerGamePacketListenerImpl connection = this.getHandle().connection; if (connection != null) { connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message, cause); -@@ -1843,9 +1843,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1963,9 +1963,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this; } @@ -2087,7 +2177,7 @@ index 7b29843302d7aba8e64a2533a4b2203e9f30ecca..2c1406a956a2154f04cd12a72cbb9692 } public void setHandle(final ServerPlayer entity) { -@@ -2871,7 +2878,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2991,7 +2998,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { { if ( CraftPlayer.this.getHealth() <= 0 && CraftPlayer.this.isOnline() ) { @@ -2245,10 +2335,10 @@ index c888415f9b4f19db69667525e37279ab8be794f6..3951fa2f21932dc1b4948fab08998afa } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java -index ca8e35fbf04a54d60c3612f74be0b5fbf2ab7a56..cc97cab69405882bf03efacaba2a244b73dcf792 100644 +index 81ccb4bde315c42409a0c04883f5cb4551398308..e3c6a74d267ea0a10be375fc83428415ad575fc2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java -@@ -30,8 +30,16 @@ public class CraftSheep extends CraftAnimals implements Sheep { +@@ -30,8 +30,16 @@ public class CraftSheep extends CraftAnimals implements Sheep, io.papermc.paper. this.getHandle().setSheared(flag); } @@ -2433,6 +2523,27 @@ index d8b4df1300791aaf310465ec1577b1b8c202901a..17b83eb8563586f1ddf252f438d52d55 return (net.minecraft.world.entity.projectile.SmallFireball) entity; } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java +index 92d1c7943c7ddb5d29b657f8da74e29dfe051c2b..5dc45789f92a49ce461db06b322d14e897d2f951 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java +@@ -10,8 +10,16 @@ public class CraftSniffer extends CraftAnimals implements Sniffer { + super(server, entity); + } + ++ // Folia start - region threading ++ @Override ++ public net.minecraft.world.entity.animal.sniffer.Sniffer getHandleRaw() { ++ return (net.minecraft.world.entity.animal.sniffer.Sniffer)this.entity; ++ } ++ // Folia end - region threading ++ + @Override + public net.minecraft.world.entity.animal.sniffer.Sniffer 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.sniffer.Sniffer) super.getHandle(); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java index b747aa0fb5821988ea851273559182997abf9931..117cdf4b1315f2de32aa13844f0f4c46f21cc96d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java @@ -2455,7 +2566,7 @@ index b747aa0fb5821988ea851273559182997abf9931..117cdf4b1315f2de32aa13844f0f4c46 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java -index 659e2959c5330e4764ea1edc7f8de9f464f9ff52..e336ee895fced776f5857005eefc336c231f0a83 100644 +index 42b7058d93fab8cbee49dba130734e1df9910096..00907c925fdb0d709ff421cdc8a1742282ad372f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java @@ -20,8 +20,16 @@ public class CraftSnowman extends CraftGolem implements Snowman, com.destroystok @@ -2560,7 +2671,7 @@ index 3c0faedaac8cb8d70c0c0767361ebc563a3f0581..10875cdf36b426de512c52ae60ac7e2c } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java -index 61bdfa1d50b228c27b7c719938a09e7715d303c3..aa851b01d3cfe456eef9fc6a8d2527ab61ef7d01 100644 +index af5344b0edd1f8126d36a79d7497ca52112ce6d1..89cd22b73c38773961d6955d429564e816b8183a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java @@ -66,8 +66,16 @@ public class CraftStrider extends CraftAnimals implements Strider { @@ -2643,6 +2754,27 @@ index 428437970cac144be53cd0e30af7af0cd1ce603b..dc09e141ba2b12f1955bec521f2170d2 return (TamableAnimal) super.getHandle(); } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java +index 2d04443a9efd6e4b5eb1e360a727d8492323724b..47ba133c7a4100892e95d8c9c1a1773088c48e55 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java +@@ -14,8 +14,16 @@ public class CraftTextDisplay extends CraftDisplay implements TextDisplay { + super(server, entity); + } + ++ // Folia start - region threading ++ @Override ++ public net.minecraft.world.entity.Display.TextDisplay getHandleRaw() { ++ return (net.minecraft.world.entity.Display.TextDisplay)this.entity; ++ } ++ // Folia end - region threading ++ + @Override + public net.minecraft.world.entity.Display.TextDisplay 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.Display.TextDisplay) super.getHandle(); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java index 989c5c499a52ad0777abecd14a1a9d5803ce1aaf..8e66e9ac17a8a06130d6b039f27868d42554f337 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java @@ -2918,7 +3050,7 @@ index ecf0c4a7d1ce2b254d91b3276fa24c149329737a..fadc797d3c298c6ad4b2e6abc70b59e5 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java -index 963928fc8e29b8abc2026c0b0183ebb07f0de4d1..7ac95b6290a86177ca2a649e0d38ffc13f6ec5ab 100644 +index 6ecdc4bf1f6b8f0363e667135ba463433be5c0fb..a4ede0f5973d18ed6b8ae3ee425c4445f39e86c4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java @@ -16,8 +16,16 @@ public class CraftWarden extends CraftMonster implements org.bukkit.entity.Warde diff --git a/patches/server/0010-Disable-mid-tick-task-execution.patch b/patches/server/0010-Disable-mid-tick-task-execution.patch index d6de7d6..35aa27c 100644 --- a/patches/server/0010-Disable-mid-tick-task-execution.patch +++ b/patches/server/0010-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 fb2f7cde13ef96334a42448798a4902e8c1e06a3..d43202f7de86e8d0c74abc0b7ff23baa69da7c87 100644 +index 58eee2965ce3e92b0f90eb7e908c6eee40052670..81767d54db0109b78c7da2161d544537c6237d27 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -2873,6 +2873,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop