From 1db3411c0e1552341b18f6854d9d42f89677df96 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Wed, 24 Apr 2024 20:40:32 -0700
Subject: [PATCH] compile fixes

compile fixes

compile fixes
---
 patches/server/Add-Destroy-Speed-API.patch    |  2 +-
 ...ackByEntityEvent-and-EntityPushedByE.patch | 13 ++++++++
 patches/server/Add-TNTPrimeEvent.patch        |  2 +-
 .../server/Add-drops-to-shear-events.patch    |  8 ++---
 patches/server/Adventure.patch                |  2 +-
 ...llow-delegation-to-vanilla-chunk-gen.patch | 28 ++++++++---------
 patches/server/Book-Size-Limits.patch         |  2 +-
 ...nfigurable-Region-Compression-Format.patch |  2 +-
 ...ate-HoverEvent-from-ItemStack-Entity.patch |  3 ++
 patches/server/Custom-Potion-Mixes.patch      |  2 +-
 ...place-methods-with-old-StructureType.patch |  2 +-
 .../Do-not-load-chunks-for-Pathfinding.patch  |  2 +-
 ...-allowed-colored-signs-to-be-created.patch |  4 +--
 ...Folia-scheduler-and-owned-region-API.patch |  2 +-
 patches/server/Friction-API.patch             |  2 +-
 .../Implement-enchantWithLevels-API.patch     | 12 ++++++--
 patches/server/ItemStack-damage-API.patch     |  6 +---
 patches/server/MC-Utils.patch                 | 30 +++++++++----------
 patches/server/More-World-API.patch           |  2 +-
 ...Timer-for-Wandering-Traders-spawned-.patch |  2 +-
 20 files changed, 73 insertions(+), 55 deletions(-)

diff --git a/patches/server/Add-Destroy-Speed-API.patch b/patches/server/Add-Destroy-Speed-API.patch
index c2a4f4d919..fca8b7972c 100644
--- a/patches/server/Add-Destroy-Speed-API.patch
+++ b/patches/server/Add-Destroy-Speed-API.patch
@@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.unwrap(itemStack);
 +        float speed = nmsItemStack.getDestroySpeed(this.state);
 +        if (speed > 1.0F && considerEnchants) {
-+            int enchantLevel = net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.BLOCK_EFFICIENCY, nmsItemStack);
++            int enchantLevel = net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.EFFICIENCY, nmsItemStack);
 +            if (enchantLevel > 0) {
 +                speed += enchantLevel * enchantLevel + 1;
 +            }
diff --git a/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch b/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch
index 6fabb6da6a..932110843b 100644
--- a/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch
+++ b/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch
@@ -204,6 +204,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
                      }
                  }
  
+diff --git a/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java b/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java
++++ b/src/main/java/net/minecraft/world/entity/projectile/windcharge/AbstractWindCharge.java
+@@ -0,0 +0,0 @@ public abstract class AbstractWindCharge extends AbstractHurtingProjectile imple
+     }
+ 
+     @Override
+-    public void push(double deltaX, double deltaY, double deltaZ) {}
++    public void push(double deltaX, double deltaY, double deltaZ, @org.jetbrains.annotations.Nullable Entity pushingEntity) {} // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
+ 
+     public abstract void explode();
+ 
 diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/level/Explosion.java
diff --git a/patches/server/Add-TNTPrimeEvent.patch b/patches/server/Add-TNTPrimeEvent.patch
index 501a2c22aa..ff71cf714e 100644
--- a/patches/server/Add-TNTPrimeEvent.patch
+++ b/patches/server/Add-TNTPrimeEvent.patch
@@ -96,7 +96,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +            // 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 InteractionResult.FAIL;
++                return ItemInteractionResult.FAIL;
 +            }
 +            // Paper end - TNTPrimeEvent
              TntBlock.explode(world, pos, player);
