diff --git a/build.gradle.kts b/build.gradle.kts index bf08d00038..817a52601d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { java `maven-publish` id("com.github.johnrengelman.shadow") version "8.1.1" apply false - id("io.papermc.paperweight.patcher") version "1.5.8" + id("io.papermc.paperweight.patcher") version "1.5.9" } val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" diff --git a/gradle.properties b/gradle.properties index f50982b59d..c225a6cb3d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ group=dev.folia version=1.20.2-R0.1-SNAPSHOT mcVersion=1.20.2 -paperRef=4b0bc74c90582f2d52d720c795228130545cd103 +paperRef=ce7f0680956bb1c779ac4db9fe0fd1f00bb35bae org.gradle.caching=true org.gradle.parallel=true 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 cdaafc614f..8adea2e223 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 @@ -31,10 +31,10 @@ index ef393f1f93ca48264fc1b6e3a27787f6a9152e1b..1325f9fed80731b74b80145dadc843b1 + } diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java -index 32986df9a9854e561a77eefab99c934efbcb5aac..36547643e61a8da979bd1e51527f9c197c79569b 100644 +index c0691a849831f99268fdcb7b0f471f80a1a2a70e..6f1d3935c2c398571c32e1be9786f74ec911c7bd 100644 --- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java -@@ -258,6 +258,21 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf +@@ -259,6 +259,21 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf private Set awareness = ImmutableSet.of(); private String apiVersion = null; private List libraries = ImmutableList.of(); @@ -56,7 +56,7 @@ index 32986df9a9854e561a77eefab99c934efbcb5aac..36547643e61a8da979bd1e51527f9c19 // Paper start - oh my goddddd /** * Don't use this. -@@ -1241,6 +1256,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf +@@ -1242,6 +1257,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf if (map.get("prefix") != null) { prefix = map.get("prefix").toString(); } @@ -68,7 +68,7 @@ index 32986df9a9854e561a77eefab99c934efbcb5aac..36547643e61a8da979bd1e51527f9c19 } @NotNull -@@ -1317,6 +1337,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf +@@ -1318,6 +1338,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf if (prefix != null) { map.put("prefix", prefix); } diff --git a/patches/api/0005-Add-API-for-checking-ownership-of-region-by-position.patch b/patches/api/0005-Add-API-for-checking-ownership-of-region-by-position.patch index 92056cc985..c14b660d4e 100644 --- a/patches/api/0005-Add-API-for-checking-ownership-of-region-by-position.patch +++ b/patches/api/0005-Add-API-for-checking-ownership-of-region-by-position.patch @@ -11,10 +11,10 @@ the schedulers depending on the result of the ownership check. diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index f78b5fd3c3347d28da58777bff88903d2eb140f6..26b32a5935aaed9b1fe356af0208a778144aac87 100644 +index 884902cb7f86c0b56594ccafc7d05c6c7a23ab53..b7e1c8bd8dd38e1a9e74925740b22dad61a75f49 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -2751,6 +2751,14 @@ public final class Bukkit { +@@ -2827,6 +2827,14 @@ public final class Bukkit { return server.isOwnedByCurrentRegion(entity); } // Paper end - Folia region threading API @@ -30,10 +30,10 @@ index f78b5fd3c3347d28da58777bff88903d2eb140f6..26b32a5935aaed9b1fe356af0208a778 @NotNull public static Server.Spigot spigot() { diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 8d8fe04e6b09d2a5b1cc05002073df5c58cdcb96..b6a8217b97842cd07af24fadb21e0e44226e5bb9 100644 +index d0c634629aa0b6bac0da93655dd86ad3aea0ce30..85b169c04f44431363d4e14d4857140f160ceace 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2404,4 +2404,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2473,4 +2473,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ boolean isOwnedByCurrentRegion(@NotNull Entity entity); // Paper end - Folia region threading API diff --git a/patches/server/0001-Build-changes.patch b/patches/server/0001-Build-changes.patch index 72c31de25a..6b630138ef 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 a79461457ea19339f47572c70705d655ebc55276..b62a25bd32b7976dd00f53521d0e050d60c34ca7 100644 +index 79beac737c17412913983614bd478d33e3c6ed58..a748157d6ce9c088ed3c663d9ddd6f5c2d82b6d8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,8 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { @@ -93,7 +93,7 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..e2f704c115fd6e00960bb56bb0779f11 ).openBufferedStream()) { JsonObject json = new Gson().fromJson(reader, JsonObject.class); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 97745f0bab8d82d397c6c2a5775aed92bca0a034..a17160766eb15e8d11ddcce23747f8ab1923b676 100644 +index 8f31413c939cc2b0454ad3d9a1b618dbae449d00..6758e3ff1100bba2852e44cbb0b38ce4f22490e8 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1697,7 +1697,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop unloadQueue; -@@ -146,13 +146,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -146,69 +146,33 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper - rewrite chunk system // Paper start - distance maps - private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>(); -+ //private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>(); // Folia - region threading +- // Paper start - use distance map to optimise tracker +- public static boolean isLegacyTrackingEntity(Entity entity) { +- return entity.isLegacyTrackingEntity; +- } +- +- // inlined EnumMap, TrackingRange.TrackingRangeType +- static final org.spigotmc.TrackingRange.TrackingRangeType[] TRACKING_RANGE_TYPES = org.spigotmc.TrackingRange.TrackingRangeType.values(); +- public final com.destroystokyo.paper.util.misc.PlayerAreaMap[] playerEntityTrackerTrackMaps; +- final int[] entityTrackerTrackRanges; +- public final int getEntityTrackerRange(final int ordinal) { +- return this.entityTrackerTrackRanges[ordinal]; +- } +- +- private int convertSpigotRangeToVanilla(final int vanilla) { +- return net.minecraft.server.MinecraftServer.getServer().getScaledTrackingDistance(vanilla); +- } +- // Paper end - use distance map to optimise tracker ++ // Folia - region threading void addPlayerToDistanceMaps(ServerPlayer player) { int chunkX = io.papermc.paper.util.MCUtil.getChunkCoordinate(player.getX()); @@ -12131,15 +12148,29 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 - this.nearbyPlayers.addPlayer(player); + // Folia - region threading this.level.playerChunkLoader.addPlayer(player); // Paper - replace chunk loader +- // Paper start - use distance map to optimise entity tracker +- for (int i = 0, len = TRACKING_RANGE_TYPES.length; i < len; ++i) { +- com.destroystokyo.paper.util.misc.PlayerAreaMap trackMap = this.playerEntityTrackerTrackMaps[i]; +- int trackRange = this.entityTrackerTrackRanges[i]; +- +- trackMap.add(player, chunkX, chunkZ, Math.min(trackRange, io.papermc.paper.chunk.system.ChunkSystem.getSendViewDistance(player))); +- } +- // Paper end - use distance map to optimise entity tracker ++ // Folia - region threading } -@@ -160,16 +160,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + void removePlayerFromDistanceMaps(ServerPlayer player) { int chunkX = io.papermc.paper.util.MCUtil.getChunkCoordinate(player.getX()); int chunkZ = io.papermc.paper.util.MCUtil.getChunkCoordinate(player.getZ()); // Note: players need to be explicitly added to distance maps before they can be updated - this.nearbyPlayers.removePlayer(player); + // Folia - region threading this.level.playerChunkLoader.removePlayer(player); // Paper - replace chunk loader +- // Paper start - use distance map to optimise tracker +- for (int i = 0, len = TRACKING_RANGE_TYPES.length; i < len; ++i) { +- this.playerEntityTrackerTrackMaps[i].remove(player); +- } +- // Paper end - use distance map to optimise tracker - this.playerMobSpawnMap.remove(player); // Paper - optimise chunk tick iteration + // Folia - region threading } @@ -12151,9 +12182,19 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 - this.nearbyPlayers.tickPlayer(player); + // Folia - region threading this.level.playerChunkLoader.updatePlayer(player); // Paper - replace chunk loader +- // Paper start - use distance map to optimise entity tracker +- for (int i = 0, len = TRACKING_RANGE_TYPES.length; i < len; ++i) { +- com.destroystokyo.paper.util.misc.PlayerAreaMap trackMap = this.playerEntityTrackerTrackMaps[i]; +- int trackRange = this.entityTrackerTrackRanges[i]; +- +- trackMap.update(player, chunkX, chunkZ, Math.min(trackRange, io.papermc.paper.chunk.system.ChunkSystem.getSendViewDistance(player))); +- } +- // Paper end - use distance map to optimise entity tracker ++ // Folia - region threading } // Paper end -@@ -202,19 +202,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + // Paper start +@@ -240,19 +204,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public final ChunkHolder getUnloadingChunkHolder(int chunkX, int chunkZ) { return null; // Paper - rewrite chunk system } @@ -12178,7 +12219,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 this.chunkTypeCache = new Long2ByteOpenHashMap(); this.chunkSaveCooldowns = new Long2LongOpenHashMap(); this.unloadQueue = Queues.newConcurrentLinkedQueue(); -@@ -259,15 +259,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -297,57 +261,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.setServerViewDistance(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); @@ -12187,6 +12228,49 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 + //this.regionManagers.add(this.dataRegionManager); // Folia - region threading + //this.nearbyPlayers = new io.papermc.paper.util.player.NearbyPlayers(this.level); // Folia - region threading // Paper end + // Paper start - use distance map to optimise entity tracker +- this.playerEntityTrackerTrackMaps = new com.destroystokyo.paper.util.misc.PlayerAreaMap[TRACKING_RANGE_TYPES.length]; +- this.entityTrackerTrackRanges = new int[TRACKING_RANGE_TYPES.length]; +- +- org.spigotmc.SpigotWorldConfig spigotWorldConfig = this.level.spigotConfig; +- +- for (int ordinal = 0, len = TRACKING_RANGE_TYPES.length; ordinal < len; ++ordinal) { +- org.spigotmc.TrackingRange.TrackingRangeType trackingRangeType = TRACKING_RANGE_TYPES[ordinal]; +- int configuredSpigotValue; +- switch (trackingRangeType) { +- case PLAYER: +- configuredSpigotValue = spigotWorldConfig.playerTrackingRange; +- break; +- case ANIMAL: +- configuredSpigotValue = spigotWorldConfig.animalTrackingRange; +- break; +- case MONSTER: +- configuredSpigotValue = spigotWorldConfig.monsterTrackingRange; +- break; +- case MISC: +- configuredSpigotValue = spigotWorldConfig.miscTrackingRange; +- break; +- case OTHER: +- configuredSpigotValue = spigotWorldConfig.otherTrackingRange; +- break; +- case ENDERDRAGON: +- configuredSpigotValue = EntityType.ENDER_DRAGON.clientTrackingRange() * 16; +- break; +- case DISPLAY: +- configuredSpigotValue = spigotWorldConfig.displayTrackingRange; +- break; +- default: +- throw new IllegalStateException("Missing case for enum " + trackingRangeType); +- } +- configuredSpigotValue = convertSpigotRangeToVanilla(configuredSpigotValue); +- +- int trackRange = (configuredSpigotValue >>> 4) + ((configuredSpigotValue & 15) != 0 ? 1 : 0); +- this.entityTrackerTrackRanges[ordinal] = trackRange; +- +- this.playerEntityTrackerTrackMaps[ordinal] = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets); +- } ++ // Folia - region threading + // Paper end - use distance map to optimise entity tracker } // Paper start @@ -12197,7 +12281,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 } // Paper end -@@ -595,6 +595,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -675,6 +600,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) { @@ -12210,7 +12294,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 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 -@@ -848,6 +854,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -928,6 +859,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkcoordintpair, boolean reducedRange) { @@ -12246,10 +12330,10 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 + return false; + } + // Folia end - region threading - int chunkRange = level.spigotConfig.mobSpawnRange; - chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange; + int chunkRange = this.level.spigotConfig.mobSpawnRange; + chunkRange = (chunkRange > this.level.spigotConfig.viewDistance) ? (byte) this.level.spigotConfig.viewDistance : chunkRange; chunkRange = (chunkRange > 8) ? 8 : chunkRange; -@@ -859,7 +897,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -939,7 +902,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (!this.distanceManager.hasPlayersNearby(chunkcoordintpair.toLong())) { return false; } else { @@ -12258,7 +12342,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 ServerPlayer entityplayer; -@@ -891,7 +929,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -971,7 +934,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return List.of(); } else { Builder builder = ImmutableList.builder(); @@ -12267,7 +12351,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 while (iterator.hasNext()) { ServerPlayer entityplayer = (ServerPlayer) iterator.next(); -@@ -920,25 +958,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1000,25 +963,19 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } void updatePlayerStatus(ServerPlayer player, boolean added) { @@ -12297,21 +12381,11 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 this.removePlayerFromDistanceMaps(player); // Paper - distance maps // Paper - handled by player chunk loader -@@ -953,41 +985,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1033,31 +990,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public void move(ServerPlayer player) { -- ObjectIterator objectiterator = this.entityMap.values().iterator(); -- -- while (objectiterator.hasNext()) { -- ChunkMap.TrackedEntity playerchunkmap_entitytracker = (ChunkMap.TrackedEntity) objectiterator.next(); -- -- if (playerchunkmap_entitytracker.entity == player) { -- playerchunkmap_entitytracker.updatePlayers(this.level.players()); -- } else { -- playerchunkmap_entitytracker.updatePlayer(player); -- } -- } +- // Paper - delay this logic for the entity tracker tick, no need to duplicate it + // Folia - region threading - entity tracker optimisations - SectionPos sectionposition = player.getLastSectionPos(); @@ -12343,7 +12417,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 // Paper - replaced by PlayerChunkLoader } -@@ -1018,9 +1022,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1088,9 +1027,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 @@ -12355,7 +12429,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 return; } if (entity instanceof ServerPlayer && ((ServerPlayer) entity).supressTrackerForLogin) return; // Delay adding to tracker until after list packets -@@ -1033,27 +1037,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1103,27 +1042,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (i != 0) { int j = entitytypes.updateInterval(); @@ -12367,7 +12441,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker - this.entityMap.put(entity.getId(), playerchunkmap_entitytracker); -- playerchunkmap_entitytracker.updatePlayers(this.level.players()); +- playerchunkmap_entitytracker.updatePlayers(entity.getPlayersInTrackRange()); // Paper - don't search all players + // Folia - region threading + playerchunkmap_entitytracker.updatePlayers(this.level.getLocalPlayers()); // Folia - region threading if (entity instanceof ServerPlayer) { @@ -12391,7 +12465,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 } } -@@ -1067,16 +1069,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1137,16 +1074,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider ServerPlayer entityplayer = (ServerPlayer) entity; this.updatePlayerStatus(entityplayer, false); @@ -12415,13 +12489,59 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 if (playerchunkmap_entitytracker1 != null) { playerchunkmap_entitytracker1.broadcastRemoved(); -@@ -1084,54 +1086,35 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1154,82 +1091,37 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider entity.tracker = null; // Paper - We're no longer tracked } -- protected void tick() { -- // Paper - replaced by PlayerChunkLoader +- // Paper start - optimised tracker +- private final void processTrackQueue() { +- this.level.timings.tracker1.startTiming(); +- try { +- for (TrackedEntity tracker : this.entityMap.values()) { +- // update tracker entry +- tracker.updatePlayers(tracker.entity.getPlayersInTrackRange()); ++ // Folia start - region threading - replace entity tracking ticking ++ private void foliaEntityTrackerTick() { ++ io.papermc.paper.threadedregions.RegionizedWorldData worldData = this.level.getCurrentWorldData(); ++ io.papermc.paper.util.player.NearbyPlayers nearbyPlayers = worldData.getNearbyPlayers(); ++ for (Entity entity : worldData.getLoadedEntities()) { ++ TrackedEntity tracker = entity.tracker; ++ if (tracker == null) { ++ continue; + } +- } finally { +- this.level.timings.tracker1.stopTiming(); +- } +- - +- this.level.timings.tracker2.startTiming(); +- try { +- for (TrackedEntity tracker : this.entityMap.values()) { +- tracker.serverEntity.sendChanges(); ++ tracker.tick(nearbyPlayers.getChunk(entity.chunkPosition())); ++ tracker.serverEntity.sendChanges(); ++ } ++ // process unloads ++ for (Entity entity : worldData.takeTrackingUnloads()) { ++ TrackedEntity tracker = entity.tracker; ++ if (tracker == null) { ++ continue; + } +- } finally { +- this.level.timings.tracker2.stopTiming(); ++ tracker.clearPlayers(); + } + } +- // Paper end - optimised tracker ++ // Folia end - region threading - replace entity tracking ticking + +- protected void tick() { +- // Paper start - optimized tracker +- if (true) { +- this.processTrackQueue(); +- return; +- } +- // Paper end - optimized tracker - List list = Lists.newArrayList(); - List list1 = this.level.players(); - ObjectIterator objectiterator = this.entityMap.values().iterator(); @@ -12448,18 +12568,8 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 - - if (flag || this.distanceManager.inEntityTickingRange(sectionposition1.chunk().toLong())) { - playerchunkmap_entitytracker.serverEntity.sendChanges(); -+ // Folia start - region threading - replace entity tracking ticking -+ private void foliaEntityTrackerTick() { -+ io.papermc.paper.threadedregions.RegionizedWorldData worldData = this.level.getCurrentWorldData(); -+ io.papermc.paper.util.player.NearbyPlayers nearbyPlayers = worldData.getNearbyPlayers(); -+ for (Entity entity : worldData.getLoadedEntities()) { -+ TrackedEntity tracker = entity.tracker; -+ if (tracker == null) { -+ continue; - } -+ tracker.tick(nearbyPlayers.getChunk(entity.chunkPosition())); -+ tracker.serverEntity.sendChanges(); - } +- } +- } - level.timings.tracker1.stopTiming(); // Paper - - if (!list.isEmpty()) { @@ -12469,17 +12579,10 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 - while (objectiterator.hasNext()) { - playerchunkmap_entitytracker = (ChunkMap.TrackedEntity) objectiterator.next(); - playerchunkmap_entitytracker.updatePlayers(list); -+ // process unloads -+ for (Entity entity : worldData.takeTrackingUnloads()) { -+ TrackedEntity tracker = entity.tracker; -+ if (tracker == null) { -+ continue; - } +- } - level.timings.tracker2.stopTiming(); // Paper -+ tracker.clearPlayers(); - } -+ } -+ // Folia end - region threading - replace entity tracking ticking +- } ++ // Folia - region threading - replace entity tracking ticking + protected void tick() { + this.foliaEntityTrackerTick(); // Folia - region threading - replace entity tracking ticking @@ -12491,7 +12594,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 if (playerchunkmap_entitytracker != null) { playerchunkmap_entitytracker.broadcast(packet); -@@ -1140,7 +1123,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1238,7 +1130,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } protected void broadcastAndSend(Entity entity, Packet packet) { @@ -12500,7 +12603,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 if (playerchunkmap_entitytracker != null) { playerchunkmap_entitytracker.broadcastAndSend(packet); -@@ -1281,6 +1264,78 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1415,6 +1307,78 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } } @@ -12579,7 +12682,7 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 public void updatePlayer(ServerPlayer player) { org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot -@@ -1300,9 +1355,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1434,9 +1398,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } } // Paper end - check Y @@ -12590,8 +12693,8 @@ index 0c2617574e21037d94ac56ad08b490f9bca5c5af..a1cbf387c72482034eeee6be8a5c2228 + // Folia end - region threading // CraftBukkit start - respect vanish API -- if (!player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { -+ if (flag && (!io.papermc.paper.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSee(this.entity.getBukkitEntity()))) { // Folia - region threading +- if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits ++ if (flag && (!io.papermc.paper.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSee(this.entity.getBukkitEntity()))) { // Paper - only consider hits // Folia - region threading flag = false; } // CraftBukkit end @@ -12614,7 +12717,7 @@ index 55f96545d6db95e3e657502a7910d96fded1113e..b39dd5a11a34407244666d8b9c1e775d public String getDebugStatus() { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 17b6925b46f8386dcfc561483693de516465ec12..18735dbd0d2bae1576d2bdb7402d98e9affbd599 100644 +index 8c33a12ca879c46893150d6adfb8aa4d397c6b4c..a97c0a86d7a07041d1f8e9c6ea59eb4cce1243e6 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -60,73 +60,42 @@ public class ServerChunkCache extends ChunkSource { @@ -12767,8 +12870,8 @@ index 17b6925b46f8386dcfc561483693de516465ec12..18735dbd0d2bae1576d2bdb7402d98e9 gameprofilerfiller.push("pollingChunks"); int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); -- boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit -+ boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getRedstoneGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit // Folia - region threading +- boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit ++ boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getRedstoneGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit // Folia - region threading gameprofilerfiller.push("naturalSpawnCount"); this.level.timings.countNaturalMobs.startTiming(); // Paper - timings @@ -12963,7 +13066,7 @@ index 17b6925b46f8386dcfc561483693de516465ec12..18735dbd0d2bae1576d2bdb7402d98e9 } diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 17610196db7a1c6feb2cf74a02479a8691aa323f..32fdb3d70442257201472f9f1c1ad4664ca735d7 100644 +index 584a768f2ce1c98a1de7749060c47f21721f9055..10cf0ffb2cf519f0904dbe709b9042d30d5fd827 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -192,36 +192,35 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -13214,7 +13317,7 @@ index 17610196db7a1c6feb2cf74a02479a8691aa323f..32fdb3d70442257201472f9f1c1ad466 - j = this.levelData.getDayTime() + 24000L; - TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (j - j % 24000L) - this.getDayTime()); - if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { -- getCraftServer().getPluginManager().callEvent(event); +- this.getCraftServer().getPluginManager().callEvent(event); - if (!event.isCancelled()) { - this.setDayTime(this.getDayTime() + event.getSkipAmount()); - } @@ -13234,7 +13337,7 @@ index 17610196db7a1c6feb2cf74a02479a8691aa323f..32fdb3d70442257201472f9f1c1ad466 + if (region == null) this.updateSkyBrightness(); // Folia - region threading this.tickTime(); gameprofilerfiller.popPush("tickPending"); - timings.scheduledBlocks.startTiming(); // Paper + this.timings.scheduledBlocks.startTiming(); // Paper if (!this.isDebug()) { - j = this.getGameTime(); + j = regionizedWorldData.getRedstoneGameTime(); // Folia - region threading @@ -13246,11 +13349,11 @@ index 17610196db7a1c6feb2cf74a02479a8691aa323f..32fdb3d70442257201472f9f1c1ad466 + regionizedWorldData.getFluidLevelTicks().tick(j, 65536, this::tickFluid); // Folia - region ticking gameprofilerfiller.pop(); } - timings.scheduledBlocks.stopTiming(); // Paper + this.timings.scheduledBlocks.stopTiming(); // Paper @@ -858,7 +929,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - timings.doSounds.startTiming(); // Spigot + this.timings.doSounds.startTiming(); // Spigot this.runBlockEvents(); - timings.doSounds.stopTiming(); // Spigot + this.timings.doSounds.stopTiming(); // Spigot - this.handlingTick = false; + regionizedWorldData.setHandlingTick(false); // Folia - regionised ticking gameprofilerfiller.pop(); @@ -13258,7 +13361,7 @@ index 17610196db7a1c6feb2cf74a02479a8691aa323f..32fdb3d70442257201472f9f1c1ad466 @@ -870,20 +941,30 @@ public class ServerLevel extends Level implements WorldGenLevel { gameprofilerfiller.push("entities"); - timings.tickEntities.startTiming(); // Spigot + this.timings.tickEntities.startTiming(); // Spigot if (this.dragonFight != null) { + if (io.papermc.paper.util.TickThread.isTickThreadFor(this, this.dragonFight.origin)) { // Folia - region threading gameprofilerfiller.push("dragonFight"); @@ -13275,7 +13378,7 @@ index 17610196db7a1c6feb2cf74a02479a8691aa323f..32fdb3d70442257201472f9f1c1ad466 } org.spigotmc.ActivationRange.activateEntities(this); // Spigot - timings.entityTick.startTiming(); // Spigot + this.timings.entityTick.startTiming(); // Spigot - this.entityTickList.forEach((entity) -> { + regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking if (!entity.isRemoved()) { @@ -13295,12 +13398,12 @@ index 17610196db7a1c6feb2cf74a02479a8691aa323f..32fdb3d70442257201472f9f1c1ad466 + // Folia start - region threading + public void tickSleep() { + int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); long j; // Folia moved from tick loop -+ if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { // Folia - region threading - moved to global tick ++ if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { + // CraftBukkit start + j = this.levelData.getDayTime() + 24000L; + TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (j - j % 24000L) - this.getDayTime()); + if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { -+ getCraftServer().getPluginManager().callEvent(event); ++ this.getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + this.setDayTime(this.getDayTime() + event.getSkipAmount()); + } @@ -13704,7 +13807,7 @@ index 17610196db7a1c6feb2cf74a02479a8691aa323f..32fdb3d70442257201472f9f1c1ad466 - return sendParticles(players, sender, t0, d0, d1, d2, i, d3, d4, d5, d6, force); + return sendParticles(this.getLocalPlayers(), sender, t0, d0, d1, d2, i, d3, d4, d5, d6, force); // Folia - region threading } - 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) { + public int sendParticles(List receivers, @Nullable ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) { // Paper end @@ -2053,7 +2214,14 @@ public class ServerLevel extends Level implements WorldGenLevel { public Entity getEntityOrPart(int id) { @@ -13815,7 +13918,7 @@ index 17610196db7a1c6feb2cf74a02479a8691aa323f..32fdb3d70442257201472f9f1c1ad466 public void blockUpdated(BlockPos pos, Block block) { if (!this.isDebug()) { // CraftBukkit start -- if (populating) { +- if (this.populating) { + if (this.getCurrentWorldData().populating) { // Folia - region threading return; } @@ -13993,7 +14096,7 @@ index 17610196db7a1c6feb2cf74a02479a8691aa323f..32fdb3d70442257201472f9f1c1ad466 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 ba972d1661426d7e30f6f61bad3b9608e66ea721..f490bf6a1caed16fd4238ead6565fc5a7ec219bf 100644 +index f71a4a8307fb092d33545e12d253e0b80c884168..89f7825a8cf415f3c2e0ddcb41c159a84d2e4bd1 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -185,7 +185,7 @@ import org.bukkit.inventory.MainHand; @@ -14550,7 +14653,7 @@ index ba972d1661426d7e30f6f61bad3b9608e66ea721..f490bf6a1caed16fd4238ead6565fc5a this.camera = (Entity) (entity == null ? this : entity); if (entity1 != this.camera) { // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Event -@@ -2630,7 +3072,7 @@ public class ServerPlayer extends Player { +@@ -2633,7 +3075,7 @@ public class ServerPlayer extends Player { this.experienceLevel = this.newLevel; this.totalExperience = this.newTotalExp; this.experienceProgress = 0; @@ -14560,7 +14663,7 @@ index ba972d1661426d7e30f6f61bad3b9608e66ea721..f490bf6a1caed16fd4238ead6565fc5a 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 b2c2bd5ec0afd479973f7237a5c610f21231c505..fff64e3b5cd72a64d95a1439b42472f8a646d18a 100644 +index 106a312aba249d1e83e4b535fc6e741e04ccfd14..0806559b4f4cebc88fb1f724a6916dac0c0c95e4 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java @@ -128,7 +128,7 @@ public class ServerPlayerGameMode { @@ -14585,8 +14688,8 @@ index b2c2bd5ec0afd479973f7237a5c610f21231c505..fff64e3b5cd72a64d95a1439b42472f8 } else { // CraftBukkit start org.bukkit.block.BlockState state = bblock.getState(); -- level.captureDrops = new ArrayList<>(); -+ level.getCurrentWorldData().captureDrops = new ArrayList<>(); // Folia - region threading +- this.level.captureDrops = new ArrayList<>(); ++ this.level.getCurrentWorldData().captureDrops = new ArrayList<>(); // Folia - region threading // CraftBukkit end block.playerWillDestroy(this.level, pos, iblockdata, this.player); boolean flag = this.level.removeBlock(pos, false); @@ -14594,10 +14697,10 @@ index b2c2bd5ec0afd479973f7237a5c610f21231c505..fff64e3b5cd72a64d95a1439b42472f8 // return true; // CraftBukkit } // CraftBukkit start -- java.util.List itemsToDrop = level.captureDrops; // Paper - store current list -- level.captureDrops = null; // Paper - Remove this earlier so that we can actually drop stuff -+ java.util.List itemsToDrop = level.getCurrentWorldData().captureDrops; // Paper - store current list // Folia - region threading -+ level.getCurrentWorldData().captureDrops = null; // Paper - Remove this earlier so that we can actually drop stuff // Folia - region threading +- java.util.List itemsToDrop = this.level.captureDrops; // Paper - store current list +- this.level.captureDrops = null; // Paper - Remove this earlier so that we can actually drop stuff ++ java.util.List itemsToDrop = this.level.getCurrentWorldData().captureDrops; // Paper - store current list // Folia - region threading ++ this.level.getCurrentWorldData().captureDrops = null; // Paper - Remove this earlier so that we can actually drop stuff // Folia - region threading if (event.isDropItems()) { org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, itemsToDrop); // Paper - use stored ref } @@ -14730,7 +14833,7 @@ index 50ed7cfe1ecef6d075ba484804827cec83ba2bf2..41c03421edd88dba669354595a2ace12 this.generatingStatus = status; this.writeRadiusCutoff = placementRadius; diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 20122bf191ebc74c223310aea1f004fdbb163e57..578f5989037acbca98f22316630c15da689f1dc0 100644 +index 598f807f0d0caac98b81e0e2991f1bd497c4534e..2bb944cef9bc8c5e56023ef20921ef13509d4823 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -85,6 +85,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -14889,7 +14992,7 @@ index 79326308f6126f84a3cbb3d5a33302de048d8a50..81090d1b5d67506268a41c6387a1d453 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 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ffa7363fbc 100644 +index 65bb221993147a558995b36fb835f7b82e0eb4bd..159d3a27c1686fd2b0025cab5b7e7775679c4ce9 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -289,7 +289,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -15027,7 +15130,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff return; } -@@ -770,13 +805,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -771,13 +806,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // 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 @@ -15043,7 +15146,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff return; } // Paper end -@@ -801,7 +836,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -802,7 +837,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (!event.isHandled()) { if (!event.isCancelled()) { @@ -15052,7 +15155,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { -@@ -817,7 +852,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -818,7 +853,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.connection.send(new ClientboundCommandSuggestionsPacket(packet.getId(), suggestEvent.getSuggestions())); // Paper end - Brigadier API }); @@ -15061,7 +15164,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff } } else if (!completions.isEmpty()) { final com.mojang.brigadier.suggestion.SuggestionsBuilder builder0 = new com.mojang.brigadier.suggestion.SuggestionsBuilder(command, stringreader.getTotalLength()); -@@ -1129,7 +1164,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1130,7 +1165,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length; if (byteLength > 256 * 4) { ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with with a page too large!"); @@ -15070,7 +15173,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff return; } byteTotal += byteLength; -@@ -1152,17 +1187,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1153,17 +1188,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (byteTotal > byteAllowed) { ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send too large of a book. Book Size: " + byteTotal + " - Allowed: "+ byteAllowed + " - Pages: " + pageList.size()); @@ -15092,7 +15195,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff // CraftBukkit end int i = packet.getSlot(); -@@ -1182,7 +1217,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1183,7 +1218,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.updateBookContents(list1, i); }; @@ -15113,7 +15216,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff } } -@@ -1348,9 +1395,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1349,9 +1396,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl int i = this.receivedMovePacketCount - this.knownMovePacketCount; // CraftBukkit start - handle custom speeds and skipped ticks @@ -15126,7 +15229,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff 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); -@@ -1536,7 +1584,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1537,7 +1585,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // If the event is cancelled we move the player back to their old location. if (event.isCancelled()) { @@ -15135,7 +15238,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff return; } -@@ -1544,7 +1592,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1545,7 +1593,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. // We only do this if the Event was not cancelled. if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { @@ -15144,7 +15247,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff return; } -@@ -1777,9 +1825,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1778,9 +1826,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (!this.player.isSpectator()) { // limit how quickly items can be dropped // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick. @@ -15156,7 +15259,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff } else { // Else we increment the drop count and check the amount. this.dropCount++; -@@ -1807,7 +1855,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1808,7 +1856,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl case ABORT_DESTROY_BLOCK: case STOP_DESTROY_BLOCK: // Paper start - Don't allow digging in unloaded chunks @@ -15165,7 +15268,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff this.player.connection.ackBlockChangesUpTo(packet.getSequence()); return; } -@@ -1891,7 +1939,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1892,7 +1940,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl BlockPos blockposition = movingobjectpositionblock.getBlockPos(); Vec3 vec3d1 = Vec3.atCenterOf(blockposition); @@ -15174,7 +15277,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff Vec3 vec3d2 = vec3d.subtract(vec3d1); double d0 = 1.0000001D; -@@ -2005,7 +2053,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2006,7 +2054,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl Entity entity = packet.getEntity(worldserver); if (entity != null) { @@ -15183,7 +15286,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff return; } } -@@ -2042,7 +2090,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2043,7 +2091,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } // CraftBukkit end ServerGamePacketListenerImpl.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), reason.getString()); @@ -15192,7 +15295,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff super.onDisconnect(reason, quitMessage); // Paper } -@@ -2051,6 +2099,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2052,6 +2100,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.removePlayerFromWorld(null); } @@ -15201,7 +15304,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff private void removePlayerFromWorld(@Nullable net.kyori.adventure.text.Component quitMessage) { // Paper end this.chatMessageChain.close(); -@@ -2063,6 +2113,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2064,6 +2114,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.player.disconnect(); // Paper start - Adventure quitMessage = quitMessage == null ? this.server.getPlayerList().remove(this.player) : this.server.getPlayerList().remove(this.player, quitMessage); // Paper - pass in quitMessage to fix kick message not being used @@ -15210,7 +15313,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) { this.server.getPlayerList().broadcastSystemMessage(PaperAdventure.asVanilla(quitMessage), false); // Paper end -@@ -2115,9 +2167,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2116,9 +2168,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } // CraftBukkit end if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.message())) { @@ -15222,7 +15325,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff } else { Optional optional = this.tryHandleChat(packet.message(), packet.timeStamp(), packet.lastSeenMessages()); -@@ -2150,23 +2202,22 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2151,23 +2203,22 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @Override public void handleChatCommand(ServerboundChatCommandPacket packet) { if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.command())) { @@ -15250,7 +15353,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff } } -@@ -2240,9 +2291,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2241,9 +2292,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl 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 @@ -15262,7 +15365,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff return Optional.empty(); } else { Optional optional = this.unpackAndApplyLastSeen(acknowledgment); -@@ -2317,7 +2368,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2318,7 +2369,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl String originalFormat = event.getFormat(), originalMessage = event.getMessage(); this.cserver.getPluginManager().callEvent(event); @@ -15271,15 +15374,15 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff // Evil plugins still listening to deprecated event final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), event.getRecipients()); queueEvent.setCancelled(event.isCancelled()); -@@ -2428,6 +2479,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2429,6 +2480,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (s.isEmpty()) { ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message"); - } else if (getCraftPlayer().isConversing()) { + } else if (this.getCraftPlayer().isConversing()) { + if (true) throw new UnsupportedOperationException(); // Folia - region threading final String conversationInput = s; this.server.processQueue.add(new Runnable() { @Override -@@ -2664,8 +2716,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2665,8 +2717,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // Spigot End public void switchToConfig() { @@ -15306,7 +15409,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff this.send(new ClientboundStartConfigurationPacket()); } -@@ -2690,7 +2759,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2691,7 +2760,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.player.resetLastActionTime(); this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); @@ -15315,7 +15418,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff if (!worldserver.getWorldBorder().isWithinBounds(entity.blockPosition())) { return; } -@@ -2831,6 +2900,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2832,6 +2901,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl switch (packetplayinclientcommand_enumclientcommand) { case PERFORM_RESPAWN: if (this.player.wonGame) { @@ -15328,7 +15431,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff this.player.wonGame = false; this.player = this.server.getPlayerList().respawn(this.player, this.server.getLevel(this.player.getRespawnDimension()), true, null, true, RespawnReason.END_PORTAL, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag.END_PORTAL); // Paper - add isEndCreditsRespawn argument CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); -@@ -2839,6 +2914,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2840,6 +2915,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl return; } @@ -15347,7 +15450,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff this.player = this.server.getPlayerList().respawn(this.player, false, RespawnReason.DEATH); if (this.server.isHardcore()) { this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper -@@ -3191,7 +3278,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -3198,7 +3285,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl // Paper start if (!org.bukkit.Bukkit.isPrimaryThread()) { if (this.recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) { @@ -15356,7 +15459,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff return; } } -@@ -3360,7 +3447,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -3367,7 +3454,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.filterTextPacket(list).thenAcceptAsync((list1) -> { this.updateSignText(packet, list1); @@ -15377,7 +15480,7 @@ index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..14eca10ba81242ec16c77cf69cfee0ff private void updateSignText(ServerboundSignUpdatePacket packet, List signText) { diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index ff2dd53e9e943aa929188fd9d4c35498b78c497a..57649d7fd11bef6395e04c075980e4c34eeffaa8 100644 +index 1c4f272219e68373eaae93fc5ea9af7d8f3fd6f9..6f483c6581daeaf68f85e3b730d31c5b7a6ae001 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -82,9 +82,13 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @@ -15480,7 +15583,7 @@ index ce43cb0152ba07c6c21e08142d65813d47c3b63b..8bdb1d10648965e2011b4a22a1dfc575 date1 = fallback; } diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651bf8a73416 100644 +index 33abcf12b4426572b74ca4c813e4392c823494bc..6cce2a9bc9beeeef25b7bacd2ad307ed3ae44432 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -133,10 +133,10 @@ public abstract class PlayerList { @@ -15563,18 +15666,20 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b player.isRealPlayer = true; // Paper player.loginTime = System.currentTimeMillis(); // Paper GameProfile gameprofile = player.getGameProfile(); -@@ -240,16 +287,37 @@ public abstract class PlayerList { - // Paper start - if (nbttagcompound == null) { +@@ -259,18 +306,42 @@ public abstract class PlayerList { player.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT; // set Player SpawnReason to DEFAULT on first login -- player.fudgeSpawnLocation(worldserver1); // only move to spawn on first login, otherwise, stay where you are.... -+ ServerPlayer.fudgeSpawnLocation(worldserver1, player, toComplete); // only move to spawn on first login, otherwise, stay where you are.... // Folia - region threading + // Paper start - reset to main world spawn if first spawn or invalid world } - // Paper end + // Folia start - region threading - rewrite login process ++ // must write to these before toComplete is invoked + data.setValue(nbttagcompound); + lastKnownName.setValue(s); -+ if (nbttagcompound != null) { ++ // Folia end - region threading - rewrite login process + if (nbttagcompound == null || invalidPlayerWorld) { + // Paper end +- player.fudgeSpawnLocation(worldserver1); // only move to spawn on first login, otherwise, stay where you are.... ++ ServerPlayer.fudgeSpawnLocation(worldserver1, player, toComplete); // only move to spawn on first login, otherwise, stay where you are.... // Folia - region threading ++ } else { // Folia start - region threading - rewrite login process + worldserver1.loadChunksForMoveAsync( + player.getBoundingBox(), + ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGHER, @@ -15582,7 +15687,10 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b + toComplete.complete(io.papermc.paper.util.MCUtil.toLocation(worldserver1, player.position())); + } + ); -+ } + } ++ // Folia end - region threading - rewrite login process + // Paper end ++ // Folia start - region threading - rewrite login process + return; + } + // nbttagcomound -> player data @@ -15603,7 +15711,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b Location loc = ev.getSpawnLocation(); worldserver1 = ((CraftWorld) loc.getWorld()).getHandle(); -@@ -268,6 +336,10 @@ public abstract class PlayerList { +@@ -289,6 +360,10 @@ public abstract class PlayerList { player.loadGameTypes(nbttagcompound); ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, clientData); @@ -15614,7 +15722,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b GameRules gamerules = worldserver1.getGameRules(); boolean flag = gamerules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN); boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); -@@ -283,7 +355,7 @@ public abstract class PlayerList { +@@ -304,7 +379,7 @@ public abstract class PlayerList { this.sendPlayerPermissionLevel(player); player.getStats().markAllDirty(); player.getRecipeBook().sendInitialRecipeBook(player); @@ -15623,7 +15731,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b this.server.invalidateStatus(); MutableComponent ichatmutablecomponent; -@@ -325,7 +397,7 @@ public abstract class PlayerList { +@@ -346,7 +421,7 @@ public abstract class PlayerList { this.cserver.getPluginManager().callEvent(playerJoinEvent); if (!player.connection.isAcceptingMessages()) { @@ -15632,7 +15740,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b } final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); -@@ -340,8 +412,7 @@ public abstract class PlayerList { +@@ -361,8 +436,7 @@ public abstract class PlayerList { ClientboundPlayerInfoUpdatePacket packet = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player)); // Paper final List onlinePlayers = Lists.newArrayListWithExpectedSize(this.players.size() - 1); // Paper - use single player info update packet @@ -15642,7 +15750,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b if (entityplayer1.getBukkitEntity().canSee(bukkitPlayer)) { // Paper start -@@ -463,7 +534,7 @@ public abstract class PlayerList { +@@ -484,7 +558,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); @@ -15651,7 +15759,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam); } // Paper end -@@ -558,7 +629,7 @@ public abstract class PlayerList { +@@ -579,7 +653,7 @@ public abstract class PlayerList { protected void save(ServerPlayer player) { if (!player.getBukkitEntity().isPersistent()) return; // CraftBukkit @@ -15660,7 +15768,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b this.playerIo.save(player); ServerStatsCounter serverstatisticmanager = (ServerStatsCounter) player.getStats(); // CraftBukkit -@@ -598,7 +669,7 @@ public abstract class PlayerList { +@@ -619,7 +693,7 @@ public abstract class PlayerList { // CraftBukkit end // Paper start - Remove from collideRule team if needed @@ -15669,7 +15777,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b final Scoreboard scoreBoard = this.server.getLevel(Level.OVERWORLD).getScoreboard(); final PlayerTeam team = scoreBoard.getPlayersTeam(this.collideRuleTeamName); if (entityplayer.getTeam() == team && team != null) { -@@ -638,7 +709,7 @@ public abstract class PlayerList { +@@ -659,7 +733,7 @@ public abstract class PlayerList { entityplayer.unRide(); worldserver.removePlayerImmediately(entityplayer, Entity.RemovalReason.UNLOADED_WITH_PLAYER); @@ -15678,7 +15786,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b entityplayer.getAdvancements().stopListening(); this.players.remove(entityplayer); this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot -@@ -657,8 +728,7 @@ public abstract class PlayerList { +@@ -678,8 +752,7 @@ public abstract class PlayerList { // CraftBukkit start // this.broadcastAll(new ClientboundPlayerInfoRemovePacket(List.of(entityplayer.getUUID()))); ClientboundPlayerInfoRemovePacket packet = new ClientboundPlayerInfoRemovePacket(List.of(entityplayer.getUUID())); @@ -15688,7 +15796,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { entityplayer2.connection.send(packet); -@@ -683,19 +753,13 @@ public abstract class PlayerList { +@@ -704,19 +777,13 @@ public abstract class PlayerList { ServerPlayer entityplayer; @@ -15710,7 +15818,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b } // Instead of kicking then returning, we need to store the kick reason -@@ -714,7 +778,7 @@ public abstract class PlayerList { +@@ -735,7 +802,7 @@ public abstract class PlayerList { ichatmutablecomponent = Component.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason()); if (gameprofilebanentry.getExpires() != null) { @@ -15719,7 +15827,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b } // return chatmessage; -@@ -727,14 +791,14 @@ public abstract class PlayerList { +@@ -748,14 +815,14 @@ public abstract class PlayerList { ichatmutablecomponent = Component.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason()); if (ipbanentry.getExpires() != null) { @@ -15736,7 +15844,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b event.disallow(PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure } } -@@ -800,6 +864,11 @@ public abstract class PlayerList { +@@ -821,6 +888,11 @@ public abstract class PlayerList { public ServerPlayer respawn(ServerPlayer entityplayer, ServerLevel worldserver, boolean flag, Location location, boolean avoidSuffocation, RespawnReason reason, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag...respawnFlags) { // Paper end @@ -15748,7 +15856,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b entityplayer.stopRiding(); // CraftBukkit this.players.remove(entityplayer); this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot -@@ -993,10 +1062,10 @@ public abstract class PlayerList { +@@ -1014,10 +1086,10 @@ public abstract class PlayerList { public void tick() { if (++this.sendAllPlayerInfoIn > 600) { // CraftBukkit start @@ -15762,7 +15870,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b @Override public boolean test(ServerPlayer input) { return target.getBukkitEntity().canSee(input.getBukkitEntity()); -@@ -1022,18 +1091,17 @@ public abstract class PlayerList { +@@ -1043,18 +1115,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) { @@ -15785,7 +15893,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b } } -@@ -1077,8 +1145,7 @@ public abstract class PlayerList { +@@ -1098,8 +1169,7 @@ public abstract class PlayerList { if (scoreboardteambase == null) { this.broadcastSystemMessage(message, false); } else { @@ -15795,7 +15903,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b if (entityplayer.getTeam() != scoreboardteambase) { entityplayer.sendSystemMessage(message); -@@ -1089,10 +1156,12 @@ public abstract class PlayerList { +@@ -1110,10 +1180,12 @@ public abstract class PlayerList { } public String[] getPlayerNamesArray() { @@ -15811,7 +15919,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b } return astring; -@@ -1111,7 +1180,9 @@ public abstract class PlayerList { +@@ -1132,7 +1204,9 @@ public abstract class PlayerList { ServerPlayer entityplayer = this.getPlayer(profile.getId()); if (entityplayer != null) { @@ -15821,7 +15929,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b } } -@@ -1121,7 +1192,10 @@ public abstract class PlayerList { +@@ -1142,7 +1216,10 @@ public abstract class PlayerList { ServerPlayer entityplayer = this.getPlayer(profile.getId()); if (entityplayer != null) { @@ -15832,7 +15940,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b } } -@@ -1182,8 +1256,7 @@ public abstract class PlayerList { +@@ -1203,8 +1280,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) { @@ -15842,7 +15950,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b // CraftBukkit start - Test if player receiving packet can see the source of the packet if (player != null && !entityplayer.getBukkitEntity().canSee(player.getBukkitEntity())) { -@@ -1213,12 +1286,21 @@ public abstract class PlayerList { +@@ -1234,12 +1310,21 @@ public abstract class PlayerList { io.papermc.paper.util.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main MinecraftTimings.savePlayers.startTiming(); // Paper int numSaved = 0; @@ -15869,7 +15977,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b } // Paper end } -@@ -1335,6 +1417,20 @@ public abstract class PlayerList { +@@ -1356,6 +1441,20 @@ public abstract class PlayerList { } public void removeAll(boolean isRestarting) { @@ -15890,7 +15998,7 @@ index 48d1444fbad1c57738807d0128b94160a5a17a4d..3f3d3cfa046124197bf7ed8d7f4b651b // Paper end // CraftBukkit start - disconnect safely for (ServerPlayer player : this.players) { -@@ -1344,7 +1440,7 @@ public abstract class PlayerList { +@@ -1365,7 +1464,7 @@ public abstract class PlayerList { // CraftBukkit end // Paper start - Remove collideRule team if it exists @@ -16139,10 +16247,10 @@ index ea27b46eec01bda427653335f922ccd068cffcb5..e551d3b875eab6851b75041f418c9a08 return blockToFallLocation(blockState); } else { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a53509829d499 100644 +index c655c6fee393c62ba79301f76baa72f9b1154a9a..dd18591d7928ab04f6f7c09aa89a26ccbe20c323 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 { +@@ -166,7 +166,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // Paper start public static RandomSource SHARED_RANDOM = new RandomRandomSource(); @@ -16151,7 +16259,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 private boolean locked = false; @Override -@@ -239,7 +239,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -240,7 +240,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper public boolean collisionLoadChunks = false; // Paper @@ -16160,7 +16268,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 public @org.jetbrains.annotations.Nullable net.minecraft.server.level.ChunkMap.TrackedEntity tracker; // Paper public @Nullable Throwable addedToWorldStack; // Paper - entity debug -@@ -528,6 +528,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -531,6 +531,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.teleportTo(worldserver, null); } // Paper end - make end portalling safe @@ -16184,9 +16292,39 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 + } + // Folia end - region ticking + public boolean isLegacyTrackingEntity = false; + +@@ -538,28 +557,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + this.isLegacyTrackingEntity = isLegacyTrackingEntity; + } + +- public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet getPlayersInTrackRange() { +- // determine highest range of passengers +- if (this.passengers.isEmpty()) { +- return ((ServerLevel)this.level).getChunkSource().chunkMap.playerEntityTrackerTrackMaps[this.trackingRangeType.ordinal()] +- .getObjectsInRange(MCUtil.getCoordinateKey(this)); +- } +- Iterable passengers = this.getIndirectPassengers(); +- net.minecraft.server.level.ChunkMap chunkMap = ((ServerLevel)this.level).getChunkSource().chunkMap; +- org.spigotmc.TrackingRange.TrackingRangeType type = this.trackingRangeType; +- int range = chunkMap.getEntityTrackerRange(type.ordinal()); +- +- for (Entity passenger : passengers) { +- org.spigotmc.TrackingRange.TrackingRangeType passengerType = passenger.trackingRangeType; +- int passengerRange = chunkMap.getEntityTrackerRange(passengerType.ordinal()); +- if (passengerRange > range) { +- type = passengerType; +- range = passengerRange; +- } +- } +- +- return chunkMap.playerEntityTrackerTrackMaps[type.ordinal()].getObjectsInRange(MCUtil.getCoordinateKey(this)); +- } ++ // Folia - region ticking + // Paper end - optimise entity tracking + public Entity(EntityType type, Level world) { - this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -770,6 +789,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -803,6 +801,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { // CraftBukkit start public void postTick() { @@ -16199,7 +16337,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 // 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(); -@@ -792,7 +817,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -825,7 +829,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.walkDistO = this.walkDist; this.xRotO = this.getXRot(); this.yRotO = this.getYRot(); @@ -16208,12 +16346,12 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -901,11 +926,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -934,11 +938,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 +- CraftEventFactory.blockDamage = (this.lastLavaContact) == null ? null : org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.lastLavaContact); ++ CraftEventFactory.blockDamageRT.set((this.lastLavaContact) == null ? null : org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.lastLavaContact)); // Folia - region threading if (this.hurt(this.damageSources().lava(), 4.0F)) { this.playSound(SoundEvents.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F); } @@ -16222,7 +16360,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls } -@@ -1050,8 +1075,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1083,8 +1087,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } else { this.wasOnFire = this.isOnFire(); if (movementType == MoverType.PISTON) { @@ -16233,7 +16371,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 movement = this.limitPistonMovement(movement); if (movement.equals(Vec3.ZERO)) { return; -@@ -2934,7 +2959,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2946,7 +2950,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.passengers = ImmutableList.copyOf(list); } @@ -16242,7 +16380,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 } } -@@ -2983,7 +3008,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2995,7 +2999,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } entity.boardingCooldown = 60; @@ -16251,7 +16389,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 } return true; // CraftBukkit } -@@ -3263,6 +3288,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3275,6 +3279,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @Nullable public Team getTeam() { @@ -16263,7 +16401,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -3378,9 +3408,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3390,9 +3399,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (this.fireImmune()) { return; } @@ -16275,7 +16413,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 return; } // CraftBukkit end -@@ -3553,6 +3583,775 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3565,6 +3574,775 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.portalEntrancePos = original.portalEntrancePos; } @@ -17051,7 +17189,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 @Nullable public Entity changeDimension(ServerLevel destination) { // CraftBukkit start -@@ -3561,6 +4360,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3573,6 +4351,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @Nullable public Entity teleportTo(ServerLevel worldserver, Vec3 location) { @@ -17063,7 +17201,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 // CraftBukkit end // Paper start - fix bad state entities causing dupes if (!this.isAlive() || !this.valid) { -@@ -3649,6 +4453,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3661,6 +4444,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } } @@ -17076,7 +17214,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 protected void removeAfterChangingDimensions() { this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION); } -@@ -4577,7 +5387,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4589,7 +5378,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } } // Paper end - fix MC-4 @@ -17086,7 +17224,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 synchronized (this.posLock) { // Paper this.position = new Vec3(x, y, z); } // Paper -@@ -4598,7 +5409,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4610,7 +5400,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 @@ -17095,7 +17233,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 this.setBoundingBox(this.makeBoundingBox()); } // Paper end -@@ -4685,6 +5496,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4697,6 +5487,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return this.removalReason != null; } @@ -17108,7 +17246,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 @Nullable public Entity.RemovalReason getRemovalReason() { return this.removalReason; -@@ -4700,6 +5517,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4712,6 +5508,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } // Paper end - rewrite chunk system final boolean alreadyRemoved = this.removalReason != null; @@ -17118,7 +17256,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 if (this.removalReason == null) { this.removalReason = reason; } -@@ -4722,6 +5542,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4734,6 +5533,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.removalReason = null; } @@ -17130,7 +17268,7 @@ index f20ae9153b7098980ce6c0e75fcbbb4da652661b..47061546345d0f367aa64c2d562a5350 /** * Invoked only when the entity is truly removed from the server, never to be added to any world. diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index b95f88d5e5b4785ee063695fd81935636a0588d1..768f7463775dd59d96196fbe789f628036d95fd5 100644 +index a76eb3d051db0229ed088b71c92ff3f131449007..db4f220bc9767ced5a98addc9e8b440b4f4f5b03 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -276,6 +276,13 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -17194,7 +17332,7 @@ index b95f88d5e5b4785ee063695fd81935636a0588d1..768f7463775dd59d96196fbe789f6280 if (this.isTickingEffects) { this.effectsToProcess.add(new ProcessableEffect(mobeffect, cause)); return true; -@@ -2334,7 +2344,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2331,7 +2341,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @Nullable public LivingEntity getKillCredit() { @@ -17203,7 +17341,7 @@ index b95f88d5e5b4785ee063695fd81935636a0588d1..768f7463775dd59d96196fbe789f6280 } public final float getMaxHealth() { -@@ -3472,7 +3482,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3469,7 +3479,7 @@ public abstract class LivingEntity extends Entity implements Attackable { this.pushEntities(); this.level().getProfiler().pop(); // Paper start @@ -17212,7 +17350,7 @@ index b95f88d5e5b4785ee063695fd81935636a0588d1..768f7463775dd59d96196fbe789f6280 if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { Location from = new Location(this.level().getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); Location to = new Location (this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -@@ -4166,7 +4176,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -4163,7 +4173,7 @@ public abstract class LivingEntity extends Entity implements Attackable { BlockPos blockposition = BlockPos.containing(d0, d1, d2); Level world = this.level(); @@ -17222,7 +17360,7 @@ index b95f88d5e5b4785ee063695fd81935636a0588d1..768f7463775dd59d96196fbe789f6280 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 d28c477171c1b6888a45175075017d960464b5cd..8d6a2966ebf5ff5813575f5451cceaddace53b4c 100644 +index 956d05e2ae59978ea9623ca0e167c0afe0b87306..4e9d510646abbc2d2b6f2d935f7416b6872eb234 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java @@ -136,6 +136,14 @@ public abstract class Mob extends LivingEntity implements Targeting { @@ -17271,7 +17409,7 @@ index d28c477171c1b6888a45175075017d960464b5cd..8d6a2966ebf5ff5813575f5451cceadd if (fireEvent) { if (reason == EntityTargetEvent.TargetReason.UNKNOWN && this.getTarget() != null && entityliving == null) { reason = this.getTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; -@@ -909,7 +929,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -907,7 +927,7 @@ public abstract class Mob extends LivingEntity implements Targeting { this.level().getProfiler().push("sensing"); this.sensing.tick(); this.level().getProfiler().pop(); @@ -17280,7 +17418,7 @@ index d28c477171c1b6888a45175075017d960464b5cd..8d6a2966ebf5ff5813575f5451cceadd if (i % 2 != 0 && this.tickCount > 1) { this.level().getProfiler().push("targetSelector"); -@@ -1746,6 +1766,15 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1744,6 +1764,15 @@ public abstract class Mob extends LivingEntity implements Targeting { this.goalSelector.removeAllGoals(predicate); } @@ -17296,7 +17434,7 @@ index d28c477171c1b6888a45175075017d960464b5cd..8d6a2966ebf5ff5813575f5451cceadd @Override protected void removeAfterChangingDimensions() { super.removeAfterChangingDimensions(); -@@ -1754,12 +1783,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1752,12 +1781,7 @@ public abstract class Mob extends LivingEntity implements Targeting { this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit this.dropLeash(true, event.isDropLeash()); // Paper end @@ -17872,7 +18010,7 @@ index 90e577b1a89b02c38daff2845a63dafe5ed929e1..150fb1fc4d70330a4c56ff5847792a1e } diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java -index 3d44f8e9f8056d7d899e90e61240b2d1d109354b..ef61663d9ba41cf02a03800c74d4ce4ccc5faec5 100644 +index 5fdad1600cc7a7c22d1d9a58b6b2dda605521b97..e2b9a18fd4a573aa2b3299a2e19afc07cc747366 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java @@ -95,7 +95,7 @@ public class Zombie extends Monster { @@ -17915,7 +18053,7 @@ index 3d44f8e9f8056d7d899e90e61240b2d1d109354b..ef61663d9ba41cf02a03800c74d4ce4c this.getEntityData().set(Zombie.DATA_DROWNED_CONVERSION_ID, true); } diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java -index 807cff3fb51269b97d9aecbcc4706f0a139dfeaa..145f7ea3b287ccd54dca9c5c284aaa251543ce64 100644 +index 94396ad1a3c280787d36c6c18256d10340ace488..8fb13d9ed74e254522e6ee7196a6c72ccc8092b7 100644 --- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java @@ -73,7 +73,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { @@ -17949,7 +18087,7 @@ index 807cff3fb51269b97d9aecbcc4706f0a139dfeaa..145f7ea3b287ccd54dca9c5c284aaa25 @Override diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java -index 5119d070dbb04f5a4f9c2def526e33e15ca8573f..1cd031634150c7d5eb6cd7ba3c92a67c3d1dc0a5 100644 +index 5a591c439c5cef6b7e7e6f836ab813cb4f29b08c..ce728f062794e239d1dfdf842d7d0c725f77fba7 100644 --- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java @@ -212,10 +212,18 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa @@ -18001,7 +18139,7 @@ index 5f407535298a31a34cfe114dd863fd6a9b977707..cb0f75fb32836efa50f0a86dfae7907b 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 f555e29c7f9ea4ddb243a018bdc93d2bf1950c3c..a1bc0dc172fc88f87b4cd59a70c46331413d585f 100644 +index cbe2a37f74f4fb2abd0b3297699e54335aaed64f..4e9ccc518f37755e86687653f7724240db754682 100644 --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java +++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java @@ -203,7 +203,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler @@ -18124,7 +18262,7 @@ index 8385eb1d60f377da94e3178ab506feefb43563fd..2f57e5025d0a0e720f49da1e5231a7d9 entityvillagertrader.setWanderTarget(blockposition1); entityvillagertrader.restrictTo(blockposition1, 16); diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index d58b4c0dbe651b5068212e5f14dce3164ee520f5..ea52f7b3620249a75cf9619481c90acdf781653e 100644 +index 481c3e321cfc0f20bb1c4c6942b8bdbd23c06339..51c31ac3d54996a6e2d870d8215546fdcf5ee506 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java @@ -1508,6 +1508,14 @@ public abstract class Player extends LivingEntity { @@ -18143,7 +18281,7 @@ index d58b4c0dbe651b5068212e5f14dce3164ee520f5..ea52f7b3620249a75cf9619481c90acd return false; } diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -index 8affdd74769aed9aa92a76ba539cd9d27208827c..cf1643ea51487caacf93712faa3c6fde6097f2ac 100644 +index 6c176933967f6ee98da3026f16a10efe4c3842fe..1b919bda12fb6c4bbad8cd477dbcbe520655b346 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 { @@ -18175,7 +18313,7 @@ index 6c9a8f062f989db022154155e8a05b334a0510da..77f55bcb120295fa11140681f63175d3 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 f349d64123686073b7f1b53a44be05fae5729587..99e16216346b7c19f7a33a5b170a3509189a2dbc 100644 +index bbdb82b319480b103df463cce3c1b8e3dd5857ec..d345e3163694588da5318e7ecd5c3d7cbbc24b32 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java +++ b/src/main/java/net/minecraft/world/entity/projectile/EvokerFangs.java @@ -129,9 +129,9 @@ public class EvokerFangs extends Entity implements TraceableEntity { @@ -18231,7 +18369,7 @@ index b2f08889139dc447f7071f1c81456035bf8de31e..619bedc55d61f83dbc5adcf76a739cf9 } } 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 a9eaa079a43bc8a5e81deaf6df5ce2f9c53cb319..1ad4623c6eb24f9615ac970edff0ae8fcf910f26 100644 +index a2093158e57d5f43c4afa66386481b82b3c4c3c4..762376c2ab61200681fd5e5732337530285e03fb 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java @@ -104,7 +104,7 @@ public class FishingHook extends Projectile { @@ -18263,7 +18401,7 @@ index a9eaa079a43bc8a5e81deaf6df5ce2f9c53cb319..1ad4623c6eb24f9615ac970edff0ae8f ItemStack itemstack = player.getMainHandItem(); ItemStack itemstack1 = player.getOffhandItem(); boolean flag = itemstack.is(Items.FISHING_ROD); -@@ -597,10 +603,18 @@ public class FishingHook extends Projectile { +@@ -605,10 +611,18 @@ public class FishingHook extends Projectile { @Override public void remove(Entity.RemovalReason reason) { @@ -18333,7 +18471,7 @@ index a90317100d32974e481e14476843f66997a2cf3a..0c8f90a904c01105ba5fa6a803715069 } } 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 04c2ea1ff44af72ae48e2d6b7b912b1c14285038..8f1a80487802c64d0a10fbba6dae3d02b2cf15e6 100644 +index 9d43c8520953d6fe0d0948f9dbe14e0650ee01c2..c7713583930240512cd94f2a6bd1ff819ca6cd48 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 { @@ -18342,7 +18480,7 @@ index 04c2ea1ff44af72ae48e2d6b7b912b1c14285038..8f1a80487802c64d0a10fbba6dae3d02 // CraftBukkit start - if (this.getOwner() != null && this.getOwner() instanceof Mob) { + if (owner != null && owner instanceof Mob) { // Folia - region threading - isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + this.isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); } // CraftBukkit end diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java @@ -18362,7 +18500,7 @@ index ab777952bda1651796ed41e8a7fc6621f27db9aa..6b9365eba3339578ee2984605240b74d boolean flag = false; diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -index e02d5dcbf69bd68b2f567c1a16a44ab59955f871..7a679c45cccf3cffaaa4b813c928578c720198b1 100644 +index f5db60cbecbe69941873e064315931089fe0e48a..39bb4ec91e096cf84221a3bddbf7425023f0f609 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java @@ -42,6 +42,62 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { @@ -19041,7 +19179,7 @@ index 45243249a561440512ef2a620c60b02e159c80e2..f875a15db0d437a32062c626fb7e42fd private final double posX, posY, posZ; private final double minX, minY, minZ; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index ea8a0961190e9aafda4fed6fecd85097c141040a..fb889cea13d8f83f193a461ebd58fdcb115a5b34 100644 +index 2354a0e5d15e9be633d9fe3a1a9feefe7b9b7782..2329d08c736ab04f640b0baef3a0d3dce6840a31 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -117,10 +117,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -19299,26 +19437,26 @@ index ea8a0961190e9aafda4fed6fecd85097c141040a..fb889cea13d8f83f193a461ebd58fdcb @@ -1257,11 +1299,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { gameprofilerfiller.push("blockEntities"); - timings.tileEntityPending.startTiming(); // Spigot + this.timings.tileEntityPending.startTiming(); // Spigot - this.tickingBlockEntities = true; - if (!this.pendingBlockEntityTickers.isEmpty()) { - this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); - this.pendingBlockEntityTickers.clear(); - } -+ final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = ((ServerLevel)this).getCurrentWorldData(); // Folia - regionised ticking ++ final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = this.getCurrentWorldData(); // Folia - regionised ticking + regionizedWorldData.seTtickingBlockEntities(true); // Folia - regionised ticking + regionizedWorldData.pushPendingTickingBlockEntities(); // Folia - regionised ticking + List blockEntityTickers = regionizedWorldData.getBlockEntityTickers(); // Folia - regionised ticking - timings.tileEntityPending.stopTiming(); // Spigot + this.timings.tileEntityPending.stopTiming(); // Spigot - timings.tileEntityTick.startTiming(); // Spigot + this.timings.tileEntityTick.startTiming(); // Spigot @@ -1270,9 +1311,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); - for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters - this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0; -- TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(tileTickPosition); +- TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition); + for (int i = 0; i < blockEntityTickers.size(); i++) { // Paper - Disable tick limiters // Folia - regionised ticking + TickingBlockEntity tickingblockentity = (TickingBlockEntity) blockEntityTickers.get(i); // Folia - regionised ticking // Spigot start @@ -19338,13 +19476,13 @@ index ea8a0961190e9aafda4fed6fecd85097c141040a..fb889cea13d8f83f193a461ebd58fdcb - this.blockEntityTickers.removeAll(toRemove); + blockEntityTickers.removeAll(toRemove); // Folia - regionised ticking - timings.tileEntityTick.stopTiming(); // Spigot + this.timings.tileEntityTick.stopTiming(); // Spigot - this.tickingBlockEntities = false; - co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper + regionizedWorldData.seTtickingBlockEntities(false); // Folia - regionised ticking + //co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper // Folia - region threading gameprofilerfiller.pop(); -- spigotConfig.currentPrimedTnt = 0; // Spigot +- this.spigotConfig.currentPrimedTnt = 0; // Spigot + regionizedWorldData.currentPrimedTnt = 0; // Spigot // Folia - region threading } @@ -19665,7 +19803,7 @@ index 7700461b8cd0bde1bf6c0d5e4b73184bed1adc4e..479f571152ebb17315b294469658665b 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 48eb8f0c1da1fc1971563934497059b21aebf7b6..b4b31087308a1556292e9154161425d722929de2 100644 +index c98a7d0cc2fcf993ab05dc9347bfb34a7e1bdde5..db3060021f9e024a6dba93498422d41e9662f68a 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 { @@ -20187,7 +20325,7 @@ index 963a596154091b79ca139af6274aa323518ad1ad..57b11cb78270a8094f772da497ad3264 } 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 1d9b23c6e458caddc2c738164e6c079cd85d3ce9..97858b410769f95e4a8d8acd757216ffe06f8cf4 100644 +index d4dcf7fe26474ae07374e7761d823bc5c8b54f97..72779080969fe9f058c19533ffc9dad5f9c47086 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 @@ -233,12 +233,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -20249,7 +20387,7 @@ index 1d9b23c6e458caddc2c738164e6c079cd85d3ce9..97858b410769f95e4a8d8acd757216ff private static ItemStack callPushMoveEvent(Container iinventory, ItemStack itemstack, HopperBlockEntity hopper) { + io.papermc.paper.threadedregions.RegionizedWorldData worldData = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegionizedWorldData(); // Folia - region threading final Inventory destinationInventory = getInventory(iinventory); - final InventoryMoveItemEvent event = new InventoryMoveItemEvent(hopper.getOwner(false).getInventory(), + final io.papermc.paper.event.inventory.PaperInventoryMoveItemEvent event = new io.papermc.paper.event.inventory.PaperInventoryMoveItemEvent(hopper.getOwner(false).getInventory(), CraftItemStack.asCraftMirror(itemstack), destinationInventory, true); final boolean result = event.callEvent(); if (!event.calledGetItem && !event.calledSetItem) { @@ -20267,7 +20405,7 @@ index 1d9b23c6e458caddc2c738164e6c079cd85d3ce9..97858b410769f95e4a8d8acd757216ff final Inventory destination = getInventory(hopper); @@ -354,7 +356,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - final InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, CraftItemStack.asCraftMirror(itemstack), destination, false); + final io.papermc.paper.event.inventory.PaperInventoryMoveItemEvent event = new io.papermc.paper.event.inventory.PaperInventoryMoveItemEvent(sourceInventory, CraftItemStack.asCraftMirror(itemstack), destination, false); final boolean result = event.callEvent(); if (!event.calledGetItem && !event.calledSetItem) { - skipPullModeEventFire = true; @@ -20304,11 +20442,11 @@ index 1d9b23c6e458caddc2c738164e6c079cd85d3ce9..97858b410769f95e4a8d8acd757216ff 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 6c378e3485fef4e8b8906c33a45a23e6f77e9cdd..27a5da7571f48a18756004ea5e18fb355798f0a2 100644 +index 65112ec3a6ea1c27f032477720ae74395523012b..7f9022a271e29d0b47bef15359f1b2dc79de6402 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 -@@ -36,9 +36,9 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi - } +@@ -43,9 +43,9 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi + // Paper end public static void serverTick(Level world, BlockPos pos, BlockState state, SculkCatalystBlockEntity blockEntity) { - org.bukkit.craftbukkit.event.CraftEventFactory.sourceBlockOverride = blockEntity.getBlockPos(); // CraftBukkit - SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPosition up to five methods deep. @@ -20761,7 +20899,7 @@ index d5c2a608e1b4c8099c96b33d9d758e968350a46d..1a4da589142c515e713d879095b105de 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 3e9758fa40bf93fe3d315cc66389193bd57bc393..20884dc82f8c95ec5ca92448c856fa9bc2c1e3ee 100644 +index fa170cc1ce7011d201295b89718292d696c7fc24..744fa3a3a62ffb4b3d1e7831c93fd76dee29fdd0 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -59,6 +59,13 @@ public class LevelChunk extends ChunkAccess { @@ -20799,8 +20937,8 @@ index 3e9758fa40bf93fe3d315cc66389193bd57bc393..20884dc82f8c95ec5ca92448c856fa9b @Nullable public BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType) { // CraftBukkit start -- BlockEntity tileentity = level.capturedTileEntities.get(pos); -+ BlockEntity tileentity = level.getCurrentWorldData().capturedTileEntities.get(pos); // Folia - region threading +- BlockEntity tileentity = this.level.capturedTileEntities.get(pos); ++ BlockEntity tileentity = this.level.getCurrentWorldData().capturedTileEntities.get(pos); // Folia - region threading if (tileentity == null) { tileentity = (BlockEntity) this.blockEntities.get(pos); } @@ -21519,10 +21657,10 @@ index 1d7c663fa0e550bd0cfb9a4b83ccd7e2968666f0..f3df9c9b6cff85565514f990597f3fe5 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 39d6c642918f59c00fcfbf6f192211879b5e5466..a4dc29b1ccaac3f8e5ea491c1fd3d25960c245fa 100644 +index bbc51ebf0dc0801ace9d5e7875fb2fe100b286bc..7ced957b11deb6643bff6547257f449c56038d74 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -309,7 +309,7 @@ public final class CraftServer implements Server { +@@ -311,7 +311,7 @@ public final class CraftServer implements Server { private final CraftPotionBrewer potionBrewer = new CraftPotionBrewer(); // Paper // Paper start - Folia region threading API @@ -21531,7 +21669,7 @@ index 39d6c642918f59c00fcfbf6f192211879b5e5466..a4dc29b1ccaac3f8e5ea491c1fd3d259 private final io.papermc.paper.threadedregions.scheduler.FoliaAsyncScheduler asyncScheduler = new io.papermc.paper.threadedregions.scheduler.FoliaAsyncScheduler(); private final io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler globalRegionScheduler = new io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler(); -@@ -377,6 +377,12 @@ public final class CraftServer implements Server { +@@ -379,6 +379,12 @@ public final class CraftServer implements Server { return io.papermc.paper.util.TickThread.isTickThreadFor(((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandleRaw()); } // Paper end - Folia reagion threading API @@ -21544,7 +21682,7 @@ index 39d6c642918f59c00fcfbf6f192211879b5e5466..a4dc29b1ccaac3f8e5ea491c1fd3d259 static { ConfigurationSerialization.registerClass(CraftOfflinePlayer.class); -@@ -961,6 +967,9 @@ public final class CraftServer implements Server { +@@ -963,6 +969,9 @@ public final class CraftServer implements Server { // NOTE: Should only be called from DedicatedServer.ah() public boolean dispatchServerCommand(CommandSender sender, ConsoleInput serverCommand) { @@ -21554,7 +21692,7 @@ index 39d6c642918f59c00fcfbf6f192211879b5e5466..a4dc29b1ccaac3f8e5ea491c1fd3d259 if (sender instanceof Conversable) { Conversable conversable = (Conversable) sender; -@@ -980,12 +989,44 @@ public final class CraftServer implements Server { +@@ -982,12 +991,44 @@ public final class CraftServer implements Server { } } @@ -21599,7 +21737,7 @@ index 39d6c642918f59c00fcfbf6f192211879b5e5466..a4dc29b1ccaac3f8e5ea491c1fd3d259 if (this.commandMap.dispatch(sender, commandLine)) { return true; } -@@ -3107,7 +3148,7 @@ public final class CraftServer implements Server { +@@ -3171,7 +3212,7 @@ public final class CraftServer implements Server { @Override public int getCurrentTick() { @@ -21609,10 +21747,10 @@ index 39d6c642918f59c00fcfbf6f192211879b5e5466..a4dc29b1ccaac3f8e5ea491c1fd3d259 @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e77d6b3b4 100644 +index c3060d1d4d0caf369c6ab516cb424f45eb851019..bcbf7ba7c687ecaa530d4de3af45ebeb80dd15c5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -183,7 +183,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -184,7 +184,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getTickableTileEntityCount() { @@ -21621,7 +21759,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e } @Override -@@ -239,7 +239,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -240,7 +240,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper start - per world spawn limits for (SpawnCategory spawnCategory : SpawnCategory.values()) { if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { @@ -21630,7 +21768,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e } } // Paper end -@@ -326,6 +326,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -327,6 +327,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Chunk getChunkAt(int x, int z) { @@ -21638,7 +21776,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e warnUnsafeChunk("getting a faraway chunk", x, z); // Paper // Paper start - add ticket to hold chunk for a little while longer if plugin accesses it net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); -@@ -349,7 +350,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -350,7 +351,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper start private void addTicket(int x, int z) { @@ -21647,7 +21785,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e } // Paper end -@@ -368,10 +369,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -369,10 +370,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean isChunkGenerated(int x, int z) { // Paper start - Fix this method @@ -21660,7 +21798,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e } ChunkAccess chunk = world.getChunkSource().getChunkAtImmediately(x, z); if (chunk == null) { -@@ -425,7 +426,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -426,7 +427,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { } private boolean unloadChunk0(int x, int z, boolean save) { @@ -21669,7 +21807,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e if (!this.isChunkLoaded(x, z)) { return true; } -@@ -440,7 +441,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -441,7 +442,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean regenerateChunk(int x, int z) { @@ -21678,7 +21816,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e warnUnsafeChunk("regenerating a faraway chunk", x, z); // Paper // Paper start - implement regenerateChunk method final ServerLevel serverLevel = this.world; -@@ -501,6 +502,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -502,6 +503,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean refreshChunk(int x, int z) { @@ -21686,7 +21824,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z)); if (playerChunk == null) return false; -@@ -536,7 +538,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -537,7 +539,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean loadChunk(int x, int z, boolean generate) { @@ -21695,7 +21833,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e warnUnsafeChunk("loading a faraway chunk", x, z); // Paper // Paper start - Optimize this method ChunkPos chunkPos = new ChunkPos(x, z); -@@ -608,7 +610,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -609,7 +611,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { DistanceManager chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager; if (chunkDistanceManager.addRegionTicketAtDistance(TicketType.PLUGIN_TICKET, new ChunkPos(x, z), 2, plugin)) { // keep in-line with force loading, add at level 31 @@ -21704,41 +21842,41 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e return true; } -@@ -799,13 +801,15 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -800,13 +802,15 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { -- world.captureTreeGeneration = true; -- world.captureBlockStates = true; +- this.world.captureTreeGeneration = true; +- this.world.captureBlockStates = true; + io.papermc.paper.util.TickThread.ensureTickThread(this.world, loc.getX(), loc.getZ(), "Cannot generate tree asynchronously"); // Folia - region threading + io.papermc.paper.threadedregions.RegionizedWorldData worldData = world.getCurrentWorldData(); // Folia - region threading + worldData.captureTreeGeneration = true; // Folia - region threading + worldData.captureBlockStates = true; // Folia - region threading boolean grownTree = this.generateTree(loc, type); -- world.captureBlockStates = false; -- world.captureTreeGeneration = false; +- this.world.captureBlockStates = false; +- this.world.captureTreeGeneration = false; + worldData.captureBlockStates = false; // Folia - region threading + worldData.captureTreeGeneration = false; // Folia - region threading if (grownTree) { // Copy block data to delegate -- for (BlockState blockstate : world.capturedBlockStates.values()) { +- for (BlockState blockstate : this.world.capturedBlockStates.values()) { + for (BlockState blockstate : worldData.capturedBlockStates.values()) { // Folia - region threading BlockPos position = ((CraftBlockState) blockstate).getPosition(); net.minecraft.world.level.block.state.BlockState oldBlock = this.world.getBlockState(position); int flag = ((CraftBlockState) blockstate).getFlag(); -@@ -813,10 +817,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -814,10 +818,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { net.minecraft.world.level.block.state.BlockState newBlock = this.world.getBlockState(position); this.world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, newBlock, flag, 512); } -- world.capturedBlockStates.clear(); +- this.world.capturedBlockStates.clear(); + worldData.capturedBlockStates.clear(); // Folia - region threading return true; } else { -- world.capturedBlockStates.clear(); +- this.world.capturedBlockStates.clear(); + worldData.capturedBlockStates.clear(); // Folia - region threading return false; } } -@@ -850,6 +854,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -851,6 +855,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setTime(long time) { @@ -21746,7 +21884,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e long margin = (time - this.getFullTime()) % 24000; if (margin < 0) margin += 24000; this.setFullTime(this.getFullTime() + margin); -@@ -862,6 +867,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -863,6 +868,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setFullTime(long time) { @@ -21754,16 +21892,16 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e // Notify anyone who's listening TimeSkipEvent event = new TimeSkipEvent(this, TimeSkipEvent.SkipReason.CUSTOM, time - this.world.getDayTime()); this.server.getPluginManager().callEvent(event); -@@ -889,7 +895,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -890,7 +896,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public long getGameTime() { -- return world.levelData.getGameTime(); +- return this.world.levelData.getGameTime(); + return this.getHandle().getGameTime(); // Folia - region threading } @Override -@@ -909,11 +915,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -910,11 +916,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) { @@ -21777,7 +21915,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e return !world.explode(source != null ? ((org.bukkit.craftbukkit.entity.CraftEntity) source).getHandle() : null, loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks ? net.minecraft.world.level.Level.ExplosionInteraction.MOB : net.minecraft.world.level.Level.ExplosionInteraction.NONE).wasCanceled; } // Paper end -@@ -983,6 +991,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -984,6 +992,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) { @@ -21785,7 +21923,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper // Transient load for this tick return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z); -@@ -1013,6 +1022,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1014,6 +1023,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setBiome(int x, int y, int z, Holder bb) { BlockPos pos = new BlockPos(x, 0, z); @@ -21793,63 +21931,63 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e if (this.world.hasChunkAt(pos)) { net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkAt(pos); -@@ -1288,6 +1298,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1309,6 +1319,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setStorm(boolean hasStorm) { + io.papermc.paper.threadedregions.RegionizedServer.ensureGlobalTickThread("Cannot modify weather off of the global region"); // Folia - region threading - world.serverLevelData.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper + this.world.serverLevelData.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper this.setWeatherDuration(0); // Reset weather duration (legacy behaviour) this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) -@@ -1300,6 +1311,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1321,6 +1332,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setWeatherDuration(int duration) { + io.papermc.paper.threadedregions.RegionizedServer.ensureGlobalTickThread("Cannot modify weather off of the global region"); // Folia - region threading - world.serverLevelData.setRainTime(duration); + this.world.serverLevelData.setRainTime(duration); } -@@ -1310,6 +1322,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1331,6 +1343,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setThundering(boolean thundering) { + io.papermc.paper.threadedregions.RegionizedServer.ensureGlobalTickThread("Cannot modify weather off of the global region"); // Folia - region threading - world.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper + this.world.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper this.setThunderDuration(0); // Reset weather duration (legacy behaviour) this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) -@@ -1322,6 +1335,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1343,6 +1356,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setThunderDuration(int duration) { + io.papermc.paper.threadedregions.RegionizedServer.ensureGlobalTickThread("Cannot modify weather off of the global region"); // Folia - region threading - world.serverLevelData.setThunderTime(duration); + this.world.serverLevelData.setThunderTime(duration); } -@@ -1332,6 +1346,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1353,6 +1367,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setClearWeatherDuration(int duration) { + io.papermc.paper.threadedregions.RegionizedServer.ensureGlobalTickThread("Cannot modify weather off of the global region"); // Folia - region threading - world.serverLevelData.setClearWeatherTime(duration); + this.world.serverLevelData.setClearWeatherTime(duration); } -@@ -1526,6 +1541,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1547,6 +1562,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setKeepSpawnInMemory(boolean keepLoaded) { + io.papermc.paper.threadedregions.RegionizedServer.ensureGlobalTickThread("Cannot modify keep spawn in memory off of the global region"); // Folia - region threading // Paper start - Configurable spawn radius - if (keepLoaded == world.keepSpawnInMemory) { + if (keepLoaded == this.world.keepSpawnInMemory) { // do nothing, nothing has changed -@@ -1604,6 +1620,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1625,6 +1641,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setHardcore(boolean hardcore) { + io.papermc.paper.threadedregions.RegionizedServer.ensureGlobalTickThread("Cannot modify server settings off of the global region"); // Folia - region threading - world.serverLevelData.settings.hardcore = hardcore; + this.world.serverLevelData.settings.hardcore = hardcore; } -@@ -1616,6 +1633,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1637,6 +1654,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns) { @@ -21857,7 +21995,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.setTicksPerSpawns(SpawnCategory.ANIMAL, ticksPerAnimalSpawns); } -@@ -1628,6 +1646,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1649,6 +1667,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns) { @@ -21865,7 +22003,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.setTicksPerSpawns(SpawnCategory.MONSTER, ticksPerMonsterSpawns); } -@@ -1640,6 +1659,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1661,6 +1680,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterSpawns(int ticksPerWaterSpawns) { @@ -21873,7 +22011,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.setTicksPerSpawns(SpawnCategory.WATER_ANIMAL, ticksPerWaterSpawns); } -@@ -1652,6 +1672,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1673,6 +1693,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterAmbientSpawns(int ticksPerWaterAmbientSpawns) { @@ -21881,7 +22019,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.setTicksPerSpawns(SpawnCategory.WATER_AMBIENT, ticksPerWaterAmbientSpawns); } -@@ -1664,6 +1685,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1685,6 +1706,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterUndergroundCreatureSpawns(int ticksPerWaterUndergroundCreatureSpawns) { @@ -21889,7 +22027,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.setTicksPerSpawns(SpawnCategory.WATER_UNDERGROUND_CREATURE, ticksPerWaterUndergroundCreatureSpawns); } -@@ -1676,11 +1698,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1697,11 +1719,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerAmbientSpawns(int ticksPerAmbientSpawns) { @@ -21903,7 +22041,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e Preconditions.checkArgument(spawnCategory != null, "SpawnCategory cannot be null"); Preconditions.checkArgument(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory.%s are not supported", spawnCategory); -@@ -1697,21 +1721,25 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1718,21 +1742,25 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { @@ -21929,7 +22067,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.server.getWorldMetadata().removeMetadata(this, metadataKey, owningPlugin); } -@@ -1724,6 +1752,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1745,6 +1773,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setMonsterSpawnLimit(int limit) { @@ -21937,7 +22075,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.setSpawnLimit(SpawnCategory.MONSTER, limit); } -@@ -1736,6 +1765,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1757,6 +1786,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setAnimalSpawnLimit(int limit) { @@ -21945,7 +22083,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.setSpawnLimit(SpawnCategory.ANIMAL, limit); } -@@ -1748,6 +1778,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1769,6 +1799,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterAnimalSpawnLimit(int limit) { @@ -21953,7 +22091,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.setSpawnLimit(SpawnCategory.WATER_ANIMAL, limit); } -@@ -1760,6 +1791,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1781,6 +1812,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterAmbientSpawnLimit(int limit) { @@ -21961,7 +22099,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.setSpawnLimit(SpawnCategory.WATER_AMBIENT, limit); } -@@ -1772,6 +1804,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1793,6 +1825,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterUndergroundCreatureSpawnLimit(int limit) { @@ -21969,7 +22107,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.setSpawnLimit(SpawnCategory.WATER_UNDERGROUND_CREATURE, limit); } -@@ -1784,6 +1817,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1805,6 +1838,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setAmbientSpawnLimit(int limit) { @@ -21977,7 +22115,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e this.setSpawnLimit(SpawnCategory.AMBIENT, limit); } -@@ -1806,6 +1840,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1827,6 +1861,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setSpawnLimit(SpawnCategory spawnCategory, int limit) { @@ -21985,7 +22123,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e Preconditions.checkArgument(spawnCategory != null, "SpawnCategory cannot be null"); Preconditions.checkArgument(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory.%s are not supported", spawnCategory); -@@ -1860,7 +1895,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1881,7 +1916,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(CraftSound.bukkitToMinecraftHolder(sound), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, this.getHandle().getRandom().nextLong()); @@ -21994,7 +22132,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e if (entityTracker != null) { entityTracker.broadcastAndSend(packet); } -@@ -1871,7 +1906,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1892,7 +1927,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(Holder.direct(SoundEvent.createVariableRangeEvent(new ResourceLocation(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, this.getHandle().getRandom().nextLong()); @@ -22003,7 +22141,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e if (entityTracker != null) { entityTracker.broadcastAndSend(packet); } -@@ -1957,6 +1992,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1978,6 +2013,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean setGameRuleValue(String rule, String value) { @@ -22011,7 +22149,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e // No null values allowed if (rule == null || value == null) return false; -@@ -1999,6 +2035,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2020,6 +2056,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean setGameRule(GameRule rule, T newValue) { @@ -22019,7 +22157,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e Preconditions.checkArgument(rule != null, "GameRule cannot be null"); Preconditions.checkArgument(newValue != null, "GameRule value cannot be null"); -@@ -2264,6 +2301,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2272,6 +2309,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) { @@ -22032,7 +22170,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e getHandle().gameEvent(sourceEntity != null ? ((CraftEntity) sourceEntity).getHandle(): null, net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.get(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(gameEvent.getKey())), org.bukkit.craftbukkit.util.CraftVector.toBlockPos(position)); } // Paper end -@@ -2396,7 +2439,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2426,7 +2469,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 @@ -22041,7 +22179,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e net.minecraft.world.level.chunk.LevelChunk immediate = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); if (immediate != null) { return java.util.concurrent.CompletableFuture.completedFuture(new CraftChunk(immediate)); -@@ -2413,7 +2456,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2443,7 +2486,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) -> { @@ -22051,7 +22189,7 @@ index 0e670de77a7f9926e295e1dd63d909bed1a959ca..b8f10ad8687f047f2b6705d47a91831e if (chunk != null) this.addTicket(x, z); // Paper ret.complete(chunk == null ? null : new CraftChunk(chunk)); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java -index 38ccf1a75b37e7745426706c2ccbe86506b93f51..ccf735fed67ed2cf24f8a3f550e9421251f4b5e5 100644 +index a8760f015b9ee3ee408c3b9220266eb76b313ba0..fadf10c6a7fabde2c13f3aff00739a21e9f05ced 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java @@ -52,6 +52,7 @@ public final class CapturedBlockState extends CraftBlockState { @@ -22063,7 +22201,7 @@ index 38ccf1a75b37e7745426706c2ccbe86506b93f51..ccf735fed67ed2cf24f8a3f550e94212 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 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c84d2e59c 100644 +index bec8e6b62dba2bd0e4e85a7d1fb51287384f1290..6c91ee8b61cca34bd9e251076d8e9881729526da 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -74,6 +74,11 @@ public class CraftBlock implements Block { @@ -22071,11 +22209,11 @@ index 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c public net.minecraft.world.level.block.state.BlockState getNMS() { + // Folia start - region threading -+ if (world instanceof ServerLevel serverWorld) { -+ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously"); ++ if (this.world instanceof ServerLevel serverWorld) { ++ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, this.position, "Cannot read world asynchronously"); + } + // Folia end - region threading - return this.world.getBlockState(position); + return this.world.getBlockState(this.position); } @@ -150,6 +155,11 @@ public class CraftBlock implements Block { @@ -22083,11 +22221,11 @@ index 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c private void setData(final byte data, int flag) { + // Folia start - region threading -+ if (world instanceof ServerLevel serverWorld) { -+ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously"); ++ if (this.world instanceof ServerLevel serverWorld) { ++ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, this.position, "Cannot read world asynchronously"); + } + // Folia end - region threading - this.world.setBlock(position, CraftMagicNumbers.getBlock(this.getType(), data), flag); + this.world.setBlock(this.position, CraftMagicNumbers.getBlock(this.getType(), data), flag); } @@ -191,6 +201,11 @@ public class CraftBlock implements Block { @@ -22107,8 +22245,8 @@ index 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c @Override public Biome getBiome() { + // Folia start - region threading -+ if (world instanceof ServerLevel serverWorld) { -+ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously"); ++ if (this.world instanceof ServerLevel serverWorld) { ++ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, this.position, "Cannot read world asynchronously"); + } + // Folia end - region threading return this.getWorld().getBiome(this.getX(), this.getY(), this.getZ()); @@ -22118,8 +22256,8 @@ index 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c @Override public Biome getComputedBiome() { + // Folia start - region threading -+ if (world instanceof ServerLevel serverWorld) { -+ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously"); ++ if (this.world instanceof ServerLevel serverWorld) { ++ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, this.position, "Cannot read world asynchronously"); + } + // Folia end - region threading return this.getWorld().getComputedBiome(this.getX(), this.getY(), this.getZ()); @@ -22129,8 +22267,8 @@ index 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c @Override public void setBiome(Biome bio) { + // Folia start - region threading -+ if (world instanceof ServerLevel serverWorld) { -+ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously"); ++ if (this.world instanceof ServerLevel serverWorld) { ++ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, this.position, "Cannot read world asynchronously"); + } + // Folia end - region threading this.getWorld().setBiome(this.getX(), this.getY(), this.getZ(), bio); @@ -22141,11 +22279,11 @@ index 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c @Override public boolean isBlockFaceIndirectlyPowered(BlockFace face) { + // Folia start - region threading -+ if (world instanceof ServerLevel serverWorld) { -+ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously"); ++ if (this.world instanceof ServerLevel serverWorld) { ++ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, this.position, "Cannot read world asynchronously"); + } + // Folia end - region threading - int power = this.world.getMinecraftWorld().getSignal(position, CraftBlock.blockFaceToNotch(face)); + int power = this.world.getMinecraftWorld().getSignal(this.position, CraftBlock.blockFaceToNotch(face)); Block relative = this.getRelative(face); @@ -407,6 +442,11 @@ public class CraftBlock implements Block { @@ -22153,8 +22291,8 @@ index 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c @Override public int getBlockPower(BlockFace face) { + // Folia start - region threading -+ if (world instanceof ServerLevel serverWorld) { -+ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot read world asynchronously"); ++ if (this.world instanceof ServerLevel serverWorld) { ++ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, this.position, "Cannot read world asynchronously"); + } + // Folia end - region threading int power = 0; @@ -22165,8 +22303,8 @@ index 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c @Override public boolean breakNaturally(ItemStack item, boolean triggerEffect, boolean dropExperience) { + // Folia start - region threading -+ if (world instanceof ServerLevel serverWorld) { -+ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously"); ++ if (this.world instanceof ServerLevel serverWorld) { ++ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, this.position, "Cannot read world asynchronously"); + } + // Folia end - region threading // Paper end @@ -22177,8 +22315,8 @@ index 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c @Override public boolean applyBoneMeal(BlockFace face) { + // Folia start - region threading -+ if (world instanceof ServerLevel serverWorld) { -+ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously"); ++ if (this.world instanceof ServerLevel serverWorld) { ++ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, this.position, "Cannot read world asynchronously"); + } + // Folia end - region threading Direction direction = CraftBlock.blockFaceToNotch(face); @@ -22236,8 +22374,8 @@ index 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c @Override public void tick() { + // Folia start - region threading -+ if (world instanceof ServerLevel serverWorld) { -+ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously"); ++ if (this.world instanceof ServerLevel serverWorld) { ++ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, this.position, "Cannot read world asynchronously"); + } + // Folia end - region threading net.minecraft.world.level.block.state.BlockState blockData = this.getNMS(); @@ -22248,15 +22386,15 @@ index 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..0dc3f04b6e0c07d13f5da385af0d150c @Override public void randomTick() { + // Folia start - region threading -+ if (world instanceof ServerLevel serverWorld) { -+ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, position, "Cannot modify world asynchronously"); ++ if (this.world instanceof ServerLevel serverWorld) { ++ io.papermc.paper.util.TickThread.ensureTickThread(serverWorld, this.position, "Cannot read world asynchronously"); + } + // Folia end - region threading net.minecraft.world.level.block.state.BlockState blockData = this.getNMS(); net.minecraft.server.level.ServerLevel level = this.world.getMinecraftWorld(); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java -index cfd1c68d7ad23ef20242306d7d8148921d697ca5..5adc18b46dfbaffec769459a43895ca25fa71f0b 100644 +index 390e1b7fd2721b99cb3ce268c6bc1bf0a38e08a3..9bf02fde730932d356803d2ab6d3c193e0437c8a 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -210,6 +210,12 @@ public class CraftBlockState implements BlockState { @@ -22283,7 +22421,7 @@ index cfd1c68d7ad23ef20242306d7d8148921d697ca5..5adc18b46dfbaffec769459a43895ca2 // Modelled off EntityHuman#hasBlock diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java -index cd4ad8261e56365850068db1d83d6a8454026737..78f7e72f2912dae503c2dab7d1992b652b404ae5 100644 +index 12eeabafbad9da8796dc6fc383b732cf75bb7ddb..6ede423639c8e2012da897f517e8f7c9de72095f 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java +++ b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java @@ -50,7 +50,7 @@ public class ConsoleCommandCompleter implements Completer { @@ -22305,7 +22443,7 @@ index cd4ad8261e56365850068db1d83d6a8454026737..78f7e72f2912dae503c2dab7d1992b65 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 f7ebddd35ff5a60a81034fd7de035ebba83e9517..bdb0198a609028d45501f98d4df62f3a227a25d2 100644 +index 0e6c7284b9aee6c5f2454a3a095ebf349f887740..690e57b55adb53d56d874cbddec6226a515f43a2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -581,6 +581,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @@ -22403,7 +22541,7 @@ index f7ebddd35ff5a60a81034fd7de035ebba83e9517..bdb0198a609028d45501f98d4df62f3a @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 604ed1f6742a6b028b9db2809f7bd4b9a3b38f4d..13fd0b86f5b4b4f97bd0fdec4313a12210ffb38c 100644 +index 83aaf3e6e377d731ce02f779f80b7bf5db46f89f..249887106315ed0625b08bc8b2a74404cf0a418b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -591,7 +591,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -22415,7 +22553,7 @@ index 604ed1f6742a6b028b9db2809f7bd4b9a3b38f4d..13fd0b86f5b4b4f97bd0fdec4313a122 if (this.getHandle().connection == null) return; this.getHandle().connection.disconnect(message == null ? "" : message, org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); // Paper - kick event cause -@@ -1308,6 +1308,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1298,6 +1298,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean teleport(Location location, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause, io.papermc.paper.entity.TeleportFlag... flags) { @@ -22427,7 +22565,7 @@ index 604ed1f6742a6b028b9db2809f7bd4b9a3b38f4d..13fd0b86f5b4b4f97bd0fdec4313a122 java.util.Set relativeArguments; java.util.Set allFlags; if (flags.length == 0) { -@@ -1890,7 +1895,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1880,7 +1885,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { private void unregisterEntity(Entity other) { // Paper end ChunkMap tracker = ((ServerLevel) this.getHandle().level()).getChunkSource().chunkMap; @@ -22436,7 +22574,7 @@ index 604ed1f6742a6b028b9db2809f7bd4b9a3b38f4d..13fd0b86f5b4b4f97bd0fdec4313a122 if (entry != null) { entry.removePlayer(this.getHandle()); } -@@ -1987,7 +1992,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1977,7 +1982,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (original != null) otherPlayer.setUUID(original); // Paper - uuid override } @@ -22446,10 +22584,10 @@ index 604ed1f6742a6b028b9db2809f7bd4b9a3b38f4d..13fd0b86f5b4b4f97bd0fdec4313a122 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 193ad79f57255b1ea4cf7930071b4f4988dc2b04..b86ec508e6a2ce13d47ca38966679b657964a0a2 100644 +index 5dc160b743534665c6b3efb10b10f7c36e2da5ab..606551330859fd423b31d246bc14891d1236ba42 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -244,8 +244,8 @@ import org.bukkit.potion.PotionEffect; +@@ -246,8 +246,8 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; public class CraftEventFactory { @@ -22460,7 +22598,7 @@ index 193ad79f57255b1ea4cf7930071b4f4988dc2b04..b86ec508e6a2ce13d47ca38966679b65 // helper methods private static boolean canBuild(ServerLevel world, Player player, int x, int z) { -@@ -892,7 +892,7 @@ public class CraftEventFactory { +@@ -920,7 +920,7 @@ public class CraftEventFactory { return CraftEventFactory.handleBlockSpreadEvent(world, source, target, block, 2); } @@ -22469,7 +22607,7 @@ index 193ad79f57255b1ea4cf7930071b4f4988dc2b04..b86ec508e6a2ce13d47ca38966679b65 public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState block, int flag) { // Suppress during worldgen -@@ -904,7 +904,7 @@ public class CraftEventFactory { +@@ -932,7 +932,7 @@ public class CraftEventFactory { CraftBlockState state = CraftBlockStates.getBlockState(world, target, flag); state.setData(block); @@ -22478,7 +22616,7 @@ index 193ad79f57255b1ea4cf7930071b4f4988dc2b04..b86ec508e6a2ce13d47ca38966679b65 Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { -@@ -1019,8 +1019,8 @@ public class CraftEventFactory { +@@ -1047,8 +1047,8 @@ public class CraftEventFactory { private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, Map modifiers, Map> modifierFunctions, boolean cancelled) { if (source.is(DamageTypeTags.IS_EXPLOSION)) { DamageCause damageCause; @@ -22489,7 +22627,7 @@ index 193ad79f57255b1ea4cf7930071b4f4988dc2b04..b86ec508e6a2ce13d47ca38966679b65 EntityDamageEvent event; if (damager == null) { event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, modifiers, modifierFunctions, source.explodedBlockState); // Paper - handle block state in damage -@@ -1081,13 +1081,13 @@ public class CraftEventFactory { +@@ -1109,13 +1109,13 @@ public class CraftEventFactory { } return event; } else if (source.is(DamageTypes.LAVA)) { @@ -22507,7 +22645,7 @@ index 193ad79f57255b1ea4cf7930071b4f4988dc2b04..b86ec508e6a2ce13d47ca38966679b65 if (!event.isCancelled()) { event.getEntity().setLastDamageCause(event); -@@ -1095,9 +1095,9 @@ public class CraftEventFactory { +@@ -1123,9 +1123,9 @@ public class CraftEventFactory { entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled } return event; @@ -22519,7 +22657,7 @@ index 193ad79f57255b1ea4cf7930071b4f4988dc2b04..b86ec508e6a2ce13d47ca38966679b65 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.is(DamageTypes.HOT_FLOOR)) { -@@ -1112,9 +1112,9 @@ public class CraftEventFactory { +@@ -1140,9 +1140,9 @@ public class CraftEventFactory { EntityDamageEvent event = new EntityDamageByBlockEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions); event.setCancelled(cancelled); @@ -22531,7 +22669,7 @@ index 193ad79f57255b1ea4cf7930071b4f4988dc2b04..b86ec508e6a2ce13d47ca38966679b65 if (!event.isCancelled()) { event.getEntity().setLastDamageCause(event); -@@ -1122,10 +1122,10 @@ public class CraftEventFactory { +@@ -1150,10 +1150,10 @@ public class CraftEventFactory { entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled } return event; @@ -22545,7 +22683,7 @@ index 193ad79f57255b1ea4cf7930071b4f4988dc2b04..b86ec508e6a2ce13d47ca38966679b65 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) { -@@ -2076,7 +2076,7 @@ public class CraftEventFactory { +@@ -2123,7 +2123,7 @@ public class CraftEventFactory { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemStack.copyWithCount(1)); org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(to.getX(), to.getY(), to.getZ())); @@ -22555,7 +22693,7 @@ index 193ad79f57255b1ea4cf7930071b4f4988dc2b04..b86ec508e6a2ce13d47ca38966679b65 return itemStack; } diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index d7ce4971d9271dbeff4adb9d852e4e7bdf60bf03..eb84a8dd97f92de4a7dd3826d9e124a442cba565 100644 +index 3ceb5d83be20183da907915f70ba9e64369373a9..b23e43f7ac22bc106a0bcde4a8bca9ecba1a9ae4 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -530,6 +530,7 @@ public class CraftScheduler implements BukkitScheduler { @@ -22567,10 +22705,10 @@ index d7ce4971d9271dbeff4adb9d852e4e7bdf60bf03..eb84a8dd97f92de4a7dd3826d9e124a4 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 806fb1064a1769d1251f2a2b04372275754d2aeb..41333c019e005821e4a180f6489538be9359167d 100644 +index 548c77592a3520e8053483644eba805079a14f1a..73c395cd5fd3dc07640cdc06e174cd99de43df4c 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -365,6 +365,12 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -380,6 +380,12 @@ public final class CraftMagicNumbers implements UnsafeValues { String minimumVersion = MinecraftServer.getServer().server.minimumAPI; int minimumIndex = CraftMagicNumbers.SUPPORTED_API.indexOf(minimumVersion); @@ -22602,7 +22740,7 @@ index cbedb6f002bc01daa16d349421c4ef04d4bcbcb2..2d708bb11f841bb265d12a025dbaa657 return this.handle; } diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index 2f9e5a1adf9d67ffe18d95f2822ca3d2288fb27a..23ec7dd6fe49f33e9cac78fd084dc660fc5a2b2e 100644 +index 59103744ac6beeb12719fdefcda54eeff498229e..d88988200016c1a3cc76c017dfb7deabf6fc17af 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -65,26 +65,27 @@ public class ActivationRange @@ -22674,9 +22812,9 @@ index 2f9e5a1adf9d67ffe18d95f2822ca3d2288fb27a..23ec7dd6fe49f33e9cac78fd084dc660 // Paper end // Paper start -- java.util.List entities = world.getEntities((Entity)null, maxBB, null); +- java.util.List entities = world.getEntities((Entity)null, ActivationRange.maxBB, null); + java.util.List entities = new java.util.ArrayList<>(); // Folia - region ticking - bypass getEntities thread check, we perform a check on the entities later -+ ((net.minecraft.server.level.ServerLevel)world).getEntityLookup().getEntities((Entity)null, maxBB, entities, null); // Paper - optimise this call // Folia - region ticking - bypass getEntities thread check, we perform a check on the entities later ++ ((net.minecraft.server.level.ServerLevel)world).getEntityLookup().getEntities((Entity)null, maxBB, entities, null); // Folia - region ticking - bypass getEntities thread check, we perform a check on the entities later boolean tickMarkers = world.paperConfig().entities.markers.tick; // Paper - configurable marker ticking for (int i = 0; i < entities.size(); i++) { Entity entity = entities.get(i); @@ -22745,7 +22883,7 @@ index 2f9e5a1adf9d67ffe18d95f2822ca3d2288fb27a..23ec7dd6fe49f33e9cac78fd084dc660 entity.isTemporarilyActive = true; } diff --git a/src/main/java/org/spigotmc/SpigotCommand.java b/src/main/java/org/spigotmc/SpigotCommand.java -index 3112a8695639c402e9d18710acbc11cff5611e9c..b0249d9b61819d4a259753150df795a84ce1d4ff 100644 +index ac0fd418fcb437896dfdff53ab3eff19833d25fb..130220977477a5d8d51e17dcb989ae0c858643cb 100644 --- a/src/main/java/org/spigotmc/SpigotCommand.java +++ b/src/main/java/org/spigotmc/SpigotCommand.java @@ -29,6 +29,7 @@ public class SpigotCommand extends Command { @@ -22765,7 +22903,7 @@ index 3112a8695639c402e9d18710acbc11cff5611e9c..b0249d9b61819d4a259753150df795a8 return true; diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java -index 612c3169c3463d702b85975e1db79ae6e47d60d0..6f77134ba451e7bd6bcba1000134ce8a2c762979 100644 +index 68602dfb171d47e47fd0710b4324013ef05214d0..2d75cefc69ea1da96a99370aef3df7bd6fcf11b9 100644 --- a/src/main/java/org/spigotmc/SpigotConfig.java +++ b/src/main/java/org/spigotmc/SpigotConfig.java @@ -228,7 +228,7 @@ public class SpigotConfig @@ -22773,8 +22911,8 @@ index 612c3169c3463d702b85975e1db79ae6e47d60d0..6f77134ba451e7bd6bcba1000134ce8a SpigotConfig.restartScript = SpigotConfig.getString( "settings.restart-script", SpigotConfig.restartScript ); SpigotConfig.restartMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.restart", "Server is restarting" ) ); - SpigotConfig.commands.put( "restart", new RestartCommand( "restart" ) ); -+ //SpigotConfig.commands.put( "restart", new RestartCommand( "restart" ) ); // Folia - region threading - // WatchdogThread.doStart( timeoutTime, restartOnCrash ); // Paper - moved to after paper config initialization ++ // SpigotConfig.commands.put( "restart", new RestartCommand( "restart" ) ); // Folia - region threading + // WatchdogThread.doStart( SpigotConfig.timeoutTime, SpigotConfig.restartOnCrash ); // Paper - moved to after paper config initialization } @@ -283,7 +283,7 @@ public class SpigotConfig @@ -22787,7 +22925,7 @@ index 612c3169c3463d702b85975e1db79ae6e47d60d0..6f77134ba451e7bd6bcba1000134ce8a public static int playerSample; diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java -index 5b5109e942b18418b3a3a0e2109fe4ef15045fe5..80ed6d548aeeeadf341d0373945aac2360eb5805 100644 +index f9b8e2bc039f1a37e47f84909c8785f3ef530284..315b860807bed537f8dbd85c9a053e39216e7b71 100644 --- a/src/main/java/org/spigotmc/SpigotWorldConfig.java +++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java @@ -433,7 +433,7 @@ public class SpigotWorldConfig diff --git a/patches/server/0004-Max-pending-logins.patch b/patches/server/0004-Max-pending-logins.patch index bc0dd66c16..133970133f 100644 --- a/patches/server/0004-Max-pending-logins.patch +++ b/patches/server/0004-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 57649d7fd11bef6395e04c075980e4c34eeffaa8..106b06a1d8fbda3fae7229252e78b9c17793e988 100644 +index 6f483c6581daeaf68f85e3b730d31c5b7a6ae001..f7c2d6d82ee1b5975cd114934b7beaec3d5d490d 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -88,7 +88,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @@ -19,7 +19,7 @@ index 57649d7fd11bef6395e04c075980e4c34eeffaa8..106b06a1d8fbda3fae7229252e78b9c1 if (this.state == ServerLoginPacketListenerImpl.State.WAITING_FOR_DUPE_DISCONNECT && !this.isPlayerAlreadyInWorld((GameProfile) Objects.requireNonNull(this.authenticatedProfile))) { diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 3f3d3cfa046124197bf7ed8d7f4b651bf8a73416..3ed41fc4c73e418ea11ed11e365423e014c88715 100644 +index 6cce2a9bc9beeeef25b7bacd2ad307ed3ae44432..41ba8950b3aada5eea55a0db841c6b9291262bf2 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -173,6 +173,17 @@ public abstract class PlayerList { diff --git a/patches/server/0006-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch b/patches/server/0006-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch index 63e5cd0fe2..00ca31ce91 100644 --- a/patches/server/0006-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch +++ b/patches/server/0006-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch @@ -29,10 +29,10 @@ index 41bf71d116ffc5431586ce54abba7f8def6c1dcf..519da6886613b8460e989767b1a21e31 } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 47061546345d0f367aa64c2d562a53509829d499..e1b6673729e71bdc929bc7b76983108a59e55891 100644 +index dd18591d7928ab04f6f7c09aa89a26ccbe20c323..385d5bc08928dd990b690b926e174af86f178c64 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2872,6 +2872,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2863,6 +2863,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -40,7 +40,7 @@ index 47061546345d0f367aa64c2d562a53509829d499..e1b6673729e71bdc929bc7b76983108a // CraftBukkit start if (entity.getBukkitEntity() instanceof Vehicle && this.getBukkitEntity() instanceof LivingEntity) { VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.getBukkitEntity()); -@@ -2893,6 +2894,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2884,6 +2885,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (event.isCancelled()) { return false; } @@ -48,7 +48,7 @@ index 47061546345d0f367aa64c2d562a53509829d499..e1b6673729e71bdc929bc7b76983108a // Spigot end if (this.isPassenger()) { this.stopRiding(); -@@ -2971,6 +2973,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2962,6 +2964,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { // CraftBukkit start @@ -56,7 +56,7 @@ index 47061546345d0f367aa64c2d562a53509829d499..e1b6673729e71bdc929bc7b76983108a CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); Entity orig = craft == null ? null : craft.getHandle(); if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { -@@ -2998,6 +3001,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2989,6 +2992,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (event.isCancelled()) { return false; } @@ -98,7 +98,7 @@ index 0f7ae4a5c672039828454bf18c770dd99e250212..df182782756f674e2ce5d8c6add5c23c } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java -index 90a989c7c9de6f9ba55ab640761915e98320642a..c43ce4c9f6d011a7403dd37ff62953aba29852aa 100644 +index f9cd595ec28f0284d11bae6bfc5bf92d56526ef9..a8479fa2839c77399be83dbf20051b33900044bb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -17,8 +17,16 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac @@ -115,7 +115,7 @@ index 90a989c7c9de6f9ba55ab640761915e98320642a..c43ce4c9f6d011a7403dd37ff62953ab @Override public net.minecraft.world.entity.animal.horse.AbstractHorse 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.horse.AbstractHorse) entity; + return (net.minecraft.world.entity.animal.horse.AbstractHorse) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java @@ -141,7 +141,7 @@ index 5beaa2bb0d58fe477ce8d2de8b77600d3b416d8c..fa1bc80ae320c6d04acc20d6dec7df52 } // Paper end diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java -index 762354681315e4c74e414bf7d677b5422385161e..e3d57d4f65d1f3c03f407d497ff360dcd40a0fb1 100644 +index 8db2c70d3600555bcb419260cafd56409478b227..50a715cf0c4c87b9a26c57c6eb7e133ae443edd3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java @@ -17,8 +17,16 @@ public class CraftAbstractVillager extends CraftAgeable implements AbstractVilla @@ -158,11 +158,11 @@ index 762354681315e4c74e414bf7d677b5422385161e..e3d57d4f65d1f3c03f407d497ff360dc @Override public net.minecraft.world.entity.npc.AbstractVillager getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (Villager) entity; + return (Villager) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java -index f6d9ccc993a067e554d6a7ef98c5fff1392efaef..69118f8ff00755ba1c31845a2704dd95fa2aee6e 100644 +index ae16e8d1bfe8e9315391510eddb367a3fbdc9e03..bdbb54cc60c9afa8a7b89419563fcbe502554aac 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAgeable.java @@ -63,8 +63,16 @@ public class CraftAgeable extends CraftCreature implements Ageable { @@ -179,11 +179,11 @@ index f6d9ccc993a067e554d6a7ef98c5fff1392efaef..69118f8ff00755ba1c31845a2704dd95 @Override public AgeableMob getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (AgeableMob) entity; + return (AgeableMob) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAllay.java -index dc19a0ad99deed9cc71c243322e375b740db7a9b..87f5073b02d5989ee0adde4f22becabb42a90651 100644 +index c64918175ec08d20cde2bda9e0cac8b474385fe0..633c7581f9eec8a04598a62eae64adb617cf0fa7 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 @@ -200,11 +200,11 @@ index dc19a0ad99deed9cc71c243322e375b740db7a9b..87f5073b02d5989ee0adde4f22becabb @Override public Allay getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (Allay) entity; + return (Allay) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java -index 2a477dcd9d31a251868e342d1e7f5b9b58ddf66f..4ce13017e17bc327547ce4dd2dba7a5eff9e444f 100644 +index 2a2f9f0907eafcabef26a41d20f64a0aa953d181..8f654e3a210a332dc2d526b579d8fcf0c54e4d28 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java @@ -9,8 +9,16 @@ public class CraftAmbient extends CraftMob implements Ambient { @@ -221,11 +221,11 @@ index 2a477dcd9d31a251868e342d1e7f5b9b58ddf66f..4ce13017e17bc327547ce4dd2dba7a5e @Override public AmbientCreature getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (AmbientCreature) entity; + return (AmbientCreature) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java -index 56bc26f227b97e8e935a20c6393d3f2eb806b285..5cf8ea3a7dd4e8ea96ca6061aa1aaefc7ac8fcce 100644 +index ab42bc721d5b6c17c2ca6c7153b757571aea05e8..2887699c16b9452ce948f8b945c595ca55488cf7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java @@ -15,8 +15,16 @@ public class CraftAnimals extends CraftAgeable implements Animals { @@ -242,14 +242,14 @@ index 56bc26f227b97e8e935a20c6393d3f2eb806b285..5cf8ea3a7dd4e8ea96ca6061aa1aaefc @Override public Animal getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (Animal) entity; + return (Animal) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java -index c13d7fd15d8614f1ced30569fd1eae732a31b800..a0979910520442b2cabd9e87b78448e40e753641 100644 +index a46b2dfb2f1c0c7c3b55d81fc881e481348f98b8..17f1d4bdd3ee642e5fa5e0d9f5a61348d9ee1e1d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java -@@ -26,8 +26,16 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud +@@ -27,8 +27,16 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud super(server, entity); } @@ -267,7 +267,7 @@ index c13d7fd15d8614f1ced30569fd1eae732a31b800..a0979910520442b2cabd9e87b78448e4 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java -index dc26be80f2c1f058451c0d446165bc78a0ff8c47..774f0f90ad66a0f5f33d1008c036ff515937b18c 100644 +index ccda0d7a96c201905f0f62dcb0e5b278a51dee9f..3ba6c46e0f5bc5f6b5994d41aaa9c4dd8276df9b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java @@ -20,8 +20,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { @@ -288,7 +288,7 @@ index dc26be80f2c1f058451c0d446165bc78a0ff8c47..774f0f90ad66a0f5f33d1008c036ff51 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java -index 96a20efc60efef4485eca9ebffed92dc195ed357..4a7ec1c1b479c68d0ec08b78e06b53255d725c08 100644 +index 6d2fe30742f8b41d53dd2cbff120fcc042ea0e0c..ed236cf2b405d954e69390c6f6fa4e79369058ee 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -142,8 +142,16 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { @@ -305,7 +305,7 @@ index 96a20efc60efef4485eca9ebffed92dc195ed357..4a7ec1c1b479c68d0ec08b78e06b5325 @Override public net.minecraft.world.entity.projectile.AbstractArrow getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.projectile.AbstractArrow) entity; + return (net.minecraft.world.entity.projectile.AbstractArrow) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAxolotl.java @@ -330,7 +330,7 @@ index cbfca242f820d238b112f8ce64e9de8398c48a1c..c5f0cd5e69a20f1fffcd017385bf9fab } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java -index 7592ecac3d0893974d9d22ce40c50f1008ab9695..83d5d7503f1c4988f057743331c6f1eb7c5b57d9 100644 +index 1bb72f28085f3885bec068b586ec222111044884..1d09154b76d7f76e013a6980b5263215d26e81d9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java @@ -8,8 +8,16 @@ public class CraftBat extends CraftAmbient implements Bat { @@ -347,11 +347,11 @@ index 7592ecac3d0893974d9d22ce40c50f1008ab9695..83d5d7503f1c4988f057743331c6f1eb @Override public net.minecraft.world.entity.ambient.Bat 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.ambient.Bat) entity; + return (net.minecraft.world.entity.ambient.Bat) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java -index 17608e0e8cc5288905d2e42ae1429f7d947511fb..b486054e5e9c543cf5e6f2b4356a9f843242cd34 100644 +index 3dac93b0ab5d5acf5b33dc4b0efed60319eb657b..4fce53e012067f2cc91ae89b2254ebfd030017d5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java @@ -13,8 +13,16 @@ public class CraftBee extends CraftAnimals implements Bee { @@ -368,11 +368,11 @@ index 17608e0e8cc5288905d2e42ae1429f7d947511fb..b486054e5e9c543cf5e6f2b4356a9f84 @Override public net.minecraft.world.entity.animal.Bee 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.Bee) entity; + return (net.minecraft.world.entity.animal.Bee) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java -index 6be071da0637a97123c5100c4e7a2af2c5e83d7e..28edb6913d70c18512fc117735260aa707c2224c 100644 +index a4c9c73691300880777483b0beb17e1bd6779d06..e19c8cb6cf3d4306d2779bc7329e0fdc7aef59da 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlaze.java @@ -8,8 +8,16 @@ public class CraftBlaze extends CraftMonster implements Blaze { @@ -389,7 +389,7 @@ index 6be071da0637a97123c5100c4e7a2af2c5e83d7e..28edb6913d70c18512fc117735260aa7 @Override public net.minecraft.world.entity.monster.Blaze getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Blaze) entity; + return (net.minecraft.world.entity.monster.Blaze) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBlockDisplay.java @@ -414,7 +414,7 @@ index dd91de8f24c27b9318c2a898a49991d74c100bff..d7c34f601ce66a6b090ec431a0503462 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java -index 338e5ec5a518f9542e82ad43efeaa2a8cf04af42..85842cdf946e69398e6f64fa1b6d2315519780e0 100644 +index 859f233197ebe738511011e36668c4eb5d4b7d8e..c53af70cd12f0378d697398e090f95b1498f69e7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -102,8 +102,16 @@ public class CraftBoat extends CraftVehicle implements Boat { @@ -431,7 +431,7 @@ index 338e5ec5a518f9542e82ad43efeaa2a8cf04af42..85842cdf946e69398e6f64fa1b6d2315 @Override public net.minecraft.world.entity.vehicle.Boat 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.vehicle.Boat) entity; + return (net.minecraft.world.entity.vehicle.Boat) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCamel.java @@ -477,7 +477,7 @@ index 6c9531c018be29b5794d047b50007fde1b50b494..cb2f710a48c1e42cf800f657befaac4e } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java -index 2d897ded3cb95d988aa3d99d69e904936c7ca8e7..8eaced8d8528d25d3b69816c8ec67e8f44030f6d 100644 +index 4f661fbdb860cf550da0d952b775fe6f990b43b3..4a8b2b6bf80d43bba551c34a1a03fd5c9a9d7a02 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCaveSpider.java @@ -8,8 +8,16 @@ public class CraftCaveSpider extends CraftSpider implements CaveSpider { @@ -494,11 +494,11 @@ index 2d897ded3cb95d988aa3d99d69e904936c7ca8e7..8eaced8d8528d25d3b69816c8ec67e8f @Override public net.minecraft.world.entity.monster.CaveSpider getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.CaveSpider) entity; + return (net.minecraft.world.entity.monster.CaveSpider) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java -index c332e8504b96a4437325b5a64430c97c5afb6b4b..6f4ee6e3224a25a121a8075929597c5acb691fd2 100644 +index f1844d697b91e61878ade5b922cf2a3a538365c7..c07479ea6eca28e47bb618b420e57814c861ef8d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java @@ -18,8 +18,16 @@ public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.Chest @@ -515,7 +515,7 @@ index c332e8504b96a4437325b5a64430c97c5afb6b4b..6f4ee6e3224a25a121a8075929597c5a @Override public ChestBoat getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (ChestBoat) entity; + return (ChestBoat) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java @@ -540,7 +540,7 @@ index 40ee96e31dea64ab3a77553dbb6daad001736f2e..1a9986acde12881e32db67b9e7263072 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java -index 5e0b611db52452c00bf3cd2fc07dd713f238a581..f4858d41c482cc91322cd68cf00a73e2d46cbe18 100644 +index 96f6e2fd9c6b20d34122abfe5c7fba732502d5a0..a32874bc84a13c3be3512b46519e66b24a4dbce0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java @@ -9,8 +9,16 @@ public class CraftChicken extends CraftAnimals implements Chicken { @@ -557,7 +557,7 @@ index 5e0b611db52452c00bf3cd2fc07dd713f238a581..f4858d41c482cc91322cd68cf00a73e2 @Override public net.minecraft.world.entity.animal.Chicken 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.Chicken) entity; + return (net.minecraft.world.entity.animal.Chicken) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java @@ -582,7 +582,7 @@ index 63e6b07e3b159c74d9ef17be20b5ab43d07f0f5f..7e3a560ff4a3d56e52534eb909eaf604 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java -index c59bd22ba9df070e63e23372e52ba43686a06aa4..3a615a61fedaacb7845fe9c07d4aa3d9e76b2c51 100644 +index c2583982d84c736639eec511daba594d7806a628..963ef176acd9e3a182b51722544001e309f5d7ae 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java @@ -32,8 +32,16 @@ public class CraftComplexPart extends CraftEntity implements ComplexEntityPart { @@ -599,11 +599,11 @@ index c59bd22ba9df070e63e23372e52ba43686a06aa4..3a615a61fedaacb7845fe9c07d4aa3d9 @Override public EnderDragonPart getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (EnderDragonPart) entity; + return (EnderDragonPart) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java -index b893974440b2f1e6976f52ca663244bf6e2bbc12..646415cf9da4148a32f4d703f009dbb48393897e 100644 +index 7babc404e4920cd264206d4e83b1be6f841cdb8c..6fef0910ee934aedc09bac212ef3fba4f546d5ce 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCow.java @@ -9,8 +9,16 @@ public class CraftCow extends CraftAnimals implements Cow { @@ -620,11 +620,11 @@ index b893974440b2f1e6976f52ca663244bf6e2bbc12..646415cf9da4148a32f4d703f009dbb4 @Override public net.minecraft.world.entity.animal.Cow 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.Cow) entity; + return (net.minecraft.world.entity.animal.Cow) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java -index 5bc62af195a7b11182d411296c978b4f6f5f837f..062a625e178ac9bbbb26f3d6548fb663b01d889b 100644 +index 664d9c1793b823ed03f198a936f2ebd9b7695898..da9a83f9b020f637e4485ca53bc97bb50596808c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java @@ -9,8 +9,16 @@ public class CraftCreature extends CraftMob implements Creature { @@ -641,11 +641,11 @@ index 5bc62af195a7b11182d411296c978b4f6f5f837f..062a625e178ac9bbbb26f3d6548fb663 @Override public PathfinderMob getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (PathfinderMob) entity; + return (PathfinderMob) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java -index 6ccb32786b3abe1109dcc2d083cd231b70d8c6b4..c3a489167197ab6392491257d9d11d8077fe4957 100644 +index 4191845bfe05d8691e50143c42090566522f7e74..7aea0d9f5c17c8dcab73ffe9906a456534c292b0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java @@ -79,8 +79,16 @@ public class CraftCreeper extends CraftMonster implements Creeper { @@ -662,7 +662,7 @@ index 6ccb32786b3abe1109dcc2d083cd231b70d8c6b4..c3a489167197ab6392491257d9d11d80 @Override public net.minecraft.world.entity.monster.Creeper getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Creeper) entity; + return (net.minecraft.world.entity.monster.Creeper) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDisplay.java @@ -708,7 +708,7 @@ index f93f8f6509b12eb9b1e07c829278bb0822dd7988..c693daa86c2e44165ca6a293563670dc } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java -index 14b575254171f66b8792033c93cf5a325a42b467..b7c805ab1b2e4c8abd2728bcd17afab0979efc2d 100644 +index 51fc4acae9f20e8891069704e4a27f212b870766..9afa5a291deb68fca8e03cb89d2c192ec9bb53d0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java @@ -9,8 +9,16 @@ public class CraftDrowned extends CraftZombie implements Drowned, com.destroysto @@ -725,11 +725,11 @@ index 14b575254171f66b8792033c93cf5a325a42b467..b7c805ab1b2e4c8abd2728bcd17afab0 @Override public net.minecraft.world.entity.monster.Drowned getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Drowned) entity; + return (net.minecraft.world.entity.monster.Drowned) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java -index dbc27792bf84c07ca342b95231b4b34e90239da1..822f81ab0c790acde135080c0851dc2e4b408e82 100644 +index 010e9e922a6e30df4e40da151cfd398d1062633e..250479c6b9c5089c7cc260588ef1ce574c1ce24a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEgg.java @@ -9,8 +9,16 @@ public class CraftEgg extends CraftThrowableProjectile implements Egg { @@ -746,11 +746,11 @@ index dbc27792bf84c07ca342b95231b4b34e90239da1..822f81ab0c790acde135080c0851dc2e @Override public ThrownEgg getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (ThrownEgg) entity; + return (ThrownEgg) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java -index 5109fa0e665e484194eb9ccbafec7ff532ebd0fa..acb9be933c33566fe991ea90f7199d1f58262e5a 100644 +index 676dd5331bec75407a74aea2a89e78ab72d69724..b87d6ccd12323f1760d83365c1bdd1d55baf3a0a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderCrystal.java @@ -39,8 +39,16 @@ public class CraftEnderCrystal extends CraftEntity implements EnderCrystal { @@ -767,11 +767,11 @@ index 5109fa0e665e484194eb9ccbafec7ff532ebd0fa..acb9be933c33566fe991ea90f7199d1f @Override public EndCrystal getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (EndCrystal) entity; + return (EndCrystal) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java -index 492fdc855fe9735b614b6831aa5baaa6b252cfb6..57ab36ea7e973e8deb47240d2adad63d26ace04d 100644 +index 6eae6efa35a1ccc224e2f311e25ecf13e8647ec8..e26b538b4bc9ff182974a4323313567ffc66223b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java @@ -30,8 +30,16 @@ public class CraftEnderDragon extends CraftMob implements EnderDragon, CraftEnem @@ -788,11 +788,11 @@ index 492fdc855fe9735b614b6831aa5baaa6b252cfb6..57ab36ea7e973e8deb47240d2adad63d @Override public net.minecraft.world.entity.boss.enderdragon.EnderDragon 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.boss.enderdragon.EnderDragon) entity; + return (net.minecraft.world.entity.boss.enderdragon.EnderDragon) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java -index a407e802164603c74ec1f4ad3c98bc50398954bc..c1f73d89805eca8e13bdee80bcd89ef23cc4b332 100644 +index 5817f497424bb0e680c34d125b3fe53dba07a5cc..6dd1d6e7a504a76d84f5bc1140ff5223d9fa1e98 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java @@ -15,8 +15,16 @@ public class CraftEnderDragonPart extends CraftComplexPart implements EnderDrago @@ -809,11 +809,11 @@ index a407e802164603c74ec1f4ad3c98bc50398954bc..c1f73d89805eca8e13bdee80bcd89ef2 @Override public net.minecraft.world.entity.boss.EnderDragonPart 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.boss.EnderDragonPart) entity; + return (net.minecraft.world.entity.boss.EnderDragonPart) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java -index 03e2c43cdbd75a6c0127e1c3f708bbad3242d238..55b2d8ad3f1724793ee9631d3872cc9405759990 100644 +index 3bb8d74f2b59c7f0c7c1cbde47a570d628ceceb2..83308195a3a55abeb4c28b9cc69dc98e61c351af 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderPearl.java @@ -9,8 +9,16 @@ public class CraftEnderPearl extends CraftThrowableProjectile implements EnderPe @@ -830,11 +830,11 @@ index 03e2c43cdbd75a6c0127e1c3f708bbad3242d238..55b2d8ad3f1724793ee9631d3872cc94 @Override public ThrownEnderpearl getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (ThrownEnderpearl) entity; + return (ThrownEnderpearl) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java -index 18712bfd46d3852bc1210c8f0dea7e9af3e55b4d..fb1009a7cd2a8440f9faeed3e12fe9daefea72e6 100644 +index 1fb5760681bf0c745f9f3517489a83666a6d6805..8fb76a38ce3b1021e17acf1cc166d8dac3c61410 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java @@ -15,8 +15,16 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { @@ -851,11 +851,11 @@ index 18712bfd46d3852bc1210c8f0dea7e9af3e55b4d..fb1009a7cd2a8440f9faeed3e12fe9da @Override public EyeOfEnder getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (EyeOfEnder) entity; + return (EyeOfEnder) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java -index 92eb829161079c4a96447698aee58cc6e7cbd29f..7299780db54c9a5acef2e8c0d24885991e80b6e3 100644 +index 983b9d6ddb58eff297e96e5c8b28ec427efa267d..6ce0c8f24e5359c68e70092c8f488f1817221704 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java @@ -62,8 +62,16 @@ public class CraftEnderman extends CraftMonster implements Enderman { @@ -872,7 +872,7 @@ index 92eb829161079c4a96447698aee58cc6e7cbd29f..7299780db54c9a5acef2e8c0d2488599 @Override public EnderMan getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (EnderMan) entity; + return (EnderMan) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java @@ -897,7 +897,7 @@ index d657fd2c507a5b215aeab0a5f3e9c2ee892a27c8..9fc90b162aab15a9cd60b02aba563181 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index bdb0198a609028d45501f98d4df62f3a227a25d2..d584c168b5523fda4ebc823f956895178c4b8d13 100644 +index 690e57b55adb53d56d874cbddec6226a515f43a2..9f070a9f0894d88688ff50efc3f4dba8188c3885 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -826,7 +826,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @@ -939,10 +939,10 @@ index b66dd5c5c5d98c9285e0d0a4ad4b99a66419f732..3d284b790c869fb30180b92b891b2920 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java -index be52662bcaf7f7d1914ba0db7bd4b3f62974cc70..591e710d5296dddc0bdd7279a3c98c47c9e01239 100644 +index 19b368cc862cd7e3e1f0e89401a7d099e3eaefa3..5ae51638114a7931efdfc367b26791a22d7e8e2b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java -@@ -10,8 +10,16 @@ public class CraftEvokerFangs extends CraftEntity implements EvokerFangs { +@@ -11,8 +11,16 @@ public class CraftEvokerFangs extends CraftEntity implements EvokerFangs { super(server, entity); } @@ -960,7 +960,7 @@ index be52662bcaf7f7d1914ba0db7bd4b3f62974cc70..591e710d5296dddc0bdd7279a3c98c47 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java -index 26c795983515580b30b5ef8c701faa95ab1aea8e..990709bd56a96a60df020947f99b4f30cbe4192e 100644 +index 5a7d314ec0562e472f5dc45924a7b24841cff126..4708a11935efe5cb6727f8fc6d4a3cd2470b7091 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java @@ -30,8 +30,16 @@ public class CraftExperienceOrb extends CraftEntity implements ExperienceOrb { @@ -977,11 +977,11 @@ index 26c795983515580b30b5ef8c701faa95ab1aea8e..990709bd56a96a60df020947f99b4f30 @Override public net.minecraft.world.entity.ExperienceOrb 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.ExperienceOrb) entity; + return (net.minecraft.world.entity.ExperienceOrb) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java -index a8bed9c1d129ac31486af8b65e26aa245920d6b5..d2cf436c76d9ed0db0c95aafa1df22386fa09515 100644 +index 73911b81f4e927026657953a0c68ddda9a8f93c1..b5384f3f60dd6bba96a59fe60f6fb39fa41a71e6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java @@ -14,8 +14,16 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock { @@ -998,11 +998,11 @@ index a8bed9c1d129ac31486af8b65e26aa245920d6b5..d2cf436c76d9ed0db0c95aafa1df2238 @Override public FallingBlockEntity getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (FallingBlockEntity) entity; + return (FallingBlockEntity) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java -index 22d59ca52229dc566b8dfb460b92ecd6318e6db0..e80426bfcd55e9b2d308eb43b6ec4488668f9dbe 100644 +index 774ed1fdc909c911bf93a1b720285b43e9f728b8..f4555fb246cccdeae0498b1ce2f9aa1e4c7afd34 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -58,8 +58,16 @@ public class CraftFireball extends AbstractProjectile implements Fireball { @@ -1019,11 +1019,11 @@ index 22d59ca52229dc566b8dfb460b92ecd6318e6db0..e80426bfcd55e9b2d308eb43b6ec4488 @Override public AbstractHurtingProjectile getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (AbstractHurtingProjectile) entity; + return (AbstractHurtingProjectile) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java -index 1605ac0e726accdbd7953ffb95a302c2a21d64ce..b5c224998080433dea345b88b238042fb5ccfb72 100644 +index c13cdbaf7abdf120a3969f8e887b4c3b78989c9c..2f6c4fe06405f8efdc42c9ab43ab4d6a2bb4e2b4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java @@ -37,8 +37,16 @@ public class CraftFirework extends CraftProjectile implements Firework { @@ -1040,11 +1040,11 @@ index 1605ac0e726accdbd7953ffb95a302c2a21d64ce..b5c224998080433dea345b88b238042f @Override public FireworkRocketEntity getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (FireworkRocketEntity) entity; + return (FireworkRocketEntity) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java -index 3c64461119391ec2e987fc936104e21ef0a95ce4..d702e34f65de28df677a9d3616f38b2cf9abfa23 100644 +index eb10f94d5ed8ca89d3786138647dd43357609a6c..e0ad8cedd4d2646d87f3b5abda23c0c603adfd3a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java @@ -10,8 +10,16 @@ public class CraftFish extends CraftWaterMob implements Fish, io.papermc.paper.e @@ -1061,11 +1061,11 @@ index 3c64461119391ec2e987fc936104e21ef0a95ce4..d702e34f65de28df677a9d3616f38b2c @Override public AbstractFish getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (AbstractFish) entity; + return (AbstractFish) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java -index 96b6e537ec4493a0cdd98ccfe7816f7ffb69c7dd..ccb54c8da9f27666ec08347b3c4c738a6a1fe245 100644 +index 116f23a3ee9fa409d7bc34c3769b94ed2bb07183..5951f9fa14177bf5c781990dd77016268280abe0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java @@ -14,8 +14,16 @@ public class CraftFishHook extends CraftProjectile implements FishHook { @@ -1082,11 +1082,11 @@ index 96b6e537ec4493a0cdd98ccfe7816f7ffb69c7dd..ccb54c8da9f27666ec08347b3c4c738a @Override public FishingHook getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (FishingHook) entity; + return (FishingHook) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java -index 8038e1bdac4166bfaf228118e87cb246cb49b9a1..e1e51f050959aa23bd85bb794a7098a549c819c8 100644 +index 8117faa0c89a966d057f4bf251c03a09d1e8797e..7bdd9e033862a7d86742e05a63848c2fb804f6b2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java @@ -10,8 +10,16 @@ public class CraftFlying extends CraftMob implements Flying { @@ -1103,11 +1103,11 @@ index 8038e1bdac4166bfaf228118e87cb246cb49b9a1..e1e51f050959aa23bd85bb794a7098a5 @Override public FlyingMob getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (FlyingMob) entity; + return (FlyingMob) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java -index 6149067a14b950e727d3387055016a19e55c0fc6..929c817b7101973c4cc9f8f5a23f1941d67508cb 100644 +index c455deb4fd2a7684bcc01a8212c362a2375c190b..50ee6d3c3aa157fe69a483e02f33f23193628088 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -14,8 +14,16 @@ public class CraftFox extends CraftAnimals implements Fox { @@ -1128,7 +1128,7 @@ index 6149067a14b950e727d3387055016a19e55c0fc6..929c817b7101973c4cc9f8f5a23f1941 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java -index 20284ba684d29c619532e076f46e11572b50d367..ad5dcae61a58dd85e01b4dcb915348acc7e74642 100644 +index 65131d153b78a0787b977b9f65c15cfcbd395d11..e7501d8ec8f920939ef7599d5a88bd6ce7ab4f53 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFrog.java @@ -16,8 +16,16 @@ public class CraftFrog extends CraftAnimals implements org.bukkit.entity.Frog { @@ -1145,11 +1145,11 @@ index 20284ba684d29c619532e076f46e11572b50d367..ad5dcae61a58dd85e01b4dcb915348ac @Override public Frog getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (Frog) entity; + return (Frog) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java -index 3adcf36c7b4beb0f752f91b7333593a610ec118c..d8372cc3ff0f0cbfc5638cb0f4842bfcc54a9565 100644 +index 97fa4e1e70203194bd939618b2fad92665af6d59..8dc0e1332a5f8dd32e2b478432627a5d0c5cebcd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java @@ -9,8 +9,16 @@ public class CraftGhast extends CraftFlying implements Ghast, CraftEnemy { @@ -1166,11 +1166,11 @@ index 3adcf36c7b4beb0f752f91b7333593a610ec118c..d8372cc3ff0f0cbfc5638cb0f4842bfc @Override public net.minecraft.world.entity.monster.Ghast getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Ghast) entity; + return (net.minecraft.world.entity.monster.Ghast) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java -index cf788207c3c81074d54b1ff69fe814a2e0adf55f..d65b641d1bbd325547c16e186f4ec2558bcdc5c4 100644 +index 5826205339e99e2536b93c8589d95917749f8417..300f06f78c2814aa5650c02f714fee594ba61f98 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGiant.java @@ -9,8 +9,16 @@ public class CraftGiant extends CraftMonster implements Giant { @@ -1187,11 +1187,11 @@ index cf788207c3c81074d54b1ff69fe814a2e0adf55f..d65b641d1bbd325547c16e186f4ec255 @Override public net.minecraft.world.entity.monster.Giant getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Giant) entity; + return (net.minecraft.world.entity.monster.Giant) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java -index 7dd9d670a1436d2bbfcae6c3e597ca6c7b759623..47afda44cb474d9752cf97405b546a534382880a 100644 +index b9a7576d2481b64b7e5b46d66c1f55d1dc28c540..c288adee8ec60fa2bb83ae83f7be98c391379604 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGlowItemFrame.java @@ -9,8 +9,16 @@ public class CraftGlowItemFrame extends CraftItemFrame implements GlowItemFrame @@ -1254,7 +1254,7 @@ index 2c21de478bff9cdf13ba46cd041831d54c11e924..ab87340df483787d59d8b1e2ce3a6923 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java -index 79d2395b4a5efb042b80a315cc8e32d9c2521306..1ab70f244ed31eea22cc2614788072dbf3b4bbb5 100644 +index e27e469894bdd17cf7a004a85fdf0eaa746111a6..9fde15e62fd99c842c7c22e97217cc6d68460dfd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGolem.java @@ -9,8 +9,16 @@ public class CraftGolem extends CraftCreature implements Golem { @@ -1271,11 +1271,11 @@ index 79d2395b4a5efb042b80a315cc8e32d9c2521306..1ab70f244ed31eea22cc2614788072db @Override public AbstractGolem getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (AbstractGolem) entity; + return (AbstractGolem) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java -index 70e75921a20978d730ca02aea47186c79e1632d8..c11304434217a48400ec147f3b4e63d40d3b7280 100644 +index e232350f2c6ef1900b05fda4d3f94099057d10e5..96e7759b64f075e9f803763403d22573a4e35feb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java @@ -13,8 +13,16 @@ public class CraftGuardian extends CraftMonster implements Guardian { @@ -1296,7 +1296,7 @@ index 70e75921a20978d730ca02aea47186c79e1632d8..c11304434217a48400ec147f3b4e63d4 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java -index 0ef629a7c76e7f3f24edd76bac3560bf7e55d663..0ea8bcfc368e519d1f4906654ad5c72f80e84a3f 100644 +index cbdcf767c01e2c173913f56747d2dacbda2f0094..f45db5bb1a16bc3be5f70094c3f3902538f29b5b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java @@ -57,8 +57,16 @@ public class CraftHanging extends CraftEntity implements Hanging { @@ -1313,11 +1313,11 @@ index 0ef629a7c76e7f3f24edd76bac3560bf7e55d663..0ea8bcfc368e519d1f4906654ad5c72f @Override public HangingEntity getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (HangingEntity) entity; + return (HangingEntity) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java -index e2d95c9b894ccac04fb552d2e934c8ec9efade55..e13f9b88dee6f0e98550dc39bb16373366aa97ce 100644 +index 37007775d27598e319c0c78929c6a808b697724a..17265ad2eaa38259f3c311c1c73576a79001aa7e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java @@ -51,8 +51,16 @@ public class CraftHoglin extends CraftAnimals implements Hoglin, CraftEnemy { @@ -1334,11 +1334,11 @@ index e2d95c9b894ccac04fb552d2e934c8ec9efade55..e13f9b88dee6f0e98550dc39bb163733 @Override public net.minecraft.world.entity.monster.hoglin.Hoglin getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.hoglin.Hoglin) entity; + return (net.minecraft.world.entity.monster.hoglin.Hoglin) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java -index 8b13f6c315675bca8362be16f6511b5b7da34670..584703f2d7d14efd79568663cd833cb31f55c422 100644 +index 8746f80d08df5501b32958eb123aa7d814573ddf..c6c6eb55f4649e18beef9832c2ea7b9d1515666f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java @@ -13,8 +13,16 @@ public class CraftHorse extends CraftAbstractHorse implements Horse { @@ -1359,7 +1359,7 @@ index 8b13f6c315675bca8362be16f6511b5b7da34670..584703f2d7d14efd79568663cd833cb3 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -index 017e97c1618b8ee4640b36a0ec1b07026047bfc3..546a7fd563cc0291b5e15e8f67b4c3b8fc4067af 100644 +index aefb9879b2edadfb4b21d80135d713b9d34c9941..320b69a62a01d54d116115cc6b571ad63558befd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -291,8 +291,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @@ -1376,7 +1376,7 @@ index 017e97c1618b8ee4640b36a0ec1b07026047bfc3..546a7fd563cc0291b5e15e8f67b4c3b8 @Override public Player getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (Player) entity; + return (Player) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java @@ -1422,7 +1422,7 @@ index 5b2af80e584977683cd39e6f440e65a76e929be9..89c0121c40da1596a4bf5db6e1d7d611 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java -index 0e6edf0723314693ec904078c8a557a4f18e2db1..ed741f77fbe8f5c40a3923b0a431da768104a1b5 100644 +index caa3016bf9742222205e3ea9a327fad3c4f912bb..4a77b1cf13cfae35331c1e5c5df0b3b9972a0ac1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftInteraction.java @@ -12,8 +12,16 @@ public class CraftInteraction extends CraftEntity implements Interaction { @@ -1443,7 +1443,7 @@ index 0e6edf0723314693ec904078c8a557a4f18e2db1..ed741f77fbe8f5c40a3923b0a431da76 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java -index 75d10b5322eb0a62bce2855c04a5151eb857d7de..a920bfcfa4a977b4107f5f34fe9e625039d3ad39 100644 +index 63cae1a2e95d8da17c45c4404a8dd0ca6a413c39..f57139f03da9519802ee156f37691d0824bc531b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java @@ -8,8 +8,16 @@ public class CraftIronGolem extends CraftGolem implements IronGolem { @@ -1460,7 +1460,28 @@ index 75d10b5322eb0a62bce2855c04a5151eb857d7de..a920bfcfa4a977b4107f5f34fe9e6250 @Override public net.minecraft.world.entity.animal.IronGolem 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.IronGolem) entity; + return (net.minecraft.world.entity.animal.IronGolem) this.entity; + } + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +index f444e843535ec68ede0f05e7e7ef182ce872342b..c8fdfb3ee9ad5ca1853ac2ec3a7ff04ce8081dbb 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +@@ -18,8 +18,16 @@ public class CraftItem extends CraftEntity implements Item { + super(server, entity); + } + ++ // Folia start - region threading ++ @Override ++ public ItemEntity getHandleRaw() { ++ return (ItemEntity)this.entity; ++ } ++ // Folia end - region threading ++ + @Override + public ItemEntity getHandle() { ++ io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading + return (ItemEntity) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemDisplay.java @@ -1485,7 +1506,7 @@ index 787f91566fc53c2b4aeba1ec10d8f46ccf15cbe6..eb2b4272b09e5df06e49afc2ccf7063e } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java -index 58489a6a34e66cd6fc0d0e28141a3ebc32ac0e05..3ee9c2e5f66026375a88bcfcb6b46fbd43770309 100644 +index 2fcd9b836d42e3549a3b6b921c57a4c103146dff..051d15967436109d4267a800ab7e1bdf83cbd47a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -157,8 +157,16 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { @@ -1502,11 +1523,11 @@ index 58489a6a34e66cd6fc0d0e28141a3ebc32ac0e05..3ee9c2e5f66026375a88bcfcb6b46fbd @Override public net.minecraft.world.entity.decoration.ItemFrame 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.decoration.ItemFrame) entity; + return (net.minecraft.world.entity.decoration.ItemFrame) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java -index 16dd5a6fb7d97c8f42700be67de27369bfb0a69c..125e676efc79e582f19a44b68e5faea806f5dda4 100644 +index 0848963e61e03aa2a1740208ee372fd9edb7fc11..a55a329125775a7b78b3a779a8525ab1e734235b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java @@ -14,8 +14,16 @@ public class CraftLargeFireball extends CraftSizedFireball implements LargeFireb @@ -1523,11 +1544,11 @@ index 16dd5a6fb7d97c8f42700be67de27369bfb0a69c..125e676efc79e582f19a44b68e5faea8 @Override public net.minecraft.world.entity.projectile.LargeFireball getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.projectile.LargeFireball) entity; + return (net.minecraft.world.entity.projectile.LargeFireball) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java -index c8379778adabb513ebac40e9b3308cd2c1623678..9829c809ec385e15bbb1ef48c1bda5ff0adb5774 100644 +index 06fa256c5528af9c1d63fbd044f53b63bed324ee..896d34bd55e308fe322865f8cf7fd077a382df5e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLeash.java @@ -24,8 +24,16 @@ public class CraftLeash extends CraftHanging implements LeashHitch { @@ -1544,11 +1565,11 @@ index c8379778adabb513ebac40e9b3308cd2c1623678..9829c809ec385e15bbb1ef48c1bda5ff @Override public LeashFenceKnotEntity getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (LeashFenceKnotEntity) entity; + return (LeashFenceKnotEntity) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java -index ef5a5aed9e1b15a29fd3a97ccd502c40b1d865ac..d6e78621601f1553c267f25c527242c813908436 100644 +index 70b377c03346cb8573827aeb493f3b6eb8efb1f8..b2e8c26162dd5782a0447cd03ca00fb4583fd442 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java @@ -41,8 +41,16 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike @@ -1565,11 +1586,11 @@ index ef5a5aed9e1b15a29fd3a97ccd502c40b1d865ac..d6e78621601f1553c267f25c527242c8 @Override public LightningBolt getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (LightningBolt) entity; + return (LightningBolt) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -index daadfec2d86f7957072a639e1e36d4082448f35f..666742df2f0547922ad40c38821c9fc70b654d24 100644 +index 1992bd985d1beae77b88d71c5fa551a277943fdb..abc18d0e52d1e6ab4d04a9d8b97f91c9d6c4c02e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -417,6 +417,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @@ -1591,7 +1612,7 @@ index daadfec2d86f7957072a639e1e36d4082448f35f..666742df2f0547922ad40c38821c9fc7 @Override public net.minecraft.world.entity.LivingEntity 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.LivingEntity) entity; + return (net.minecraft.world.entity.LivingEntity) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -1637,7 +1658,7 @@ index 47633f05b4fab1dcabc2117e7645fe6d6949622a..f1e78960622b71aa63e172a1d856a757 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java -index c99cbd36f9bd52cdd1fbcec60ed6981cdfecbeed..b55d9add57561339f86e9c54e1a9e135ee01e8f6 100644 +index 58b638ffd338e1b0f4962490c665c1eebcf33dcc..321e41e21723fa3e28f73176c9abe34d16a42fcc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java @@ -9,8 +9,16 @@ public class CraftMagmaCube extends CraftSlime implements MagmaCube { @@ -1654,7 +1675,7 @@ index c99cbd36f9bd52cdd1fbcec60ed6981cdfecbeed..b55d9add57561339f86e9c54e1a9e135 @Override public net.minecraft.world.entity.monster.MagmaCube getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.MagmaCube) entity; + return (net.minecraft.world.entity.monster.MagmaCube) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMarker.java @@ -1679,7 +1700,7 @@ index e6782a48d22ba1e683e3fe463e970e8a5ed60fbd..9c04388e9d38103b40a154b6f0e13920 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java -index 067fcc1f44d59dd675a9cc5485234c87366ffe10..6cce3d64a4f506fcebbe34eae58163c57d43137c 100644 +index 8920af5a0dfe737c1f38d906b53e6a278456d2aa..8bc87cfe29d61b09eee8ecfccda319b5610c6969 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java @@ -86,8 +86,16 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart { @@ -1696,11 +1717,11 @@ index 067fcc1f44d59dd675a9cc5485234c87366ffe10..6cce3d64a4f506fcebbe34eae58163c5 @Override public AbstractMinecart getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (AbstractMinecart) entity; + return (AbstractMinecart) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java -index 2534abcdce426189ac15e0659ab62840b3d54762..9fe092113bf3db33527670ebc2a2a351960cf458 100644 +index 0ee159d488b15e571f9b19ec852fe279755696fa..356ac7fcea71f173d8698f3de33bfe9616c08312 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java @@ -20,8 +20,16 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca @@ -1717,11 +1738,11 @@ index 2534abcdce426189ac15e0659ab62840b3d54762..9fe092113bf3db33527670ebc2a2a351 @Override public MinecartCommandBlock getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (MinecartCommandBlock) entity; + return (MinecartCommandBlock) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java -index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b7d0892953f357e58665e87fbcf794a75f1c0980 100644 +index 313ee5c8737b2e57f9b5db6512c1871766b2ccd4..a0a136893a09185577cb46dfe8426fdb3a9a6ccd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java @@ -16,8 +16,16 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo @@ -1738,11 +1759,11 @@ index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b7d0892953f357e58665e87fbcf794a7 @Override public AbstractMinecartContainer getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (AbstractMinecartContainer) entity; + return (AbstractMinecartContainer) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java -index 1027c915c0a2f981703908fdb2eb6beeb548f347..bff74243c147727087f4869d02ab31938afb16e3 100644 +index 1b41026ab638bb2764b19429706eb0aded5aad12..c04acbffe5e0b1024f885490c5238cd40b36e701 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java @@ -11,8 +11,16 @@ public class CraftMinecartFurnace extends CraftMinecart implements PoweredMineca @@ -1759,15 +1780,15 @@ index 1027c915c0a2f981703908fdb2eb6beeb548f347..bff74243c147727087f4869d02ab3193 @Override public MinecartFurnace getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (MinecartFurnace) entity; + return (MinecartFurnace) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java -index fbabf86510c582e372b0b1ac5585c7287734c985..2e43d3667cc9ba35baf04658c13a8ed35b44e5cd 100644 +index 3a3563a1bdbc0d84d973b3a04b50b78b4bc3d379..9a9f37b9c8931771d90ae22c4ca9a684e24fff32 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java @@ -34,8 +34,17 @@ public final class CraftMinecartHopper extends CraftMinecartContainer implements - ((MinecartHopper) getHandle()).setEnabled(enabled); + ((MinecartHopper) this.getHandle()).setEnabled(enabled); } // Paper start + @@ -1806,7 +1827,7 @@ index 79b608e89d4d1f76a58868c585bb87c82e2689b1..7767a342b3d8bf9c07fbd73ad4ccacd8 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -index 153e4c88c168097eb4a78650e7c9c120bec202a3..d03069ef4e2b2b82d399cc5d4d6c093a9a763a88 100644 +index 5f6a1fb323782816f706ccf7df922cb203238302..4cae2bb318f8f6e060314fe4bd24051e84982787 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -55,8 +55,16 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { @@ -1823,7 +1844,7 @@ index 153e4c88c168097eb4a78650e7c9c120bec202a3..d03069ef4e2b2b82d399cc5d4d6c093a @Override public net.minecraft.world.entity.Mob 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.Mob) entity; + return (net.minecraft.world.entity.Mob) this.entity; } @@ -64,7 +72,7 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { @@ -1836,7 +1857,7 @@ index 153e4c88c168097eb4a78650e7c9c120bec202a3..d03069ef4e2b2b82d399cc5d4d6c093a // Paper end diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java -index 11b23670cd80a643f266c59542a380b42b17dfbd..d3b655ab5adacd60f04f912187662c5717a72962 100644 +index 706c74c832f6893df3797023f68add31139c7d57..80a612f16669e571e336dd6369a968b4664c98e4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMonster.java @@ -9,8 +9,16 @@ public class CraftMonster extends CraftCreature implements Monster, CraftEnemy { @@ -1853,11 +1874,11 @@ index 11b23670cd80a643f266c59542a380b42b17dfbd..d3b655ab5adacd60f04f912187662c57 @Override public net.minecraft.world.entity.monster.Monster getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Monster) entity; + return (net.minecraft.world.entity.monster.Monster) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java -index efecddaa165decac6e0958b202ad838405220627..c79bb57c3734fb313ae1a02c2c5185ba35d676f1 100644 +index 7ee489da5963fd722fc2531fef14911447a16557..f07b07805ce0b168e945c81ae82b690db0ba79e5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java @@ -10,8 +10,16 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow, io.paperm @@ -1874,11 +1895,11 @@ index efecddaa165decac6e0958b202ad838405220627..c79bb57c3734fb313ae1a02c2c5185ba @Override public net.minecraft.world.entity.animal.MushroomCow 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.MushroomCow) entity; + return (net.minecraft.world.entity.animal.MushroomCow) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java -index b6c10507d4d62178cdf82033cc379d66d763aa9b..e0cc8454d7c2e6f3ae1805c686f3ee25dd5f0b9c 100644 +index 5c60a30e80448fbf04b5fa4b1ef12fb2ee99bfd5..77eefdff4a5102fbc3abba7d7037fa7a5bcc61fa 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java @@ -9,8 +9,16 @@ public class CraftOcelot extends CraftAnimals implements Ocelot { @@ -1895,11 +1916,11 @@ index b6c10507d4d62178cdf82033cc379d66d763aa9b..e0cc8454d7c2e6f3ae1805c686f3ee25 @Override public net.minecraft.world.entity.animal.Ocelot 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.Ocelot) entity; + return (net.minecraft.world.entity.animal.Ocelot) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java -index 3d13a79f9add2e45db7f8538ee15e0d4e37a1314..bf06c6250c98ecc10b3585a1a0a4a2385e9a789e 100644 +index bcac1359c667ef1ee46384f9c7a5adf4010d2b08..f131a80df94a9f0d42a64a86424451fb06755b12 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -50,8 +50,16 @@ public class CraftPainting extends CraftHanging implements Painting { @@ -1916,11 +1937,11 @@ index 3d13a79f9add2e45db7f8538ee15e0d4e37a1314..bf06c6250c98ecc10b3585a1a0a4a238 @Override public net.minecraft.world.entity.decoration.Painting 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.decoration.Painting) entity; + return (net.minecraft.world.entity.decoration.Painting) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java -index 56f9630dbe5d18d5ec33dc85f6531723022d6a3b..2683bcfea4812a0ec57b8c09758eb2b58c02d582 100644 +index 01d104d91de9e1319d27e39d3f474318c7809486..a4d201e832d59c64d932f8b26564a783bd4bbdf4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java @@ -11,8 +11,16 @@ public class CraftPanda extends CraftAnimals implements Panda { @@ -1941,7 +1962,7 @@ index 56f9630dbe5d18d5ec33dc85f6531723022d6a3b..2683bcfea4812a0ec57b8c09758eb2b5 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java -index f12b424c7d69b8a64075e1e48c2ac2d4e213d379..8cf5187ac315fdbff0df90fb612f4c9b7d52eccd 100644 +index 04d6cf6a1f3ae8316e3b2862c2d1b04e84a3b20a..b1cdcfee5e575b29d844f04140dd0b0486d1dc45 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java @@ -11,8 +11,16 @@ public class CraftParrot extends CraftTameableAnimal implements Parrot { @@ -1958,7 +1979,7 @@ index f12b424c7d69b8a64075e1e48c2ac2d4e213d379..8cf5187ac315fdbff0df90fb612f4c9b @Override public net.minecraft.world.entity.animal.Parrot 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.Parrot) entity; + return (net.minecraft.world.entity.animal.Parrot) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java @@ -1983,7 +2004,7 @@ index 8338effd39b1709dbe578e247710a8e58d83e3aa..1d998942280db00ba7dab1c9d9a0f818 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java -index 2e7410678ffc3d742fb622f4d916df3974b661b1..33aad743e5e55881a1edefcf05d938a6a7301755 100644 +index 8016c810aeaf6ee953bca549bc1e7f9a85f860fc..4566f5d84e70b0296aabb4bf0d2caf517809132a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -55,8 +55,16 @@ public class CraftPig extends CraftAnimals implements Pig { @@ -2000,11 +2021,11 @@ index 2e7410678ffc3d742fb622f4d916df3974b661b1..33aad743e5e55881a1edefcf05d938a6 @Override public net.minecraft.world.entity.animal.Pig 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.Pig) entity; + return (net.minecraft.world.entity.animal.Pig) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java -index fd9a841ed8a0062ece142d0cd2591786104fdda7..45653b31d2b4febe8d14bc6e1b9aa86ab6d7d2be 100644 +index 49beb836d2801aadf869feefa602616daebe633f..0de7eadb1cac6979ce7cffd38a3b250812cae260 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java @@ -30,8 +30,16 @@ public class CraftPigZombie extends CraftZombie implements PigZombie { @@ -2021,7 +2042,7 @@ index fd9a841ed8a0062ece142d0cd2591786104fdda7..45653b31d2b4febe8d14bc6e1b9aa86a @Override public ZombifiedPiglin getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (ZombifiedPiglin) entity; + return (ZombifiedPiglin) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java @@ -2109,7 +2130,7 @@ index 2638c341bc02f201f7ab17fdebcdbdf3a7ec05bf..0f5c2d31a2dea13a46ba81e353393633 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 13fd0b86f5b4b4f97bd0fdec4313a12210ffb38c..44c09217241fae975fa4f734dfc5be4b03094e73 100644 +index 249887106315ed0625b08bc8b2a74404cf0a418b..6c8f6e26687b557fcdcd65c657d8b35d3fde805e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -611,7 +611,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -2121,7 +2142,7 @@ index 13fd0b86f5b4b4f97bd0fdec4313a12210ffb38c..44c09217241fae975fa4f734dfc5be4b final ServerGamePacketListenerImpl connection = this.getHandle().connection; if (connection != null) { connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message, cause); -@@ -2148,9 +2148,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2138,9 +2138,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this; } @@ -2134,22 +2155,22 @@ index 13fd0b86f5b4b4f97bd0fdec4313a12210ffb38c..44c09217241fae975fa4f734dfc5be4b + @Override public ServerPlayer getHandle() { -- return (ServerPlayer) entity; -+ return (ServerPlayer) entity; // Folia - region threading - no checks for players, as it's a total mess +- return (ServerPlayer) this.entity; ++ return (ServerPlayer) this.entity; // Folia - region threading - no checks for players, as it's a total mess } public void setHandle(final ServerPlayer entity) { -@@ -3164,7 +3171,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -3156,7 +3163,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { { if ( CraftPlayer.this.getHealth() <= 0 && CraftPlayer.this.isOnline() ) { -- server.getServer().getPlayerList().respawn( CraftPlayer.this.getHandle(), false, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason.PLUGIN ); +- CraftPlayer.this.server.getServer().getPlayerList().respawn( CraftPlayer.this.getHandle(), false, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason.PLUGIN ); + CraftPlayer.this.getHandle().respawn(null); // Folia - region threading } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java -index 3c4cbde06c768912332edf57768eabe082e47345..fa4bb2533d17d2e97301ba959144df478b195449 100644 +index fe075cfdf3097d6cb768e71b8cc360abb8eaf367..9147771e26d2dbd29754d3fc07c02596669cd602 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java @@ -8,8 +8,17 @@ public class CraftPolarBear extends CraftAnimals implements PolarBear { @@ -2167,11 +2188,11 @@ index 3c4cbde06c768912332edf57768eabe082e47345..fa4bb2533d17d2e97301ba959144df47 @Override public net.minecraft.world.entity.animal.PolarBear 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.PolarBear) entity; + return (net.minecraft.world.entity.animal.PolarBear) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java -index fd5beb956f643532e08613366ebd380d7999e79f..1521ad3c160062f22e6e17d2dacde5d8db5ccc00 100644 +index 4f1fa7dec78970bdfc184d3c1f1632dc9d75a574..d4889dbca359aab6e11fa6231b0ddcb6f33ef18b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java @@ -12,8 +12,16 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj @@ -2188,7 +2209,7 @@ index fd5beb956f643532e08613366ebd380d7999e79f..1521ad3c160062f22e6e17d2dacde5d8 @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 - return (net.minecraft.world.entity.projectile.Projectile) entity; + return (net.minecraft.world.entity.projectile.Projectile) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java @@ -2213,7 +2234,7 @@ index 35a8219734633529325430810e88755b2dd23125..85ebd34ed143304c603078f2e949179a } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java -index 1a1dfb9e5164f9962059ebf11a9c3334a1987153..38972d1aec6b32aee12972cbca2411caeb823350 100644 +index eb7e2902dc134847711284dd2af8abda7627c7ab..9fd64b06e973527e6fb808cc836490f75dfb9bea 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java @@ -11,8 +11,16 @@ public class CraftRabbit extends CraftAnimals implements Rabbit { @@ -2230,7 +2251,7 @@ index 1a1dfb9e5164f9962059ebf11a9c3334a1987153..38972d1aec6b32aee12972cbca2411ca @Override public net.minecraft.world.entity.animal.Rabbit 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.Rabbit) entity; + return (net.minecraft.world.entity.animal.Rabbit) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java @@ -2297,7 +2318,7 @@ index d4d8ce60098c74508e2de9541bf6534988779764..081d7f454b3556110f5a300602fbe923 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java -index 19e8fc7fa6037b063bc1809c85c703996cd9b5ac..7aa1df10cafdaa778432dc43085b3e4502a2e79a 100644 +index 37291d7ad9fdf0fe78894f82a418f40bb581f58b..1a0041a788f65ec30d329a86f65c04659a68ad7c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSheep.java @@ -29,8 +29,16 @@ public class CraftSheep extends CraftAnimals implements Sheep, io.papermc.paper. @@ -2314,11 +2335,11 @@ index 19e8fc7fa6037b063bc1809c85c703996cd9b5ac..7aa1df10cafdaa778432dc43085b3e45 @Override public net.minecraft.world.entity.animal.Sheep 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.Sheep) entity; + return (net.minecraft.world.entity.animal.Sheep) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java -index 147db69955ad3b8b2f50aae87aa9c8f446ac22d2..6332f85b8b604a2fecba460ceb16380a626ec971 100644 +index 05ec06b71642ab1ef03829039f7ac1e4c527ee50..fd4168a8bcf1537ccc2496139f5c5b63c5e2f41a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java @@ -18,8 +18,16 @@ public class CraftShulker extends CraftGolem implements Shulker, CraftEnemy { @@ -2335,11 +2356,11 @@ index 147db69955ad3b8b2f50aae87aa9c8f446ac22d2..6332f85b8b604a2fecba460ceb16380a @Override public net.minecraft.world.entity.monster.Shulker getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Shulker) entity; + return (net.minecraft.world.entity.monster.Shulker) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java -index 807a498c2a80a5bd5eedf5322c699adebf25872f..d46d5c1c6934eb83ec46704573cf29d225429930 100644 +index 636c4481e3afdf20197e502cf221f5d34d18f101..436a921106697916118cec8007ffd1cac1745fcd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java @@ -65,8 +65,16 @@ public class CraftShulkerBullet extends AbstractProjectile implements ShulkerBul @@ -2356,11 +2377,11 @@ index 807a498c2a80a5bd5eedf5322c699adebf25872f..d46d5c1c6934eb83ec46704573cf29d2 @Override public net.minecraft.world.entity.projectile.ShulkerBullet getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.projectile.ShulkerBullet) entity; + return (net.minecraft.world.entity.projectile.ShulkerBullet) this.entity; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java -index 598992e13586c38d6526ab496c773d5e5b39a7f2..a1ae5b9ffe97ee7fa55efc8b1cd04e7a682c5ee4 100644 +index 7c75d78e5e28d7320c6dbe979bcd576658fb310b..83de93bd751b1c15ad763819e4fe87ecb13bf6e8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSilverfish.java @@ -8,8 +8,16 @@ public class CraftSilverfish extends CraftMonster implements Silverfish { @@ -2377,11 +2398,11 @@ index 598992e13586c38d6526ab496c773d5e5b39a7f2..a1ae5b9ffe97ee7fa55efc8b1cd04e7a @Override public net.minecraft.world.entity.monster.Silverfish getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Silverfish) entity; + return (net.minecraft.world.entity.monster.Silverfish) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java -index 5d16db88c243279a581092c98d37027aa6731485..c9bfe84cbd2c5835e070251ace2ef06ccb7004cf 100644 +index 824638b3428fd480419f559c07d1fc7fbd434a24..278ad88925fb5530fdeef35cb19002a0cdab68a0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java @@ -27,8 +27,16 @@ public class CraftSizedFireball extends CraftFireball implements SizedFireball { @@ -2398,11 +2419,11 @@ index 5d16db88c243279a581092c98d37027aa6731485..c9bfe84cbd2c5835e070251ace2ef06c @Override public Fireball getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (Fireball) entity; + return (Fireball) this.entity; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java -index 16e6325a944c1eb21dd5a3835aa8a00d238e7b5d..9944be024fc0e0ceb12410d7168f0caf52a0728d 100644 +index 6f98da9be6aef35e3b5c940188b872459a383c8e..79465c30d59c50574b215e1f4ad75a2b426404a3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java @@ -31,8 +31,16 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton { @@ -2419,11 +2440,11 @@ index 16e6325a944c1eb21dd5a3835aa8a00d238e7b5d..9944be024fc0e0ceb12410d7168f0caf @Override public net.minecraft.world.entity.monster.Skeleton getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Skeleton) entity; + return (net.minecraft.world.entity.monster.Skeleton) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java -index bba6dcac6df4841561cf39b9ea0fc116f57a901b..72c43e1ee4f2df751402e4d95a411c1ae110d21a 100644 +index fbb47491dcc75f8247dee9f123f946f99ef1467f..9dfd108be5185eb897faa802411297183a960cee 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java @@ -20,8 +20,16 @@ public class CraftSkeletonHorse extends CraftAbstractHorse implements SkeletonHo @@ -2440,11 +2461,11 @@ index bba6dcac6df4841561cf39b9ea0fc116f57a901b..72c43e1ee4f2df751402e4d95a411c1a @Override public net.minecraft.world.entity.animal.horse.SkeletonHorse 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.horse.SkeletonHorse) entity; + return (net.minecraft.world.entity.animal.horse.SkeletonHorse) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java -index 2b1211ee410a0246195053ad041eaa131f859bcd..a61121c6e103fce394e2fd93e60711d6e42c7ad1 100644 +index e48f7d1cbec4a2319745ba48a5d44ab9925214e2..1ffb16e5e8e243f684c7c0b9fbdd2a7b885d412d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java @@ -19,8 +19,16 @@ public class CraftSlime extends CraftMob implements Slime, CraftEnemy { @@ -2461,11 +2482,11 @@ index 2b1211ee410a0246195053ad041eaa131f859bcd..a61121c6e103fce394e2fd93e60711d6 @Override public net.minecraft.world.entity.monster.Slime getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Slime) entity; + return (net.minecraft.world.entity.monster.Slime) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java -index 262e9abf0887c82876d8843504c2dec362e68e6f..74b20c726a0b055180f6385b8020c646939d6690 100644 +index 072df206858944ef78179b0a6d61ed990a844d2b..c022ca9c630cfe9a37583c65afc6d390c13f5886 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSmallFireball.java @@ -8,8 +8,16 @@ public class CraftSmallFireball extends CraftSizedFireball implements SmallFireb @@ -2482,11 +2503,11 @@ index 262e9abf0887c82876d8843504c2dec362e68e6f..74b20c726a0b055180f6385b8020c646 @Override public net.minecraft.world.entity.projectile.SmallFireball getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.projectile.SmallFireball) entity; + return (net.minecraft.world.entity.projectile.SmallFireball) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java -index 01328768ef2baba2aa7fea7e10b0eb9783497f4b..737b5ea7f6cbf3db6a8e5ee1bccbcd68191bbf32 100644 +index 555337018fe218ac5a296a5e6a1d82720fee05e1..a6929f512a99eed376878ae11aa7bac0b5828e27 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSniffer.java @@ -16,8 +16,16 @@ public class CraftSniffer extends CraftAnimals implements Sniffer { @@ -2507,7 +2528,7 @@ index 01328768ef2baba2aa7fea7e10b0eb9783497f4b..737b5ea7f6cbf3db6a8e5ee1bccbcd68 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java -index 1650bd74e37e6963becd9d510d2b640da5c3fede..f72decb7c43337130d3caee6a15ae91cdaf57522 100644 +index d959825fd11a94aba175934cd7739544a23958fc..e22be41875f2d772bcc1219e54f4f436813034a1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowball.java @@ -8,8 +8,16 @@ public class CraftSnowball extends CraftThrowableProjectile implements Snowball @@ -2524,11 +2545,11 @@ index 1650bd74e37e6963becd9d510d2b640da5c3fede..f72decb7c43337130d3caee6a15ae91c @Override public net.minecraft.world.entity.projectile.Snowball getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.projectile.Snowball) entity; + return (net.minecraft.world.entity.projectile.Snowball) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java -index e4a14cdfeb91a3d32e622d27d612605b1bca08e2..b1b87ad34caf0d7888ddf59692c8c766358a6b85 100644 +index 4ce2373ff71c3c1b8951646e057587a3ab09e145..9041c121b9bc41152640c8e2ed983b9ec29df81a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java @@ -19,8 +19,16 @@ public class CraftSnowman extends CraftGolem implements Snowman, com.destroystok @@ -2545,11 +2566,11 @@ index e4a14cdfeb91a3d32e622d27d612605b1bca08e2..b1b87ad34caf0d7888ddf59692c8c766 @Override public SnowGolem getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (SnowGolem) entity; + return (SnowGolem) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java -index f6ff0e5b16812ae6f577ec30cd6cca337a534ce2..8d89889fafa153d16a8b0a39e8c5ef6b0323ac65 100644 +index 6dff6db2e6a3a4fb2ada257041b168347d33bc6a..62b9c7fce1e3f7e17e9a1be999cf94760c057445 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpectralArrow.java @@ -9,8 +9,16 @@ public class CraftSpectralArrow extends CraftArrow implements SpectralArrow { @@ -2566,7 +2587,7 @@ index f6ff0e5b16812ae6f577ec30cd6cca337a534ce2..8d89889fafa153d16a8b0a39e8c5ef6b @Override public net.minecraft.world.entity.projectile.SpectralArrow getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.projectile.SpectralArrow) entity; + return (net.minecraft.world.entity.projectile.SpectralArrow) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java @@ -2591,7 +2612,7 @@ index 525827f1747631fa108be7e1b7395b47d33aa397..3dbb5f7f88979d616e185980d96cc2c3 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java -index 3da93b408a864e1663291ed22aaccfa6beba1280..3d09be063f750ecb79b1fc7f2bc4d65a3688e3c6 100644 +index b4afc37c21fc478df44fca7ec3fbc33d337dc6b7..911822f4e2e1eba6a9d3e9b781499314d7f9427f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpider.java @@ -9,8 +9,16 @@ public class CraftSpider extends CraftMonster implements Spider { @@ -2608,11 +2629,11 @@ index 3da93b408a864e1663291ed22aaccfa6beba1280..3d09be063f750ecb79b1fc7f2bc4d65a @Override public net.minecraft.world.entity.monster.Spider getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Spider) entity; + return (net.minecraft.world.entity.monster.Spider) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java -index 7f970e1a8d1b6d12cbfc1c6606ab537989655e5a..6f0197156e79fb34d8c54b4317ff6d66a19cb75b 100644 +index a6e3b61c391a8b266d2b030d9ba600ac6be76952..f93b160ae82b7cae6b11d214531df4618fd79f74 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSquid.java @@ -9,8 +9,16 @@ public class CraftSquid extends CraftWaterMob implements Squid { @@ -2629,11 +2650,11 @@ index 7f970e1a8d1b6d12cbfc1c6606ab537989655e5a..6f0197156e79fb34d8c54b4317ff6d66 @Override public net.minecraft.world.entity.animal.Squid 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.Squid) entity; + return (net.minecraft.world.entity.animal.Squid) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java -index 09ca1e92b63507554a0801999a917f91375d9d59..796eca2bf20ec7a9de69027418d922473444e588 100644 +index 9472a6f9c9584048abf1f8d11ab6254b7c7a287d..f2daf0fc0f07d90040887b0cee8f1924d3c146bc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java @@ -65,8 +65,16 @@ public class CraftStrider extends CraftAnimals implements Strider { @@ -2650,11 +2671,11 @@ index 09ca1e92b63507554a0801999a917f91375d9d59..796eca2bf20ec7a9de69027418d92247 @Override public net.minecraft.world.entity.monster.Strider getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Strider) entity; + return (net.minecraft.world.entity.monster.Strider) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java -index dc13deb1cea14f0650b292ddb6437fadefc0b8be..c433fda809e9452046ff07aabaa216be3199862b 100644 +index 3f32c683ddc6999b89f2e4051eb6ae784b296b8f..c15141d2ffa4638f251681063e7ecae4186972d8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java @@ -42,8 +42,16 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed { @@ -2671,11 +2692,11 @@ index dc13deb1cea14f0650b292ddb6437fadefc0b8be..c433fda809e9452046ff07aabaa216be @Override public PrimedTnt getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (PrimedTnt) entity; + return (PrimedTnt) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java -index 730a25ef2fe934f64f65c21e4e007cf1dbab8bf2..57df8021ce87cb688f84b28156d3f0c41888705d 100644 +index d7c6a0bbc5671ea8f2488230c94df5146a1e98b9..71faf263dd5ac43ab9b89b5a152dd0d1ee93b91b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java @@ -9,8 +9,16 @@ public class CraftTadpole extends CraftFish implements org.bukkit.entity.Tadpole @@ -2692,11 +2713,11 @@ index 730a25ef2fe934f64f65c21e4e007cf1dbab8bf2..57df8021ce87cb688f84b28156d3f0c4 @Override public Tadpole getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (Tadpole) entity; + return (Tadpole) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java -index 428437970cac144be53cd0e30af7af0cd1ce603b..dc09e141ba2b12f1955bec521f2170d2fe4ba113 100644 +index a06679e1e5686d9bd601b3dcf8492add58918bc4..389ba1c170014f9d5b7e4acf10b494338f46efcb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java @@ -12,8 +12,16 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat @@ -2738,7 +2759,7 @@ index 9ef939b76d06874b856e0c850addb364146f5a00..d3975a461778d9815f68f323e616e25c } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java -index 989c5c499a52ad0777abecd14a1a9d5803ce1aaf..8e66e9ac17a8a06130d6b039f27868d42554f337 100644 +index 2a57a2ce8c21d2ab2376d34d1343315209715579..04a28b8bcd449d312dcb495e496913f470705c10 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java @@ -26,8 +26,16 @@ public abstract class CraftThrowableProjectile extends CraftProjectile implement @@ -2755,11 +2776,11 @@ index 989c5c499a52ad0777abecd14a1a9d5803ce1aaf..8e66e9ac17a8a06130d6b039f27868d4 @Override public ThrowableItemProjectile getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (ThrowableItemProjectile) entity; + return (ThrowableItemProjectile) this.entity; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java -index 6b3c381dbda3686b2644475fef2d373da4c2360a..40fe0132f877e8088b828744823981eb3351f650 100644 +index 5e7fef664c56d6087502e56a0eb4fc07d34ade9f..7538d449e24a8d680628f31b22924e7de9e8b503 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownExpBottle.java @@ -9,8 +9,16 @@ public class CraftThrownExpBottle extends CraftThrowableProjectile implements Th @@ -2776,11 +2797,11 @@ index 6b3c381dbda3686b2644475fef2d373da4c2360a..40fe0132f877e8088b828744823981eb @Override public ThrownExperienceBottle getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (ThrownExperienceBottle) entity; + return (ThrownExperienceBottle) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java -index 04bcb1f26db12556d70e41541a5df0700d20d964..6bbb6f2720ed8fc8b54edc3922d8423274ed8642 100644 +index d3aeb4b614b2b17d9613aa3ffa34ebfc81666f79..a8eba002d3620192781abcccd1b5172b77cdd1c5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java @@ -60,8 +60,17 @@ public class CraftThrownPotion extends CraftThrowableProjectile implements Throw @@ -2798,14 +2819,14 @@ index 04bcb1f26db12556d70e41541a5df0700d20d964..6bbb6f2720ed8fc8b54edc3922d84232 @Override public net.minecraft.world.entity.projectile.ThrownPotion getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.projectile.ThrownPotion) entity; + return (net.minecraft.world.entity.projectile.ThrownPotion) this.entity; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java -index 182e8e9ecb789d639b2dd7348a68e37096da53ac..3d3ce1392dc9d86965c4baf80e3d92089da5ed2c 100644 +index b2747e37600cadc385e2e9e1115ba1d4ec22f5da..11f7c05740e68fdc171aa5cbf6f8b3f71026948f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java -@@ -22,8 +22,16 @@ public class CraftTippedArrow extends CraftArrow implements Arrow { +@@ -23,8 +23,16 @@ public class CraftTippedArrow extends CraftArrow implements Arrow { super(server, entity); } @@ -2819,7 +2840,7 @@ index 182e8e9ecb789d639b2dd7348a68e37096da53ac..3d3ce1392dc9d86965c4baf80e3d9208 @Override public net.minecraft.world.entity.projectile.Arrow getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.projectile.Arrow) entity; + return (net.minecraft.world.entity.projectile.Arrow) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java @@ -2865,7 +2886,7 @@ index c8b65210d2416b5a293cb4bcc1b71f56ed365cd7..0e3045647382111066000fc03925596c } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java -index d1d932dd27cff00e0ab69443a58715e3cbc1e57c..0deb1cb458d84f9321c4a020cb4bb26163b18fa7 100644 +index 9e53c30801c700719c78c0fd521fd615c94e02c8..201d4db7a455cde7c6feb4263a054a5cb66ea672 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java @@ -13,8 +13,16 @@ public class CraftTropicalFish extends io.papermc.paper.entity.PaperSchoolableFi @@ -2882,7 +2903,7 @@ index d1d932dd27cff00e0ab69443a58715e3cbc1e57c..0deb1cb458d84f9321c4a020cb4bb261 @Override public net.minecraft.world.entity.animal.TropicalFish 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.TropicalFish) entity; + return (net.minecraft.world.entity.animal.TropicalFish) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java @@ -2907,7 +2928,7 @@ index d44e6f4bb682d18c1497eee9fb2802f2bda6e840..f2d589721a335d1f92ab04ce70e7678a } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java -index 6079581ba2eef8ac9272d0bbbf77e31f593edf0f..f89b72a75dc685c08641105c8445f4e14aa9ee35 100644 +index e9ec3455eabc473e104b5342a615a38c1ac25a4f..2f0aac537bd71e6db8e3554ce8d615e521897e27 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -13,8 +13,16 @@ public class CraftVex extends CraftMonster implements Vex { @@ -2928,7 +2949,7 @@ index 6079581ba2eef8ac9272d0bbbf77e31f593edf0f..f89b72a75dc685c08641105c8445f4e1 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java -index a67b5d20b956e0bf801c9eeb9330567c21927010..6f353590ff2de58fb147bf65495018045976c1f6 100644 +index 6c15d40979fd3e3d246a447c432b321fbf29ada3..771eb799b032fcf4fc33c5e445b7fa252baee72b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -31,8 +31,16 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { @@ -2945,7 +2966,7 @@ index a67b5d20b956e0bf801c9eeb9330567c21927010..6f353590ff2de58fb147bf6549501804 @Override public net.minecraft.world.entity.npc.Villager 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.npc.Villager) entity; + return (net.minecraft.world.entity.npc.Villager) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -2991,7 +3012,7 @@ index bcd3370bc48520ea4bb53af25b892131d6ca0b33..c89dfec6f61d4f487bd6292d509a3392 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java -index fd6ac99dae7e54b90f2b0e01430ac6db9410ccd4..ff3458e986a1063b097b6ae65ba4b2653aca8888 100644 +index 3cceefa0d6278924a19641a49bdf16bcdacb2233..0664afee1d66c44318f12ff38ac8c8509491b9d6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java @@ -9,8 +9,16 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements Wande @@ -3008,11 +3029,11 @@ index fd6ac99dae7e54b90f2b0e01430ac6db9410ccd4..ff3458e986a1063b097b6ae65ba4b265 @Override public net.minecraft.world.entity.npc.WanderingTrader 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.npc.WanderingTrader) entity; + return (net.minecraft.world.entity.npc.WanderingTrader) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java -index 46e3cc146a4b109c4baaf94f42d825646abade68..e41005b7df193d36bf11a12625d1774c8321cfd6 100644 +index c284eb96a1e330078076cbe61f0f6e2ff4ed89bd..68094bea75635376665ef850ed01484a2b27f630 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java @@ -15,8 +15,16 @@ public class CraftWarden extends CraftMonster implements org.bukkit.entity.Warde @@ -3029,11 +3050,11 @@ index 46e3cc146a4b109c4baaf94f42d825646abade68..e41005b7df193d36bf11a12625d1774c @Override public Warden getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (Warden) entity; + return (Warden) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java -index 684f983e95459f7065274e0b494e754fd317d42d..c03b8291bac77696daf24caaff3512d6a0ba10db 100644 +index 1b347deb6eb0b39c4a23936f7cd387421f06350d..4e5d311e10736f84964c22cb01a9fafe38bc445c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWaterMob.java @@ -10,8 +10,16 @@ public class CraftWaterMob extends CraftCreature implements WaterMob { @@ -3050,11 +3071,11 @@ index 684f983e95459f7065274e0b494e754fd317d42d..c03b8291bac77696daf24caaff3512d6 @Override public WaterAnimal getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (WaterAnimal) entity; + return (WaterAnimal) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java -index 0acb96ae2102ab6af4b5610254ab3a1408ed9822..f0cfe156924e036639e5ba368a91be3a382c4780 100644 +index 4b3d783cabcb2de1a67d7fbfb6f525bfb493aed1..b8d1fe35b9c0b00389b2aaca229f31a6d0de85c6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java @@ -15,8 +15,16 @@ public class CraftWitch extends CraftRaider implements Witch, com.destroystokyo. @@ -3071,11 +3092,11 @@ index 0acb96ae2102ab6af4b5610254ab3a1408ed9822..f0cfe156924e036639e5ba368a91be3a @Override public net.minecraft.world.entity.monster.Witch getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Witch) entity; + return (net.minecraft.world.entity.monster.Witch) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java -index 5a97c92f9b044d8ab7bd3346ceb464455a09046e..c44a349c7dbb5e48f9476fbbda3a8277e8b59aa1 100644 +index 7a8ce6956db56061af93ba9761f5d1057a90bc49..97891857b2c942c7f6e95c94e3c00abc3da2feea 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java @@ -21,8 +21,16 @@ public class CraftWither extends CraftMonster implements Wither, com.destroystok @@ -3092,11 +3113,11 @@ index 5a97c92f9b044d8ab7bd3346ceb464455a09046e..c44a349c7dbb5e48f9476fbbda3a8277 @Override public WitherBoss getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (WitherBoss) entity; + return (WitherBoss) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java -index cb228731bdefd90776261cba29328d56e9217d04..ad8ac056ef9e6abe1afe21622ba187c2d7f9e3a7 100644 +index bc978391255c9414e06ff393f2e6707d329d020a..5af2d0f7c496d49dcb66b888047836c05299ffc7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java @@ -18,8 +18,16 @@ public class CraftWitherSkull extends CraftFireball implements WitherSkull { @@ -3113,11 +3134,11 @@ index cb228731bdefd90776261cba29328d56e9217d04..ad8ac056ef9e6abe1afe21622ba187c2 @Override public net.minecraft.world.entity.projectile.WitherSkull getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.projectile.WitherSkull) entity; + return (net.minecraft.world.entity.projectile.WitherSkull) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java -index e16459c9cfcac790edd6d912750d32c68387cbbc..4100c8beb897b931ac0bf168a934286a4a43732a 100644 +index 38b6d2c377800134de592a780b737b45c8096a11..ca35b9bdabc456b64272046cb069b8d7477aa1b2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java @@ -23,8 +23,16 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf { @@ -3134,11 +3155,11 @@ index e16459c9cfcac790edd6d912750d32c68387cbbc..4100c8beb897b931ac0bf168a934286a @Override public net.minecraft.world.entity.animal.Wolf 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.Wolf) entity; + return (net.minecraft.world.entity.animal.Wolf) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java -index 24165f605708239076f839e4e1accd0560996f88..4af64566b17c39d21acc8f445eb993c9652f9928 100644 +index c134c4bb8c0377ceb7f8a5c40c94fd6312a9e448..e119b2d0f9b3264a6105d18c9c67b91ae3466540 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java @@ -19,8 +19,16 @@ public class CraftZoglin extends CraftMonster implements Zoglin { @@ -3155,11 +3176,11 @@ index 24165f605708239076f839e4e1accd0560996f88..4af64566b17c39d21acc8f445eb993c9 @Override public net.minecraft.world.entity.monster.Zoglin getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Zoglin) entity; + return (net.minecraft.world.entity.monster.Zoglin) this.entity; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java -index ed211b123354ece21dd8beae7192a26727f5124f..323634b642f8af27ba0eb8647c01acab865d300e 100644 +index 46336111dcf62a29390e724b1879c84c697076e9..ff6965694ffeee0e895a128351270361360c701d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -12,8 +12,16 @@ public class CraftZombie extends CraftMonster implements Zombie { @@ -3176,6 +3197,6 @@ index ed211b123354ece21dd8beae7192a26727f5124f..323634b642f8af27ba0eb8647c01acab @Override public net.minecraft.world.entity.monster.Zombie getHandle() { + io.papermc.paper.util.TickThread.ensureTickThread(this.entity, "Accessing entity state off owning region's thread"); // Folia - region threading - return (net.minecraft.world.entity.monster.Zombie) entity; + return (net.minecraft.world.entity.monster.Zombie) this.entity; } diff --git a/patches/server/0007-Disable-mid-tick-task-execution.patch b/patches/server/0007-Disable-mid-tick-task-execution.patch index 9ea402befb..13acb65ef9 100644 --- a/patches/server/0007-Disable-mid-tick-task-execution.patch +++ b/patches/server/0007-Disable-mid-tick-task-execution.patch @@ -10,7 +10,7 @@ the impact from scaling the region threads, but is not a fix to the underlying issue. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3f283e1a5c181819b223c0f44cc5d8f274fd88a6..f9cf331202d0768a054e575c8909369920b3d59f 100644 +index 75d5e7f1b247e27f526a3f76fa7df7aeca4e90ac..5ded3dbc379f199ed735b6ce0ebf6a2e3485f93b 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -2877,6 +2877,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { // Folia - regionised ticking if (!entity.isRemoved()) { @@ -1701,8 +1701,8 @@ index 32fdb3d70442257201472f9f1c1ad4664ca735d7..02937e40d429f42643f77b17c04277be } }); + } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); } // Folia - profiler - timings.entityTick.stopTiming(); // Spigot - timings.tickEntities.stopTiming(); // Spigot + this.timings.entityTick.stopTiming(); // Spigot + this.timings.tickEntities.stopTiming(); // Spigot gameprofilerfiller.pop(); + profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TILE_ENTITY); try { // Folia - profiler this.tickBlockEntities(); @@ -1769,10 +1769,10 @@ index 32fdb3d70442257201472f9f1c1ad4664ca735d7..02937e40d429f42643f77b17c04277be } else { passenger.stopRiding(); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 7bfbcda5cf086c3c50f8cb202ceaf685a899141c..9da89e8e9569666227081ebc6cb1f0348e1a183d 100644 +index 4b1ee6b9351aeb96ac7a3c2aaa8c464bbca91e22..7edaa7558e40942f94c459e9b480ef640146ec6b 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -1301,6 +1301,7 @@ public abstract class PlayerList { +@@ -1325,6 +1325,7 @@ public abstract class PlayerList { public void saveAll(int interval) { io.papermc.paper.util.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main @@ -1780,7 +1780,7 @@ index 7bfbcda5cf086c3c50f8cb202ceaf685a899141c..9da89e8e9569666227081ebc6cb1f034 MinecraftTimings.savePlayers.startTiming(); // Paper int numSaved = 0; long now = System.nanoTime(); // Folia - region threading -@@ -1312,7 +1313,9 @@ public abstract class PlayerList { +@@ -1336,7 +1337,9 @@ public abstract class PlayerList { } // Folia end - region threading if (interval == -1 || now - entityplayer.lastSave >= timeInterval) { // Folia - region threading @@ -1822,7 +1822,7 @@ index 73871f456a85bda1e51f54986d0e61fb629822e8..3f3494c20cd15a721090f1b36293562a this.factory = factory; this.category = spawnGroup; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index f9641a54b2d1f2eed2a48323cfa6cdd67dafdf00..0ff6764c747ee6258ab9d722b48c24f0ddb2afdf 100644 +index 1480ddf3a1cc3164571a867be1f5aa02f4c66864..c58ca3dd28b9c113a26feb1a7f05bd78c0dbd678 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -226,6 +226,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -1853,16 +1853,16 @@ index f9641a54b2d1f2eed2a48323cfa6cdd67dafdf00..0ff6764c747ee6258ab9d722b48c24f0 ProfilerFiller gameprofilerfiller = this.getProfiler(); gameprofilerfiller.push("blockEntities"); - timings.tileEntityPending.startTiming(); // Spigot - final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = ((ServerLevel)this).getCurrentWorldData(); // Folia - regionised ticking + this.timings.tileEntityPending.startTiming(); // Spigot + final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = this.getCurrentWorldData(); // Folia - regionised ticking regionizedWorldData.seTtickingBlockEntities(true); // Folia - regionised ticking + profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TILE_ENTITY_PENDING); try { // Folia - profiler regionizedWorldData.pushPendingTickingBlockEntities(); // Folia - regionised ticking + } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TILE_ENTITY_PENDING); } // Folia - profiler List blockEntityTickers = regionizedWorldData.getBlockEntityTickers(); // Folia - regionised ticking - timings.tileEntityPending.stopTiming(); // Spigot + this.timings.tileEntityPending.stopTiming(); // Spigot - timings.tileEntityTick.startTiming(); // Spigot + this.timings.tileEntityTick.startTiming(); // Spigot + profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TILE_ENTITY_TICK); try { // Folia - profiler // Spigot start // Iterator iterator = this.blockEntityTickers.iterator(); @@ -1873,7 +1873,7 @@ index f9641a54b2d1f2eed2a48323cfa6cdd67dafdf00..0ff6764c747ee6258ab9d722b48c24f0 blockEntityTickers.removeAll(toRemove); // Folia - regionised ticking + } finally { profiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TILE_ENTITY_TICK); } // Folia - profiler - timings.tileEntityTick.stopTiming(); // Spigot + this.timings.tileEntityTick.stopTiming(); // Spigot regionizedWorldData.seTtickingBlockEntities(false); // Folia - regionised ticking diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java index 2c1bc515468e2ba99d463021758fb72ef160fbe9..93cc5523a1c3637bf4f04ff4ef0f8ef6e1050a59 100644 @@ -1913,7 +1913,7 @@ index 2c1bc515468e2ba99d463021758fb72ef160fbe9..93cc5523a1c3637bf4f04ff4ef0f8ef6 } } 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 20884dc82f8c95ec5ca92448c856fa9bc2c1e3ee..955d125e028f83a79068d5ad6aa7c38e67a5f55a 100644 +index 744fa3a3a62ffb4b3d1e7831c93fd76dee29fdd0..3c42478dd38d29dedc638e7bbbbd23818e111335 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -1182,11 +1182,14 @@ public class LevelChunk extends ChunkAccess {