diff --git a/patches/unapplied/server/0214-Improve-BlockPosition-inlining.patch b/patches/server/0213-Improve-BlockPosition-inlining.patch similarity index 96% rename from patches/unapplied/server/0214-Improve-BlockPosition-inlining.patch rename to patches/server/0213-Improve-BlockPosition-inlining.patch index 469c5f7390..e1e44f61f0 100644 --- a/patches/unapplied/server/0214-Improve-BlockPosition-inlining.patch +++ b/patches/server/0213-Improve-BlockPosition-inlining.patch @@ -21,7 +21,7 @@ This is based upon conclusions drawn from inspecting the assenmbly generated byt They had 'callq' (invoke) instead of 'mov' (get from memory) instructions. diff --git a/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java -index ea4660fe600db94e97a5dd335135f76dd5951468..df4c9b275752ad97a4efe9380ae0d511ee760695 100644 +index 671550477476a7252a52686aa60fe6454eda2055..7d5f99cac756c54e5922bf85d5d359edcc21f1e8 100644 --- a/src/main/java/net/minecraft/core/Vec3i.java +++ b/src/main/java/net/minecraft/core/Vec3i.java @@ -35,12 +35,12 @@ public class Vec3i implements Comparable { diff --git a/patches/unapplied/server/0215-Option-to-prevent-armor-stands-from-doing-entity-loo.patch b/patches/server/0214-Option-to-prevent-armor-stands-from-doing-entity-loo.patch similarity index 85% rename from patches/unapplied/server/0215-Option-to-prevent-armor-stands-from-doing-entity-loo.patch rename to patches/server/0214-Option-to-prevent-armor-stands-from-doing-entity-loo.patch index fbe09d5031..db5ae6ef64 100644 --- a/patches/unapplied/server/0215-Option-to-prevent-armor-stands-from-doing-entity-loo.patch +++ b/patches/server/0214-Option-to-prevent-armor-stands-from-doing-entity-loo.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Option to prevent armor stands from doing entity lookups diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -index dae6835696e90bc5a541cacd37ea7aa88c60f4f4..1057679ceec86898a3e62bd183c6944f561aa7fd 100644 +index aea97a30a9226275f8fbf9cb2c15d5ddf36371ac..e9d6211eb0f955eb95d2f73ad96799ef4740d506 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -343,6 +343,7 @@ public class ArmorStand extends LivingEntity { +@@ -348,6 +348,7 @@ public class ArmorStand extends LivingEntity { @Override protected void pushEntities() { @@ -17,10 +17,10 @@ index dae6835696e90bc5a541cacd37ea7aa88c60f4f4..1057679ceec86898a3e62bd183c6944f Iterator iterator = list.iterator(); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 6944c0b0cfcde9fa4dd78742aee3e3b87d679abf..a9227581ec78a56e96dc3a342006e4a649906326 100644 +index c628524274110bcad175472dbcb82e6c62476a12..3ccd28193bec6363eb87f916589310ee8b45dd3a 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -764,6 +764,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -766,6 +766,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Paper end - Prevent block entity and entity crashes } } diff --git a/patches/unapplied/server/0216-Vanished-players-don-t-have-rights.patch b/patches/server/0215-Vanished-players-don-t-have-rights.patch similarity index 91% rename from patches/unapplied/server/0216-Vanished-players-don-t-have-rights.patch rename to patches/server/0215-Vanished-players-don-t-have-rights.patch index 5820c721da..59109ecdaa 100644 --- a/patches/unapplied/server/0216-Vanished-players-don-t-have-rights.patch +++ b/patches/server/0215-Vanished-players-don-t-have-rights.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Vanished players don't have rights diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index a39de724848d6dc796dd99dde5206f20e513fd18..30eb86b52f00cfa61af4f93aca50ffc3547c95e8 100644 +index 55c0d23ea68cd328881bd40d6bfd12d58477d15b..e7fe338572a8bb740d6023c688d8c84ea04a2169 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -288,6 +288,15 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -387,6 +387,15 @@ public abstract class Projectile extends Entity implements TraceableEntity { } else { Entity entity1 = this.getOwner(); @@ -25,10 +25,10 @@ index a39de724848d6dc796dd99dde5206f20e513fd18..30eb86b52f00cfa61af4f93aca50ffc3 } } diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java -index 6ca74a5cf691ee92c84bd031e875f72440df6b32..cee3f1200af602b5dfd0b27d05eb01826c5bbb1d 100644 +index 752929f3bcd6404b08dad1c67e9a0023b671f10d..407f5db0a4b3884440bc49bf4f00d9c035899e86 100644 --- a/src/main/java/net/minecraft/world/item/BlockItem.java +++ b/src/main/java/net/minecraft/world/item/BlockItem.java -@@ -174,7 +174,8 @@ public class BlockItem extends Item { +@@ -168,7 +168,8 @@ public class BlockItem extends Item { Player entityhuman = context.getPlayer(); CollisionContext voxelshapecollision = entityhuman == null ? CollisionContext.empty() : CollisionContext.of(entityhuman); // CraftBukkit start - store default return @@ -39,7 +39,7 @@ index 6ca74a5cf691ee92c84bd031e875f72440df6b32..cee3f1200af602b5dfd0b27d05eb0182 BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(context.getLevel(), context.getClickedPos()), player, CraftBlockData.fromData(state), defaultReturn); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index a9227581ec78a56e96dc3a342006e4a649906326..5929b450a26e7c3cf63de3dc1d0e67cb781b24c7 100644 +index 3ccd28193bec6363eb87f916589310ee8b45dd3a..cf422de89f0ed81e7c9759328e28ca6b190283ef 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -265,6 +265,45 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -89,10 +89,10 @@ index a9227581ec78a56e96dc3a342006e4a649906326..5929b450a26e7c3cf63de3dc1d0e67cb public boolean isClientSide() { return this.isClientSide; diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 9b6607700ed23b97755a2171a49b22d498a60626..0613bdf3c2325d5cab64783af7211b07fcf5124a 100644 +index 41c6a7260317ed575a3320ac36b0f2be22c120aa..474f330f381aa74e9f2fd0accdbaf2617ec1c557 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -1329,6 +1329,14 @@ public class CraftEventFactory { +@@ -1327,6 +1327,14 @@ public class CraftEventFactory { Projectile projectile = (Projectile) entity.getBukkitEntity(); org.bukkit.entity.Entity collided = position.getEntity().getBukkitEntity(); com.destroystokyo.paper.event.entity.ProjectileCollideEvent event = new com.destroystokyo.paper.event.entity.ProjectileCollideEvent(projectile, collided); diff --git a/patches/unapplied/server/0217-Allow-disabling-armor-stand-ticking.patch b/patches/server/0216-Allow-disabling-armor-stand-ticking.patch similarity index 90% rename from patches/unapplied/server/0217-Allow-disabling-armor-stand-ticking.patch rename to patches/server/0216-Allow-disabling-armor-stand-ticking.patch index bf0bbc008e..52031cba6b 100644 --- a/patches/unapplied/server/0217-Allow-disabling-armor-stand-ticking.patch +++ b/patches/server/0216-Allow-disabling-armor-stand-ticking.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Allow disabling armor stand ticking diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -index 1057679ceec86898a3e62bd183c6944f561aa7fd..ee3902cbada46ffb78c42dbf6f00c859546c76e1 100644 +index e9d6211eb0f955eb95d2f73ad96799ef4740d506..2caba38a50b7ea535337a3540aa5272d4a9f1878 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -96,9 +96,16 @@ public class ArmorStand extends LivingEntity { +@@ -108,9 +108,16 @@ public class ArmorStand extends LivingEntity { public Rotations leftLegPose; public Rotations rightLegPose; public boolean canMove = true; // Paper @@ -25,7 +25,7 @@ index 1057679ceec86898a3e62bd183c6944f561aa7fd..ee3902cbada46ffb78c42dbf6f00c859 this.handItems = NonNullList.withSize(2, ItemStack.EMPTY); this.armorItems = NonNullList.withSize(4, ItemStack.EMPTY); this.headPose = ArmorStand.DEFAULT_HEAD_POSE; -@@ -201,6 +208,7 @@ public class ArmorStand extends LivingEntity { +@@ -213,6 +220,7 @@ public class ArmorStand extends LivingEntity { this.onEquipItem(enumitemslot, (ItemStack) this.armorItems.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit } @@ -33,7 +33,7 @@ index 1057679ceec86898a3e62bd183c6944f561aa7fd..ee3902cbada46ffb78c42dbf6f00c859 } @Override -@@ -243,6 +251,7 @@ public class ArmorStand extends LivingEntity { +@@ -248,6 +256,7 @@ public class ArmorStand extends LivingEntity { } nbt.put("Pose", this.writePose()); @@ -41,7 +41,7 @@ index 1057679ceec86898a3e62bd183c6944f561aa7fd..ee3902cbada46ffb78c42dbf6f00c859 } @Override -@@ -277,6 +286,12 @@ public class ArmorStand extends LivingEntity { +@@ -282,6 +291,12 @@ public class ArmorStand extends LivingEntity { this.setNoBasePlate(nbt.getBoolean("NoBasePlate")); this.setMarker(nbt.getBoolean("Marker")); this.noPhysics = !this.hasPhysics(); @@ -54,7 +54,7 @@ index 1057679ceec86898a3e62bd183c6944f561aa7fd..ee3902cbada46ffb78c42dbf6f00c859 CompoundTag nbttagcompound2 = nbt.getCompound("Pose"); this.readPose(nbttagcompound2); -@@ -664,7 +679,29 @@ public class ArmorStand extends LivingEntity { +@@ -661,7 +676,29 @@ public class ArmorStand extends LivingEntity { @Override public void tick() { @@ -84,7 +84,7 @@ index 1057679ceec86898a3e62bd183c6944f561aa7fd..ee3902cbada46ffb78c42dbf6f00c859 Rotations vector3f = (Rotations) this.entityData.get(ArmorStand.DATA_HEAD_POSE); if (!this.headPose.equals(vector3f)) { -@@ -799,31 +836,37 @@ public class ArmorStand extends LivingEntity { +@@ -796,31 +833,37 @@ public class ArmorStand extends LivingEntity { public void setHeadPose(Rotations angle) { this.headPose = angle; this.entityData.set(ArmorStand.DATA_HEAD_POSE, angle); @@ -123,7 +123,7 @@ index 1057679ceec86898a3e62bd183c6944f561aa7fd..ee3902cbada46ffb78c42dbf6f00c859 public Rotations getHeadPose() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java -index 52ffc401bbb9fa768534a4b871f9cc7dbebb8b20..9923cea74ba39a774d6b16a225bc3e455e54c418 100644 +index 56fcd9dd40e6a63e1af5fbd470ece0d6100292a2..1bb080a8af45411b68a0f2a3c40718d60fdc9d97 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java @@ -232,5 +232,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { diff --git a/patches/unapplied/server/0218-SkeletonHorse-Additions.patch b/patches/server/0217-SkeletonHorse-Additions.patch similarity index 94% rename from patches/unapplied/server/0218-SkeletonHorse-Additions.patch rename to patches/server/0217-SkeletonHorse-Additions.patch index 3d2b910a9b..2b721231ef 100644 --- a/patches/unapplied/server/0218-SkeletonHorse-Additions.patch +++ b/patches/server/0217-SkeletonHorse-Additions.patch @@ -5,7 +5,7 @@ Subject: [PATCH] SkeletonHorse Additions diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java b/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java -index 3cb84856c10347162a8736ae1ef65165183ec8fe..5042d1d10061d611c6d283a1a1ba9f94c5ba1db5 100644 +index 521b09ac14372f524b06ffdce57932d0a590700b..b782fd54d94d1a1704ddc8e7bfda03d3aefbccbe 100644 --- a/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java +++ b/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java @@ -20,6 +20,7 @@ import net.minecraft.world.item.enchantment.providers.VanillaEnchantmentProvider @@ -32,10 +32,10 @@ index 3cb84856c10347162a8736ae1ef65165183ec8fe..5042d1d10061d611c6d283a1a1ba9f94 this.horse.setTrap(false); diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java -index 77ae7882a08441d9a80b50492be5e48487a2fdab..d465fb01af4c8610f83ecb9c68b83127cf7e95ae 100644 +index fb043d67eaa6336fc0b5d62774b8f1107f9dfa1e..dac8305f1c897e6f82a2dde67c5b1b6b8b649b19 100644 --- a/src/main/java/net/minecraft/world/level/EntityGetter.java +++ b/src/main/java/net/minecraft/world/level/EntityGetter.java -@@ -97,6 +97,28 @@ public interface EntityGetter { +@@ -94,6 +94,28 @@ public interface EntityGetter { return player; } diff --git a/patches/unapplied/server/0219-Expand-ArmorStand-API.patch b/patches/server/0218-Expand-ArmorStand-API.patch similarity index 98% rename from patches/unapplied/server/0219-Expand-ArmorStand-API.patch rename to patches/server/0218-Expand-ArmorStand-API.patch index d68ca34219..c5c9563242 100644 --- a/patches/unapplied/server/0219-Expand-ArmorStand-API.patch +++ b/patches/server/0218-Expand-ArmorStand-API.patch @@ -14,7 +14,7 @@ public net.minecraft.world.entity.decoration.ArmorStand isDisabled(Lnet/minecraf Co-authored-by: SoSeDiK diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java -index 9923cea74ba39a774d6b16a225bc3e455e54c418..1087840331f68ffe79e79f6493137b2b894832f9 100644 +index 1bb080a8af45411b68a0f2a3c40718d60fdc9d97..e1cedcb95e9b2e2e9587b623256b5cffa7b08ce4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java @@ -233,6 +233,149 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { diff --git a/patches/unapplied/server/0220-AnvilDamageEvent.patch b/patches/server/0219-AnvilDamageEvent.patch similarity index 91% rename from patches/unapplied/server/0220-AnvilDamageEvent.patch rename to patches/server/0219-AnvilDamageEvent.patch index 7437518ee2..8e5891eb7c 100644 --- a/patches/unapplied/server/0220-AnvilDamageEvent.patch +++ b/patches/server/0219-AnvilDamageEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] AnvilDamageEvent diff --git a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java -index 4a6295c0133606131c2b2b881b4dbe7f1e3e47b0..ffda2c984c5683edb38a56f04c53b0ea339e08fc 100644 +index ab59f5cdd5ce76a0408f4b6ce907e7be103d7950..126565e673e94b9c66aa4547596bbf198c57c7ad 100644 --- a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java +++ b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java -@@ -110,6 +110,16 @@ public class AnvilMenu extends ItemCombinerMenu { +@@ -111,6 +111,16 @@ public class AnvilMenu extends ItemCombinerMenu { if (!player.hasInfiniteMaterials() && iblockdata.is(BlockTags.ANVIL) && player.getRandom().nextFloat() < 0.12F) { BlockState iblockdata1 = AnvilBlock.damage(iblockdata); diff --git a/patches/unapplied/server/0221-Add-TNTPrimeEvent.patch b/patches/server/0220-Add-TNTPrimeEvent.patch similarity index 76% rename from patches/unapplied/server/0221-Add-TNTPrimeEvent.patch rename to patches/server/0220-Add-TNTPrimeEvent.patch index 1dc0962e1d..4cf9d43050 100644 --- a/patches/unapplied/server/0221-Add-TNTPrimeEvent.patch +++ b/patches/server/0220-Add-TNTPrimeEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add TNTPrimeEvent diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -index b02a77b486f8d5eee31850de4a1b033fe6a107c7..a2cde7b1b316e43382cb1639ffccf29d89f5ebfc 100644 +index ba1bb0f82634054e02c5f4bc062c1822a356e2a6..25d2226c2a5dda411a9e35f7a0e3ab183110c227 100644 --- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -573,6 +573,11 @@ public class EnderDragon extends Mob implements Enemy { +@@ -543,6 +543,11 @@ public class EnderDragon extends Mob implements Enemy { }); craftBlock.getNMS().spawnAfterBreak((ServerLevel) this.level(), blockposition, ItemStack.EMPTY, false); } @@ -17,11 +17,11 @@ index b02a77b486f8d5eee31850de4a1b033fe6a107c7..a2cde7b1b316e43382cb1639ffccf29d + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, explosionSource.getIndirectSourceEntity().getBukkitEntity()).callEvent()) + continue; + // Paper end - TNTPrimeEvent - nmsBlock.wasExploded(this.level(), blockposition, this.explosionSource); + nmsBlock.wasExploded((ServerLevel) this.level(), blockposition, this.explosionSource); this.level().removeBlock(blockposition, false); diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java -index b288db03dd5385a8a9cc49a8a7d89a9fab7224a7..c1111bd8065b53cb140e4289cb72985f03e6f549 100644 +index 88976aa06028adcb8f0c91e32b794887d0b55308..f44457c0d75efe323cc8242ef5173a3d5067fad0 100644 --- a/src/main/java/net/minecraft/world/level/block/FireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java @@ -302,12 +302,19 @@ public class FireBlock extends BaseFireBlock { @@ -46,10 +46,10 @@ index b288db03dd5385a8a9cc49a8a7d89a9fab7224a7..c1111bd8065b53cb140e4289cb72985f } } diff --git a/src/main/java/net/minecraft/world/level/block/TntBlock.java b/src/main/java/net/minecraft/world/level/block/TntBlock.java -index d80b4b3b38069016a5238f619fa3b156f576d9ae..4896ddca849646135ae101236e534ab8f59bd617 100644 +index 5e14568b325dc805e507d23ae66e789fc35ec3df..d256b0f3998028709334dd6c394d184f2c36efce 100644 --- a/src/main/java/net/minecraft/world/level/block/TntBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TntBlock.java -@@ -50,6 +50,12 @@ public class TntBlock extends Block { +@@ -52,6 +52,12 @@ public class TntBlock extends Block { protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { if (!oldState.is(state.getBlock())) { if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent @@ -62,10 +62,10 @@ index d80b4b3b38069016a5238f619fa3b156f576d9ae..4896ddca849646135ae101236e534ab8 TntBlock.explode(world, pos); world.removeBlock(pos, false); } -@@ -60,6 +66,12 @@ public class TntBlock extends Block { +@@ -62,6 +68,12 @@ public class TntBlock extends Block { @Override - protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { - if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, sourcePos)) { // CraftBukkit - TNTPrimeEvent + protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, @Nullable Orientation wireOrientation, boolean notify) { + if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent + // Paper start - TNTPrimeEvent + org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent()) { @@ -75,28 +75,28 @@ index d80b4b3b38069016a5238f619fa3b156f576d9ae..4896ddca849646135ae101236e534ab8 TntBlock.explode(world, pos); world.removeBlock(pos, false); } -@@ -78,6 +90,13 @@ public class TntBlock extends Block { +@@ -79,6 +91,13 @@ public class TntBlock extends Block { + @Override - public void wasExploded(Level world, BlockPos pos, Explosion explosion) { - if (!world.isClientSide) { -+ // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); -+ org.bukkit.entity.Entity source = explosion.source != null ? explosion.source.getBukkitEntity() : null; -+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, source).callEvent()) { -+ return; -+ } -+ // Paper end - TNTPrimeEvent - PrimedTnt entitytntprimed = new PrimedTnt(world, (double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D, explosion.getIndirectSourceEntity()); - int i = entitytntprimed.getFuse(); + public void wasExploded(ServerLevel world, BlockPos pos, Explosion explosion) { ++ // Paper start - TNTPrimeEvent ++ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); ++ org.bukkit.entity.Entity source = explosion.getDirectSourceEntity() != null ? explosion.getDirectSourceEntity().getBukkitEntity() : null; ++ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, source).callEvent()) { ++ return; ++ } ++ // Paper end - TNTPrimeEvent + PrimedTnt entitytntprimed = new PrimedTnt(world, (double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D, explosion.getIndirectSourceEntity()); + int i = entitytntprimed.getFuse(); @@ -110,6 +129,12 @@ public class TntBlock extends Block { - return ItemInteractionResult.CONSUME; + return InteractionResult.CONSUME; } // CraftBukkit end + // Paper start - TNTPrimeEvent + org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.ITEM, player.getBukkitEntity()).callEvent()) { -+ return ItemInteractionResult.FAIL; ++ return InteractionResult.FAIL; + } + // Paper end - TNTPrimeEvent TntBlock.explode(world, pos, player); diff --git a/patches/unapplied/server/0222-Break-up-and-make-tab-spam-limits-configurable.patch b/patches/server/0221-Break-up-and-make-tab-spam-limits-configurable.patch similarity index 50% rename from patches/unapplied/server/0222-Break-up-and-make-tab-spam-limits-configurable.patch rename to patches/server/0221-Break-up-and-make-tab-spam-limits-configurable.patch index 504d5c5e39..2320ac4554 100644 --- a/patches/unapplied/server/0222-Break-up-and-make-tab-spam-limits-configurable.patch +++ b/patches/server/0221-Break-up-and-make-tab-spam-limits-configurable.patch @@ -22,31 +22,39 @@ to take the burden of this into their own hand without having to rely on plugins doing unsafe things. diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 0321128ab745250e79fa5f66079c9aeb7f394cc0..5ed35d744a87290a03e9bf58143b5650501af0e6 100644 +index bcceb9d18524ddcf7cdf2ab6dcb95a67f1155414..816b53894c6420a6b1603252e53facacecc07c52 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -265,6 +265,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -7,6 +7,7 @@ import com.mojang.brigadier.ParseResults; + import com.mojang.brigadier.StringReader; + import com.mojang.brigadier.suggestion.Suggestions; + import com.mojang.logging.LogUtils; ++import io.papermc.paper.configuration.GlobalConfiguration; + import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry; + import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; + import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +@@ -272,6 +273,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + private int tickCount; private int ackBlockChangesUpTo = -1; - // CraftBukkit start - multithreaded fields - private final AtomicInteger chatSpamTickCount = new AtomicInteger(); -+ private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits - // CraftBukkit end - private int dropSpamTickCount; + private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200); ++ private final TickThrottler tabSpamThrottler = new TickThrottler(GlobalConfiguration.get().spamLimiter.tabSpamIncrement, GlobalConfiguration.get().spamLimiter.tabSpamLimit); // Paper - configurable tab spam limits + private final TickThrottler dropSpamThrottler = new TickThrottler(20, 1480); private double firstGoodX; -@@ -381,6 +382,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + private double firstGoodY; +@@ -387,6 +389,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + this.keepConnectionAlive(); - // CraftBukkit start - for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !this.chatSpamTickCount.compareAndSet(spam, spam - 1); ) ; -+ if (tabSpamLimiter.get() > 0) tabSpamLimiter.getAndDecrement(); // Paper - configurable tab spam limits - /* Use thread-safe field access instead - if (this.chatSpamTickCount > 0) { - --this.chatSpamTickCount; -@@ -719,7 +721,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + this.chatSpamThrottler.tick(); ++ this.tabSpamThrottler.tick(); // Paper - configurable tab spam limits + this.dropSpamThrottler.tick(); + if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) { + this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854 +@@ -722,7 +725,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) { // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // Paper - AsyncTabCompleteEvent; run this async // CraftBukkit start -- if (this.chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { -+ if (this.chatSpamTickCount.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamLimit && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper - configurable tab spam limits +- if (!this.chatSpamThrottler.isIncrementAndUnderThreshold(1, 500) && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { ++ if (!this.tabSpamThrottler.isIncrementAndUnderThreshold() && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { // Paper - configurable tab spam limits this.disconnect(Component.translatable("disconnect.spam")); return; } diff --git a/patches/unapplied/server/0223-Fix-NBT-type-issues.patch b/patches/server/0222-Fix-NBT-type-issues.patch similarity index 83% rename from patches/unapplied/server/0223-Fix-NBT-type-issues.patch rename to patches/server/0222-Fix-NBT-type-issues.patch index 7444db91d2..bae1fe4393 100644 --- a/patches/unapplied/server/0223-Fix-NBT-type-issues.patch +++ b/patches/server/0222-Fix-NBT-type-issues.patch @@ -8,10 +8,10 @@ Addresses two issues: - Allay duplication cooldown is saved and exposed as a long, but loaded as an int diff --git a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java -index 2d438cd3e69503fdc45a706f25c219af6f7a5db3..0916e24271d07ad5db51c5bc68791722b0f69c2b 100644 +index 74a0bebbf829fdb2bbae87100c4e2523c34f95a0..9d9e3daebc5da0af627c3d3cdb50029aacbc587b 100644 --- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java +++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java -@@ -305,7 +305,7 @@ public class ExperienceOrb extends Entity { +@@ -309,7 +309,7 @@ public class ExperienceOrb extends Entity { public void addAdditionalSaveData(CompoundTag nbt) { nbt.putShort("Health", (short) this.health); nbt.putShort("Age", (short) this.age); @@ -20,7 +20,7 @@ index 2d438cd3e69503fdc45a706f25c219af6f7a5db3..0916e24271d07ad5db51c5bc68791722 nbt.putInt("Count", this.count); this.savePaperNBT(nbt); // Paper } -@@ -314,7 +314,7 @@ public class ExperienceOrb extends Entity { +@@ -318,7 +318,7 @@ public class ExperienceOrb extends Entity { public void readAdditionalSaveData(CompoundTag nbt) { this.health = nbt.getShort("Health"); this.age = nbt.getShort("Age"); @@ -30,10 +30,10 @@ index 2d438cd3e69503fdc45a706f25c219af6f7a5db3..0916e24271d07ad5db51c5bc68791722 this.loadPaperNBT(nbt); // Paper } diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -index 56b9123b42d05e0fb20763b8988aa68583a36781..69986f75d3cf729204cca0c7e5428536af31f695 100644 +index c0c054b604cdf87591e4ce7c9f15baa5c942aadc..05c3d43fafc781e2c2d762dd5f509753df8da3b3 100644 --- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java +++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -@@ -489,7 +489,7 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS +@@ -495,7 +495,7 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS }); } diff --git a/patches/unapplied/server/0224-Remove-unnecessary-itemmeta-handling.patch b/patches/server/0223-Remove-unnecessary-itemmeta-handling.patch similarity index 94% rename from patches/unapplied/server/0224-Remove-unnecessary-itemmeta-handling.patch rename to patches/server/0223-Remove-unnecessary-itemmeta-handling.patch index 787fe866f3..d573a1e6f9 100644 --- a/patches/unapplied/server/0224-Remove-unnecessary-itemmeta-handling.patch +++ b/patches/server/0223-Remove-unnecessary-itemmeta-handling.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Remove unnecessary itemmeta handling diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 1138d238caa18171b6562cc748c92cec03bfbb97..b0d0e08e81e3b87e5d4faf62e9afe9606c254115 100644 +index 1ebaedc9617e5b79458fa119887fd72cb1f39852..957c112b4145fda5078a6f8f1689935fa0290806 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -165,7 +165,7 @@ public final class ItemStack implements DataComponentHolder { diff --git a/patches/unapplied/server/0225-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch b/patches/server/0224-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch similarity index 92% rename from patches/unapplied/server/0225-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch rename to patches/server/0224-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch index 07722aef15..c1032d9949 100644 --- a/patches/unapplied/server/0225-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch +++ b/patches/server/0224-Add-Debug-Entities-option-to-debug-dupe-uuid-issues.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 4f777c9d8c3052f68bc0465c8a7386b8fb486c83..e9d08662c065d04a67918f0aa2cd4fde5798f2a6 100644 +index 438c936fceede5b21435e1f37f2372072a9d4571..3f4d3e2f45c2b2228a333076ec1f34228560593e 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1201,6 +1201,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1196,6 +1196,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // CraftBukkit start private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot diff --git a/patches/unapplied/server/0226-Add-Early-Warning-Feature-to-WatchDog.patch b/patches/server/0225-Add-Early-Warning-Feature-to-WatchDog.patch similarity index 94% rename from patches/unapplied/server/0226-Add-Early-Warning-Feature-to-WatchDog.patch rename to patches/server/0225-Add-Early-Warning-Feature-to-WatchDog.patch index babdb2e00b..86e962e7df 100644 --- a/patches/unapplied/server/0226-Add-Early-Warning-Feature-to-WatchDog.patch +++ b/patches/server/0225-Add-Early-Warning-Feature-to-WatchDog.patch @@ -9,10 +9,10 @@ thread dumps at an interval until the point of crash. This will help diagnose what was going on in that time before the crash. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index cc0968182ab597892dbae8dd9b3e803fb62b7065..2d5ae71c143556a938f078d2fb84cab7bd4f789b 100644 +index 6abcb987109c01d012c70c4c3b411f91b7630bb4..cc15ec47155ee16377a65c9f56a62339dc0a129d 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1107,6 +1107,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements WritableRegistry { - private static final Logger LOGGER = LogUtils.getLogger(); - final ResourceKey> key; +@@ -33,11 +33,11 @@ import net.minecraft.util.RandomSource; + public class MappedRegistry implements WritableRegistry { + private final ResourceKey> key; private final ObjectList> byId = new ObjectArrayList<>(256); - private final Reference2IntMap toId = Util.make(new Reference2IntOpenHashMap<>(), map -> map.defaultReturnValue(-1)); - private final Map> byLocation = new HashMap<>(); @@ -26,5 +26,5 @@ index 1dcbde18bd9c462cca48887b904a9c43261e1854..edbbafd1705345282e5e6251eb71bfde + private final Map> byValue = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map, RegistrationInfo> registrationInfos = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions private Lifecycle registryLifecycle; - private volatile Map, HolderSet.Named> tags = new IdentityHashMap<>(); - private boolean frozen; + private final Map, HolderSet.Named> frozenTags = new IdentityHashMap<>(); + MappedRegistry.TagSet allTags = MappedRegistry.TagSet.unbound(); diff --git a/patches/unapplied/server/0236-Add-PhantomPreSpawnEvent.patch b/patches/server/0235-Add-PhantomPreSpawnEvent.patch similarity index 89% rename from patches/unapplied/server/0236-Add-PhantomPreSpawnEvent.patch rename to patches/server/0235-Add-PhantomPreSpawnEvent.patch index 42c7ae9133..3398693ce4 100644 --- a/patches/unapplied/server/0236-Add-PhantomPreSpawnEvent.patch +++ b/patches/server/0235-Add-PhantomPreSpawnEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add PhantomPreSpawnEvent diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java -index 81e75e9d6619f7108fd769e462f24d72cbd5a73c..3c3f70d05fb51b530b792adf84c324840bd03c14 100644 +index d9d374e18b1cacf0b04e6e02f3a94b145f4052fb..748f07c7036fe5955d76e28c4e7d23f8c0235d5f 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java +++ b/src/main/java/net/minecraft/world/entity/monster/Phantom.java -@@ -165,6 +165,11 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -161,6 +161,11 @@ public class Phantom extends FlyingMob implements Enemy { } this.setPhantomSize(nbt.getInt("Size")); @@ -20,7 +20,7 @@ index 81e75e9d6619f7108fd769e462f24d72cbd5a73c..3c3f70d05fb51b530b792adf84c32484 } @Override -@@ -174,6 +179,11 @@ public class Phantom extends FlyingMob implements Enemy { +@@ -170,6 +175,11 @@ public class Phantom extends FlyingMob implements Enemy { nbt.putInt("AY", this.anchorPoint.getY()); nbt.putInt("AZ", this.anchorPoint.getZ()); nbt.putInt("Size", this.getPhantomSize()); @@ -33,7 +33,7 @@ index 81e75e9d6619f7108fd769e462f24d72cbd5a73c..3c3f70d05fb51b530b792adf84c32484 @Override @@ -219,6 +229,17 @@ public class Phantom extends FlyingMob implements Enemy { - return entitysize.scale(1.0F + 0.15F * (float) i); + return predicate.test(world, this, target); } + // Paper start @@ -51,7 +51,7 @@ index 81e75e9d6619f7108fd769e462f24d72cbd5a73c..3c3f70d05fb51b530b792adf84c32484 CIRCLE, SWOOP; diff --git a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java -index 9d28e3855a9b150534ef8b6c89e186f5c4c47694..bb7f2d3ff7fc6f5cadb4ab24efb5a3a2f5bdc33f 100644 +index 1ef81620541c97dce0fca4d85951202e9532e733..499b124f905ffa8e375efa354a3f2240997ddea5 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java +++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java @@ -69,9 +69,19 @@ public class PhantomSpawner implements CustomSpawner { @@ -67,12 +67,12 @@ index 9d28e3855a9b150534ef8b6c89e186f5c4c47694..bb7f2d3ff7fc6f5cadb4ab24efb5a3a2 + continue; + } + // Paper end - PhantomPreSpawnEvent - Phantom entityphantom = (Phantom) EntityType.PHANTOM.create(world); + Phantom entityphantom = (Phantom) EntityType.PHANTOM.create(world, EntitySpawnReason.NATURAL); if (entityphantom != null) { + entityphantom.setSpawningEntity(entityplayer.getUUID()); // Paper - PhantomPreSpawnEvent entityphantom.moveTo(blockposition1, 0.0F, 0.0F); - groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, MobSpawnType.NATURAL, groupdataentity); + groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, EntitySpawnReason.NATURAL, groupdataentity); world.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java index 0359c161448941f1b9fdac545a5c47a68f19b760..305a635b049741ac5e2670060c6818cb2c07e5ab 100644 diff --git a/patches/unapplied/server/0237-Add-More-Creeper-API.patch b/patches/server/0236-Add-More-Creeper-API.patch similarity index 89% rename from patches/unapplied/server/0237-Add-More-Creeper-API.patch rename to patches/server/0236-Add-More-Creeper-API.patch index 931f2b6158..04605aa213 100644 --- a/patches/unapplied/server/0237-Add-More-Creeper-API.patch +++ b/patches/server/0236-Add-More-Creeper-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add More Creeper API diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src/main/java/net/minecraft/world/entity/monster/Creeper.java -index 95df4ac539ec284654c53d39955870a46478c27d..9bf11a8b44e696b6587bc775904a836d390e437b 100644 +index 0552cc23391ec305754339d000630ccab0729100..7a18dc59aed5294cd442994aa2d34ea00b877f46 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java +++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java -@@ -134,7 +134,7 @@ public class Creeper extends Monster implements PowerableMob { +@@ -133,7 +133,7 @@ public class Creeper extends Monster { } if (nbt.getBoolean("ignited")) { @@ -17,7 +17,7 @@ index 95df4ac539ec284654c53d39955870a46478c27d..9bf11a8b44e696b6587bc775904a836d } } -@@ -315,7 +315,18 @@ public class Creeper extends Monster implements PowerableMob { +@@ -315,7 +315,18 @@ public class Creeper extends Monster { } public void ignite() { diff --git a/patches/unapplied/server/0238-Inventory-removeItemAnySlot.patch b/patches/server/0237-Inventory-removeItemAnySlot.patch similarity index 100% rename from patches/unapplied/server/0238-Inventory-removeItemAnySlot.patch rename to patches/server/0237-Inventory-removeItemAnySlot.patch diff --git a/patches/unapplied/server/0239-Make-CraftWorld-loadChunk-int-int-false-load-unconve.patch b/patches/server/0238-Make-CraftWorld-loadChunk-int-int-false-load-unconve.patch similarity index 87% rename from patches/unapplied/server/0239-Make-CraftWorld-loadChunk-int-int-false-load-unconve.patch rename to patches/server/0238-Make-CraftWorld-loadChunk-int-int-false-load-unconve.patch index 911ca5db1f..79a35711a9 100644 --- a/patches/unapplied/server/0239-Make-CraftWorld-loadChunk-int-int-false-load-unconve.patch +++ b/patches/server/0238-Make-CraftWorld-loadChunk-int-int-false-load-unconve.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Make CraftWorld#loadChunk(int, int, false) load unconverted diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 281fa67cb5c95e6016c7220c0ef912bbfd28cd9f..333e3109d19c867e8a74f20693952bdb3df804e4 100644 +index 1982385aa0e4984544d2aef88f5cafd5c0d5a49a..0a53b01094bd8070e57fb3c967c1129a53bd7ff8 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -432,7 +432,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -438,7 +438,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean loadChunk(int x, int z, boolean generate) { org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot diff --git a/patches/unapplied/server/0240-Add-ray-tracing-methods-to-LivingEntity.patch b/patches/server/0239-Add-ray-tracing-methods-to-LivingEntity.patch similarity index 91% rename from patches/unapplied/server/0240-Add-ray-tracing-methods-to-LivingEntity.patch rename to patches/server/0239-Add-ray-tracing-methods-to-LivingEntity.patch index 0962c2d288..8ec63c01c8 100644 --- a/patches/unapplied/server/0240-Add-ray-tracing-methods-to-LivingEntity.patch +++ b/patches/server/0239-Add-ray-tracing-methods-to-LivingEntity.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add ray tracing methods to LivingEntity diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index d90e74b7323a60e781d942baffe9b4bdb8ae2943..08f756b4fbb4732d73ca281b7006024b21504880 100644 +index c9d7589a18e9cee204f4e52368a60aa421c1e150..35dfaf46429f5478049835e1a5e4b03c362a64e8 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -3980,6 +3980,19 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -4114,6 +4114,19 @@ public abstract class LivingEntity extends Entity implements Attackable { } // Paper start - Make shield blocking delay configurable @@ -29,10 +29,10 @@ index d90e74b7323a60e781d942baffe9b4bdb8ae2943..08f756b4fbb4732d73ca281b7006024b public int getShieldBlockingDelay() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -index 2612e5016646591bb65ac255804b612b348a32fd..c8ac50351b7b1b2f4afc138570b8098a3c0ce1ba 100644 +index 2033354daafc739a8bd9ddf4a6128d3204d32094..0c7bf4124d67258ebca9b9b73b92c2e0efbdaa86 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -@@ -202,6 +202,33 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { +@@ -207,6 +207,33 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { return blocks.get(0); } diff --git a/patches/unapplied/server/0241-Expose-attack-cooldown-methods-for-Player.patch b/patches/server/0240-Expose-attack-cooldown-methods-for-Player.patch similarity index 86% rename from patches/unapplied/server/0241-Expose-attack-cooldown-methods-for-Player.patch rename to patches/server/0240-Expose-attack-cooldown-methods-for-Player.patch index 0d19ca5bf3..889ae1c623 100644 --- a/patches/unapplied/server/0241-Expose-attack-cooldown-methods-for-Player.patch +++ b/patches/server/0240-Expose-attack-cooldown-methods-for-Player.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Expose attack cooldown methods for Player diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 12c61db6d4b1284765f9bed3ae26131a118b318e..a7e611aaeb457820ad303b95822d8ea86b060477 100644 +index ad75996926b7e054f1053d07fb978ac745f22ce6..535e0438b02fd7c10aee0d24786a6e38c6e48359 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -2980,6 +2980,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2993,6 +2993,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this.adventure$pointers; } diff --git a/patches/unapplied/server/0242-Improve-death-events.patch b/patches/server/0241-Improve-death-events.patch similarity index 78% rename from patches/unapplied/server/0242-Improve-death-events.patch rename to patches/server/0241-Improve-death-events.patch index 32eb4bc818..26de33a12c 100644 --- a/patches/unapplied/server/0242-Improve-death-events.patch +++ b/patches/server/0241-Improve-death-events.patch @@ -19,10 +19,10 @@ public net.minecraft.world.entity.LivingEntity getDeathSound()Lnet/minecraft/sou public net.minecraft.world.entity.LivingEntity getSoundVolume()F diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 0dee94f1dd27a0d7e709367450c5ef7956e27217..fa8640f961b93dc811296131dfda58faa1908add 100644 +index 29b836a75b835f0d5233db419fc5ca8dde885fdb..2bd97344502a63173de923542f27759d7e98b6cc 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -269,6 +269,10 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { +@@ -296,6 +296,10 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { private int containerCounter; public boolean wonGame; private int containerUpdateDelay; // Paper - Configurable container update tick rate @@ -33,16 +33,16 @@ index 0dee94f1dd27a0d7e709367450c5ef7956e27217..fa8640f961b93dc811296131dfda58fa // CraftBukkit start public CraftPlayer.TransferCookieConnection transferCookieConnection; -@@ -894,7 +898,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { +@@ -1154,7 +1158,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { @Override public void die(DamageSource damageSource) { - this.gameEvent(GameEvent.ENTITY_DIE); + // this.gameEvent(GameEvent.ENTITY_DIE); // Paper - move below event cancellation check - boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); + boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); // CraftBukkit start - fire PlayerDeathEvent if (this.isRemoved()) { -@@ -922,6 +926,16 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { +@@ -1182,6 +1186,16 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { String deathmessage = defaultMessage.getString(); this.keepLevel = keepInventory; // SPIGOT-2222: pre-set keepLevel org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, damageSource, loot, PaperAdventure.asAdventure(defaultMessage), keepInventory); // Paper - Adventure @@ -59,16 +59,15 @@ index 0dee94f1dd27a0d7e709367450c5ef7956e27217..fa8640f961b93dc811296131dfda58fa // SPIGOT-943 - only call if they have an inventory open if (this.containerMenu != this.inventoryMenu) { -@@ -1070,8 +1084,17 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { - } +@@ -1331,7 +1345,17 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { } } -- -- return super.hurt(source, amount); + +- return super.hurtServer(world, source, amount); + // Paper start - cancellable death events + //return super.hurt(source, amount); + this.queueHealthUpdatePacket = true; -+ boolean damaged = super.hurt(source, amount); ++ boolean damaged = super.hurtServer(world, source, amount); + this.queueHealthUpdatePacket = false; + if (this.queuedHealthUpdatePacket != null) { + this.connection.send(this.queuedHealthUpdatePacket); @@ -80,10 +79,10 @@ index 0dee94f1dd27a0d7e709367450c5ef7956e27217..fa8640f961b93dc811296131dfda58fa } } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 39dff0a38b53624c935f27cc86ff036c831f407f..bdee5725029eda3a0e7bee407286480c0bb47db1 100644 +index 35dfaf46429f5478049835e1a5e4b03c362a64e8..a7e950bc5aa827c1b137a12c9eaaf7eac867bdc3 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -283,6 +283,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -297,6 +297,7 @@ public abstract class LivingEntity extends Entity implements Attackable { public Set collidableExemptions = new HashSet<>(); public boolean bukkitPickUpLoot; public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper @@ -91,7 +90,7 @@ index 39dff0a38b53624c935f27cc86ff036c831f407f..bdee5725029eda3a0e7bee407286480c @Override public float getBukkitYaw() { -@@ -1537,11 +1538,12 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1574,11 +1575,12 @@ public abstract class LivingEntity extends Entity implements Attackable { if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(source)) { @@ -107,7 +106,7 @@ index 39dff0a38b53624c935f27cc86ff036c831f407f..bdee5725029eda3a0e7bee407286480c } } else if (flag1) { this.playHurtSound(source); -@@ -1700,6 +1702,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1740,6 +1742,7 @@ public abstract class LivingEntity extends Entity implements Attackable { Entity entity = damageSource.getEntity(); LivingEntity entityliving = this.getKillCredit(); @@ -115,7 +114,7 @@ index 39dff0a38b53624c935f27cc86ff036c831f407f..bdee5725029eda3a0e7bee407286480c if (this.deathScore >= 0 && entityliving != null) { entityliving.awardKillScore(this, this.deathScore, damageSource); } -@@ -1711,24 +1714,59 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1751,24 +1754,59 @@ public abstract class LivingEntity extends Entity implements Attackable { if (!this.level().isClientSide && this.hasCustomName()) { if (org.spigotmc.SpigotConfig.logNamedDeaths) LivingEntity.LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); // Spigot } @@ -179,16 +178,16 @@ index 39dff0a38b53624c935f27cc86ff036c831f407f..bdee5725029eda3a0e7bee407286480c } } -@@ -1736,7 +1774,7 @@ public abstract class LivingEntity extends Entity implements Attackable { - if (!this.level().isClientSide) { +@@ -1778,7 +1816,7 @@ public abstract class LivingEntity extends Entity implements Attackable { + if (world instanceof ServerLevel worldserver) { boolean flag = false; - if (adversary instanceof WitherBoss) { + if (this.dead && adversary instanceof WitherBoss) { // Paper - if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { BlockPos blockposition = this.blockPosition(); BlockState iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); -@@ -1765,24 +1803,37 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1807,24 +1845,37 @@ public abstract class LivingEntity extends Entity implements Attackable { } } @@ -200,9 +199,9 @@ index 39dff0a38b53624c935f27cc86ff036c831f407f..bdee5725029eda3a0e7bee407286480c + // Paper end boolean flag = this.lastHurtByPlayerTime > 0; - this.dropEquipment(); // CraftBukkit - from below + this.dropEquipment(world); // CraftBukkit - from below if (this.shouldDropLoot() && world.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - this.dropFromLootTable(damageSource, flag); + this.dropFromLootTable(world, damageSource, flag); + // Paper start + final boolean prev = this.clearEquipmentSlots; + this.clearEquipmentSlots = false; @@ -218,21 +217,21 @@ index 39dff0a38b53624c935f27cc86ff036c831f407f..bdee5725029eda3a0e7bee407286480c this.drops = new ArrayList<>(); // CraftBukkit end - // this.dropEquipment();// CraftBukkit - moved up - this.dropExperience(damageSource.getEntity()); + // this.dropEquipment(worldserver);// CraftBukkit - moved up + this.dropExperience(world, damageSource.getEntity()); + return deathEvent; // Paper } - protected void dropEquipment() {} + protected void dropEquipment(ServerLevel world) {} + protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {} // Paper - method for post death logic that cannot be ran before the event is potentially cancelled - public int getExpReward(@Nullable Entity entity) { // CraftBukkit - Level world = this.level(); + public int getExpReward(ServerLevel worldserver, @Nullable Entity entity) { // CraftBukkit + if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 25a71cc5ca8cf8a5070cd24eb56fe0d79e765669..b46572f6e3b52f498b395d3b8c5def2aa799ff03 100644 +index 2b8bfccbf520f9a356f816522ac3a5caa51e44e1..a8ab3c03a6f96658ce2a3f5758225954a36de6a9 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -1123,6 +1123,12 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab +@@ -1117,6 +1117,12 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab } @@ -245,18 +244,18 @@ index 25a71cc5ca8cf8a5070cd24eb56fe0d79e765669..b46572f6e3b52f498b395d3b8c5def2a @Override protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) { super.dropCustomDeathLoot(world, source, causedByPlayer); -@@ -1131,6 +1137,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab +@@ -1124,6 +1130,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab - for (int j = 0; j < i; ++j) { - EquipmentSlot enumitemslot = aenumitemslot[j]; + while (iterator.hasNext()) { + EquipmentSlot enumitemslot = (EquipmentSlot) iterator.next(); + if (this.shouldSkipLoot(enumitemslot)) continue; // Paper ItemStack itemstack = this.getItemBySlot(enumitemslot); float f = this.getEquipmentDropChance(enumitemslot); -@@ -1155,7 +1162,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab +@@ -1148,7 +1155,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab } - this.spawnAtLocation(itemstack); + this.spawnAtLocation(world, itemstack); + if (this.clearEquipmentSlots) { // Paper this.setItemSlot(enumitemslot, ItemStack.EMPTY); + // Paper start @@ -268,10 +267,10 @@ index 25a71cc5ca8cf8a5070cd24eb56fe0d79e765669..b46572f6e3b52f498b395d3b8c5def2a } } diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main/java/net/minecraft/world/entity/animal/Fox.java -index a6788da1505f9e119c03b94488f5e006da13e918..e46c8231ee318eda0512afbb6343b426b4838643 100644 +index faffc3a9ed8bc306277cad37bc43af2ef7303493..205aefd38a185fa411ff17cfb0155769de8fc2fd 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Fox.java +++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java -@@ -704,16 +704,38 @@ public class Fox extends Animal implements VariantHolder { +@@ -689,16 +689,38 @@ public class Fox extends Animal implements VariantHolder { return this.getTrustedUUIDs().contains(uuid); } @@ -290,8 +289,8 @@ index a6788da1505f9e119c03b94488f5e006da13e918..e46c8231ee318eda0512afbb6343b426 - if (!itemstack.isEmpty()) { + boolean releaseMouth = false; -+ if (!itemstack.isEmpty() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Fix MC-153010 - this.spawnAtLocation(itemstack); ++ if (!itemstack.isEmpty() && world.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Fix MC-153010 + this.spawnAtLocation(world, itemstack); + releaseMouth = true; + } + @@ -314,17 +313,16 @@ index a6788da1505f9e119c03b94488f5e006da13e918..e46c8231ee318eda0512afbb6343b426 public static boolean isPathClear(Fox fox, LivingEntity chasedEntity) { diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java -index 767817fb1418958c89d0db9da4ae7eb8a5a16076..5654c614f07f07ff642ba4851b0cb6fa185924ae 100644 +index dd7ef4c873d5e06eb5be3abc8049bf8acbd5a3fb..112b82ba7709b36e996e2f984c72ce40ca718720 100644 --- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java +++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java -@@ -71,9 +71,17 @@ public abstract class AbstractChestedHorse extends AbstractHorse { - this.spawnAtLocation(Blocks.CHEST); - } - +@@ -69,9 +69,16 @@ public abstract class AbstractChestedHorse extends AbstractHorse { + super.dropEquipment(world); + if (this.hasChest()) { + this.spawnAtLocation(world, Blocks.CHEST); + //this.setChest(false); // Paper - moved to post death logic + } + } -+ + // Paper start + protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) { + if (this.hasChest() && (event == null || !event.isCancelled())) { @@ -336,40 +334,39 @@ index 767817fb1418958c89d0db9da4ae7eb8a5a16076..5654c614f07f07ff642ba4851b0cb6fa @Override public void addAdditionalSaveData(CompoundTag nbt) { diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -index ee3902cbada46ffb78c42dbf6f00c859546c76e1..92bb0c63330ad3a4cb13b2dc655020714e9b1ffd 100644 +index 2caba38a50b7ea535337a3540aa5272d4a9f1878..e20565cf256aacd012a1722c5ebbf9016bc82e42 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -505,8 +505,10 @@ public class ArmorStand extends LivingEntity { - } - // CraftBukkit end - if (source.is(DamageTypeTags.IS_EXPLOSION)) { -- this.brokenByAnything(worldserver, source); -- this.kill(source); // CraftBukkit -+ // Paper start - avoid duplicate event call -+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(worldserver, source); -+ if (!event.isCancelled()) this.kill(source, false); // CraftBukkit -+ // Paper end - return false; - } else if (source.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { - if (this.isOnFire()) { -@@ -549,9 +551,9 @@ public class ArmorStand extends LivingEntity { - this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity()); - this.lastHit = i; - } else { -- this.brokenByPlayer(worldserver, source); -+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(worldserver, source); // Paper - this.showBreakingParticles(); -- this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event -+ if (!event.isCancelled()) this.kill(source, false); // Paper - we still need to kill to follow vanilla logic (emit the game event etc...) - } - - return true; -@@ -604,8 +606,10 @@ public class ArmorStand extends LivingEntity { +@@ -506,8 +506,10 @@ public class ArmorStand extends LivingEntity { + } + // CraftBukkit end + if (source.is(DamageTypeTags.IS_EXPLOSION)) { +- this.brokenByAnything(world, source); +- this.kill(world, source); // CraftBukkit ++ // Paper start - avoid duplicate event call ++ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(world, source); ++ if (!event.isCancelled()) this.kill(source, false); // CraftBukkit ++ // Paper end + return false; + } else if (source.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { + if (this.isOnFire()) { +@@ -550,9 +552,9 @@ public class ArmorStand extends LivingEntity { + this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity()); + this.lastHit = i; + } else { +- this.brokenByPlayer(world, source); ++ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(world, source); // Paper + this.showBreakingParticles(); +- this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event ++ if (!event.isCancelled()) this.kill(source, false); // Paper - we still need to kill to follow vanilla logic (emit the game event etc...) + } + return true; +@@ -602,7 +604,10 @@ public class ArmorStand extends LivingEntity { f1 -= amount; if (f1 <= 0.5F) { -- this.brokenByAnything(world, damageSource); -- this.kill(damageSource); // CraftBukkit + this.brokenByAnything(world, damageSource); +- this.kill(world, damageSource); // CraftBukkit + // Paper start - avoid duplicate event call + org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(world, damageSource); + if (!event.isCancelled()) this.kill(damageSource, false); // CraftBukkit @@ -377,7 +374,7 @@ index ee3902cbada46ffb78c42dbf6f00c859546c76e1..92bb0c63330ad3a4cb13b2dc65502071 } else { this.setHealth(f1); this.gameEvent(GameEvent.ENTITY_DAMAGE, damageSource.getEntity()); -@@ -613,15 +617,15 @@ public class ArmorStand extends LivingEntity { +@@ -610,15 +615,15 @@ public class ArmorStand extends LivingEntity { } @@ -396,7 +393,7 @@ index ee3902cbada46ffb78c42dbf6f00c859546c76e1..92bb0c63330ad3a4cb13b2dc65502071 this.playBrokenSound(); // this.dropAllDeathLoot(worldserver, damagesource); // CraftBukkit - moved down -@@ -643,7 +647,7 @@ public class ArmorStand extends LivingEntity { +@@ -640,7 +645,7 @@ public class ArmorStand extends LivingEntity { this.armorItems.set(i, ItemStack.EMPTY); } } @@ -405,10 +402,10 @@ index ee3902cbada46ffb78c42dbf6f00c859546c76e1..92bb0c63330ad3a4cb13b2dc65502071 } -@@ -770,7 +774,15 @@ public class ArmorStand extends LivingEntity { +@@ -767,7 +772,15 @@ public class ArmorStand extends LivingEntity { } - public void kill(DamageSource damageSource) { + public void kill(ServerLevel worldserver, DamageSource damageSource) { - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, (damageSource == null ? this.damageSources().genericKill() : damageSource), this.drops); // CraftBukkit - call event + // Paper start - make cancellable + this.kill(damageSource, true); @@ -423,10 +420,10 @@ index ee3902cbada46ffb78c42dbf6f00c859546c76e1..92bb0c63330ad3a4cb13b2dc65502071 // CraftBukkit end this.gameEvent(GameEvent.ENTITY_DIE); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index a7e611aaeb457820ad303b95822d8ea86b060477..004ac565d4124f6059d530034cf0c9a28f0be467 100644 +index 535e0438b02fd7c10aee0d24786a6e38c6e48359..c132b4d4d871eaeadec78921a99ba7066c59ddda 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -2517,7 +2517,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2530,7 +2530,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void sendHealthUpdate() { FoodData foodData = this.getHandle().getFoodData(); @@ -443,15 +440,14 @@ index a7e611aaeb457820ad303b95822d8ea86b060477..004ac565d4124f6059d530034cf0c9a2 public void injectScaledMaxHealth(Collection collection, boolean force) { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 0613bdf3c2325d5cab64783af7211b07fcf5124a..6a018f9c289a539b07855d75e4cc2d3c2828ded1 100644 +index 474f330f381aa74e9f2fd0accdbaf2617ec1c557..834516cac1f3ac5f078dd4e4dfa449f39462658c 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -903,9 +903,16 @@ public class CraftEventFactory { - CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); +@@ -902,8 +902,15 @@ public class CraftEventFactory { CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource); - EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(damageSource.getEntity())); -+ populateFields(victim, event); // Paper - make cancellable CraftWorld world = (CraftWorld) entity.getWorld(); + EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(world.getHandle(), damageSource.getEntity())); ++ populateFields(victim, event); // Paper - make cancellable Bukkit.getServer().getPluginManager().callEvent(event); + // Paper start - make cancellable @@ -463,11 +459,11 @@ index 0613bdf3c2325d5cab64783af7211b07fcf5124a..6a018f9c289a539b07855d75e4cc2d3c victim.expToDrop = event.getDroppedExp(); for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { -@@ -923,7 +930,14 @@ public class CraftEventFactory { - PlayerDeathEvent event = new PlayerDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(damageSource.getEntity()), 0, deathMessage); +@@ -921,7 +928,14 @@ public class CraftEventFactory { + PlayerDeathEvent event = new PlayerDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(victim.serverLevel(), damageSource.getEntity()), 0, deathMessage); event.setKeepInventory(keepInventory); event.setKeepLevel(victim.keepLevel); // SPIGOT-2222: pre-set keepLevel -+ populateFields(victim, event); // Paper - make cancellable ++populateFields(victim, event); // Paper - make cancellable Bukkit.getServer().getPluginManager().callEvent(event); + // Paper start - make cancellable + if (event.isCancelled()) { @@ -478,7 +474,7 @@ index 0613bdf3c2325d5cab64783af7211b07fcf5124a..6a018f9c289a539b07855d75e4cc2d3c victim.keepLevel = event.getKeepLevel(); victim.newLevel = event.getNewLevel(); -@@ -946,6 +960,31 @@ public class CraftEventFactory { +@@ -944,6 +958,31 @@ public class CraftEventFactory { return event; }