diff --git a/patches/server/Add-drops-to-shear-events.patch b/patches/server/Add-drops-to-shear-events.patch
index 1d340c81a0..7893e47a4e 100644
--- a/patches/server/Add-drops-to-shear-events.patch
+++ b/patches/server/Add-drops-to-shear-events.patch
@@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 -            if (!CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemstack, hand)) {
 -                return InteractionResult.PASS;
 +            // Paper start - custom shear drops
-+            List<ItemStack> drops = this.generateDefaultDrops();
++            java.util.List<ItemStack> drops = this.generateDefaultDrops();
 +            org.bukkit.event.player.PlayerShearEntityEvent event = CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemstack, hand, drops);
 +            if (event != null) {
 +                if (event.isCancelled()) {
@@ -78,8 +78,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    }
 +
 +    @Override
-+    public List<ItemStack> generateDefaultDrops() {
-+        List<ItemStack> dropEntities = new java.util.ArrayList<>(5);
++    public java.util.List<ItemStack> generateDefaultDrops() {
++        java.util.List<ItemStack> dropEntities = new java.util.ArrayList<>(5);
 +        for (int i = 0; i < 5; ++i) {
 +            dropEntities.add(new ItemStack(this.getVariant().getBlockState().getBlock()));
 +        }
@@ -87,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    }
 +
 +    @Override
-+    public void shear(SoundSource shearedSoundCategory, List<ItemStack> drops) { // If drops is null, need to generate drops
++    public void shear(SoundSource shearedSoundCategory, java.util.List<ItemStack> drops) { // If drops is null, need to generate drops
 +        // Paper end - custom shear drops
          this.level().playSound((Player) null, (Entity) this, SoundEvents.MOOSHROOM_SHEAR, shearedSoundCategory, 1.0F, 1.0F);
          if (!this.level().isClientSide()) {
diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch
index 240670230b..ef4202badd 100644
--- a/patches/server/Adventure.patch
+++ b/patches/server/Adventure.patch
@@ -4766,7 +4766,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    // Paper start - Adventure
 +    @Override
 +    public net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowItem> asHoverEvent(final ItemStack item, final java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowItem> op) {
-+        return net.kyori.adventure.text.event.HoverEvent.showItem(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowItem.showItem(item.getType().getKey(), item.getAmount(), io.papermc.paper.adventure.PaperAdventure.asAdventure(CraftItemStack.asNMSCopy(item)))));
++        return net.kyori.adventure.text.event.HoverEvent.showItem(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowItem.showItem(item.getType().getKey(), item.getAmount(), io.papermc.paper.adventure.PaperAdventure.asAdventure(CraftItemStack.asNMSCopy(item).getComponentsPatch()))));
 +    }
 +
 +    @Override
diff --git a/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch b/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch
index 9419bd139c..c08bbc8b85 100644
--- a/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch
+++ b/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch
@@ -13,17 +13,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      }
  
 +    // Paper start - Allow delegation to vanilla chunk gen
-+    private static final List<net.minecraft.world.level.chunk.ChunkStatus> VANILLA_GEN_STATUSES = List.of(
-+        net.minecraft.world.level.chunk.ChunkStatus.EMPTY,
-+        net.minecraft.world.level.chunk.ChunkStatus.STRUCTURE_STARTS,
-+        net.minecraft.world.level.chunk.ChunkStatus.STRUCTURE_REFERENCES,
-+        net.minecraft.world.level.chunk.ChunkStatus.BIOMES,
-+        net.minecraft.world.level.chunk.ChunkStatus.NOISE,
-+        net.minecraft.world.level.chunk.ChunkStatus.SURFACE,
-+        net.minecraft.world.level.chunk.ChunkStatus.CARVERS,
-+        net.minecraft.world.level.chunk.ChunkStatus.FEATURES,
-+        net.minecraft.world.level.chunk.ChunkStatus.INITIALIZE_LIGHT,
-+        net.minecraft.world.level.chunk.ChunkStatus.LIGHT
++    private static final List<net.minecraft.world.level.chunk.status.ChunkStatus> VANILLA_GEN_STATUSES = List.of(
++        net.minecraft.world.level.chunk.status.ChunkStatus.EMPTY,
++        net.minecraft.world.level.chunk.status.ChunkStatus.STRUCTURE_STARTS,
++        net.minecraft.world.level.chunk.status.ChunkStatus.STRUCTURE_REFERENCES,
++        net.minecraft.world.level.chunk.status.ChunkStatus.BIOMES,
++        net.minecraft.world.level.chunk.status.ChunkStatus.NOISE,
++        net.minecraft.world.level.chunk.status.ChunkStatus.SURFACE,
++        net.minecraft.world.level.chunk.status.ChunkStatus.CARVERS,
++        net.minecraft.world.level.chunk.status.ChunkStatus.FEATURES,
++        net.minecraft.world.level.chunk.status.ChunkStatus.INITIALIZE_LIGHT,
++        net.minecraft.world.level.chunk.status.ChunkStatus.LIGHT
 +    );
 +
 +    @Override
@@ -52,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +            net.minecraft.Util.backgroundExecutor(),
 +            "CraftServer#createVanillaChunkData(worldName='" + world.getName() + "', x='" + x + "', z='" + z + "')"
 +        );
-+        for (final net.minecraft.world.level.chunk.ChunkStatus chunkStatus : VANILLA_GEN_STATUSES) {
++        for (final net.minecraft.world.level.chunk.status.ChunkStatus chunkStatus : VANILLA_GEN_STATUSES) {
 +            final List<net.minecraft.world.level.chunk.ChunkAccess> chunks = Lists.newArrayList();
 +            final int statusRange = Math.max(1, chunkStatus.getRange());
 +
@@ -79,8 +79,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +                },
 +                chunks
 +            ).thenAccept(either -> {
-+                if (chunkStatus == net.minecraft.world.level.chunk.ChunkStatus.NOISE) {
-+                    either.left().ifPresent(chunk -> net.minecraft.world.level.levelgen.Heightmap.primeHeightmaps(chunk, net.minecraft.world.level.chunk.ChunkStatus.POST_FEATURES));
++                if (chunkStatus == net.minecraft.world.level.chunk.status.ChunkStatus.NOISE) {
++                    either.left().ifPresent(chunk -> net.minecraft.world.level.levelgen.Heightmap.primeHeightmaps(chunk, net.minecraft.world.level.chunk.status.ChunkStatus.POST_FEATURES));
 +                }
 +            }).join();
 +        }
diff --git a/patches/server/Book-Size-Limits.patch b/patches/server/Book-Size-Limits.patch
index 315d8243b0..7861c9e0ad 100644
--- a/patches/server/Book-Size-Limits.patch
+++ b/patches/server/Book-Size-Limits.patch
@@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      public void handleEditBook(ServerboundEditBookPacket packet) {
 +        // Paper start - Book size limits
 +        if (!this.cserver.isPrimaryThread()) {
-+            List<String> pageList = packet.getPages();
++            List<String> pageList = packet.pages();
 +            long byteTotal = 0;
 +            int maxBookPageSize = io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.pageMax;
 +            double multiplier = Math.max(0.3D, Math.min(1D, io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.totalMultiplier));
diff --git a/patches/server/Configurable-Region-Compression-Format.patch b/patches/server/Configurable-Region-Compression-Format.patch
index 97d8d01900..58461d36b3 100644
--- a/patches/server/Configurable-Region-Compression-Format.patch
+++ b/patches/server/Configurable-Region-Compression-Format.patch
@@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
      public RegionFile(RegionStorageInfo storageKey, Path directory, Path path, boolean dsync) throws IOException {
 -        this(storageKey, directory, path, RegionFileVersion.getSelected(), dsync);
-+        this(file, directory, RegionFileVersion.getCompressionFormat(), dsync); // Paper - Configurable region compression format
++        this(storageKey, directory, path, RegionFileVersion.getCompressionFormat(), dsync); // Paper - Configurable region compression format
      }
  
      public RegionFile(RegionStorageInfo storageKey, Path path, Path directory, RegionFileVersion compressionFormat, boolean dsync) throws IOException {
diff --git a/patches/server/Create-HoverEvent-from-ItemStack-Entity.patch b/patches/server/Create-HoverEvent-from-ItemStack-Entity.patch
index 340b54bb11..e133374ad7 100644
--- a/patches/server/Create-HoverEvent-from-ItemStack-Entity.patch
+++ b/patches/server/Create-HoverEvent-from-ItemStack-Entity.patch
@@ -16,11 +16,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    // Paper start - bungee hover events
 +    @Override
 +    public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(ItemStack itemStack) {
++        throw new UnsupportedOperationException("BungeeCord Chat API does not support data components");
++        /*
 +        net.md_5.bungee.api.chat.ItemTag itemTag = net.md_5.bungee.api.chat.ItemTag.ofNbt(CraftItemStack.asNMSCopy(itemStack).getOrCreateTag().toString());
 +        return new net.md_5.bungee.api.chat.hover.content.Item(
 +            itemStack.getType().getKey().toString(),
 +            itemStack.getAmount(),
 +            itemTag);
++         */
 +    }
 +
 +    @Override
diff --git a/patches/server/Custom-Potion-Mixes.patch b/patches/server/Custom-Potion-Mixes.patch
index 297671bdd0..a374dec926 100644
--- a/patches/server/Custom-Potion-Mixes.patch
+++ b/patches/server/Custom-Potion-Mixes.patch
@@ -179,7 +179,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      private final io.papermc.paper.datapack.PaperDatapackManager datapackManager; // Paper
      public static Exception excessiveVelEx; // Paper - Velocity warnings
      private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper
-+    private final CraftPotionBrewer potionBrewer = new CraftPotionBrewer(); // Paper - Custom Potion Mixes
++    private final org.bukkit.craftbukkit.potion.CraftPotionBrewer potionBrewer = new org.bukkit.craftbukkit.potion.CraftPotionBrewer(); // Paper - Custom Potion Mixes
  
      static {
          ConfigurationSerialization.registerClass(CraftOfflinePlayer.class);
diff --git a/patches/server/Deprecate-and-replace-methods-with-old-StructureType.patch b/patches/server/Deprecate-and-replace-methods-with-old-StructureType.patch
index 431d3256f1..40479eb09e 100644
--- a/patches/server/Deprecate-and-replace-methods-with-old-StructureType.patch
+++ b/patches/server/Deprecate-and-replace-methods-with-old-StructureType.patch
@@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        net.minecraft.world.item.ItemStack stack = MapItem.create(worldServer, structurePosition.getX(), structurePosition.getZ(), MapView.Scale.NORMAL.getValue(), true, true);
 +        MapItem.renderBiomePreviewMap(worldServer, stack);
 +        // "+" map ID taken from VillagerTrades$TreasureMapForEmeralds
-+        MapItem.getSavedData(stack, worldServer).addTargetDecoration(stack, structurePosition, "+", MapDecoration.Type.byIcon(mapIcon.getValue()));
++        MapItem.getSavedData(stack, worldServer).addTargetDecoration(stack, structurePosition, "+", CraftMapCursor.CraftType.bukkitToMinecraftHolder(mapIcon));
 +
 +        return CraftItemStack.asBukkitCopy(stack);
 +    }
diff --git a/patches/server/Do-not-load-chunks-for-Pathfinding.patch b/patches/server/Do-not-load-chunks-for-Pathfinding.patch
index 7377aa2c08..058661dbd1 100644
--- a/patches/server/Do-not-load-chunks-for-Pathfinding.patch
+++ b/patches/server/Do-not-load-chunks-for-Pathfinding.patch
@@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        // Paper start - Do not load chunks during pathfinding
 +        BlockState blockState = world.getBlockStateIfLoaded(pos);
 +        if (blockState == null) {
-+            return BlockPathTypes.BLOCKED;
++            return PathType.BLOCKED;
 +        }
 +        // Paper end
          Block block = blockState.getBlock();
diff --git a/patches/server/Fix-exploit-that-allowed-colored-signs-to-be-created.patch b/patches/server/Fix-exploit-that-allowed-colored-signs-to-be-created.patch
index 1abb23d4e9..27755e6c89 100644
--- a/patches/server/Fix-exploit-that-allowed-colored-signs-to-be-created.patch
+++ b/patches/server/Fix-exploit-that-allowed-colored-signs-to-be-created.patch
@@ -13,10 +13,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
              if (entityhuman.isTextFilteringEnabled()) {
 -                signtext = signtext.setMessage(i, Component.literal(filteredtext.filteredOrEmpty()).setStyle(chatmodifier));
-+                signtext = signtext.setMessage(i, Component.literal(net.minecraft.SharedConstants.filterText(filteredtext.filteredOrEmpty())).setStyle(chatmodifier)); // Paper - filter sign text to chat only
++                signtext = signtext.setMessage(i, Component.literal(net.minecraft.util.StringUtil.filterText(filteredtext.filteredOrEmpty())).setStyle(chatmodifier)); // Paper - filter sign text to chat only
              } else {
 -                signtext = signtext.setMessage(i, Component.literal(filteredtext.raw()).setStyle(chatmodifier), Component.literal(filteredtext.filteredOrEmpty()).setStyle(chatmodifier));
-+                signtext = signtext.setMessage(i, Component.literal(net.minecraft.SharedConstants.filterText(filteredtext.raw())).setStyle(chatmodifier), Component.literal(net.minecraft.SharedConstants.filterText(filteredtext.filteredOrEmpty())).setStyle(chatmodifier)); // Paper - filter sign text to chat only
++                signtext = signtext.setMessage(i, Component.literal(net.minecraft.util.StringUtil.filterText(filteredtext.raw())).setStyle(chatmodifier), Component.literal(net.minecraft.util.StringUtil.filterText(filteredtext.filteredOrEmpty())).setStyle(chatmodifier)); // Paper - filter sign text to chat only
              }
          }
  
diff --git a/patches/server/Folia-scheduler-and-owned-region-API.patch b/patches/server/Folia-scheduler-and-owned-region-API.patch
index 37082a840a..1238551941 100644
--- a/patches/server/Folia-scheduler-and-owned-region-API.patch
+++ b/patches/server/Folia-scheduler-and-owned-region-API.patch
@@ -1256,7 +1256,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
 @@ -0,0 +0,0 @@ public final class CraftServer implements Server {
      private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper
-     private final CraftPotionBrewer potionBrewer = new CraftPotionBrewer(); // Paper - Custom Potion Mixes
+     private final org.bukkit.craftbukkit.potion.CraftPotionBrewer potionBrewer = new org.bukkit.craftbukkit.potion.CraftPotionBrewer(); // Paper - Custom Potion Mixes
  
 +    // Paper start - Folia region threading API
 +    private final io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler();
diff --git a/patches/server/Friction-API.patch b/patches/server/Friction-API.patch
index dfc60b54f2..de81f4a1be 100644
--- a/patches/server/Friction-API.patch
+++ b/patches/server/Friction-API.patch
@@ -137,7 +137,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
 @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
-         });
+         nmsStack.hurtAndBreak(amount, this.getHandle(), slot);
      }
      // Paper end - ItemStack damage API
 +
diff --git a/patches/server/Implement-enchantWithLevels-API.patch b/patches/server/Implement-enchantWithLevels-API.patch
index 29e535a83f..c2207edfba 100644
--- a/patches/server/Implement-enchantWithLevels-API.patch
+++ b/patches/server/Implement-enchantWithLevels-API.patch
@@ -21,10 +21,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        Preconditions.checkArgument(levels > 0 && levels <= 30, "Argument 'levels' must be in range [1, 30] (attempted " + levels + ")");
 +        Preconditions.checkArgument(random != null, "Argument 'random' must not be null");
 +        final net.minecraft.world.item.ItemStack internalStack = CraftItemStack.asNMSCopy(itemStack);
-+        if (internalStack.getTag() != null) {
-+            internalStack.getTag().remove(net.minecraft.world.item.ItemStack.TAG_ENCH);
++        if (internalStack.isEnchanted()) {
++            internalStack.applyComponents(net.minecraft.core.component.DataComponentPatch.builder().remove(net.minecraft.core.component.DataComponents.ENCHANTMENTS).build());
 +        }
-+        final net.minecraft.world.item.ItemStack enchanted = net.minecraft.world.item.enchantment.EnchantmentHelper.enchantItem(new org.bukkit.craftbukkit.util.RandomSourceWrapper(random), internalStack, levels, allowTreasure);
++        final net.minecraft.world.item.ItemStack enchanted = net.minecraft.world.item.enchantment.EnchantmentHelper.enchantItem(
++            MinecraftServer.getServer().getWorldData().enabledFeatures(),
++            new org.bukkit.craftbukkit.util.RandomSourceWrapper(random),
++            internalStack,
++            levels,
++            allowTreasure
++        );
 +        return CraftItemStack.asCraftMirror(enchanted);
 +    }
 +    // Paper end - enchantWithLevels API
diff --git a/patches/server/ItemStack-damage-API.patch b/patches/server/ItemStack-damage-API.patch
index 6d985d9357..0a67545d0f 100644
--- a/patches/server/ItemStack-damage-API.patch
+++ b/patches/server/ItemStack-damage-API.patch
@@ -59,11 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    }
 +
 +    private void damageItemStack0(final net.minecraft.world.item.ItemStack nmsStack, final int amount, final net.minecraft.world.entity.EquipmentSlot slot) {
-+        nmsStack.hurtAndBreak(amount, this.getHandle(), livingEntity -> {
-+            if (slot != null) {
-+                livingEntity.broadcastBreakEvent(slot);
-+            }
-+        });
++        nmsStack.hurtAndBreak(amount, this.getHandle(), slot);
 +    }
 +    // Paper end - ItemStack damage API
  }
