diff --git a/gradle.properties b/gradle.properties index 195e60b..ac46e46 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ group=dev.folia version=1.20.4-R0.1-SNAPSHOT mcVersion=1.20.4 -paperRef=9e171ef8ff0a0ec57ebc75772fc9de578c987059 +paperRef=31699ae9a8f3a57491e9c9276cffa5a51e9a5f60 org.gradle.caching=true org.gradle.parallel=true 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 3251639..1360595 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 2d53675907f411046978b0a234c0b6f33c909973..15252f744d60408a816dba1c0ca0c7104236ae6f 100644 +index ca27559cf4aa1c2e44fdca2022e213b1b1c80f4e..3fae7b21353d18ff1e8005fbbe83be783de8a953 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -2837,6 +2837,14 @@ public final class Bukkit { +@@ -2857,6 +2857,14 @@ public final class Bukkit { return server.isOwnedByCurrentRegion(entity); } // Paper end - Folia region threading API @@ -30,10 +30,10 @@ index 2d53675907f411046978b0a234c0b6f33c909973..15252f744d60408a816dba1c0ca0c710 @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 9af4bc16da09e59009c47911219e99450cdf2aa5..8d51301e1a0a2a528353b90e2e2d0e4c69c6a4f5 100644 +index b4f8281d3797ec825a7671f38077cd65d5a1d76e..fe3d89c2c319c4f4b2b3e4a121d6626a898f501b 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2481,4 +2481,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2497,4 +2497,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 b047cd0..626cadb 100644 --- a/patches/server/0001-Build-changes.patch +++ b/patches/server/0001-Build-changes.patch @@ -106,10 +106,10 @@ index d06185566b447c432d4dc2e3ba04d121bcdbc71b..680919045310be7e50e2d503a23d265f public SystemReport fillSystemReport(SystemReport details) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 4df3b94c8126f00188f5e125757411a0359728fa..825e7abebd6eb898198106ca6e783ec462e64173 100644 +index 9f7ed337463cc9bb370a5541d9de5cd8f9c1a78a..c4144c239a5d91bc0faec84fe49829337aa339dc 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -264,7 +264,7 @@ import javax.annotation.Nullable; // Paper +@@ -266,7 +266,7 @@ import javax.annotation.Nullable; // Paper import javax.annotation.Nonnull; // Paper public final class CraftServer implements Server { diff --git a/patches/server/0003-Threaded-Regions.patch b/patches/server/0003-Threaded-Regions.patch index 4e53bfe..1ddba62 100644 --- a/patches/server/0003-Threaded-Regions.patch +++ b/patches/server/0003-Threaded-Regions.patch @@ -2421,7 +2421,7 @@ index 385ca2c1022e0985550a5cc2bbff953f1aa33f5c..f7a66f54a450f1a46e9d0a138544e974 public int maxAutoSaveChunksPerTick = 24; public int fixedChunkInhabitedTime = -1; diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java -index eeea1e6f7b1ed64567a3f90d8eb2e2cfd53e5912..ae9892b7d5233e32a9d81fdd3978b608bb55ea14 100644 +index eedbf46e04b5ae420f9bedcbc2bbb10643ba7e22..afc9c6e6e8bc4a4706474134dae5484459531226 100644 --- a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java +++ b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java @@ -242,12 +242,7 @@ class PaperPluginInstanceManager { @@ -9467,7 +9467,7 @@ index b7f338e982d0dcab99137ab6dc200b82ac6b7cba..4f25b35a037e6c697e5e345f38b94a8e private void runSync(ServerPlayer player, Collection bukkit, RootCommandNode rootcommandnode) { diff --git a/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java -index 155bd3d6d9c7d3cac7fd04de8210301251d1e17a..446f590dcf8f1d30b365e71515683c9a592a608b 100644 +index bc2e763a848b4bf7e9598ffe1ca2aa35a9af4677..9496464d1400009d523b84373e8b47fdc1085ce3 100644 --- a/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/AbstractProjectileDispenseBehavior.java @@ -32,7 +32,7 @@ public abstract class AbstractProjectileDispenseBehavior extends DefaultDispense @@ -9506,7 +9506,7 @@ index f28705547a62da790f5df071400986aacba39367..4bbed8e057a32ce22d768392cebc2711 } diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be12913c45 100644 +index e2e1273d787536d2fe1bdbbf8af36eb5ac220599..bee5d0a0516fbae4f550c0a77fcca6afcff8675f 100644 --- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java @@ -222,7 +222,7 @@ public interface DispenseItemBehavior { @@ -9518,7 +9518,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -277,7 +277,7 @@ public interface DispenseItemBehavior { +@@ -281,7 +281,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -9527,7 +9527,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -333,7 +333,7 @@ public interface DispenseItemBehavior { +@@ -338,7 +338,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) list.get(0).getBukkitEntity()); @@ -9536,7 +9536,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be world.getCraftServer().getPluginManager().callEvent(event); } -@@ -389,7 +389,7 @@ public interface DispenseItemBehavior { +@@ -394,7 +394,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorseabstract.getBukkitEntity()); @@ -9545,7 +9545,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be world.getCraftServer().getPluginManager().callEvent(event); } -@@ -463,7 +463,7 @@ public interface DispenseItemBehavior { +@@ -468,7 +468,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorsechestedabstract.getBukkitEntity()); @@ -9554,7 +9554,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be world.getCraftServer().getPluginManager().callEvent(event); } -@@ -502,7 +502,7 @@ public interface DispenseItemBehavior { +@@ -507,7 +507,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(enumdirection.getStepX(), enumdirection.getStepY(), enumdirection.getStepZ())); @@ -9563,7 +9563,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -560,7 +560,7 @@ public interface DispenseItemBehavior { +@@ -565,7 +565,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5)); @@ -9572,7 +9572,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -639,7 +639,7 @@ public interface DispenseItemBehavior { +@@ -645,7 +645,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); @@ -9581,7 +9581,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -713,7 +713,7 @@ public interface DispenseItemBehavior { +@@ -722,7 +722,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -9590,7 +9590,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -760,7 +760,7 @@ public interface DispenseItemBehavior { +@@ -769,7 +769,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack); // Paper - ignore stack size on damageable items BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -9599,7 +9599,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -821,7 +821,7 @@ public interface DispenseItemBehavior { +@@ -830,7 +830,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -9608,7 +9608,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -839,7 +839,8 @@ public interface DispenseItemBehavior { +@@ -848,7 +848,8 @@ public interface DispenseItemBehavior { } } @@ -9618,7 +9618,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be // CraftBukkit end if (!BoneMealItem.growCrop(stack, worldserver, blockposition) && !BoneMealItem.growWaterPlant(stack, worldserver, blockposition, (Direction) null)) { -@@ -848,13 +849,13 @@ public interface DispenseItemBehavior { +@@ -857,13 +858,13 @@ public interface DispenseItemBehavior { worldserver.levelEvent(1505, blockposition, 0); } // CraftBukkit start @@ -9638,7 +9638,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be StructureGrowEvent structureEvent = null; if (treeType != null) { structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks); -@@ -890,7 +891,7 @@ public interface DispenseItemBehavior { +@@ -899,7 +900,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D)); @@ -9647,7 +9647,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -947,7 +948,7 @@ public interface DispenseItemBehavior { +@@ -956,7 +957,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -9656,7 +9656,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -996,7 +997,7 @@ public interface DispenseItemBehavior { +@@ -1005,7 +1006,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -9665,7 +9665,7 @@ index 1fb809486ee56efd3d0ef3fa02503ba9be459f68..c709f7e2fc2dfe6455ccfcb00c63f0be worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -1069,7 +1070,7 @@ public interface DispenseItemBehavior { +@@ -1078,7 +1079,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - only single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -9688,7 +9688,7 @@ index 8d65cdb013706a932c2c73231108b2810b99e1c7..728e2f00de43b5363fdee2d982acab26 } diff --git a/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java -index 6f2adf2334e35e8a617a4ced0c1af2abf32bbd8d..de323c881b6d54061f7fef2b56658bebc2d71604 100644 +index cb308808906a8cdb127df8284e106e00553473ca..05bc1f010b50e673e9a185d96e338baef7ccad03 100644 --- a/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java @@ -37,7 +37,7 @@ public class ShulkerBoxDispenseBehavior extends OptionalDispenseItemBehavior { @@ -12145,10 +12145,10 @@ index 812f2adc6fc20aa126e629284fe594a923b24540..0a5e6961fb37e9a53cd39b1bd233e020 } } diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 6de6dad36203479677a29ad61e21bc369d4e5513..0f8c868fce0a054a0ba356350baf4c3824c2c958 100644 +index 68d268b6fff126e8645b6deec3fb549ea2286b77..6b3242117d62175de462d04e4d178b49ae2521e9 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -442,9 +442,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -443,9 +443,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } @Override @@ -12161,7 +12161,7 @@ index 6de6dad36203479677a29ad61e21bc369d4e5513..0f8c868fce0a054a0ba356350baf4c38 } @Override -@@ -766,7 +766,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -767,7 +767,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface Waitable[] waitableArray = new Waitable[1]; // Paper rconConsoleSource.prepareForCommand(); final java.util.concurrent.atomic.AtomicReference command = new java.util.concurrent.atomic.AtomicReference<>(s); // Paper @@ -12170,7 +12170,7 @@ index 6de6dad36203479677a29ad61e21bc369d4e5513..0f8c868fce0a054a0ba356350baf4c38 CommandSourceStack wrapper = rconConsoleSource.createCommandSourceStack(); RemoteServerCommandEvent event = new RemoteServerCommandEvent(rconConsoleSource.getBukkitSender(wrapper), s); this.server.getPluginManager().callEvent(event); -@@ -790,7 +790,16 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -791,7 +791,16 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface ConsoleInput serverCommand = new ConsoleInput(event.getCommand(), wrapper); this.server.dispatchServerCommand(event.getSender(), serverCommand); } // Paper @@ -14226,7 +14226,7 @@ index 6934e9dac0d69c043b73b7c46d59f2d39b37c67f..172f8e1abb036669b787fde570da8d32 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 0dba30c41affafe7b1d585b515925043b37712fa..b9e7c8776b5b4086fb2455035857947f9a4b3dba 100644 +index 58591bf2f63b9c5e97d9ce4188dff3366968a178..add6fc106d3c38d97b48ec0df3ac2515c8c0486e 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -191,7 +191,7 @@ import org.bukkit.inventory.MainHand; @@ -15144,7 +15144,7 @@ index 586521a2cbb1d4dcfb912029f65e4363ec7674a7..6e95017f4c36208abdf344e3b7d55efe Collections.shuffle( this.connections ); } diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index a7e40f72a3b56916620a7f089410ec3a6db0cffc..095134bb3c07ad8daeaf4b28076d60b96b481458 100644 +index 6d943b5c38932de5fc3abb28618bf518c36edb47..bcd5d0a274960ccd02a18f754c7ccfdaea698ecc 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -291,7 +291,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -16340,10 +16340,10 @@ index 9c99b2e365aacb8309f29acb9025faccd2c676b3..d02bc26812321745795d2f0bc3705add public Component getDeathMessage() { diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java -index fc6903b20a6e084729306fc960a6fc80e094f76c..31635964ee2cc73e04c1661521df2956ed5a1089 100644 +index fe9b45bfc3d000956f6de5594bf5732fa0e6bb08..1588b48a646c5fe3913dbc83a522b39c8e368ab6 100644 --- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java +++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java -@@ -106,13 +106,13 @@ public class DamageSource { +@@ -149,13 +149,13 @@ public class DamageSource { LivingEntity entityliving1 = killed.getKillCredit(); String s1 = s + ".player"; @@ -16373,7 +16373,7 @@ index ea27b46eec01bda427653335f922ccd068cffcb5..e551d3b875eab6851b75041f418c9a08 return blockToFallLocation(blockState); } else { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913de024ca60 100644 +index 906eded9a2ab61737a30cfe89292a71237ce4eb7..b8e77755a1706e60e9dfa1310aa2449ee0dbc6ad 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -169,7 +169,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -16463,21 +16463,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -943,11 +938,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - // 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(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); - } -- CraftEventFactory.blockDamage = null; -+ CraftEventFactory.blockDamageRT.set(null); // Folia - region threading - // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls - - } -@@ -1093,8 +1088,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1092,8 +1087,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } else { this.wasOnFire = this.isOnFire(); if (movementType == MoverType.PISTON) { @@ -16488,7 +16474,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d movement = this.limitPistonMovement(movement); if (movement.equals(Vec3.ZERO)) { return; -@@ -2998,7 +2993,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3002,7 +2997,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S this.passengers = ImmutableList.copyOf(list); } @@ -16497,7 +16483,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d } } -@@ -3046,7 +3041,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3050,7 +3045,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } entity.boardingCooldown = 60; @@ -16506,7 +16492,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d } return true; // CraftBukkit } -@@ -3326,6 +3321,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3330,6 +3325,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @Nullable public PlayerTeam getTeam() { @@ -16518,19 +16504,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper - Perf: Disable Scoreboards for non players by default return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -3441,9 +3441,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - if (this.fireImmune()) { - return; - } -- CraftEventFactory.entityDamage = lightning; -+ CraftEventFactory.entityDamageRT.set(lightning); // Folia - region threading - if (!this.hurt(this.damageSources().lightningBolt(), 5.0F)) { -- CraftEventFactory.entityDamage = null; -+ CraftEventFactory.entityDamageRT.set(null); // Folia - region threading - return; - } - // CraftBukkit end -@@ -3616,6 +3616,775 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3619,6 +3619,775 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S this.portalEntrancePos = original.portalEntrancePos; } @@ -17306,7 +17280,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d @Nullable public Entity changeDimension(ServerLevel destination) { // CraftBukkit start -@@ -3624,6 +4393,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3627,6 +4396,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @Nullable public Entity teleportTo(ServerLevel worldserver, Vec3 location) { @@ -17318,7 +17292,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d // CraftBukkit end // Paper start - Fix item duplication and teleport issues if (!this.isAlive() || !this.valid) { -@@ -3716,6 +4490,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3719,6 +4493,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } } @@ -17331,7 +17305,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d protected void removeAfterChangingDimensions() { this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION); } -@@ -4650,7 +5430,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4653,7 +5433,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } } // Paper end - Fix MC-4 @@ -17341,7 +17315,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d synchronized (this.posLock) { // Paper this.position = new Vec3(x, y, z); } // Paper -@@ -4671,7 +5452,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4674,7 +5455,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S // Paper start - Block invalid positions and bounding box; don't allow desync of pos and AABB // hanging has its own special logic @@ -17350,7 +17324,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d this.setBoundingBox(this.makeBoundingBox()); } // Paper end - Block invalid positions and bounding box -@@ -4758,6 +5539,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4761,6 +5542,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S return this.removalReason != null; } @@ -17363,7 +17337,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d @Nullable public Entity.RemovalReason getRemovalReason() { return this.removalReason; -@@ -4773,6 +5560,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4776,6 +5563,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } // Paper end - rewrite chunk system final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers @@ -17373,7 +17347,7 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d if (this.removalReason == null) { this.removalReason = reason; } -@@ -4795,6 +5585,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4798,6 +5588,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S this.removalReason = null; } @@ -17385,10 +17359,10 @@ index 9ee1e3da1cb16291ff3e37829e25227a6b97a177..b736cb55542ea7bc35d1a02e7fe5913d /** * 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 6523795e715e5d472739e9bc6433143115c3de8f..03e96af48a1d54d19383a3f0b270248f673ad0aa 100644 +index 902c0e7f2a167845f46adef4578bc71ca8cabfe8..a463c46778e5ee641c1b7d634b79ec68414cd936 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -274,6 +274,13 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -275,6 +275,13 @@ public abstract class LivingEntity extends Entity implements Attackable { ++this.noActionTime; // Above all the floats } // Spigot end @@ -17402,7 +17376,7 @@ index 6523795e715e5d472739e9bc6433143115c3de8f..03e96af48a1d54d19383a3f0b270248f protected LivingEntity(EntityType type, Level world) { super(type, world); -@@ -479,7 +486,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -480,7 +487,7 @@ public abstract class LivingEntity extends Entity implements Attackable { if (this.isDeadOrDying() && this.level().shouldTickDeath(this)) { this.tickDeath(); @@ -17411,7 +17385,7 @@ index 6523795e715e5d472739e9bc6433143115c3de8f..03e96af48a1d54d19383a3f0b270248f if (this.lastHurtByPlayerTime > 0) { --this.lastHurtByPlayerTime; -@@ -625,11 +632,14 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -626,11 +633,14 @@ public abstract class LivingEntity extends Entity implements Attackable { return true; } @@ -17428,7 +17402,7 @@ index 6523795e715e5d472739e9bc6433143115c3de8f..03e96af48a1d54d19383a3f0b270248f } } -@@ -851,9 +861,9 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -852,9 +862,9 @@ public abstract class LivingEntity extends Entity implements Attackable { } this.hurtTime = nbt.getShort("HurtTime"); @@ -17440,7 +17414,7 @@ index 6523795e715e5d472739e9bc6433143115c3de8f..03e96af48a1d54d19383a3f0b270248f String s = nbt.getString("Team"); PlayerTeam scoreboardteam = this.level().getScoreboard().getPlayerTeam(s); if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof net.minecraft.world.entity.player.Player)) { scoreboardteam = null; } // Paper - Perf: Disable Scoreboards for non players by default -@@ -1140,6 +1150,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1141,6 +1151,7 @@ public abstract class LivingEntity extends Entity implements Attackable { public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent) { // Paper end - Don't fire sync event during generation // org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API @@ -17448,7 +17422,7 @@ index 6523795e715e5d472739e9bc6433143115c3de8f..03e96af48a1d54d19383a3f0b270248f if (this.isTickingEffects) { this.effectsToProcess.add(new ProcessableEffect(mobeffect, cause)); return true; -@@ -2338,7 +2349,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2351,7 +2362,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @Nullable public LivingEntity getKillCredit() { @@ -17457,7 +17431,7 @@ index 6523795e715e5d472739e9bc6433143115c3de8f..03e96af48a1d54d19383a3f0b270248f } public final float getMaxHealth() { -@@ -3481,7 +3492,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3494,7 +3505,7 @@ public abstract class LivingEntity extends Entity implements Attackable { this.pushEntities(); this.level().getProfiler().pop(); // Paper start - Add EntityMoveEvent @@ -17466,7 +17440,7 @@ index 6523795e715e5d472739e9bc6433143115c3de8f..03e96af48a1d54d19383a3f0b270248f 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()); -@@ -4174,7 +4185,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -4187,7 +4198,7 @@ public abstract class LivingEntity extends Entity implements Attackable { BlockPos blockposition = BlockPos.containing(d0, d1, d2); Level world = this.level(); @@ -17476,7 +17450,7 @@ index 6523795e715e5d472739e9bc6433143115c3de8f..03e96af48a1d54d19383a3f0b270248f 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 24629412d2b4acaa81788ce70412b03387cc777c..a1a0ac986e2052d3669428a29987630bc226d80f 100644 +index fa0b78139fecc0245e168ebeb4172ea2531a3fec..a3992e21e7d4112b9903e8d16a5e898d448eaea8 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java @@ -137,6 +137,14 @@ public abstract class Mob extends LivingEntity implements Targeting { @@ -17534,7 +17508,7 @@ index 24629412d2b4acaa81788ce70412b03387cc777c..a1a0ac986e2052d3669428a29987630b if (i % 2 != 0 && this.tickCount > 1) { this.level().getProfiler().push("targetSelector"); -@@ -1750,6 +1770,17 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1757,6 +1777,17 @@ public abstract class Mob extends LivingEntity implements Targeting { this.goalSelector.removeAllGoals(predicate); } @@ -17552,7 +17526,7 @@ index 24629412d2b4acaa81788ce70412b03387cc777c..a1a0ac986e2052d3669428a29987630b @Override protected void removeAfterChangingDimensions() { super.removeAfterChangingDimensions(); -@@ -1758,12 +1789,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -1765,12 +1796,7 @@ public abstract class Mob extends LivingEntity implements Targeting { this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit this.dropLeash(true, event.isDropLeash()); // Paper end - Expand EntityUnleashEvent @@ -17953,22 +17927,6 @@ index f760ce7d9df79ef58f8963de3e901cba3e12fcaa..03bd7038bda7bd3bf592eab39ec6d985 this.setVariant((CatVariant) BuiltInRegistries.CAT_VARIANT.getOrThrow(CatVariant.ALL_BLACK)); this.setPersistenceRequired(); } -diff --git a/src/main/java/net/minecraft/world/entity/animal/Turtle.java b/src/main/java/net/minecraft/world/entity/animal/Turtle.java -index d595f1590619b24d460fc2c10a5412844f62cba0..520f9da801d2d0420feb2af5ab63bf234a72b705 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/Turtle.java -+++ b/src/main/java/net/minecraft/world/entity/animal/Turtle.java -@@ -336,9 +336,9 @@ public class Turtle extends Animal { - - @Override - public void thunderHit(ServerLevel world, LightningBolt lightning) { -- org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = lightning; // CraftBukkit -+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamageRT.set(lightning); // CraftBukkit // Folia - region threading - this.hurt(this.damageSources().lightningBolt(), Float.MAX_VALUE); -- org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit -+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamageRT.set(null); // CraftBukkit // Folia - region threading - } - - @Override diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java index 80303f9466b8c7097151be313afc9a383693d18a..d53905cafc7bf257907e6c9b9ea2ba97fb266361 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java @@ -17984,22 +17942,6 @@ index 80303f9466b8c7097151be313afc9a383693d18a..d53905cafc7bf257907e6c9b9ea2ba97 } }); -diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -index 9daf8aa557d9f4fdbcc138a47892ea5a061dd877..25b7b85cbd1130c5320e55b3c6b6f81ec228da81 100644 ---- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -293,9 +293,9 @@ public class FallingBlockEntity extends Entity { - float f2 = (float) Math.min(Mth.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax); - - this.level().getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> { -- CraftEventFactory.entityDamage = this; // CraftBukkit -+ CraftEventFactory.entityDamageRT.set(this); // CraftBukkit // Folia - region threading - entity.hurt(damagesource2, f2); -- CraftEventFactory.entityDamage = null; // CraftBukkit -+ CraftEventFactory.entityDamageRT.set(null); // CraftBukkit // Folia - region threading - }); - boolean flag = this.blockState.is(BlockTags.ANVIL); - diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java index eb0d6238588efa35fa868f26290547574a08eca2..7c416a0e4734e6987279cfbb34103a0bf00ed087 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java @@ -18380,10 +18322,10 @@ index d7bddedb19c10f62fd1f7d3128453ad706ed16be..948749a0a3ef9d06f0482bc5331a5283 entityvillagertrader.setWanderTarget(blockposition1); entityvillagertrader.restrictTo(blockposition1, 16); diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index df8d6f3eb675354ce0d180fc56886ce12788d6ae..07855c28a032c5d3d1e2056d817d788cd86442d9 100644 +index 5ca1f834f311a87323ced2578535e66efa14e47f..d52823d8a6e3aefabe47a938b105c19545d10e98 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1519,6 +1519,14 @@ public abstract class Player extends LivingEntity { +@@ -1520,6 +1520,14 @@ public abstract class Player extends LivingEntity { } @@ -18430,27 +18372,11 @@ index c4ecc5faa4f61e7974e8c475762924a89615b377..40489886060782681f960d1c4eab3698 if (this.shouldBurn()) { 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 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 { - - if (target.isAlive() && !target.isInvulnerable() && target != entityliving1) { - if (entityliving1 == null) { -- org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = this; // CraftBukkit -+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamageRT.set(this); // CraftBukkit // Folia - region threading - target.hurt(this.damageSources().magic(), 6.0F); -- org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit -+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamageRT.set(null); // CraftBukkit // Folia - region threading - } else { - if (entityliving1.isAlliedTo((Entity) target)) { - return; diff --git a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -index b2f08889139dc447f7071f1c81456035bf8de31e..619bedc55d61f83dbc5adcf76a739cf9e6a1c55c 100644 +index 7005b3a26e9b5d79064981a4a41bee21b65a9fc3..3cdfe382b0d4f35ce34628e7c1630dff7c2623c4 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -129,6 +129,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { +@@ -128,6 +128,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { }); } @@ -18462,30 +18388,6 @@ index b2f08889139dc447f7071f1c81456035bf8de31e..619bedc55d61f83dbc5adcf76a739cf9 if (this.attachedToEntity != null) { if (this.attachedToEntity.isFallFlying()) { -@@ -240,9 +245,9 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { - - if (f > 0.0F) { - if (this.attachedToEntity != null) { -- CraftEventFactory.entityDamage = this; // CraftBukkit -+ CraftEventFactory.entityDamageRT.set(this); // CraftBukkit // Folia - region threading - this.attachedToEntity.hurt(this.damageSources().fireworks(this, this.getOwner()), 5.0F + (float) (nbttaglist.size() * 2)); -- CraftEventFactory.entityDamage = null; // CraftBukkit -+ CraftEventFactory.entityDamageRT.set(null); // CraftBukkit // Folia - region threading - } - - double d0 = 5.0D; -@@ -269,9 +274,9 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { - if (flag) { - float f1 = f * (float) Math.sqrt((5.0D - (double) this.distanceTo(entityliving)) / 5.0D); - -- CraftEventFactory.entityDamage = this; // CraftBukkit -+ CraftEventFactory.entityDamageRT.set(this); // CraftBukkit // Folia - region threading - entityliving.hurt(this.damageSources().fireworks(this, this.getOwner()), f1); -- CraftEventFactory.entityDamage = null; // CraftBukkit -+ CraftEventFactory.entityDamageRT.set(null); // CraftBukkit // Folia - region threading - } - } - } diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java index 90a5f6bd729148f2adc745273536e48d704fcd1e..702949d3d4c46222d2ef8227a559acd54d399bc0 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java @@ -18619,7 +18521,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 af4da25c9b13c114179fab3254aea5323210d7da..79c175cbcde3f19854b0221791a6624e75562697 100644 +index 3be611e7ae35b696ba44cd361042f79b69391815..2a304be5dc10db22de93aad4b9fccf321028c54d 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEnderpearl.java @@ -45,6 +45,62 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { @@ -18706,19 +18608,7 @@ index af4da25c9b13c114179fab3254aea5323210d7da..79c175cbcde3f19854b0221791a6624e Entity entity = this.getOwner(); if (entity instanceof ServerPlayer) { -@@ -85,9 +155,9 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { - - entityplayer.connection.teleport(teleEvent.getTo()); - entity.resetFallDistance(); -- CraftEventFactory.entityDamage = this; -+ CraftEventFactory.entityDamageRT.set(this); // Folia - region threading - entity.hurt(this.damageSources().fall(), 5.0F); -- CraftEventFactory.entityDamage = null; -+ CraftEventFactory.entityDamageRT.set(null); // Folia - region threading - } - // CraftBukkit end - this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_TELEPORT, SoundSource.PLAYERS); -@@ -114,6 +184,14 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { +@@ -112,6 +182,14 @@ public class ThrownEnderpearl extends ThrowableItemProjectile { } @@ -18934,10 +18824,10 @@ index fc35cfc9d045f3e5b6a50af1d0ba83b6e322091f..c87765a28f31673d547653b293c48856 // Paper end diff --git a/src/main/java/net/minecraft/world/item/ArmorItem.java b/src/main/java/net/minecraft/world/item/ArmorItem.java -index 42d87800a328f71c5127ce5599ca4c71cc9bb1cd..4b08175b71e7f92e9bb578f9f6c2c0efb2ce898f 100644 +index 6b81be03f87967124b046708557e05d519aa79e4..2220ac02eec17c0791e5b4ce8f5e085333471127 100644 --- a/src/main/java/net/minecraft/world/item/ArmorItem.java +++ b/src/main/java/net/minecraft/world/item/ArmorItem.java -@@ -69,7 +69,7 @@ public class ArmorItem extends Item implements Equipable { +@@ -75,7 +75,7 @@ public class ArmorItem extends Item implements Equipable { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity()); @@ -18947,10 +18837,10 @@ index 42d87800a328f71c5127ce5599ca4c71cc9bb1cd..4b08175b71e7f92e9bb578f9f6c2c0ef } diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index ed27a963223bfe18310ad5adabf461b5e307ef9c..c9a40483db8750db8dc0fa7ffc80b97786486ff6 100644 +index 1ad126d992d95062a3db08374db7a927f23a0cac..7de615a1b474269bb1c1dcb613d564fbc59c13b5 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -378,31 +378,32 @@ public final class ItemStack { +@@ -379,31 +379,32 @@ public final class ItemStack { CompoundTag oldData = this.getTagClone(); int oldCount = this.getCount(); ServerLevel world = (ServerLevel) context.getLevel(); @@ -18992,7 +18882,7 @@ index ed27a963223bfe18310ad5adabf461b5e307ef9c..c9a40483db8750db8dc0fa7ffc80b977 StructureGrowEvent structureEvent = null; if (treeType != null) { boolean isBonemeal = this.getItem() == Items.BONE_MEAL; -@@ -431,13 +432,13 @@ public final class ItemStack { +@@ -432,13 +433,13 @@ public final class ItemStack { SignItem.openSign = null; // SPIGOT-6758 - Reset on early return return enuminteractionresult; } @@ -19009,7 +18899,7 @@ index ed27a963223bfe18310ad5adabf461b5e307ef9c..c9a40483db8750db8dc0fa7ffc80b977 if (blocks.size() > 1) { placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, enumhand, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ()); } else if (blocks.size() == 1 && item != Items.POWDER_SNOW_BUCKET) { // Paper - Fix cancelled powdered snow bucket placement -@@ -448,13 +449,13 @@ public final class ItemStack { +@@ -449,13 +450,13 @@ public final class ItemStack { enuminteractionresult = InteractionResult.FAIL; // cancel placement // PAIL: Remove this when MC-99075 fixed placeEvent.getPlayer().updateInventory(); @@ -19026,7 +18916,7 @@ index ed27a963223bfe18310ad5adabf461b5e307ef9c..c9a40483db8750db8dc0fa7ffc80b977 // Brute force all possible updates // Paper start - Don't resync blocks -@@ -471,7 +472,7 @@ public final class ItemStack { +@@ -472,7 +473,7 @@ public final class ItemStack { this.setCount(newCount); } @@ -19035,7 +18925,7 @@ index ed27a963223bfe18310ad5adabf461b5e307ef9c..c9a40483db8750db8dc0fa7ffc80b977 world.setBlockEntity(e.getValue()); } -@@ -558,8 +559,8 @@ public final class ItemStack { +@@ -559,8 +560,8 @@ public final class ItemStack { entityhuman.awardStat(Stats.ITEM_USED.get(item)); } } @@ -19254,28 +19144,10 @@ index ed84c87a3f76bc0254c1abb189e6b8b808823465..894a25e9dfd61b8409f2883fc0af7c79 return player; } diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 28ef910885dbd48965fba6f08cec412697b1b7f0..d38d88062bac04c8c03f4e43d55fe8ee7deaaabc 100644 +index f0fbde839a527481314f54a1aefa0fc317ba2221..57d072f20d6a3b3fc86d542c7953ed6517ea2e6c 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -584,7 +584,7 @@ public class Explosion { - continue; - } - -- CraftEventFactory.entityDamage = this.source; -+ CraftEventFactory.entityDamageRT.set(this.source); // Folia - region threading - entity.lastDamageCancelled = false; - - if (entity instanceof EnderDragon) { -@@ -598,7 +598,7 @@ public class Explosion { - entity.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, getSeenFraction(vec3d, entity, blockCache, blockPos))); // Paper - actually optimise explosions - } - -- CraftEventFactory.entityDamage = null; -+ CraftEventFactory.entityDamageRT.set(null); // Folia - region threading - if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled - continue; - } -@@ -854,17 +854,18 @@ public class Explosion { +@@ -860,17 +860,18 @@ public class Explosion { if (!this.level.paperConfig().environment.optimizeExplosions) { return this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise explosions } @@ -19891,38 +19763,6 @@ index bed3d9c781c7d3ca260027b4737970889a54689c..46c81d73813c6607d95062358e6e3cd0 return Blocks.AIR.defaultBlockState(); } } -diff --git a/src/main/java/net/minecraft/world/level/block/CactusBlock.java b/src/main/java/net/minecraft/world/level/block/CactusBlock.java -index 232a3a0332d8d2c1ec625f3f2155316c69d95153..75d03ee9bdd3ad4f43d52b29f6c90642e36b5fc9 100644 ---- a/src/main/java/net/minecraft/world/level/block/CactusBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/CactusBlock.java -@@ -122,9 +122,9 @@ public class CactusBlock extends Block { - @Override - public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { - if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent -- CraftEventFactory.blockDamage = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); // CraftBukkit -+ CraftEventFactory.blockDamageRT.set(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); // CraftBukkit // Folia - region threading - entity.hurt(world.damageSources().cactus(), 1.0F); -- CraftEventFactory.blockDamage = null; // CraftBukkit -+ CraftEventFactory.blockDamageRT.set(null); // CraftBukkit // Folia - region threading - } - - @Override -diff --git a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java b/src/main/java/net/minecraft/world/level/block/CampfireBlock.java -index 20dbfeb68ac33ee8ba8214edcca0d7f7ce1be58e..925dee7941a81e5dd454bf026a216d2c6a52f745 100644 ---- a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/CampfireBlock.java -@@ -110,9 +110,9 @@ public class CampfireBlock extends BaseEntityBlock implements SimpleWaterloggedB - public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { - if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent - if ((Boolean) state.getValue(CampfireBlock.LIT) && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity) entity)) { -- org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = CraftBlock.at(world, pos); // CraftBukkit -+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamageRT.set(CraftBlock.at(world, pos)); // CraftBukkit // Folia - region threading - entity.hurt(world.damageSources().inFire(), (float) this.fireDamage); -- org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit -+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamageRT.set(null); // CraftBukkit // Folia - region threading - } - - super.entityInside(state, world, pos, entity); diff --git a/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java b/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java index de6f00d03223939386aa2ccfdec1e696a68313d7..eb7c2c5b762dbadbe9ccbddc37757bdf97ea4bfe 100644 --- a/src/main/java/net/minecraft/world/level/block/DaylightDetectorBlock.java @@ -20028,51 +19868,19 @@ index ec4aaaca2160312452d724dc6639ac8c4fa42ae4..e1f67599724f67f4f1321f219af8099e ParticleUtils.spawnParticlesAlongAxis(((Direction) state.getValue(LightningRodBlock.FACING)).getAxis(), world, pos, 0.125D, ParticleTypes.ELECTRIC_SPARK, UniformInt.of(1, 2)); } } -diff --git a/src/main/java/net/minecraft/world/level/block/MagmaBlock.java b/src/main/java/net/minecraft/world/level/block/MagmaBlock.java -index 10f5ffacc72a5e0116e2599ca83ee57a5b1ce0eb..64253e85e87c823d5ead285587496f6f8d825a43 100644 ---- a/src/main/java/net/minecraft/world/level/block/MagmaBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/MagmaBlock.java -@@ -30,9 +30,9 @@ public class MagmaBlock extends Block { - @Override - public void stepOn(Level world, BlockPos pos, BlockState state, Entity entity) { - if (!entity.isSteppingCarefully() && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity) entity)) { -- org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); // CraftBukkit -+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamageRT.set(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); // CraftBukkit // Folia - region threading - entity.hurt(world.damageSources().hotFloor(), 1.0F); -- org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit -+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamageRT.set(null); // CraftBukkit // Folia - region threading - } - - super.stepOn(world, pos, state, entity); diff --git a/src/main/java/net/minecraft/world/level/block/MushroomBlock.java b/src/main/java/net/minecraft/world/level/block/MushroomBlock.java -index 96f9ca2439a617b5f90b826d4fc99c857301b1c2..b5d85501b188525d88268bfb6d6997cf09f4719e 100644 +index 1f27ae8abd5891a0b8057b454f2210b088b4e95a..a978a6130f5f6fdd1dab194e753cbe2491713c9d 100644 --- a/src/main/java/net/minecraft/world/level/block/MushroomBlock.java +++ b/src/main/java/net/minecraft/world/level/block/MushroomBlock.java @@ -105,7 +105,7 @@ public class MushroomBlock extends BushBlock implements BonemealableBlock { return false; } else { world.removeBlock(pos, false); -- SaplingBlock.treeType = (this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.RED_MUSHROOM; // CraftBukkit // Paper -+ SaplingBlock.treeTypeRT.set((this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.RED_MUSHROOM); // CraftBukkit // Paper // Folia - region threading +- SaplingBlock.treeType = (this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.RED_MUSHROOM; // CraftBukkit ++ SaplingBlock.treeTypeRT.set((this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.RED_MUSHROOM); // CraftBukkit // Folia - region threading if (((ConfiguredFeature) ((Holder) optional.get()).value()).place(world, world.getChunkSource().getGenerator(), random, pos)) { return true; } else { -diff --git a/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java b/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java -index e310abaca79615caaa75d92183a57242734266a3..ea78392580e2cc71fd95a682ec69774f56699fd3 100644 ---- a/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/PointedDripstoneBlock.java -@@ -150,9 +150,9 @@ public class PointedDripstoneBlock extends Block implements Fallable, SimpleWate - @Override - public void fallOn(Level world, BlockState state, BlockPos pos, Entity entity, float fallDistance) { - if (state.getValue(PointedDripstoneBlock.TIP_DIRECTION) == Direction.UP && state.getValue(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) { -- CraftEventFactory.blockDamage = CraftBlock.at(world, pos); // CraftBukkit -+ CraftEventFactory.blockDamageRT.set(CraftBlock.at(world, pos)); // CraftBukkit // Folia - region threading - entity.causeFallDamage(fallDistance + 2.0F, 2.0F, world.damageSources().stalagmite()); -- CraftEventFactory.blockDamage = null; // CraftBukkit -+ CraftEventFactory.blockDamageRT.set(null); // CraftBukkit // Folia - region threading - } else { - super.fallOn(world, state, pos, entity, fallDistance); - } diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java index b5a71fd4e2f55bf036c2c697da5d50cc90fc657c..18cb719ae55b736a6dade61237a845c866fb6858 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java @@ -20249,10 +20057,10 @@ index 1dbfda52a4423fb031eecad24e5766f49ecf6050..332f606d9a41ab19707f2f11bd43d288 } } diff --git a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java b/src/main/java/net/minecraft/world/level/block/SaplingBlock.java -index 836c86104ed4f0d375330c9123af5d502efefa4d..68bd6dfb3b99b8e524f808effd1299278a9be23c 100644 +index 3ff0d08e4964aae82d8e51d3b8bf9aa002096f81..d4e86aa35a36ce0ef2cac3567e044b78fa58c87e 100644 --- a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SaplingBlock.java -@@ -34,7 +34,7 @@ public class SaplingBlock extends BushBlock implements BonemealableBlock { +@@ -35,7 +35,7 @@ public class SaplingBlock extends BushBlock implements BonemealableBlock { protected static final float AABB_OFFSET = 6.0F; protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); protected final TreeGrower treeGrower; @@ -20261,7 +20069,7 @@ index 836c86104ed4f0d375330c9123af5d502efefa4d..68bd6dfb3b99b8e524f808effd129927 @Override public MapCodec codec() { -@@ -65,18 +65,19 @@ public class SaplingBlock extends BushBlock implements BonemealableBlock { +@@ -66,18 +66,19 @@ public class SaplingBlock extends BushBlock implements BonemealableBlock { world.setBlock(pos, (net.minecraft.world.level.block.state.BlockState) state.cycle(SaplingBlock.STAGE), 4); } else { // CraftBukkit start @@ -20302,22 +20110,6 @@ index f3003a3832deff7724d28b4b3a091f4802a4cb29..d628cee1f72ee973bc10a49f2dd65bec // Paper start - Perf: optimize dirt and snow spreading net.minecraft.world.level.chunk.ChunkAccess cachedBlockChunk = world.getChunkIfLoaded(pos); if (cachedBlockChunk == null) { // Is this needed? -diff --git a/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java b/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java -index 6c1ed9d37adb97b47f0288a5986b805ee0e13842..a5d5a4b030da5057b2597536f8fbf77f69cd639c 100644 ---- a/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java -@@ -92,9 +92,9 @@ public class SweetBerryBushBlock extends BushBlock implements BonemealableBlock - double d1 = Math.abs(entity.getZ() - entity.zOld); - - if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { -- CraftEventFactory.blockDamage = CraftBlock.at(world, pos); // CraftBukkit -+ CraftEventFactory.blockDamageRT.set(CraftBlock.at(world, pos)); // CraftBukkit // Folia - region threading - entity.hurt(world.damageSources().sweetBerryBush(), 1.0F); -- CraftEventFactory.blockDamage = null; // CraftBukkit -+ CraftEventFactory.blockDamageRT.set(null); // CraftBukkit // Folia - region threading - } - } - diff --git a/src/main/java/net/minecraft/world/level/block/WitherSkullBlock.java b/src/main/java/net/minecraft/world/level/block/WitherSkullBlock.java index fb180f0bcd20e51d41cfc924029c0b23d3d26258..3db0727cd8d835e8d1b7b3fab93613d2e97b95ab 100644 --- a/src/main/java/net/minecraft/world/level/block/WitherSkullBlock.java @@ -20380,7 +20172,7 @@ index 9ea74d37cd951e0dc76d20ed8234b5871035566c..5be70de980d8b475d64dfbb029d11ba3 } diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -index bc01481ac5990ad1cfd1def5a16dd0ed2f9de8c9..4a62ac73dd89bc3c2aed1e58152e93c5043c6633 100644 +index 9bb542ce3a8c52e1688bb1f66fc916dd23a5fd10..23ebbc58f8f7eeb6398d21b3e96772971d02bcac 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java @@ -56,7 +56,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements @@ -20390,7 +20182,7 @@ index bc01481ac5990ad1cfd1def5a16dd0ed2f9de8c9..4a62ac73dd89bc3c2aed1e58152e93c5 - private int lastTick = MinecraftServer.currentTick; + //private int lastTick = MinecraftServer.currentTick; // Folia - region ticking - restore original timers public List transaction = new java.util.ArrayList(); - private int maxStack = 64; + private int maxStack = MAX_STACK; @@ -173,11 +173,10 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements ItemStack itemstack1 = (ItemStack) blockEntity.items.get(3); @@ -20425,10 +20217,10 @@ index f08c77e20462bada221b5ed395ceb2f7d39ee7c0..8422e4fb36342555937002afcb3611d6 public boolean isValid() { return !CommandBlockEntity.this.isRemoved(); diff --git a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -index 963a596154091b79ca139af6274aa323518ad1ad..57b11cb78270a8094f772da497ad3264a0a67db1 100644 +index 37e0b762b86e74f607a4541ecb7b24ad7a591d0e..4ddc3b3dc704610bf1fb7082e1c89a284c245fce 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -@@ -87,7 +87,7 @@ public class ConduitBlockEntity extends BlockEntity { +@@ -83,7 +83,7 @@ public class ConduitBlockEntity extends BlockEntity { public static void clientTick(Level world, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity) { ++blockEntity.tickCount; @@ -20437,7 +20229,7 @@ index 963a596154091b79ca139af6274aa323518ad1ad..57b11cb78270a8094f772da497ad3264 List list = blockEntity.effectBlocks; if (i % 40L == 0L) { -@@ -105,7 +105,7 @@ public class ConduitBlockEntity extends BlockEntity { +@@ -101,7 +101,7 @@ public class ConduitBlockEntity extends BlockEntity { public static void serverTick(Level world, BlockPos pos, BlockState state, ConduitBlockEntity blockEntity) { ++blockEntity.tickCount; @@ -20446,20 +20238,6 @@ index 963a596154091b79ca139af6274aa323518ad1ad..57b11cb78270a8094f772da497ad3264 List list = blockEntity.effectBlocks; if (i % 40L == 0L) { -@@ -235,11 +235,11 @@ public class ConduitBlockEntity extends BlockEntity { - - if (blockEntity.destroyTarget != null) { - // CraftBukkit start -- CraftEventFactory.blockDamage = CraftBlock.at(world, pos); -+ CraftEventFactory.blockDamageRT.set(CraftBlock.at(world, pos)); // Folia - region threading - if (blockEntity.destroyTarget.hurt(world.damageSources().magic(), 4.0F)) { - world.playSound((Player) null, blockEntity.destroyTarget.getX(), blockEntity.destroyTarget.getY(), blockEntity.destroyTarget.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F); - } -- CraftEventFactory.blockDamage = null; -+ CraftEventFactory.blockDamageRT.set(null); // Folia - region threading - // CraftBukkit end - } - 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 a61d7cd2b078fe511ff00344197b6ea11feebfb2..26ff1a3d07c92f7035020d08d35116f7feede600 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -21132,7 +20910,7 @@ index 6ec3fc801453fd54c25b642e6fa71c19b463311d..852fef18497435827a03e0056a09e5de public void tick() { if (!this.blockEntity.isRemoved() && this.blockEntity.hasLevel()) { diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -index afc583d5726a572f606469bba3aaba4600827992..1e4931e0d0a585219a4905562a85c2d7321fe891 100644 +index d53c4f3d47a8728d56fbd9b5e12be51885560d52..ecffd7fb1c7686479bd04ae9e391b69f3499a45d 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java @@ -644,7 +644,7 @@ public class ChunkSerializer { @@ -21305,7 +21083,7 @@ index ed80960777b18faca2d6a99783e53daf5fa19e09..b52455178290dd27478da4c062863562 while (iterator.hasNext()) { ServerPlayer entityplayer = (ServerPlayer) iterator.next(); diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureStart.java b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureStart.java -index c322827a910b6244804893784617784002758aee..22ceea2d8ff11dabd0406fb7ab50e5d02bc207f5 100644 +index 1695cff01932d435848e230921d1680b69a41d73..71658657fdaa858ffd388bb19218c30d84f3d77b 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureStart.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureStart.java @@ -28,7 +28,7 @@ public final class StructureStart { @@ -21316,8 +21094,8 @@ index c322827a910b6244804893784617784002758aee..22ceea2d8ff11dabd0406fb7ab50e5d0 + private final java.util.concurrent.atomic.AtomicInteger references; // Folia - region threading @Nullable private volatile BoundingBox cachedBoundingBox; - public org.bukkit.event.world.AsyncStructureGenerateEvent.Cause generationEventCause = org.bukkit.event.world.AsyncStructureGenerateEvent.Cause.WORLD_GENERATION; // CraftBukkit -@@ -36,7 +36,7 @@ public final class StructureStart { + +@@ -41,7 +41,7 @@ public final class StructureStart { public StructureStart(Structure structure, ChunkPos pos, int references, PiecesContainer children) { this.structure = structure; this.chunkPos = pos; @@ -21326,7 +21104,7 @@ index c322827a910b6244804893784617784002758aee..22ceea2d8ff11dabd0406fb7ab50e5d0 this.pieceContainer = children; } -@@ -127,7 +127,7 @@ public final class StructureStart { +@@ -137,7 +137,7 @@ public final class StructureStart { nbttagcompound.putString("id", context.registryAccess().registryOrThrow(Registries.STRUCTURE).getKey(this.structure).toString()); nbttagcompound.putInt("ChunkX", chunkPos.x); nbttagcompound.putInt("ChunkZ", chunkPos.z); @@ -21335,7 +21113,7 @@ index c322827a910b6244804893784617784002758aee..22ceea2d8ff11dabd0406fb7ab50e5d0 nbttagcompound.put("Children", this.pieceContainer.save(context)); return nbttagcompound; } else { -@@ -145,15 +145,29 @@ public final class StructureStart { +@@ -155,15 +155,29 @@ public final class StructureStart { } public boolean canBeReferenced() { @@ -21793,10 +21571,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 825e7abebd6eb898198106ca6e783ec462e64173..4f9c1b04ce6e4874cfb80a91c50aceda0eff2acc 100644 +index c4144c239a5d91bc0faec84fe49829337aa339dc..a4e47391105366e52b949f39ba4a1ebed94b2188 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -307,7 +307,7 @@ public final class CraftServer implements Server { +@@ -309,7 +309,7 @@ public final class CraftServer implements Server { private final CraftPotionBrewer potionBrewer = new CraftPotionBrewer(); // Paper - Custom Potion Mixes // Paper start - Folia region threading API @@ -21805,7 +21583,7 @@ index 825e7abebd6eb898198106ca6e783ec462e64173..4f9c1b04ce6e4874cfb80a91c50aceda 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(); -@@ -375,6 +375,12 @@ public final class CraftServer implements Server { +@@ -377,6 +377,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 @@ -21818,7 +21596,7 @@ index 825e7abebd6eb898198106ca6e783ec462e64173..4f9c1b04ce6e4874cfb80a91c50aceda static { ConfigurationSerialization.registerClass(CraftOfflinePlayer.class); -@@ -959,6 +965,9 @@ public final class CraftServer implements Server { +@@ -971,6 +977,9 @@ public final class CraftServer implements Server { // NOTE: Should only be called from DedicatedServer.ah() public boolean dispatchServerCommand(CommandSender sender, ConsoleInput serverCommand) { @@ -21828,7 +21606,7 @@ index 825e7abebd6eb898198106ca6e783ec462e64173..4f9c1b04ce6e4874cfb80a91c50aceda if (sender instanceof Conversable) { Conversable conversable = (Conversable) sender; -@@ -978,12 +987,46 @@ public final class CraftServer implements Server { +@@ -990,12 +999,46 @@ public final class CraftServer implements Server { } } @@ -21875,7 +21653,7 @@ index 825e7abebd6eb898198106ca6e783ec462e64173..4f9c1b04ce6e4874cfb80a91c50aceda if (this.commandMap.dispatch(sender, commandLine)) { return true; } -@@ -3202,7 +3245,7 @@ public final class CraftServer implements Server { +@@ -3219,7 +3262,7 @@ public final class CraftServer implements Server { @Override public int getCurrentTick() { @@ -21885,10 +21663,10 @@ index 825e7abebd6eb898198106ca6e783ec462e64173..4f9c1b04ce6e4874cfb80a91c50aceda @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74e6b174ae 100644 +index bfb178c69026e9759e9afaebb9da141b62d1f144..379c10e791a961d25d7de571f81ace1ac7d84381 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -186,7 +186,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -192,7 +192,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getTickableTileEntityCount() { @@ -21897,7 +21675,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 } @Override -@@ -248,7 +248,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -254,7 +254,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper start - per world spawn limits for (SpawnCategory spawnCategory : SpawnCategory.values()) { if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { @@ -21906,7 +21684,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 } } // Paper end - per world spawn limits -@@ -335,6 +335,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -341,6 +341,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public Chunk getChunkAt(int x, int z) { @@ -21914,7 +21692,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 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); -@@ -358,7 +359,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -364,7 +365,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper start private void addTicket(int x, int z) { @@ -21923,7 +21701,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 } // Paper end -@@ -377,10 +378,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -383,10 +384,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean isChunkGenerated(int x, int z) { // Paper start - Fix this method @@ -21936,7 +21714,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 } ChunkAccess chunk = world.getChunkSource().getChunkAtImmediately(x, z); if (chunk == null) { -@@ -434,7 +435,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -440,7 +441,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { } private boolean unloadChunk0(int x, int z, boolean save) { @@ -21945,7 +21723,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 if (!this.isChunkLoaded(x, z)) { return true; } -@@ -449,7 +450,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -455,7 +456,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean regenerateChunk(int x, int z) { @@ -21954,7 +21732,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 warnUnsafeChunk("regenerating a faraway chunk", x, z); // Paper // Paper start - implement regenerateChunk method final ServerLevel serverLevel = this.world; -@@ -512,6 +513,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -518,6 +519,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean refreshChunk(int x, int z) { @@ -21962,7 +21740,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z)); if (playerChunk == null) return false; -@@ -547,7 +549,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -553,7 +555,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean loadChunk(int x, int z, boolean generate) { @@ -21971,7 +21749,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 warnUnsafeChunk("loading a faraway chunk", x, z); // Paper // Paper start - Optimize this method ChunkPos chunkPos = new ChunkPos(x, z); -@@ -616,7 +618,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -622,7 +624,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 @@ -21980,7 +21758,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 return true; } -@@ -807,13 +809,15 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -813,13 +815,15 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { @@ -22001,7 +21779,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 BlockPos position = ((CraftBlockState) blockstate).getPosition(); net.minecraft.world.level.block.state.BlockState oldBlock = this.world.getBlockState(position); int flag = ((CraftBlockState) blockstate).getFlag(); -@@ -821,10 +825,10 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -827,10 +831,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); } @@ -22014,7 +21792,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 return false; } } -@@ -858,6 +862,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -864,6 +868,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setTime(long time) { @@ -22022,7 +21800,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 long margin = (time - this.getFullTime()) % 24000; if (margin < 0) margin += 24000; this.setFullTime(this.getFullTime() + margin); -@@ -870,6 +875,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -876,6 +881,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setFullTime(long time) { @@ -22030,7 +21808,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 // Notify anyone who's listening TimeSkipEvent event = new TimeSkipEvent(this, TimeSkipEvent.SkipReason.CUSTOM, time - this.world.getDayTime()); this.server.getPluginManager().callEvent(event); -@@ -897,7 +903,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -903,7 +909,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public long getGameTime() { @@ -22039,7 +21817,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 } @Override -@@ -917,11 +923,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -923,11 +929,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) { @@ -22053,7 +21831,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 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 -@@ -991,6 +999,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1004,6 +1012,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) { @@ -22061,7 +21839,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 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); -@@ -1021,6 +1030,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1034,6 +1043,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); @@ -22069,7 +21847,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 if (this.world.hasChunkAt(pos)) { net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkAt(pos); -@@ -1331,6 +1341,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1344,6 +1354,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setStorm(boolean hasStorm) { @@ -22077,7 +21855,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.world.serverLevelData.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper - Add cause to Weather/ThunderChangeEvents this.setWeatherDuration(0); // Reset weather duration (legacy behaviour) this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) -@@ -1343,6 +1354,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1356,6 +1367,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setWeatherDuration(int duration) { @@ -22085,7 +21863,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.world.serverLevelData.setRainTime(duration); } -@@ -1353,6 +1365,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1366,6 +1378,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setThundering(boolean thundering) { @@ -22093,7 +21871,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.world.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper - Add cause to Weather/ThunderChangeEvents this.setThunderDuration(0); // Reset weather duration (legacy behaviour) this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands) -@@ -1365,6 +1378,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1378,6 +1391,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setThunderDuration(int duration) { @@ -22101,7 +21879,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.world.serverLevelData.setThunderTime(duration); } -@@ -1375,6 +1389,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1388,6 +1402,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setClearWeatherDuration(int duration) { @@ -22109,7 +21887,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.world.serverLevelData.setClearWeatherTime(duration); } -@@ -1569,6 +1584,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1582,6 +1597,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setKeepSpawnInMemory(boolean keepLoaded) { @@ -22117,7 +21895,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 // Paper start - Configurable spawn radius if (keepLoaded == this.world.keepSpawnInMemory) { // do nothing, nothing has changed -@@ -1647,6 +1663,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1660,6 +1676,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setHardcore(boolean hardcore) { @@ -22125,7 +21903,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.world.serverLevelData.settings.hardcore = hardcore; } -@@ -1659,6 +1676,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1672,6 +1689,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns) { @@ -22133,7 +21911,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.setTicksPerSpawns(SpawnCategory.ANIMAL, ticksPerAnimalSpawns); } -@@ -1671,6 +1689,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1684,6 +1702,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns) { @@ -22141,7 +21919,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.setTicksPerSpawns(SpawnCategory.MONSTER, ticksPerMonsterSpawns); } -@@ -1683,6 +1702,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1696,6 +1715,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterSpawns(int ticksPerWaterSpawns) { @@ -22149,7 +21927,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.setTicksPerSpawns(SpawnCategory.WATER_ANIMAL, ticksPerWaterSpawns); } -@@ -1695,6 +1715,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1708,6 +1728,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterAmbientSpawns(int ticksPerWaterAmbientSpawns) { @@ -22157,7 +21935,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.setTicksPerSpawns(SpawnCategory.WATER_AMBIENT, ticksPerWaterAmbientSpawns); } -@@ -1707,6 +1728,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1720,6 +1741,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerWaterUndergroundCreatureSpawns(int ticksPerWaterUndergroundCreatureSpawns) { @@ -22165,7 +21943,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.setTicksPerSpawns(SpawnCategory.WATER_UNDERGROUND_CREATURE, ticksPerWaterUndergroundCreatureSpawns); } -@@ -1719,11 +1741,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1732,11 +1754,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setTicksPerAmbientSpawns(int ticksPerAmbientSpawns) { @@ -22179,7 +21957,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 Preconditions.checkArgument(spawnCategory != null, "SpawnCategory cannot be null"); Preconditions.checkArgument(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory.%s are not supported", spawnCategory); -@@ -1740,21 +1764,25 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1753,21 +1777,25 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { @@ -22205,7 +21983,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.server.getWorldMetadata().removeMetadata(this, metadataKey, owningPlugin); } -@@ -1767,6 +1795,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1780,6 +1808,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setMonsterSpawnLimit(int limit) { @@ -22213,7 +21991,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.setSpawnLimit(SpawnCategory.MONSTER, limit); } -@@ -1779,6 +1808,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1792,6 +1821,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setAnimalSpawnLimit(int limit) { @@ -22221,7 +21999,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.setSpawnLimit(SpawnCategory.ANIMAL, limit); } -@@ -1791,6 +1821,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1804,6 +1834,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterAnimalSpawnLimit(int limit) { @@ -22229,7 +22007,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.setSpawnLimit(SpawnCategory.WATER_ANIMAL, limit); } -@@ -1803,6 +1834,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1816,6 +1847,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterAmbientSpawnLimit(int limit) { @@ -22237,7 +22015,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.setSpawnLimit(SpawnCategory.WATER_AMBIENT, limit); } -@@ -1815,6 +1847,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1828,6 +1860,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setWaterUndergroundCreatureSpawnLimit(int limit) { @@ -22245,7 +22023,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.setSpawnLimit(SpawnCategory.WATER_UNDERGROUND_CREATURE, limit); } -@@ -1827,6 +1860,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1840,6 +1873,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override @Deprecated public void setAmbientSpawnLimit(int limit) { @@ -22253,7 +22031,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 this.setSpawnLimit(SpawnCategory.AMBIENT, limit); } -@@ -1849,6 +1883,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1862,6 +1896,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setSpawnLimit(SpawnCategory spawnCategory, int limit) { @@ -22261,7 +22039,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 Preconditions.checkArgument(spawnCategory != null, "SpawnCategory cannot be null"); Preconditions.checkArgument(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory.%s are not supported", spawnCategory); -@@ -1931,7 +1966,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1944,7 +1979,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(CraftSound.bukkitToMinecraftHolder(sound), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); @@ -22270,7 +22048,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 if (entityTracker != null) { entityTracker.broadcastAndSend(packet); } -@@ -1943,7 +1978,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1956,7 +1991,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(Holder.direct(SoundEvent.createVariableRangeEvent(new ResourceLocation(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); @@ -22279,7 +22057,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 if (entityTracker != null) { entityTracker.broadcastAndSend(packet); } -@@ -2032,6 +2067,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2045,6 +2080,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean setGameRuleValue(String rule, String value) { @@ -22287,7 +22065,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 // No null values allowed if (rule == null || value == null) return false; -@@ -2074,6 +2110,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2087,6 +2123,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean setGameRule(GameRule rule, T newValue) { @@ -22295,7 +22073,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 Preconditions.checkArgument(rule != null, "GameRule cannot be null"); Preconditions.checkArgument(newValue != null, "GameRule value cannot be null"); -@@ -2326,6 +2363,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2339,6 +2376,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) { @@ -22308,7 +22086,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 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 -@@ -2422,7 +2465,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2459,7 +2502,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 @@ -22317,7 +22095,7 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 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)); -@@ -2439,7 +2482,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2476,7 +2519,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) -> { @@ -22327,10 +22105,10 @@ index a139601888b88e8580bdb9c2469386a94abae975..d3bdc355bee762b90a77528e9da96d74 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 c17c8b2bff32bfd101675d73f8ab81b35a9e1c15..fe5158430fd50c95c12a0ecef4273572da4b3133 100644 +index dfe5fa29a29af06640382456ef59aed794f5362b..ba5e47037f4dc3eb3efe86cd31183b39eab823fe 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 { +@@ -64,6 +64,7 @@ public final class CapturedBlockState extends CraftBlockState { for (int k = 0; k < j; ++k) { Bee entitybee = new Bee(EntityType.BEE, generatoraccessseed.getMinecraftWorld()); @@ -22679,10 +22457,10 @@ index 8698104e3eb98e2cc5da5de87a8f538860c1d91d..ac91fe913b4f6a6148955e7181e5abda @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 39b25c2478eadd373383a3445a7f27ea30d18550..f5985bac1f72591e31a85d53a5dfde7c26966a62 100644 +index 206520f6f20b2e48b1eefdd4edb26510b88e4c92..3d47913cb590463b636cbdc052fb54778951ba61 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -554,7 +554,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -560,7 +560,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void kickPlayer(String message) { @@ -22691,7 +22469,7 @@ index 39b25c2478eadd373383a3445a7f27ea30d18550..f5985bac1f72591e31a85d53a5dfde7c if (this.getHandle().connection == null) return; this.getHandle().connection.disconnect(message == null ? "" : message, org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); // Paper - kick event cause -@@ -1277,6 +1277,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1307,6 +1307,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) { @@ -22703,7 +22481,7 @@ index 39b25c2478eadd373383a3445a7f27ea30d18550..f5985bac1f72591e31a85d53a5dfde7c Set relativeArguments; Set allFlags; if (flags.length == 0) { -@@ -1923,7 +1928,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1953,7 +1958,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { private void unregisterEntity(Entity other) { // Paper end ChunkMap tracker = ((ServerLevel) this.getHandle().level()).getChunkSource().chunkMap; @@ -22712,7 +22490,7 @@ index 39b25c2478eadd373383a3445a7f27ea30d18550..f5985bac1f72591e31a85d53a5dfde7c if (entry != null) { entry.removePlayer(this.getHandle()); } -@@ -2020,7 +2025,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2050,7 +2055,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (original != null) otherPlayer.setUUID(original); // Paper - uuid override } @@ -22722,21 +22500,10 @@ index 39b25c2478eadd373383a3445a7f27ea30d18550..f5985bac1f72591e31a85d53a5dfde7c 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 23b4b5d63d45108534bde330079c7a12b3aa4f5f..47f100ee2de9cbc5b61df2f54dad51e8f12f2ecf 100644 +index 347bd2482c89e06716121bd7d05941203bab2a8b..0b45ddbe1ecd6fd9ae81bc39fcddc3da356fd7f6 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -243,8 +243,8 @@ import org.bukkit.potion.PotionEffect; - import org.bukkit.util.Vector; - - public class CraftEventFactory { -- public static org.bukkit.block.Block blockDamage; // For use in EntityDamageByBlockEvent -- public static Entity entityDamage; // For use in EntityDamageByEntityEvent -+ public static final ThreadLocal blockDamageRT = new ThreadLocal<>(); // For use in EntityDamageByBlockEvent // Folia - region threading -+ public static final ThreadLocal entityDamageRT = new ThreadLocal<>(); // For use in EntityDamageByEntityEvent // Folia - region threading - - // helper methods - private static boolean canBuild(ServerLevel world, Player player, int x, int z) { -@@ -915,7 +915,7 @@ public class CraftEventFactory { +@@ -941,7 +941,7 @@ public class CraftEventFactory { return CraftEventFactory.handleBlockSpreadEvent(world, source, target, block, 2); } @@ -22745,7 +22512,7 @@ index 23b4b5d63d45108534bde330079c7a12b3aa4f5f..47f100ee2de9cbc5b61df2f54dad51e8 public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState block, int flag) { // Suppress during worldgen -@@ -927,7 +927,7 @@ public class CraftEventFactory { +@@ -953,7 +953,7 @@ public class CraftEventFactory { CraftBlockState state = CraftBlockStates.getBlockState(world, target, flag); state.setData(block); @@ -22754,74 +22521,7 @@ index 23b4b5d63d45108534bde330079c7a12b3aa4f5f..47f100ee2de9cbc5b61df2f54dad51e8 Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { -@@ -1056,8 +1056,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; -- Entity damager = CraftEventFactory.entityDamage; -- CraftEventFactory.entityDamage = null; -+ Entity damager = CraftEventFactory.entityDamageRT.get(); // Folia - region threading -+ CraftEventFactory.entityDamageRT.set(null); // Folia - region threading - EntityDamageEvent event; - if (damager == null) { - event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, modifiers, modifierFunctions, source.explodedBlockState); // Paper - add exploded state -@@ -1118,13 +1118,13 @@ public class CraftEventFactory { - } - return event; - } else if (source.is(DamageTypes.LAVA)) { -- EntityDamageEvent event = (new EntityDamageByBlockEvent(CraftEventFactory.blockDamage, entity.getBukkitEntity(), DamageCause.LAVA, modifiers, modifierFunctions)); -+ EntityDamageEvent event = (new EntityDamageByBlockEvent(CraftEventFactory.blockDamageRT.get(), entity.getBukkitEntity(), DamageCause.LAVA, modifiers, modifierFunctions)); // Folia - region threading - event.setCancelled(cancelled); - -- Block damager = CraftEventFactory.blockDamage; -- CraftEventFactory.blockDamage = null; // SPIGOT-6639: Clear blockDamage to allow other entity damage during event call -+ Block damager = CraftEventFactory.blockDamageRT.get(); -+ CraftEventFactory.blockDamageRT.set(null); // SPIGOT-6639: Clear blockDamage to allow other entity damage during event call // Folia - region threading - CraftEventFactory.callEvent(event); -- CraftEventFactory.blockDamage = damager; // SPIGOT-6639: Re-set blockDamage so that other entities which are also getting damaged have the right cause -+ CraftEventFactory.blockDamageRT.set(damager); // SPIGOT-6639: Re-set blockDamage so that other entities which are also getting damaged have the right cause // Folia - region threading - - if (!event.isCancelled()) { - event.getEntity().setLastDamageCause(event); -@@ -1132,9 +1132,9 @@ public class CraftEventFactory { - entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled - } - return event; -- } else if (CraftEventFactory.blockDamage != null) { -+ } else if (CraftEventFactory.blockDamageRT.get() != null) { // Folia - region threading - DamageCause cause = null; -- Block damager = CraftEventFactory.blockDamage; -+ Block damager = CraftEventFactory.blockDamageRT.get(); // Folia - region threading - 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)) { -@@ -1149,9 +1149,9 @@ public class CraftEventFactory { - EntityDamageEvent event = new EntityDamageByBlockEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions); - event.setCancelled(cancelled); - -- CraftEventFactory.blockDamage = null; // SPIGOT-6639: Clear blockDamage to allow other entity damage during event call -+ CraftEventFactory.blockDamageRT.set(null); // SPIGOT-6639: Clear blockDamage to allow other entity damage during event call // Folia - region threading - CraftEventFactory.callEvent(event); -- CraftEventFactory.blockDamage = damager; // SPIGOT-6639: Re-set blockDamage so that other entities which are also getting damaged have the right cause -+ CraftEventFactory.blockDamageRT.set(damager); // SPIGOT-6639: Re-set blockDamage so that other entities which are also getting damaged have the right cause // Folia - region threading - - if (!event.isCancelled()) { - event.getEntity().setLastDamageCause(event); -@@ -1159,10 +1159,10 @@ public class CraftEventFactory { - entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled - } - return event; -- } else if (CraftEventFactory.entityDamage != null) { -+ } else if (CraftEventFactory.entityDamageRT.get() != null) { // Folia - region threading - DamageCause cause = null; -- CraftEntity damager = CraftEventFactory.entityDamage.getBukkitEntity(); -- CraftEventFactory.entityDamage = null; -+ CraftEntity damager = CraftEventFactory.entityDamageRT.get().getBukkitEntity(); // Folia - region threading -+ CraftEventFactory.entityDamageRT.set(null); // Folia - region threading - 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) { -@@ -2163,7 +2163,7 @@ public class CraftEventFactory { +@@ -2126,7 +2126,7 @@ public class CraftEventFactory { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemStack.copyWithCount(1)); org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), CraftVector.toBukkit(to)); @@ -22843,10 +22543,10 @@ index e85b9bb3f9c225d289a4959921970b9963881199..b00e3b9b628f3d2a2fdbf1d2c7790496 if (!this.isAsyncScheduler && !task.isSync()) { this.asyncScheduler.handle(task, delay); diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index ca5312febcdd467889ad725c0263367bc5fe69f6..f75010af797b26908a38f03a6c0ec3757d3770b7 100644 +index 1324f05de8106032ce290e928cf106fb4f450517..20178003ee9a0314266d4fc6a589e9d509a25072 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -377,6 +377,12 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -382,6 +382,12 @@ public final class CraftMagicNumbers implements UnsafeValues { String minimumVersion = MinecraftServer.getServer().server.minimumAPI; int minimumIndex = CraftMagicNumbers.SUPPORTED_API.indexOf(minimumVersion); diff --git a/patches/server/0006-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch b/patches/server/0006-Make-CraftEntity-getHandle-and-overrides-perform-thr.patch index e58fe73..157b36b 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 b736cb55542ea7bc35d1a02e7fe5913de024ca60..eade31ea668c171dceafee958e265041a439c54b 100644 +index b8e77755a1706e60e9dfa1310aa2449ee0dbc6ad..0725386d7ef47171012671725ceddfe92b43b203 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2907,6 +2907,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -2911,6 +2911,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -40,7 +40,7 @@ index b736cb55542ea7bc35d1a02e7fe5913de024ca60..eade31ea668c171dceafee958e265041 // CraftBukkit start if (entity.getBukkitEntity() instanceof Vehicle && this.getBukkitEntity() instanceof LivingEntity) { VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.getBukkitEntity()); -@@ -2928,6 +2929,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -2932,6 +2933,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S return false; } // CraftBukkit end @@ -48,7 +48,7 @@ index b736cb55542ea7bc35d1a02e7fe5913de024ca60..eade31ea668c171dceafee958e265041 if (this.isPassenger()) { this.stopRiding(); } -@@ -3005,6 +3007,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3009,6 +3011,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { // CraftBukkit start @@ -56,7 +56,7 @@ index b736cb55542ea7bc35d1a02e7fe5913de024ca60..eade31ea668c171dceafee958e265041 CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); Entity orig = craft == null ? null : craft.getHandle(); if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { -@@ -3032,6 +3035,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3036,6 +3039,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S return false; } // CraftBukkit end @@ -792,10 +792,10 @@ index 7b7b89e67d53ed70efae714192c5fa32977f3d9c..00f334e5449f76b735b844fed44c9872 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java -index 5817f497424bb0e680c34d125b3fe53dba07a5cc..6dd1d6e7a504a76d84f5bc1140ff5223d9fa1e98 100644 +index cc4194ac9d7501b5d15655674dade14d59cb6733..d89885eb1d4212bf26de5f32bce2b49ecd8182e0 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 +@@ -16,8 +16,16 @@ public class CraftEnderDragonPart extends CraftComplexPart implements EnderDrago return (EnderDragon) super.getParent(); } @@ -1590,10 +1590,10 @@ index e9f471e60af0725ec34e2985d63ae9ea9f88590a..6a443f42ecec16abea3ddf7bc2e85bb8 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -index 4afc1c9d2a7638e84a55fe30932dc36db465c31a..b7be4fd0179a26d220819346457ba097f4c7d22d 100644 +index f1e4dfd203d455ec089cd2b5679c4083400dbc7f..6abb7ee0f5d32613b2ff7da09810ae407e293838 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -@@ -416,6 +416,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { +@@ -454,6 +454,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { this.getHandle().invulnerableTime = ticks; } @@ -1607,7 +1607,7 @@ index 4afc1c9d2a7638e84a55fe30932dc36db465c31a..b7be4fd0179a26d220819346457ba097 @Override public int getNoActionTicks() { return this.getHandle().getNoActionTime(); -@@ -429,6 +436,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { +@@ -467,6 +474,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public net.minecraft.world.entity.LivingEntity getHandle() { @@ -1878,10 +1878,10 @@ index 706c74c832f6893df3797023f68add31139c7d57..80a612f16669e571e336dd6369a968b4 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java -index e5df527d3f0b82327bcd4cb66c12baa439b4cec6..3ca3c62485e5701c76e4fbfac853ed128194e0ce 100644 +index 1d78ae1db211a452a42fb4a7bef4cca4b7c71a1f..e4e8d7561036ab04d069cfe54f1fba61b478c5d8 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 +@@ -19,6 +19,13 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow, io.paperm super(server, entity); } @@ -1892,6 +1892,11 @@ index e5df527d3f0b82327bcd4cb66c12baa439b4cec6..3ca3c62485e5701c76e4fbfac853ed12 + } + // Folia end - region threading + + @Override + public boolean hasEffectsForNextStew() { + return this.getHandle().stewEffects != null && !this.getHandle().stewEffects.isEmpty(); +@@ -74,6 +81,7 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow, io.paperm + @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 @@ -2130,10 +2135,10 @@ index 2638c341bc02f201f7ab17fdebcdbdf3a7ec05bf..0f5c2d31a2dea13a46ba81e353393633 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index f5985bac1f72591e31a85d53a5dfde7c26966a62..fc301fcf812b79ac7ceae710132a762f101b82b2 100644 +index 3d47913cb590463b636cbdc052fb54778951ba61..8fc071a6249193af5e1795cc19f50996ea22d96f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -574,7 +574,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -580,7 +580,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void kick(net.kyori.adventure.text.Component message, org.bukkit.event.player.PlayerKickEvent.Cause cause) { @@ -2142,7 +2147,7 @@ index f5985bac1f72591e31a85d53a5dfde7c26966a62..fc301fcf812b79ac7ceae710132a762f final ServerGamePacketListenerImpl connection = this.getHandle().connection; if (connection != null) { connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message, cause); -@@ -2179,9 +2179,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2209,9 +2209,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this; } @@ -2160,7 +2165,7 @@ index f5985bac1f72591e31a85d53a5dfde7c26966a62..fc301fcf812b79ac7ceae710132a762f } public void setHandle(final ServerPlayer entity) { -@@ -3215,7 +3222,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -3266,7 +3273,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { { if ( CraftPlayer.this.getHealth() <= 0 && CraftPlayer.this.isOnline() ) { diff --git a/patches/server/0008-Throw-UnsupportedOperationException-for-broken-APIs.patch b/patches/server/0008-Throw-UnsupportedOperationException-for-broken-APIs.patch index 9dab649..42e328d 100644 --- a/patches/server/0008-Throw-UnsupportedOperationException-for-broken-APIs.patch +++ b/patches/server/0008-Throw-UnsupportedOperationException-for-broken-APIs.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Throw UnsupportedOperationException() for broken APIs diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 4f9c1b04ce6e4874cfb80a91c50aceda0eff2acc..3f266934e70a5f29d55d390841e536999cec8582 100644 +index a4e47391105366e52b949f39ba4a1ebed94b2188..853afba9d0a814acc001ba5db5ef3653f8b16392 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1266,6 +1266,7 @@ public final class CraftServer implements Server { +@@ -1283,6 +1283,7 @@ public final class CraftServer implements Server { @Override public World createWorld(WorldCreator creator) { @@ -16,7 +16,7 @@ index 4f9c1b04ce6e4874cfb80a91c50aceda0eff2acc..3f266934e70a5f29d55d390841e53699 Preconditions.checkState(this.console.getAllLevels().iterator().hasNext(), "Cannot create additional worlds on STARTUP"); //Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot create a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes. Preconditions.checkArgument(creator != null, "WorldCreator cannot be null"); -@@ -1444,6 +1445,7 @@ public final class CraftServer implements Server { +@@ -1461,6 +1462,7 @@ public final class CraftServer implements Server { @Override public boolean unloadWorld(World world, boolean save) { diff --git a/patches/server/0013-Skip-worldstate-access-when-waking-players-up-during.patch b/patches/server/0013-Skip-worldstate-access-when-waking-players-up-during.patch index 3c1e250..ec3d36d 100644 --- a/patches/server/0013-Skip-worldstate-access-when-waking-players-up-during.patch +++ b/patches/server/0013-Skip-worldstate-access-when-waking-players-up-during.patch @@ -9,7 +9,7 @@ data deserialization and is racey even in Vanilla. But in Folia, some accesses may throw and as such we need to fix this directly. diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index b9e7c8776b5b4086fb2455035857947f9a4b3dba..c8ee0307fa6c13c34a1db80ddf65d8381fd556be 100644 +index add6fc106d3c38d97b48ec0df3ac2515c8c0486e..cbc89b8898f9243776af88c2b04ad3c2e4e23fb6 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -644,7 +644,7 @@ public class ServerPlayer extends Player { @@ -22,10 +22,10 @@ index b9e7c8776b5b4086fb2455035857947f9a4b3dba..c8ee0307fa6c13c34a1db80ddf65d838 // CraftBukkit start diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 03e96af48a1d54d19383a3f0b270248f673ad0aa..28da90b59f60d3f7618a42e149467a3a55c91682 100644 +index a463c46778e5ee641c1b7d634b79ec68414cd936..b640d877f924094bcabbf9618bbd9aa0a70bf94a 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -4361,6 +4361,11 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -4374,6 +4374,11 @@ public abstract class LivingEntity extends Entity implements Attackable { } });