diff --git a/patches/unapplied/server/0933-Dont-resend-blocks-on-interactions.patch b/patches/server/0923-Dont-resend-blocks-on-interactions.patch similarity index 91% rename from patches/unapplied/server/0933-Dont-resend-blocks-on-interactions.patch rename to patches/server/0923-Dont-resend-blocks-on-interactions.patch index 53693f4954..f522a08097 100644 --- a/patches/unapplied/server/0933-Dont-resend-blocks-on-interactions.patch +++ b/patches/server/0923-Dont-resend-blocks-on-interactions.patch @@ -8,10 +8,10 @@ In general, the client now has an acknowledgment system which will prevent block It should be noted that this system does not yet support block entities, so those still need to resynced when needed. diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -index dd78a1685bd841577aa9d5010fffda1468901baf..c5f3ba82b3ded415ff4bffc9eabf9526695e1ba7 100644 +index d839f8df658c894f144ba4637d290ffbed77e132..415d9802ae4dd75b44055b8faf19672fa50c585f 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -202,7 +202,7 @@ public class ServerPlayerGameMode { +@@ -204,7 +204,7 @@ public class ServerPlayerGameMode { PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); if (event.isCancelled()) { // Let the client know the block still exists @@ -20,7 +20,7 @@ index dd78a1685bd841577aa9d5010fffda1468901baf..c5f3ba82b3ded415ff4bffc9eabf9526 // Update any tile entity data for this block capturedBlockEntity = true; // Paper - Send block entities after destroy prediction return; -@@ -217,7 +217,7 @@ public class ServerPlayerGameMode { +@@ -219,7 +219,7 @@ public class ServerPlayerGameMode { // Spigot start - handle debug stick left click for non-creative if (this.player.getMainHandItem().is(net.minecraft.world.item.Items.DEBUG_STICK) && ((net.minecraft.world.item.DebugStickItem) net.minecraft.world.item.Items.DEBUG_STICK).handleInteraction(this.player, this.level.getBlockState(pos), this.level, pos, false, this.player.getMainHandItem())) { @@ -29,7 +29,7 @@ index dd78a1685bd841577aa9d5010fffda1468901baf..c5f3ba82b3ded415ff4bffc9eabf9526 return; } // Spigot end -@@ -235,15 +235,17 @@ public class ServerPlayerGameMode { +@@ -237,15 +237,17 @@ public class ServerPlayerGameMode { // CraftBukkit start - Swings at air do *NOT* exist. if (event.useInteractedBlock() == Event.Result.DENY) { // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. @@ -54,9 +54,9 @@ index dd78a1685bd841577aa9d5010fffda1468901baf..c5f3ba82b3ded415ff4bffc9eabf9526 + //} + // Paper end - Don't resync blocks } else if (!iblockdata.isAir()) { - iblockdata.attack(this.level, pos, this.player); - f = iblockdata.getDestroyProgress(this.player, this.player.level(), pos); -@@ -252,7 +254,7 @@ public class ServerPlayerGameMode { + EnchantmentHelper.onHitBlock(this.level, this.player.getMainHandItem(), this.player, this.player, EquipmentSlot.MAINHAND, Vec3.atCenterOf(pos), iblockdata, (item) -> { + this.player.onEquippedItemBroken(item, EquipmentSlot.MAINHAND); +@@ -257,7 +259,7 @@ public class ServerPlayerGameMode { if (event.useItemInHand() == Event.Result.DENY) { // If we 'insta destroyed' then the client needs to be informed. if (f > 1.0f) { @@ -65,7 +65,7 @@ index dd78a1685bd841577aa9d5010fffda1468901baf..c5f3ba82b3ded415ff4bffc9eabf9526 } return; } -@@ -260,7 +262,7 @@ public class ServerPlayerGameMode { +@@ -265,7 +267,7 @@ public class ServerPlayerGameMode { if (blockEvent.isCancelled()) { // Let the client know the block still exists @@ -74,7 +74,7 @@ index dd78a1685bd841577aa9d5010fffda1468901baf..c5f3ba82b3ded415ff4bffc9eabf9526 return; } -@@ -351,7 +353,7 @@ public class ServerPlayerGameMode { +@@ -356,7 +358,7 @@ public class ServerPlayerGameMode { // Tell client the block is gone immediately then process events // Don't tell the client if its a creative sword break because its not broken! @@ -83,7 +83,7 @@ index dd78a1685bd841577aa9d5010fffda1468901baf..c5f3ba82b3ded415ff4bffc9eabf9526 ClientboundBlockUpdatePacket packet = new ClientboundBlockUpdatePacket(pos, Blocks.AIR.defaultBlockState()); this.player.connection.send(packet); } -@@ -377,13 +379,15 @@ public class ServerPlayerGameMode { +@@ -382,13 +384,15 @@ public class ServerPlayerGameMode { if (isSwordNoBreak) { return false; } @@ -103,7 +103,7 @@ index dd78a1685bd841577aa9d5010fffda1468901baf..c5f3ba82b3ded415ff4bffc9eabf9526 // Update any tile entity data for this block if (!captureSentBlockEntities) { // Paper - Send block entities after destroy prediction -@@ -532,16 +536,18 @@ public class ServerPlayerGameMode { +@@ -537,16 +541,18 @@ public class ServerPlayerGameMode { if (event.useInteractedBlock() == Event.Result.DENY) { // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. if (iblockdata.getBlock() instanceof DoorBlock) { @@ -127,10 +127,10 @@ index dd78a1685bd841577aa9d5010fffda1468901baf..c5f3ba82b3ded415ff4bffc9eabf9526 } else if (iblockdata.is(Blocks.JIGSAW) || iblockdata.is(Blocks.STRUCTURE_BLOCK) || iblockdata.getBlock() instanceof net.minecraft.world.level.block.CommandBlock) { player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId)); diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java -index 6d494b80ae002aea00afa44adf83dad1ae5bbbc1..49557d6f22c5725c663a231deab019d4f6fe95fa 100644 +index 6caed156ed0cfe0017d578f58cb963ee68272d78..321188173918d0d60858a258400dfd682ccdb21c 100644 --- a/src/main/java/net/minecraft/world/item/BucketItem.java +++ b/src/main/java/net/minecraft/world/item/BucketItem.java -@@ -78,7 +78,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { +@@ -79,7 +79,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) world, user, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.getItem(), hand); if (event.isCancelled()) { @@ -139,7 +139,7 @@ index 6d494b80ae002aea00afa44adf83dad1ae5bbbc1..49557d6f22c5725c663a231deab019d4 ((ServerPlayer) user).getBukkitEntity().updateInventory(); // SPIGOT-4541 return InteractionResultHolder.fail(itemstack); } -@@ -185,7 +185,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { +@@ -187,7 +187,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { if (flag2 && entityhuman != null) { PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((ServerLevel) world, entityhuman, blockposition, clicked, enumdirection, itemstack, enumhand); if (event.isCancelled()) { @@ -149,10 +149,10 @@ index 6d494b80ae002aea00afa44adf83dad1ae5bbbc1..49557d6f22c5725c663a231deab019d4 return false; } diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 4485199c90e3efbce3e6a18a75703e86a9bdde3c..3f6082b656ec8c9b96b40fbd1c926d5211ffe4c6 100644 +index 1f2e6f57ffb827ef9bf3623bfdde07db21edf6ee..486c3769a0e6a1ecb5530a35e2591f78776619b9 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -479,10 +479,12 @@ public final class ItemStack implements DataComponentHolder { +@@ -500,10 +500,12 @@ public final class ItemStack implements DataComponentHolder { world.preventPoiUpdated = false; // Brute force all possible updates diff --git a/patches/unapplied/server/0934-add-more-scoreboard-API.patch b/patches/server/0924-add-more-scoreboard-API.patch similarity index 100% rename from patches/unapplied/server/0934-add-more-scoreboard-API.patch rename to patches/server/0924-add-more-scoreboard-API.patch diff --git a/patches/unapplied/server/0935-Improve-Registry.patch b/patches/server/0925-Improve-Registry.patch similarity index 94% rename from patches/unapplied/server/0935-Improve-Registry.patch rename to patches/server/0925-Improve-Registry.patch index 5aa02530f0..32f844a5d8 100644 --- a/patches/unapplied/server/0935-Improve-Registry.patch +++ b/patches/server/0925-Improve-Registry.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Improve Registry diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java -index a644309edb612d97da290f86a1ef6fe597c7d85d..3adf18d5e736abff701a4866ee1f8403aeafca84 100644 +index f8cf246913040ea4064f8addee0ec6927eb06237..334447e222d88bb24676bb154e7057a4147d0f41 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java -@@ -143,6 +143,7 @@ public class CraftRegistry implements Registry { +@@ -144,6 +144,7 @@ public class CraftRegistry implements Registry { private final Class bukkitClass; // Paper - relax preload class private final Map cache = new HashMap<>(); @@ -16,7 +16,7 @@ index a644309edb612d97da290f86a1ef6fe597c7d85d..3adf18d5e736abff701a4866ee1f8403 private final net.minecraft.core.Registry minecraftRegistry; private final BiFunction minecraftToBukkit; private final BiFunction serializationUpdater; // Paper - rename to make it *clear* what it is *only* for -@@ -191,6 +192,7 @@ public class CraftRegistry implements Registry { +@@ -192,6 +193,7 @@ public class CraftRegistry implements Registry { } this.cache.put(namespacedKey, bukkit); @@ -24,7 +24,7 @@ index a644309edb612d97da290f86a1ef6fe597c7d85d..3adf18d5e736abff701a4866ee1f8403 return bukkit; } -@@ -213,4 +215,11 @@ public class CraftRegistry implements Registry { +@@ -214,4 +216,11 @@ public class CraftRegistry implements Registry { return this.minecraftToBukkit.apply(namespacedKey, minecraft); } diff --git a/patches/unapplied/server/0936-Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch b/patches/server/0926-Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch similarity index 81% rename from patches/unapplied/server/0936-Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch rename to patches/server/0926-Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch index ce326110a4..a16bdcd013 100644 --- a/patches/unapplied/server/0936-Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch +++ b/patches/server/0926-Fix-NPE-on-null-loc-for-EntityTeleportEvent.patch @@ -26,10 +26,10 @@ index a306b30af19277386a2f3e560b4902a8b5796f2a..54851f6cc0d5fddb32a9a1e84a4f5ae4 x = to.getX(); y = to.getY(); diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index cb07999629ba2d56602b3ae06ef06e350a8d1fb1..b7af45eac986097ef53fa90bb4edd67f8829f13c 100644 +index 73a6ceef98f94ec801c14ca6d3c33f801b2ae442..0e8888ca5f8cde764efa9e2cda8c59e9ecb3190c 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -4173,7 +4173,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -4200,7 +4200,7 @@ public abstract class LivingEntity extends Entity implements Attackable { if (!(this instanceof ServerPlayer)) { EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.level().getWorld(), d3, d4, d5), new Location(this.level().getWorld(), d0, d6, d2)); this.level().getCraftServer().getPluginManager().callEvent(teleport); @@ -38,21 +38,21 @@ index cb07999629ba2d56602b3ae06ef06e350a8d1fb1..b7af45eac986097ef53fa90bb4edd67f Location to = teleport.getTo(); this.teleportTo(to.getX(), to.getY(), to.getZ()); } else { -diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java -index 8fa9282acd87132516329083f774345df3310cf2..edd29c2f4d0151d512618115a8fb4b7423171491 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java -+++ b/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java -@@ -130,7 +130,7 @@ public class FollowOwnerGoal extends Goal { +diff --git a/src/main/java/net/minecraft/world/entity/TamableAnimal.java b/src/main/java/net/minecraft/world/entity/TamableAnimal.java +index 39adc89b35213d5d5fb71bb4b7e0c641f77e4a06..45224dc3867892b298b006c17f7f85741fcc96d6 100644 +--- a/src/main/java/net/minecraft/world/entity/TamableAnimal.java ++++ b/src/main/java/net/minecraft/world/entity/TamableAnimal.java +@@ -299,7 +299,7 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { } else { // CraftBukkit start - EntityTeleportEvent event = CraftEventFactory.callEntityTeleportEvent(this.tamable, (double) x + 0.5D, (double) y, (double) z + 0.5D); + EntityTeleportEvent event = CraftEventFactory.callEntityTeleportEvent(this, (double) x + 0.5D, (double) y, (double) z + 0.5D); - if (event.isCancelled()) { -+ if (event.isCancelled() || event.getTo() == null) { // Paper ++ if (event.isCancelled() || event.getTo() == null) { // Paper - prevent NP on null event to location return false; } Location to = event.getTo(); diff --git a/src/main/java/net/minecraft/world/entity/monster/Shulker.java b/src/main/java/net/minecraft/world/entity/monster/Shulker.java -index c2005b86ac9ff6aa03ef7937c2b7a228addc4f01..bd6171d75fbf4a0debef3892d6f67356dc811b4d 100644 +index 632b74e84d6ee58da8806e30b75e16fb864afa64..bf58956379d0a5dbfdc34e8626847638b4111433 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Shulker.java +++ b/src/main/java/net/minecraft/world/entity/monster/Shulker.java @@ -415,7 +415,7 @@ public class Shulker extends AbstractGolem implements VariantHolder= 0, "Total experience points must not be negative (%s)", exp); this.getHandle().totalExperience = exp; } diff --git a/patches/unapplied/server/0938-Add-drops-to-shear-events.patch b/patches/server/0928-Add-drops-to-shear-events.patch similarity index 95% rename from patches/unapplied/server/0938-Add-drops-to-shear-events.patch rename to patches/server/0928-Add-drops-to-shear-events.patch index a271043b47..cdea107841 100644 --- a/patches/unapplied/server/0938-Add-drops-to-shear-events.patch +++ b/patches/server/0928-Add-drops-to-shear-events.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add drops to shear events diff --git a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java -index fbed5d57db0c0e79996f85571b9af0071fa953c7..a024c697a65bbab27408da1d6a75e531d9719b47 100644 +index f32f8d5cb22feb885a53d3b56c04ad4219d2bafa..44b79a7c2f8b95a484d1999fa2167ce588f7985b 100644 --- a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java -@@ -104,11 +104,14 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior { +@@ -103,11 +103,14 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior { if (entityliving instanceof Shearable ishearable) { if (ishearable.readyForShearing()) { // CraftBukkit start @@ -116,10 +116,10 @@ index aa125e3043b120935aaa015803f065f99eb8d050..0c21959f57ae88fcd0a4d6dc911c1ce3 } diff --git a/src/main/java/net/minecraft/world/entity/animal/Sheep.java b/src/main/java/net/minecraft/world/entity/animal/Sheep.java -index 784a89f39e0b243e2968dca33b60ae40e58d824e..3ce86f952a18cae7fda1903916903b31a63a40b4 100644 +index 6b26af41423110bd982eb8c0eea0cba5e9fdc633..38ac2759894660be1ee7ba59b0bd1270158e9232 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java +++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java -@@ -258,11 +258,18 @@ public class Sheep extends Animal implements Shearable { +@@ -256,11 +256,18 @@ public class Sheep extends Animal implements Shearable { if (itemstack.is(Items.SHEARS)) { if (!this.level().isClientSide && this.readyForShearing()) { // CraftBukkit start @@ -141,7 +141,7 @@ index 784a89f39e0b243e2968dca33b60ae40e58d824e..3ce86f952a18cae7fda1903916903b31 this.gameEvent(GameEvent.SHEAR, player); itemstack.hurtAndBreak(1, player, getSlotForHand(hand)); return InteractionResult.SUCCESS; -@@ -276,13 +283,30 @@ public class Sheep extends Animal implements Shearable { +@@ -274,13 +281,30 @@ public class Sheep extends Animal implements Shearable { @Override public void shear(SoundSource shearedSoundCategory) { @@ -233,7 +233,7 @@ index 2de1a2f666da9db1832907e1651dbff948e37252..5c2ed3c39c8eb850f3be1e2ea5b5a7ea } diff --git a/src/main/java/net/minecraft/world/entity/monster/Bogged.java b/src/main/java/net/minecraft/world/entity/monster/Bogged.java -index 9c0bfddd479eef688d2509ad700371c3c860ff1a..e9f9b041ae7195e9d23bd446454b1d8c47a1ace1 100644 +index 8420d75865b86e1d8afea2527b5521cac184e8b1..6e290d67b00c88ecd2cf2ce5f612f52ebda9e280 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Bogged.java +++ b/src/main/java/net/minecraft/world/entity/monster/Bogged.java @@ -135,6 +135,15 @@ public class Bogged extends AbstractSkeleton implements Shearable { @@ -243,20 +243,20 @@ index 9c0bfddd479eef688d2509ad700371c3c860ff1a..e9f9b041ae7195e9d23bd446454b1d8c + // Paper start - shear drops API + this.generateShearedMushrooms(stack -> { + this.forceDrops = true; -+ this.spawnAtLocation(stack); ++ this.spawnAtLocation(stack, this.getBbHeight()); + this.forceDrops = false; + }); + } + private void generateShearedMushrooms(java.util.function.Consumer stackConsumer) { + // Paper end - shear drops API - if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (this.level() instanceof ServerLevel serverLevel) { LootTable lootTable = serverLevel.getServer().reloadableRegistries().getLootTable(BuiltInLootTables.BOGGED_SHEAR); LootParams lootParams = new LootParams.Builder(serverLevel) @@ -143,11 +152,20 @@ public class Bogged extends AbstractSkeleton implements Shearable { .create(LootContextParamSets.SHEARING); for (ItemStack itemStack : lootTable.getRandomItems(lootParams)) { -- this.spawnAtLocation(itemStack); +- this.spawnAtLocation(itemStack, this.getBbHeight()); + stackConsumer.accept(itemStack); // Paper } } @@ -275,10 +275,10 @@ index 9c0bfddd479eef688d2509ad700371c3c860ff1a..e9f9b041ae7195e9d23bd446454b1d8c public boolean readyForShearing() { return !this.isSheared() && this.isAlive(); diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 8b322ade83e8e571af7c2e91a3c0d0784a7b9fad..e20feab675d05ae5b5b19870546585936c757970 100644 +index 54c9c19d773df01b0004da6587f7c7a388e61c21..a4ea5d942eb61ee733eb1b8b4a3c50fb93f037ea 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -1666,20 +1666,20 @@ public class CraftEventFactory { +@@ -1667,20 +1667,20 @@ public class CraftEventFactory { player.level().getCraftServer().getPluginManager().callEvent(event); } @@ -306,7 +306,7 @@ index 8b322ade83e8e571af7c2e91a3c0d0784a7b9fad..e20feab675d05ae5b5b1987054658593 public static Cancellable handleStatisticsIncrease(net.minecraft.world.entity.player.Player entityHuman, net.minecraft.stats.Stat statistic, int current, int newValue) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index 776437ae42865baccab4fb5d3f2715c8f0519b8a..520b637e0f281d3d3018681ec7b48b06c47f621e 100644 +index 0774711e3797c10526c65b7e5824a739c04597e7..94adc5c827c69f3cca08404faf0764ae91a9d1df 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -65,6 +65,16 @@ public final class CraftItemStack extends ItemStack { diff --git a/patches/unapplied/server/0939-Add-PlayerShieldDisableEvent.patch b/patches/server/0929-Add-PlayerShieldDisableEvent.patch similarity index 91% rename from patches/unapplied/server/0939-Add-PlayerShieldDisableEvent.patch rename to patches/server/0929-Add-PlayerShieldDisableEvent.patch index 0d87c9cbf7..f9d5404f63 100644 --- a/patches/unapplied/server/0939-Add-PlayerShieldDisableEvent.patch +++ b/patches/server/0929-Add-PlayerShieldDisableEvent.patch @@ -16,10 +16,10 @@ sideeffects, meaning the disable event cannot share a handlerlist with the cooldown event 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 32f6c029bf2f9a16d48ac73ff217c7462c64f175..9952da86af1a1a050e7485675ca2d6fb83d02422 100644 +index a77c2847a3bc161f0bf25eb4c78305ce18afd904..ffb888262ba81073062f6f513c36108688d0f158 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -989,7 +989,7 @@ public abstract class Player extends LivingEntity { +@@ -1004,7 +1004,7 @@ public abstract class Player extends LivingEntity { protected void blockUsingShield(LivingEntity attacker) { super.blockUsingShield(attacker); if (attacker.canDisableShield()) { @@ -28,7 +28,7 @@ index 32f6c029bf2f9a16d48ac73ff217c7462c64f175..9952da86af1a1a050e7485675ca2d6fb } } -@@ -1473,8 +1473,21 @@ public abstract class Player extends LivingEntity { +@@ -1499,8 +1499,21 @@ public abstract class Player extends LivingEntity { this.attack(target); } diff --git a/patches/unapplied/server/0940-Validate-ResourceLocation-in-NBT-reading.patch b/patches/server/0930-Validate-ResourceLocation-in-NBT-reading.patch similarity index 82% rename from patches/unapplied/server/0940-Validate-ResourceLocation-in-NBT-reading.patch rename to patches/server/0930-Validate-ResourceLocation-in-NBT-reading.patch index 80c525575b..46d92fed6d 100644 --- a/patches/unapplied/server/0940-Validate-ResourceLocation-in-NBT-reading.patch +++ b/patches/server/0930-Validate-ResourceLocation-in-NBT-reading.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Validate ResourceLocation in NBT reading diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index 1d7c20fe14882fdeddf315a8923669e3385652f5..f88dd37783b3c155c23b547c360b8d3c16e030c0 100644 +index 4929bac8e476664086470f078efce6c0a6164413..f88dd37783b3c155c23b547c360b8d3c16e030c0 100644 --- a/src/main/java/net/minecraft/nbt/NbtUtils.java +++ b/src/main/java/net/minecraft/nbt/NbtUtils.java @@ -149,8 +149,10 @@ public final class NbtUtils { if (!nbt.contains("Name", 8)) { return Blocks.AIR.defaultBlockState(); } else { -- ResourceLocation resourceLocation = new ResourceLocation(nbt.getString("Name")); +- ResourceLocation resourceLocation = ResourceLocation.parse(nbt.getString("Name")); - Optional> optional = blockLookup.get(ResourceKey.create(Registries.BLOCK, resourceLocation)); + // Paper start - Validate resource location + ResourceLocation resourceLocation = ResourceLocation.tryParse(nbt.getString("Name")); @@ -22,13 +22,13 @@ index 1d7c20fe14882fdeddf315a8923669e3385652f5..f88dd37783b3c155c23b547c360b8d3c return Blocks.AIR.defaultBlockState(); } else { diff --git a/src/main/java/net/minecraft/resources/ResourceLocation.java b/src/main/java/net/minecraft/resources/ResourceLocation.java -index d93b623ce973b63d4f3a77bfe459f51af7cb3c1c..2c4553312f2f37f8613ac813708b4b95f9675e9f 100644 +index 87afe84791af2d5e9f869cd4c09eed4bb5fee75b..1967c43ee3a12e63365cc40ee6565307e2fd73cf 100644 --- a/src/main/java/net/minecraft/resources/ResourceLocation.java +++ b/src/main/java/net/minecraft/resources/ResourceLocation.java -@@ -37,6 +37,13 @@ public class ResourceLocation implements Comparable { - private final String path; +@@ -41,6 +41,13 @@ public final class ResourceLocation implements Comparable { + + assert isValidPath(path); - protected ResourceLocation(String namespace, String path, @Nullable ResourceLocation.Dummy extraData) { + // Paper start - Validate ResourceLocation + // Check for the max network string length (capped at Short.MAX_VALUE) as well as the max bytes of a StringTag (length written as an unsigned short) + final String resourceLocation = namespace + ":" + path; @@ -40,40 +40,39 @@ index d93b623ce973b63d4f3a77bfe459f51af7cb3c1c..2c4553312f2f37f8613ac813708b4b95 this.path = path; } diff --git a/src/main/java/net/minecraft/world/RandomizableContainer.java b/src/main/java/net/minecraft/world/RandomizableContainer.java -index 68fadc351464dde459eb4cc86660cf9add40d04e..a9a80f8bc4a6f250fe3c20482c395058f024fabd 100644 +index 597cd5dbb4bb415a9b4d874c1c5dd621be1d6fc8..a9a80f8bc4a6f250fe3c20482c395058f024fabd 100644 --- a/src/main/java/net/minecraft/world/RandomizableContainer.java +++ b/src/main/java/net/minecraft/world/RandomizableContainer.java @@ -50,7 +50,7 @@ public interface RandomizableContainer extends Container { default boolean tryLoadLootTable(CompoundTag nbt) { if (nbt.contains("LootTable", 8)) { -- this.setLootTable(ResourceKey.create(Registries.LOOT_TABLE, new ResourceLocation(nbt.getString("LootTable")))); +- this.setLootTable(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("LootTable")))); + this.setLootTable(net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl))); // Paper - Validate ResourceLocation if (this.lootableData() != null && this.getLootTable() != null) this.lootableData().loadNbt(nbt); // Paper - LootTable API if (nbt.contains("LootTableSeed", 4)) { this.setLootTableSeed(nbt.getLong("LootTableSeed")); diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index 8c7cc9c5af0b8d8bef9b6e2d3d3e723cd76f3212..56b51096ca4147363a843accf6ef2510f05e8f1a 100644 +index b98f9246b60daf31460f41ce214dfa7c011f5684..842b0cec0397d7ae5166617627340ffac0e35db1 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java @@ -623,7 +623,7 @@ public class EntityType implements FeatureElement, EntityTypeT } public static Optional> by(CompoundTag nbt) { -- return BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id"))); +- return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.parse(nbt.getString("id"))); + return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id"))); // Paper - Validate ResourceLocation } @Nullable diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index b7af45eac986097ef53fa90bb4edd67f8829f13c..958b25e62b040943c346114ef19d56104ae0a844 100644 +index 0e8888ca5f8cde764efa9e2cda8c59e9ecb3190c..d535bb7adff273c9d4cdaac73f7dfe5bbd663c15 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -911,12 +911,13 @@ public abstract class LivingEntity extends Entity implements Attackable { - +@@ -886,11 +886,13 @@ public abstract class LivingEntity extends Entity implements Attackable { if (nbt.contains("SleepingX", 99) && nbt.contains("SleepingY", 99) && nbt.contains("SleepingZ", 99)) { BlockPos blockposition = new BlockPos(nbt.getInt("SleepingX"), nbt.getInt("SleepingY"), nbt.getInt("SleepingZ")); -- + + if (this.position().distanceToSqr(blockposition.getX(), blockposition.getY(), blockposition.getZ()) < 16 * 16) { // Paper - The sleeping pos will always also set the actual pos, so a desync suggests something is wrong this.setSleepingPos(blockposition); this.entityData.set(LivingEntity.DATA_POSE, Pose.SLEEPING); @@ -85,53 +84,53 @@ index b7af45eac986097ef53fa90bb4edd67f8829f13c..958b25e62b040943c346114ef19d5610 if (nbt.contains("Brain", 10)) { diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 5581fd6656fc13ea1d036d6caab2aba39c5320ac..748a6d81f409cf91a7aa2c88ded04f1d428cf0f6 100644 +index 56873752ae1ae0d2a36cb171d2de6884e15c01a5..5bac748649f43d74b13e7c0b4d355e67654ad59e 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -645,7 +645,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti - +@@ -605,7 +605,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + this.leashData = this.readLeashData(nbt); this.setLeftHanded(nbt.getBoolean("LeftHanded")); if (nbt.contains("DeathLootTable", 8)) { -- this.lootTable = ResourceKey.create(Registries.LOOT_TABLE, new ResourceLocation(nbt.getString("DeathLootTable"))); +- this.lootTable = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("DeathLootTable"))); + this.lootTable = net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("DeathLootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl)); // Paper - Validate ResourceLocation this.lootTableSeed = nbt.getLong("DeathLootTableSeed"); } diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -index f1bf129aecb6840d79c537338e4057557f07790b..5bc4ba7c055992a32197db96d86a3906c11900d8 100644 +index dfa44899529a7a9c32fe17fcb2091eab7d790f5a..56729d5c5f0cd383b22c127ebbb394c30bf95aa7 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -561,7 +561,7 @@ public abstract class AbstractArrow extends Projectile { +@@ -642,7 +642,7 @@ public abstract class AbstractArrow extends Projectile { this.setCritArrow(nbt.getBoolean("crit")); this.setPierceLevel(nbt.getByte("PierceLevel")); if (nbt.contains("SoundEvent", 8)) { -- this.soundEvent = (SoundEvent) BuiltInRegistries.SOUND_EVENT.getOptional(new ResourceLocation(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent()); +- this.soundEvent = (SoundEvent) BuiltInRegistries.SOUND_EVENT.getOptional(ResourceLocation.parse(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent()); + this.soundEvent = (SoundEvent) BuiltInRegistries.SOUND_EVENT.getOptional(ResourceLocation.tryParse(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent()); // Paper - Validate resource location } - this.setShotFromCrossbow(nbt.getBoolean("ShotFromCrossbow")); + if (nbt.contains("item", 10)) { diff --git a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java -index d976a6e3a79a01392a5033b05864d82782a30916..845eff7401b811c179dc9dee70eca0d724be5c80 100644 +index ccc7367ab2740bea0f2b907223a0920b11665092..845eff7401b811c179dc9dee70eca0d724be5c80 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java @@ -73,7 +73,7 @@ public interface ContainerEntity extends Container, MenuProvider { default void readChestVehicleSaveData(CompoundTag nbt, HolderLookup.Provider registriesLookup) { this.clearItemStacks(); if (nbt.contains("LootTable", 8)) { -- this.setLootTable(ResourceKey.create(Registries.LOOT_TABLE, new ResourceLocation(nbt.getString("LootTable")))); +- this.setLootTable(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("LootTable")))); + this.setLootTable(net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl))); // Paper - Validate ResourceLocation // Paper start - LootTable API if (this.getLootTable() != null) { this.lootableData().loadNbt(nbt); diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index f40b2582d9087f9dbb5cab950304698f33fdd879..a99fe191c429bb528209dd0f31b509acf9cccbb5 100644 +index 86667e93a86d84aabd05aa40a0a37a454ce7d290..2ebaf72d795b1d2f1f1ecebb2dae21a035f60d90 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -295,7 +295,12 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit while (iterator.hasNext()) { String s = (String) iterator.next(); -- this.recipesUsed.put(new ResourceLocation(s), nbttagcompound1.getInt(s)); +- this.recipesUsed.put(ResourceLocation.parse(s), nbttagcompound1.getInt(s)); + // Paper start - Validate ResourceLocation + final ResourceLocation resourceLocation = ResourceLocation.tryParse(s); + if (resourceLocation != null) { @@ -142,14 +141,14 @@ index f40b2582d9087f9dbb5cab950304698f33fdd879..a99fe191c429bb528209dd0f31b509ac // Paper start - cook speed multiplier API diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java -index f78a9698afc87408fc46de2d3d00c923500885f4..dc02a3d84b397f634f77f4df9c06e245cc4dcb75 100644 +index 32de29c385c784ab87e29b2e072f3992386cd775..dc02a3d84b397f634f77f4df9c06e245cc4dcb75 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java @@ -202,7 +202,7 @@ public class BrushableBlockEntity extends BlockEntity { private boolean tryLoadLootTable(CompoundTag nbt) { if (nbt.contains("LootTable", 8)) { -- this.lootTable = ResourceKey.create(Registries.LOOT_TABLE, new ResourceLocation(nbt.getString("LootTable"))); +- this.lootTable = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("LootTable"))); + this.lootTable = net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl)); // Paper - Validate ResourceLocation this.lootTableSeed = nbt.getLong("LootTableSeed"); return true; diff --git a/patches/unapplied/server/0941-Properly-handle-experience-dropping-on-block-break.patch b/patches/server/0931-Properly-handle-experience-dropping-on-block-break.patch similarity index 92% rename from patches/unapplied/server/0941-Properly-handle-experience-dropping-on-block-break.patch rename to patches/server/0931-Properly-handle-experience-dropping-on-block-break.patch index 3ee724786e..471a743c29 100644 --- a/patches/unapplied/server/0941-Properly-handle-experience-dropping-on-block-break.patch +++ b/patches/server/0931-Properly-handle-experience-dropping-on-block-break.patch @@ -7,10 +7,10 @@ This causes spawnAfterBreak to spawn xp by default, removing the need to manuall For classes that use custom xp amounts, they can drop the resources with disabling diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 2f018922fb12dc4c3c9c28c7b0597a2b97d1cb02..51c4877ffb77ece41e90d9c6ac06c04dc941e35c 100644 +index ffaf6e65a7314479a129fed41f58bf2d75ea5dae..16478e2b2368636394cec8a9b30c6fb03e190851 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -618,7 +618,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -619,7 +619,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { if (drop) { BlockEntity tileentity = iblockdata.hasBlockEntity() ? this.getBlockEntity(pos) : null; @@ -21,10 +21,10 @@ index 2f018922fb12dc4c3c9c28c7b0597a2b97d1cb02..51c4877ffb77ece41e90d9c6ac06c04d boolean flag1 = this.setBlock(pos, fluid.createLegacyBlock(), 3, maxUpdateDepth); diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java -index a757a45d423e1729c9374391df4186ae0522e1ac..7f0c0ca49e7575c18935b71e3180d112440289f7 100644 +index c083dc8b2a69c3747b250d13f1a28ad22b5e6119..bf52c36f31992a01a7403d8c85151327c9e944c4 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -313,23 +313,31 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -312,23 +312,31 @@ public class Block extends BlockBehaviour implements ItemLike { for (ItemStack drop : Block.getDrops(state, serverLevel, pos, blockEntity)) { items.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(drop)); } @@ -58,7 +58,7 @@ index a757a45d423e1729c9374391df4186ae0522e1ac..7f0c0ca49e7575c18935b71e3180d112 } } -@@ -413,7 +421,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -412,7 +420,7 @@ public class Block extends BlockBehaviour implements ItemLike { player.awardStat(Stats.BLOCK_MINED.get(this)); player.causeFoodExhaustion(0.005F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.BLOCK_MINED); // CraftBukkit - EntityExhaustionEvent if (includeDrops) { // Paper - fix drops not preventing stats/food exhaustion @@ -68,10 +68,10 @@ index a757a45d423e1729c9374391df4186ae0522e1ac..7f0c0ca49e7575c18935b71e3180d112 } diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -index c762a006b3f586b32209c20e85f6b8bf169dbd06..f87d9cb38caf3bf92fd32f2118f76799ede418db 100644 +index d261649aa1b7b351f325f9b752bb792f952f7b25..936b56c116de63b38a416d5bab4223a88d0469d0 100644 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -1118,6 +1118,7 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -1124,6 +1124,7 @@ public abstract class BlockBehaviour implements FeatureElement { public void spawnAfterBreak(ServerLevel world, BlockPos pos, ItemStack tool, boolean dropExperience) { this.getBlock().spawnAfterBreak(this.asState(), world, pos, tool, dropExperience); diff --git a/patches/unapplied/server/0942-Fixup-NamespacedKey-handling.patch b/patches/server/0932-Fixup-NamespacedKey-handling.patch similarity index 97% rename from patches/unapplied/server/0942-Fixup-NamespacedKey-handling.patch rename to patches/server/0932-Fixup-NamespacedKey-handling.patch index 3be8da25c8..95e2943521 100644 --- a/patches/unapplied/server/0942-Fixup-NamespacedKey-handling.patch +++ b/patches/server/0932-Fixup-NamespacedKey-handling.patch @@ -39,7 +39,7 @@ index 4f3f6ea43030853bd9df067358a1f4d16c40e6d4..531336c44c46555fef8c001fe8ca00c9 player.containerMenu.sendAllDataToRemote(); return false; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java -index 209c6b64e79c29ea3bb84ddbe89a8bff66f81d0f..1f90f4b3f310b8cf5750c3a581be178f19b979d2 100644 +index e34deaf398dc6722c3128bdd6b9bc16da2d33bf7..f028daa4f23a1f1868c9922991259739cadc5da2 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -38,7 +38,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { @@ -52,10 +52,10 @@ index 209c6b64e79c29ea3bb84ddbe89a8bff66f81d0f..1f90f4b3f310b8cf5750c3a581be178f public static NamespacedKey minecraftToBukkitKey(ResourceKey minecraft) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java -index 3adf18d5e736abff701a4866ee1f8403aeafca84..4a5778d1751b774c825bbce0e870e2998278afe3 100644 +index 334447e222d88bb24676bb154e7057a4147d0f41..d21b7e39d71c785f47f790e1ad4be33a8e8e6e51 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java -@@ -110,6 +110,16 @@ public class CraftRegistry implements Registry { +@@ -111,6 +111,16 @@ public class CraftRegistry implements Registry { + ", this can happen if a plugin creates its own registry entry with out properly registering it."); } @@ -156,7 +156,7 @@ index 82a50b06c08b632f77d73745e1fa9bd22dfd950a..f1d8ed4a2b8959873b02d57f6a40323a // Now also convert from when keys where saved return CraftRegistry.get(Registry.POTION, key, ApiVersion.CURRENT); diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java -index 5f40d240b879e3989897b6e45725a8e5a6a7f194..5014192edb9616ce725fc1592832034789527b6f 100644 +index dc88ba24ed3b0024c39a30c2d90628fc708d63cf..944bed9b6c803df1a312383fed9de7d61e7d2c70 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java @@ -13,7 +13,7 @@ public final class CraftNamespacedKey { diff --git a/patches/unapplied/server/0943-Expose-LootTable-of-DecoratedPot.patch b/patches/server/0933-Expose-LootTable-of-DecoratedPot.patch similarity index 100% rename from patches/unapplied/server/0943-Expose-LootTable-of-DecoratedPot.patch rename to patches/server/0933-Expose-LootTable-of-DecoratedPot.patch diff --git a/patches/unapplied/server/0944-Reduce-allocation-of-Vec3D-by-entity-tracker.patch b/patches/server/0934-Reduce-allocation-of-Vec3D-by-entity-tracker.patch similarity index 87% rename from patches/unapplied/server/0944-Reduce-allocation-of-Vec3D-by-entity-tracker.patch rename to patches/server/0934-Reduce-allocation-of-Vec3D-by-entity-tracker.patch index dc2cbd7a08..357d185f0a 100644 --- a/patches/unapplied/server/0944-Reduce-allocation-of-Vec3D-by-entity-tracker.patch +++ b/patches/server/0934-Reduce-allocation-of-Vec3D-by-entity-tracker.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Reduce allocation of Vec3D by entity tracker diff --git a/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java b/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java -index a3d247c93ac1a2d872ff0e3841efc3d7b84fcbc1..23fe7c4c1844d321efed6b7b886c422761ad6594 100644 +index a043ac10834562d357ef0b5aded2e916e2a0d056..74276c368016fcc4dbf9579b2ecbadc9614baf15 100644 --- a/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java +++ b/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java @@ -5,7 +5,7 @@ import org.jetbrains.annotations.VisibleForTesting; @@ -18,10 +18,10 @@ index a3d247c93ac1a2d872ff0e3841efc3d7b84fcbc1..23fe7c4c1844d321efed6b7b886c4227 @VisibleForTesting static long encode(double value) { diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 027f2734b0ff226437f4c94430215929b6ea2219..35f627c58e93c03ee58b44877398432bba57dc2d 100644 +index cf4517e57169856acd0782e5ced4eb8c045b8d78..6129720c9da217745fcd281186de7894597c267c 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1748,10 +1748,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1587,10 +1587,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public void updatePlayer(ServerPlayer player) { org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot if (player != this.entity) { @@ -39,10 +39,10 @@ index 027f2734b0ff226437f4c94430215929b6ea2219..35f627c58e93c03ee58b44877398432b boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z); // Paper start - Configurable entity tracking range by Y diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 0373b2de2b992b648f346d6df3960a3586a54567..22eec853588ded2d255ab69d408f8e987832abe2 100644 +index a2fbbbd7a66d4e7b1063638f8467e8887a417282..0e7ace92522fbd4cef7b2c2b8a0f8b86c2cce192 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -164,7 +164,13 @@ public class ServerEntity { +@@ -163,7 +163,13 @@ public class ServerEntity { i = Mth.floor(this.entity.getYRot() * 256.0F / 360.0F); j = Mth.floor(this.entity.getXRot() * 256.0F / 360.0F); Vec3 vec3d = this.entity.trackingPosition(); @@ -56,4 +56,4 @@ index 0373b2de2b992b648f346d6df3960a3586a54567..22eec853588ded2d255ab69d408f8e98 + // Paper end - reduce allocation of Vec3D here Packet packet1 = null; boolean flag2 = flag1 || this.tickCount % 60 == 0; - boolean flag3 = Math.abs(i - this.yRotp) >= 1 || Math.abs(j - this.xRotp) >= 1; + boolean flag3 = Math.abs(i - this.lastSentYRot) >= 1 || Math.abs(j - this.lastSentXRot) >= 1; diff --git a/patches/unapplied/server/0945-Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch b/patches/server/0935-Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch similarity index 98% rename from patches/unapplied/server/0945-Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch rename to patches/server/0935-Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch index 7d75e1147a..a58beffec5 100644 --- a/patches/unapplied/server/0945-Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch +++ b/patches/server/0935-Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Add PlayerTradeEvent and PlayerPurchaseEvent Co-authored-by: Alexander diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java -index 6e29b5729b8184d13065c9c4e18f6e450c9d88a6..d323cf157f2a910916baa9ce3f7e5bc81648c47d 100644 +index 6139361c0e733f981506abdd7101e5ca20eeb88f..49b35fab8ee98a384ee12d36bbe2ac813342f1d6 100644 --- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -139,11 +139,24 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa +@@ -143,11 +143,24 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa @Override public void overrideXp(int experience) {} diff --git a/patches/unapplied/server/0946-Add-ShulkerDuplicateEvent.patch b/patches/server/0936-Add-ShulkerDuplicateEvent.patch similarity index 93% rename from patches/unapplied/server/0946-Add-ShulkerDuplicateEvent.patch rename to patches/server/0936-Add-ShulkerDuplicateEvent.patch index 37ba1cb428..de864137e2 100644 --- a/patches/unapplied/server/0946-Add-ShulkerDuplicateEvent.patch +++ b/patches/server/0936-Add-ShulkerDuplicateEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add ShulkerDuplicateEvent diff --git a/src/main/java/net/minecraft/world/entity/monster/Shulker.java b/src/main/java/net/minecraft/world/entity/monster/Shulker.java -index bd6171d75fbf4a0debef3892d6f67356dc811b4d..e03119f88719c8d6d44793a6b3706ae97b2da307 100644 +index bf58956379d0a5dbfdc34e8626847638b4111433..920c7a92643e83598f39bf984cca430d9deed2cd 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Shulker.java +++ b/src/main/java/net/minecraft/world/entity/monster/Shulker.java @@ -491,6 +491,11 @@ public class Shulker extends AbstractGolem implements VariantHolder waveSpawnPos; @@ -22,7 +22,7 @@ index 364d233ca318bbf8c1bc3acfbaf2d2420fdf922f..fdff9788eaf663be79214b2ca491f0f0 public Raid(int id, ServerLevel world, BlockPos pos) { this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); -@@ -153,6 +158,11 @@ public class Raid { +@@ -150,6 +155,11 @@ public class Raid { this.heroesOfTheVillage.add(NbtUtils.loadUUID(nbtbase)); } } @@ -34,7 +34,7 @@ index 364d233ca318bbf8c1bc3acfbaf2d2420fdf922f..fdff9788eaf663be79214b2ca491f0f0 } -@@ -870,6 +880,11 @@ public class Raid { +@@ -867,6 +877,11 @@ public class Raid { } nbt.put("HeroesOfTheVillage", nbttaglist); @@ -86,7 +86,7 @@ index b8ce1c1c2447f9cff1717bfcfd6eb911ade0d4b3..51f21af9d75769abdcba713b9aa33392 + // Paper end - more Raid API } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 2536a37ab9e5a7aa7373b1880f55cdb8c32a6f53..44ed6bd76fb9e81f6c0d99fe46173685dbbfe2a7 100644 +index cb0f59def0d5ad6e2f80ebe024f12efad9a8d164..951130f8d530b84c96fb8df15122fc570cfe2a47 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -2398,6 +2398,14 @@ public class CraftWorld extends CraftRegionAccessor implements World { diff --git a/patches/unapplied/server/0959-Add-onboarding-message-for-initial-server-start.patch b/patches/server/0949-Add-onboarding-message-for-initial-server-start.patch similarity index 97% rename from patches/unapplied/server/0959-Add-onboarding-message-for-initial-server-start.patch rename to patches/server/0949-Add-onboarding-message-for-initial-server-start.patch index ef61e377b2..af83047339 100644 --- a/patches/unapplied/server/0959-Add-onboarding-message-for-initial-server-start.patch +++ b/patches/server/0949-Add-onboarding-message-for-initial-server-start.patch @@ -29,10 +29,10 @@ index ab5089781b8866cd6ad1b9570634ba84d936cfe7..4de88f74182bb596c6b5ad0351cc0dac return instance; } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 2a92268dfc8ee264e4ee6ffc56b40a87e334acc8..1a9e323659dcff12ce53919eb3d6d6f66f835292 100644 +index b7254c342501f2d7fbbe8959a6e88a5d1f6e076e..837fc12dfc57f36f06bd8e49681bb4b98a87397c 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1129,6 +1129,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop modifiers, Map> modifierFunctions, boolean cancelled) { CraftDamageSource bukkitDamageSource = new CraftDamageSource(source); diff --git a/patches/unapplied/server/0965-Fix-creation-of-invalid-block-entity-during-world-ge.patch b/patches/server/0955-Fix-creation-of-invalid-block-entity-during-world-ge.patch similarity index 90% rename from patches/unapplied/server/0965-Fix-creation-of-invalid-block-entity-during-world-ge.patch rename to patches/server/0955-Fix-creation-of-invalid-block-entity-during-world-ge.patch index 2b1eed9161..fe74841e18 100644 --- a/patches/unapplied/server/0965-Fix-creation-of-invalid-block-entity-during-world-ge.patch +++ b/patches/server/0955-Fix-creation-of-invalid-block-entity-during-world-ge.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix creation of invalid block entity during world generation diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -index a59eece9c7a8c33cb8ce963906e993c3462684fb..386fbf79afe91af445f54aeab7d1296d1407a4d8 100644 +index 682c8cfbd917c086072f1756861a340800ea40da..b26a4a38144ec1b171db911bbf949b53ed35708f 100644 --- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java +++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -@@ -323,7 +323,7 @@ public class WorldGenRegion implements WorldGenLevel { +@@ -324,7 +324,7 @@ public class WorldGenRegion implements WorldGenLevel { return false; } else { ChunkAccess ichunkaccess = this.getChunk(pos); @@ -17,7 +17,7 @@ index a59eece9c7a8c33cb8ce963906e993c3462684fb..386fbf79afe91af445f54aeab7d1296d if (iblockdata1 != null) { this.level.onBlockStateChange(pos, iblockdata1, state); -@@ -339,6 +339,17 @@ public class WorldGenRegion implements WorldGenLevel { +@@ -340,6 +340,17 @@ public class WorldGenRegion implements WorldGenLevel { ichunkaccess.removeBlockEntity(pos); } } else { @@ -36,10 +36,10 @@ index a59eece9c7a8c33cb8ce963906e993c3462684fb..386fbf79afe91af445f54aeab7d1296d nbttagcompound.putInt("x", pos.getX()); diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index 744db9eec4f7bdeb32f83300960a7fce63b393d8..8de6ad8b131061b2dae440dff71e2e6e7af2de39 100644 +index cda4413901fb465a855396e42356adaadefd4195..849efe41ff14be1fc95789b083e340363cbc93ab 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -1071,9 +1071,14 @@ public class LevelChunk extends ChunkAccess { +@@ -1081,9 +1081,14 @@ public class LevelChunk extends ChunkAccess { if (this.blockEntity.getType().isValid(iblockdata)) { this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), iblockdata, this.blockEntity); this.loggedInvalidBlockState = false; diff --git a/patches/unapplied/server/0966-Fix-possible-StackOverflowError-for-some-dispenses.patch b/patches/server/0956-Fix-possible-StackOverflowError-for-some-dispenses.patch similarity index 90% rename from patches/unapplied/server/0966-Fix-possible-StackOverflowError-for-some-dispenses.patch rename to patches/server/0956-Fix-possible-StackOverflowError-for-some-dispenses.patch index 21910b922f..5a6627392e 100644 --- a/patches/unapplied/server/0966-Fix-possible-StackOverflowError-for-some-dispenses.patch +++ b/patches/server/0956-Fix-possible-StackOverflowError-for-some-dispenses.patch @@ -14,10 +14,10 @@ Additionally equippable mob heads, wither skulls, and carved pumpkins are subject to the same possible error. diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -index 4fa838bf97ede6e1c893ba64f53aa7af5db0405a..32084df594649d8da04052bbfa111896d8ea1f91 100644 +index 7826e2a52da47914aca39fef958b8f398a2ff937..f96734580a29e0436ac808e41c6cbc3f35eff5f5 100644 --- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -238,7 +238,7 @@ public interface DispenseItemBehavior { +@@ -239,7 +239,7 @@ public interface DispenseItemBehavior { // Chain to handler for new item ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -26,7 +26,7 @@ index 4fa838bf97ede6e1c893ba64f53aa7af5db0405a..32084df594649d8da04052bbfa111896 idispensebehavior.dispense(pointer, eventStack); return stack; } -@@ -294,7 +294,7 @@ public interface DispenseItemBehavior { +@@ -295,7 +295,7 @@ public interface DispenseItemBehavior { // Chain to handler for new item ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -35,7 +35,7 @@ index 4fa838bf97ede6e1c893ba64f53aa7af5db0405a..32084df594649d8da04052bbfa111896 idispensebehavior.dispense(pointer, eventStack); return stack; } -@@ -368,7 +368,7 @@ public interface DispenseItemBehavior { +@@ -369,7 +369,7 @@ public interface DispenseItemBehavior { // Chain to handler for new item ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); @@ -44,7 +44,7 @@ index 4fa838bf97ede6e1c893ba64f53aa7af5db0405a..32084df594649d8da04052bbfa111896 idispensebehavior.dispense(pointer, eventStack); return stack; } -@@ -710,7 +710,7 @@ public interface DispenseItemBehavior { +@@ -690,7 +690,7 @@ public interface DispenseItemBehavior { OptionalDispenseItemBehavior dispensebehaviormaybe1 = new OptionalDispenseItemBehavior() { @Override protected ItemStack execute(BlockSource pointer, ItemStack stack) { @@ -53,7 +53,7 @@ index 4fa838bf97ede6e1c893ba64f53aa7af5db0405a..32084df594649d8da04052bbfa111896 return stack; } }; -@@ -764,7 +764,7 @@ public interface DispenseItemBehavior { +@@ -744,7 +744,7 @@ public interface DispenseItemBehavior { stack.shrink(1); this.setSuccess(true); } else { @@ -62,7 +62,7 @@ index 4fa838bf97ede6e1c893ba64f53aa7af5db0405a..32084df594649d8da04052bbfa111896 } return stack; -@@ -810,7 +810,7 @@ public interface DispenseItemBehavior { +@@ -790,7 +790,7 @@ public interface DispenseItemBehavior { stack.shrink(1); this.setSuccess(true); } else { @@ -72,10 +72,10 @@ index 4fa838bf97ede6e1c893ba64f53aa7af5db0405a..32084df594649d8da04052bbfa111896 return stack; diff --git a/src/main/java/net/minecraft/world/item/ArmorItem.java b/src/main/java/net/minecraft/world/item/ArmorItem.java -index e766397aae3f73548b290b0809b9d1ca0967ea39..786e4a8700cb84b16dd9b8892a0d1d5803924d81 100644 +index fb518f87cc4ccd810fb32cade2fdd7e09ab0abfc..647a4601deace52f8d855f512a73671f82b4762a 100644 --- a/src/main/java/net/minecraft/world/item/ArmorItem.java +++ b/src/main/java/net/minecraft/world/item/ArmorItem.java -@@ -48,14 +48,20 @@ public class ArmorItem extends Item implements Equipable { +@@ -39,14 +39,20 @@ public class ArmorItem extends Item implements Equipable { public static final DispenseItemBehavior DISPENSE_ITEM_BEHAVIOR = new DefaultDispenseItemBehavior() { @Override protected ItemStack execute(BlockSource pointer, ItemStack stack) { @@ -97,7 +97,7 @@ index e766397aae3f73548b290b0809b9d1ca0967ea39..786e4a8700cb84b16dd9b8892a0d1d58 BlockPos blockposition = pointer.pos().relative((Direction) pointer.state().getValue(DispenserBlock.FACING)); List list = pointer.level().getEntitiesOfClass(LivingEntity.class, new AABB(blockposition), EntitySelector.NO_SPECTATORS.and(new EntitySelector.MobCanWearArmorEntitySelector(armor))); -@@ -86,7 +92,7 @@ public class ArmorItem extends Item implements Equipable { +@@ -77,7 +83,7 @@ public class ArmorItem extends Item implements Equipable { // Chain to handler for new item ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem()); diff --git a/patches/unapplied/server/0967-Improve-tag-parser-handling.patch b/patches/server/0957-Improve-tag-parser-handling.patch similarity index 97% rename from patches/unapplied/server/0967-Improve-tag-parser-handling.patch rename to patches/server/0957-Improve-tag-parser-handling.patch index 702d71c5bd..b0e14e3bf0 100644 --- a/patches/unapplied/server/0967-Improve-tag-parser-handling.patch +++ b/patches/server/0957-Improve-tag-parser-handling.patch @@ -169,10 +169,10 @@ index 898b19887ed34c87003fc63cb5905df2ba6234a5..b47eeb23055b135d5567552ba983bfbc private void write(FriendlyByteBuf buf) { diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index bead9625a04a9c1139c54d6a56f055b80eb2d701..34d4243fb5198e36ea3291ffe8ed2480bc960cdb 100644 +index 42d3bbfc39444e2a26adb0c72e5895acba0a45ed..9116d0c89fc84ee79d2d0b81ade77264c362c25d 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -763,6 +763,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -766,6 +766,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl return; } // Paper end - Don't suggest if tab-complete is disabled @@ -186,7 +186,7 @@ index bead9625a04a9c1139c54d6a56f055b80eb2d701..34d4243fb5198e36ea3291ffe8ed2480 // Paper start - AsyncTabCompleteEvent TAB_COMPLETE_EXECUTOR.execute(() -> this.handleCustomCommandSuggestions0(packet)); } -@@ -815,6 +822,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -818,6 +825,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl private void sendServerSuggestions(final ServerboundCommandSuggestionPacket packet, final StringReader stringreader) { // Paper end - AsyncTabCompleteEvent ParseResults parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); diff --git a/patches/unapplied/server/0968-Item-Mutation-Fixes.patch b/patches/server/0958-Item-Mutation-Fixes.patch similarity index 85% rename from patches/unapplied/server/0968-Item-Mutation-Fixes.patch rename to patches/server/0958-Item-Mutation-Fixes.patch index 1a3a62c7da..0e20a90a87 100644 --- a/patches/unapplied/server/0968-Item-Mutation-Fixes.patch +++ b/patches/server/0958-Item-Mutation-Fixes.patch @@ -5,31 +5,31 @@ Subject: [PATCH] Item Mutation Fixes diff --git a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java -index 2f62957e061f513e01ec617f22791a7f27d65f02..480d093105073edfd3acdd7b079b4ca5aa5fdc6d 100644 +index c1b9c3ad2cccfa520e9d73b786142624ac5f3380..07223046761cb2186d75de8edc03a91d2e8e8b2f 100644 --- a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java +++ b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java -@@ -228,7 +228,7 @@ public class EnchantmentMenu extends AbstractContainerMenu { +@@ -235,7 +235,7 @@ public class EnchantmentMenu extends AbstractContainerMenu { return false; } else if (this.costs[id] > 0 && !itemstack.isEmpty() && (player.experienceLevel >= j && player.experienceLevel >= this.costs[id] || player.getAbilities().instabuild)) { this.access.execute((world, blockposition) -> { - ItemStack itemstack2 = itemstack; + ItemStack itemstack2 = itemstack; // Paper - diff on change - List list = this.getEnchantmentList(world.enabledFeatures(), itemstack, id, this.costs[id]); + List list = this.getEnchantmentList(world.registryAccess(), itemstack, id, this.costs[id]); // CraftBukkit start -@@ -250,10 +250,16 @@ public class EnchantmentMenu extends AbstractContainerMenu { +@@ -258,10 +258,16 @@ public class EnchantmentMenu extends AbstractContainerMenu { return; } // CraftBukkit end - if (itemstack.is(Items.BOOK)) { -- itemstack2 = itemstack.transmuteCopy(Items.ENCHANTED_BOOK, 1); +- itemstack2 = itemstack.transmuteCopy(Items.ENCHANTED_BOOK); + // Paper start + itemstack2 = org.bukkit.craftbukkit.inventory.CraftItemStack.getOrCloneOnMutation(item, event.getItem()); + if (itemstack2 != itemstack) { this.enchantSlots.setItem(0, itemstack2); } + if (itemstack2.is(Items.BOOK)) { -+ itemstack2 = itemstack2.transmuteCopy(Items.ENCHANTED_BOOK, 1); ++ itemstack2 = itemstack2.transmuteCopy(Items.ENCHANTED_BOOK); + this.enchantSlots.setItem(0, itemstack2); + } + // Paper end