diff --git a/patches/server/MC-Utils.patch b/patches/server/MC-Utils.patch
index 40fa926418..f21ab41545 100644
--- a/patches/server/MC-Utils.patch
+++ b/patches/server/MC-Utils.patch
@@ -2683,7 +2683,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +import net.minecraft.world.entity.Entity;
 +import net.minecraft.world.level.ChunkPos;
 +import net.minecraft.world.level.chunk.ChunkAccess;
-+import net.minecraft.world.level.chunk.ChunkStatus;
++import net.minecraft.world.level.chunk.status.ChunkStatus;
 +import net.minecraft.world.level.chunk.LevelChunk;
 +import org.bukkit.Bukkit;
 +import org.slf4j.Logger;
@@ -4013,8 +4013,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        }
 +    }
 +
-+    public static int getTicketLevelFor(net.minecraft.world.level.chunk.ChunkStatus status) {
-+        return net.minecraft.server.level.ChunkMap.MAX_VIEW_DISTANCE + net.minecraft.world.level.chunk.ChunkStatus.getDistance(status);
++    public static int getTicketLevelFor(net.minecraft.world.level.chunk.status.ChunkStatus status) {
++        return net.minecraft.server.level.ChunkMap.MAX_VIEW_DISTANCE + net.minecraft.world.level.chunk.status.ChunkStatus.getDistance(status);
 +    }
 +
 +    @NotNull
@@ -6262,13 +6262,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
              this.fullChunkFuture = chunkStorage.prepareAccessibleChunk(this);
              this.scheduleFullChunkPromotion(chunkStorage, this.fullChunkFuture, executor, FullChunkStatus.FULL);
 +            // Paper start - cache ticking ready status
-+            this.fullChunkFuture.thenAccept(either -> {
-+                final Optional<LevelChunk> left = either.left();
-+                if (left.isPresent() && ChunkHolder.this.fullChunkCreateCount == expectCreateCount) {
-+                    LevelChunk fullChunk = either.left().get();
-+                    ChunkHolder.this.isFullChunkReady = true;
-+                    io.papermc.paper.chunk.system.ChunkSystem.onChunkBorder(fullChunk, this);
-+                }
++            this.fullChunkFuture.thenAccept(chunkResult -> {
++                chunkResult.ifSuccess(chunk -> {
++                    if (ChunkHolder.this.fullChunkCreateCount == expectCreateCount) {
++                        ChunkHolder.this.isFullChunkReady = true;
++                        io.papermc.paper.chunk.system.ChunkSystem.onChunkBorder(chunk, this);
++                    }
++                });
 +            });
              this.updateChunkToSave(this.fullChunkFuture, "full");
          }
@@ -6276,7 +6276,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          if (flag2 && !flag3) {
 +            // Paper start
 +            if (this.isFullChunkReady) {
-+                io.papermc.paper.chunk.system.ChunkSystem.onChunkNotBorder(this.fullChunkFuture.join().left().get(), this); // Paper
++                io.papermc.paper.chunk.system.ChunkSystem.onChunkNotBorder(this.fullChunkFuture.join().orElseThrow(IllegalStateException::new), this); // Paper
 +            }
 +            // Paper end
              this.fullChunkFuture.complete(ChunkHolder.UNLOADED_LEVEL_CHUNK);
@@ -6318,8 +6318,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
              this.entityTickingChunkFuture = chunkStorage.prepareEntityTickingChunk(this);
              this.scheduleFullChunkPromotion(chunkStorage, this.entityTickingChunkFuture, executor, FullChunkStatus.ENTITY_TICKING);
 +            // Paper start - cache ticking ready status
-+            this.entityTickingChunkFuture.thenAccept(either -> {
-+                either.ifLeft(chunk -> {
++            this.entityTickingChunkFuture.thenAccept(chunkResult -> {
++                chunkResult.ifSuccess(chunk -> {
 +                    ChunkHolder.this.isEntityTickingReady = true;
 +                    io.papermc.paper.chunk.system.ChunkSystem.onChunkEntityTicking(chunk, this);
 +                });
@@ -6332,7 +6332,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 -            this.entityTickingChunkFuture.complete(ChunkHolder.UNLOADED_LEVEL_CHUNK);
 +            // Paper start
 +            if (this.isEntityTickingReady) {
-+                io.papermc.paper.chunk.system.ChunkSystem.onChunkNotEntityTicking(this.entityTickingChunkFuture.join().left().get(), this);
++                io.papermc.paper.chunk.system.ChunkSystem.onChunkNotEntityTicking(this.entityTickingChunkFuture.join().orElseThrow(IllegalStateException::new), this);
 +            }
 +            // Paper end
 +            this.entityTickingChunkFuture.complete(ChunkHolder.UNLOADED_LEVEL_CHUNK); this.isEntityTickingReady = false; // Paper - cache chunk ticking stage
@@ -6939,7 +6939,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        for (int cx = minChunkX; cx <= maxChunkX; ++cx) {
 +            for (int cz = minChunkZ; cz <= maxChunkZ; ++cz) {
 +                io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad(
-+                    this, cx, cz, net.minecraft.world.level.chunk.ChunkStatus.FULL, true, priority, consumer
++                    this, cx, cz, net.minecraft.world.level.chunk.status.ChunkStatus.FULL, true, priority, consumer
 +                );
 +            }
 +        }
diff --git a/patches/server/More-World-API.patch b/patches/server/More-World-API.patch
index 51d6244490..fe380536eb 100644
--- a/patches/server/More-World-API.patch
+++ b/patches/server/More-World-API.patch
@@ -55,7 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +
 +    @Override
 +    public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) {
-+        getHandle().gameEvent(sourceEntity != null ? ((CraftEntity) sourceEntity).getHandle(): null, net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.get(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(gameEvent.getKey())), org.bukkit.craftbukkit.util.CraftVector.toBlockPos(position));
++        getHandle().gameEvent(sourceEntity != null ? ((CraftEntity) sourceEntity).getHandle(): null, net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.getHolder(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(gameEvent.getKey())).orElseThrow(), org.bukkit.craftbukkit.util.CraftVector.toBlockPos(position));
 +    }
 +    // Paper end
 +
diff --git a/patches/server/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch b/patches/server/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch
index c7b07b3884..66c61bdc91 100644
--- a/patches/server/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch
+++ b/patches/server/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch
@@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
                  }
  
 -                WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawn(world, blockposition2, MobSpawnType.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
-+                WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawn(world, null, trader -> trader.setDespawnDelay(48000), blockposition2, MobSpawnType.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit // Paper - set despawnTimer before spawn events called
++                WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawn(world, trader -> trader.setDespawnDelay(48000), blockposition2, MobSpawnType.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit // Paper - set despawnTimer before spawn events called
  
                  if (entityvillagertrader != null) {
                      for (int i = 0; i < 2; ++i) {