From d5469c16d1b9634299937e1b351f4830ba3efe22 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 21 Sep 2023 21:05:18 -0700
Subject: [PATCH] and some more patches

---
 ...e-PlayerProfile-in-AsyncPreLoginEven.patch |  6 +--
 ...-Plugin-Tickets-to-API-Chunk-Methods.patch |  0
 ...implement-PlayerRecipeBookClickEvent.patch | 12 ++---
 .../server/Add-entity-liquid-API.patch        |  0
 ...n-for-console-having-all-permissions.patch |  0
 .../Add-permission-for-command-blocks.patch   |  4 +-
 .../server/Add-villager-reputation-API.patch  |  0
 ...nvert-legacy-attributes-in-Item-Meta.patch |  0
 ...ktraces-in-log-messages-crash-report.patch | 50 +++++++++----------
 ...sure-Entity-AABB-s-are-never-invalid.patch |  6 +--
 ...der-respects-game-and-entity-rules-f.patch |  0
 .../server/Ensure-safe-gateway-teleport.patch |  0
 .../server/ExperienceOrbMergeEvent.patch      |  0
 .../server/Expose-game-version.patch          |  0
 ...er-runTaskTimerAsynchronously-Plugin.patch |  0
 ...ld-Difficulty-Remembering-Difficulty.patch |  4 +-
 .../Fix-PotionEffect-ignores-icon-flag.patch  |  4 +-
 ...ssing-chunks-due-to-integer-overflow.patch |  0
 ...ston-physics-inconsistency-MC-188840.patch | 12 ++---
 .../server/Fix-sand-duping.patch              |  0
 ...ix-villager-trading-demand-MC-163962.patch |  0
 .../Hide-sync-chunk-writes-behind-flag.patch  |  0
 .../server/Implement-Mob-Goal-API.patch       |  0
 .../server/Improve-Arrow-API.patch            |  0
 ...-Legacy-Component-serialization-size.patch |  0
 ...ve-fix-EntityTargetLivingEntityEvent.patch |  0
 ...Holder-method-without-block-snapshot.patch |  0
 .../server/Maps-shouldn-t-load-chunks.patch   |  0
 .../Optimize-Bit-Operations-by-inlining.patch |  0
 .../server/Optimize-Voxel-Shape-Merging.patch |  0
 ...-brigadier-child-sorting-performance.patch |  0
 ...-maximum-exp-value-when-merging-orbs.patch |  0
 .../server/Paper-dumpitem-command.patch       |  2 +-
 .../server/Player.setPlayerProfile-API.patch  |  8 +--
 .../server/Potential-bed-API.patch            |  0
 ...-desync-in-playerconnection-causing-.patch |  2 +-
 .../Prevent-teleporting-dead-entities.patch   |  2 +-
 ...and-End-Portal-Frames-from-being-des.patch |  0
 .../Remove-some-streams-from-structures.patch |  0
 ...from-classes-related-villager-gossip.patch |  0
 ...-per-thread-native-byte-buffer-cache.patch |  0
 .../Support-components-in-ItemMeta.patch      |  0
 .../Support-old-UUID-format-for-NBT.patch     | 12 ++---
 ...ookup-for-Treasure-Maps-Fixes-lag-fr.patch |  0
 ...PickItem-Packet-and-kick-for-invalid.patch |  2 +-
 .../server/Villager-Restocks-API.patch        |  0
 ...Wait-for-Async-Tasks-during-shutdown.patch |  2 +-
 .../incremental-chunk-and-player-saving.patch |  4 +-
 .../server/misc-debugging-dumps.patch         | 30 +++++------
 ...llocation-of-Vec3D-by-entity-tracker.patch |  0
 ...tance-map-to-optimise-entity-tracker.patch |  0
 51 files changed, 81 insertions(+), 81 deletions(-)
 rename patches/{unapplied => }/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch (100%)
 rename patches/{unapplied => }/server/Add-and-implement-PlayerRecipeBookClickEvent.patch (90%)
 rename patches/{unapplied => }/server/Add-entity-liquid-API.patch (100%)
 rename patches/{unapplied => }/server/Add-option-for-console-having-all-permissions.patch (100%)
 rename patches/{unapplied => }/server/Add-permission-for-command-blocks.patch (97%)
 rename patches/{unapplied => }/server/Add-villager-reputation-API.patch (100%)
 rename patches/{unapplied => }/server/Convert-legacy-attributes-in-Item-Meta.patch (100%)
 rename patches/{unapplied => }/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch (94%)
 rename patches/{unapplied => }/server/Ensure-Entity-AABB-s-are-never-invalid.patch (87%)
 rename patches/{unapplied => }/server/Ensure-EntityRaider-respects-game-and-entity-rules-f.patch (100%)
 rename patches/{unapplied => }/server/Ensure-safe-gateway-teleport.patch (100%)
 rename patches/{unapplied => }/server/ExperienceOrbMergeEvent.patch (100%)
 rename patches/{unapplied => }/server/Expose-game-version.patch (100%)
 rename patches/{unapplied => }/server/Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch (100%)
 rename patches/{unapplied => }/server/Fix-Per-World-Difficulty-Remembering-Difficulty.patch (95%)
 rename patches/{unapplied => }/server/Fix-PotionEffect-ignores-icon-flag.patch (60%)
 rename patches/{unapplied => }/server/Fix-missing-chunks-due-to-integer-overflow.patch (100%)
 rename patches/{unapplied => }/server/Fix-piston-physics-inconsistency-MC-188840.patch (95%)
 rename patches/{unapplied => }/server/Fix-sand-duping.patch (100%)
 rename patches/{unapplied => }/server/Fix-villager-trading-demand-MC-163962.patch (100%)
 rename patches/{unapplied => }/server/Hide-sync-chunk-writes-behind-flag.patch (100%)
 rename patches/{unapplied => }/server/Implement-Mob-Goal-API.patch (100%)
 rename patches/{unapplied => }/server/Improve-Arrow-API.patch (100%)
 rename patches/{unapplied => }/server/Improve-Legacy-Component-serialization-size.patch (100%)
 rename patches/{unapplied => }/server/Improve-fix-EntityTargetLivingEntityEvent.patch (100%)
 rename patches/{unapplied => }/server/Inventory-getHolder-method-without-block-snapshot.patch (100%)
 rename patches/{unapplied => }/server/Maps-shouldn-t-load-chunks.patch (100%)
 rename patches/{unapplied => }/server/Optimize-Bit-Operations-by-inlining.patch (100%)
 rename patches/{unapplied => }/server/Optimize-Voxel-Shape-Merging.patch (100%)
 rename patches/{unapplied => }/server/Optimize-brigadier-child-sorting-performance.patch (100%)
 rename patches/{unapplied => }/server/Option-for-maximum-exp-value-when-merging-orbs.patch (100%)
 rename patches/{unapplied => }/server/Paper-dumpitem-command.patch (97%)
 rename patches/{unapplied => }/server/Potential-bed-API.patch (100%)
 rename patches/{unapplied => }/server/Prevent-position-desync-in-playerconnection-causing-.patch (94%)
 rename patches/{unapplied => }/server/Prevent-teleporting-dead-entities.patch (92%)
 rename patches/{unapplied => }/server/Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch (100%)
 rename patches/{unapplied => }/server/Remove-some-streams-from-structures.patch (100%)
 rename patches/{unapplied => }/server/Remove-streams-from-classes-related-villager-gossip.patch (100%)
 rename patches/{unapplied => }/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch (100%)
 rename patches/{unapplied => }/server/Support-components-in-ItemMeta.patch (100%)
 rename patches/{unapplied => }/server/Support-old-UUID-format-for-NBT.patch (90%)
 rename patches/{unapplied => }/server/Use-seed-based-lookup-for-Treasure-Maps-Fixes-lag-fr.patch (100%)
 rename patches/{unapplied => }/server/Validate-PickItem-Packet-and-kick-for-invalid.patch (94%)
 rename patches/{unapplied => }/server/Villager-Restocks-API.patch (100%)
 rename patches/{unapplied => }/server/Wait-for-Async-Tasks-during-shutdown.patch (98%)
 rename patches/{unapplied => }/server/incremental-chunk-and-player-saving.patch (98%)
 rename patches/{unapplied => }/server/misc-debugging-dumps.patch (77%)
 rename patches/unapplied/{server => skipped}/Reduce-allocation-of-Vec3D-by-entity-tracker.patch (100%)
 rename patches/unapplied/{server => skipped}/Use-distance-map-to-optimise-entity-tracker.patch (100%)

diff --git a/patches/server/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch b/patches/server/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch
index 5af1e9d64c..4673d64b2e 100644
--- a/patches/server/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch
+++ b/patches/server/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch
@@ -20,9 +20,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
                          server.getPluginManager().callEvent(asyncEvent);
 +                        profile = asyncEvent.getPlayerProfile();
 +                        profile.complete();
-+                        gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
-+                        playerName = gameProfile.getName();
-+                        uniqueId = gameProfile.getId();
++                        gameprofile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
++                        playerName = gameprofile.getName();
++                        uniqueId = gameprofile.getId();
 +                        // Paper end
  
                          if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
diff --git a/patches/unapplied/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch b/patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch
similarity index 100%
rename from patches/unapplied/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch
rename to patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch
diff --git a/patches/unapplied/server/Add-and-implement-PlayerRecipeBookClickEvent.patch b/patches/server/Add-and-implement-PlayerRecipeBookClickEvent.patch
similarity index 90%
rename from patches/unapplied/server/Add-and-implement-PlayerRecipeBookClickEvent.patch
rename to patches/server/Add-and-implement-PlayerRecipeBookClickEvent.patch
index 07feade5ec..6a7242b3f0 100644
--- a/patches/unapplied/server/Add-and-implement-PlayerRecipeBookClickEvent.patch
+++ b/patches/server/Add-and-implement-PlayerRecipeBookClickEvent.patch
@@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
 +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
+@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
              if (!this.player.containerMenu.stillValid(this.player)) {
                  ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
              } else {
@@ -37,18 +37,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +                recipeName = CraftNamespacedKey.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey());
 +                makeAll = event.isShiftClick();
 +                }
-+                if (!(this.player.containerMenu instanceof RecipeBookMenu<?>)) {
++                if (!(this.player.containerMenu instanceof RecipeBookMenu<?> recipeBookMenu)) {
 +                    return;
 +                }
 +                // Paper end
  
                  // Cast to keyed should be safe as the recipe will never be a MerchantRecipe.
--                this.server.getRecipeManager().byKey(CraftNamespacedKey.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey())).ifPresent((irecipe) -> {
--                    ((RecipeBookMenu) this.player.containerMenu).handlePlacement(event.isShiftClick(), irecipe, this.player);
+-                this.server.getRecipeManager().byKey(CraftNamespacedKey.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey())).ifPresent((recipeholder) -> {
+-                    ((RecipeBookMenu) this.player.containerMenu).handlePlacement(event.isShiftClick(), recipeholder, this.player);
 +                // Paper start
 +                final boolean finalMakeAll = makeAll;
-+                this.server.getRecipeManager().byKey(recipeName).ifPresent((irecipe) -> {
-+                    ((RecipeBookMenu) this.player.containerMenu).handlePlacement(finalMakeAll, irecipe, this.player);
++                this.server.getRecipeManager().byKey(recipeName).ifPresent((recipeholder) -> {
++                    recipeBookMenu.handlePlacement(finalMakeAll, recipeholder, this.player);
 +                    // Paper end
                  });
                  // CraftBukkit end
diff --git a/patches/unapplied/server/Add-entity-liquid-API.patch b/patches/server/Add-entity-liquid-API.patch
similarity index 100%
rename from patches/unapplied/server/Add-entity-liquid-API.patch
rename to patches/server/Add-entity-liquid-API.patch
diff --git a/patches/unapplied/server/Add-option-for-console-having-all-permissions.patch b/patches/server/Add-option-for-console-having-all-permissions.patch
similarity index 100%
rename from patches/unapplied/server/Add-option-for-console-having-all-permissions.patch
rename to patches/server/Add-option-for-console-having-all-permissions.patch
diff --git a/patches/unapplied/server/Add-permission-for-command-blocks.patch b/patches/server/Add-permission-for-command-blocks.patch
similarity index 97%
rename from patches/unapplied/server/Add-permission-for-command-blocks.patch
rename to patches/server/Add-permission-for-command-blocks.patch
index 4fd899b01a..cd0171b241 100644
--- a/patches/unapplied/server/Add-permission-for-command-blocks.patch
+++ b/patches/server/Add-permission-for-command-blocks.patch
@@ -21,7 +21,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
 +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
+@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
          PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
          if (!this.server.isCommandBlockEnabled()) {
              this.player.sendSystemMessage(Component.translatable("advMode.notEnabled"));
@@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
              this.player.sendSystemMessage(Component.translatable("advMode.notAllowed"));
          } else {
              BaseCommandBlock commandblocklistenerabstract = null;
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
+@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
          PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
          if (!this.server.isCommandBlockEnabled()) {
              this.player.sendSystemMessage(Component.translatable("advMode.notEnabled"));
diff --git a/patches/unapplied/server/Add-villager-reputation-API.patch b/patches/server/Add-villager-reputation-API.patch
similarity index 100%
rename from patches/unapplied/server/Add-villager-reputation-API.patch
rename to patches/server/Add-villager-reputation-API.patch
diff --git a/patches/unapplied/server/Convert-legacy-attributes-in-Item-Meta.patch b/patches/server/Convert-legacy-attributes-in-Item-Meta.patch
similarity index 100%
rename from patches/unapplied/server/Convert-legacy-attributes-in-Item-Meta.patch
rename to patches/server/Convert-legacy-attributes-in-Item-Meta.patch
diff --git a/patches/unapplied/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch
similarity index 94%
rename from patches/unapplied/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch
rename to patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch
index e0ca054f6a..57275490cc 100644
--- a/patches/unapplied/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch
+++ b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch
@@ -14,8 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      implementation("org.spongepowered:configurate-yaml:4.1.2") // Paper - config files
      implementation("commons-lang:commons-lang:2.6")
 +    implementation("net.fabricmc:mapping-io:0.3.0") // Paper - needed to read mappings for stacktrace deobfuscation
-     runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.0")
-     runtimeOnly("com.mysql:mysql-connector-j:8.0.33")
+     runtimeOnly("org.xerial:sqlite-jdbc:3.43.0.0")
+     runtimeOnly("com.mysql:mysql-connector-j:8.1.0")
      runtimeOnly("com.lmax:disruptor:3.4.4") // Paper
 @@ -0,0 +0,0 @@ tasks.check {
  }
@@ -498,22 +498,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/network/Connection.java
 +++ b/src/main/java/net/minecraft/network/Connection.java
 @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
-     });
-     public static final AttributeKey<ConnectionProtocol> ATTRIBUTE_PROTOCOL = AttributeKey.valueOf("protocol");
-     public static final LazyLoadedValue<NioEventLoopGroup> NETWORK_WORKER_GROUP = new LazyLoadedValue<>(() -> {
+     public static final AttributeKey<ConnectionProtocol.CodecData<?>> ATTRIBUTE_SERVERBOUND_PROTOCOL = AttributeKey.valueOf("serverbound_protocol");
+     public static final AttributeKey<ConnectionProtocol.CodecData<?>> ATTRIBUTE_CLIENTBOUND_PROTOCOL = AttributeKey.valueOf("clientbound_protocol");
+     public static final Supplier<NioEventLoopGroup> NETWORK_WORKER_GROUP = Suppliers.memoize(() -> {
 -        return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).build());
 +        return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper
      });
-     public static final LazyLoadedValue<EpollEventLoopGroup> NETWORK_EPOLL_WORKER_GROUP = new LazyLoadedValue<>(() -> {
+     public static final Supplier<EpollEventLoopGroup> NETWORK_EPOLL_WORKER_GROUP = Suppliers.memoize(() -> {
 -        return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).build());
 +        return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper
      });
-     public static final LazyLoadedValue<DefaultEventLoopGroup> LOCAL_WORKER_GROUP = new LazyLoadedValue<>(() -> {
+     public static final Supplier<DefaultEventLoopGroup> LOCAL_WORKER_GROUP = Suppliers.memoize(() -> {
 -        return new DefaultEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).build());
 +        return new DefaultEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper
      });
      private final PacketFlow receiving;
-     private final Queue<Connection.PacketHolder> queue = Queues.newConcurrentLinkedQueue();
+     private final Queue<Consumer<Connection>> pendingActions = Queues.newConcurrentLinkedQueue();
 @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
  
              }
@@ -559,6 +559,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
                  getAddToWorldStackTrace(entity).printStackTrace();
              }
              // Paper end
+diff --git a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
++++ b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
+@@ -0,0 +0,0 @@ public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketLis
+             ServerConfigurationPacketListenerImpl.LOGGER.error("Couldn't place player in world", exception);
+             // Paper start
+             if (MinecraftServer.getServer().isDebugging()) {
+-                exception.printStackTrace();
++                io.papermc.paper.util.TraceUtil.printStackTrace(exception);
+             }
+             // Paper end
+             this.connection.send(new ClientboundDisconnectPacket(ServerConfigurationPacketListenerImpl.DISCONNECT_REASON_INVALID_DATA));
 diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
@@ -566,29 +579,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 @@ -0,0 +0,0 @@ public class ServerConnectionListener {
  
      private static final Logger LOGGER = LogUtils.getLogger();
-     public static final LazyLoadedValue<NioEventLoopGroup> SERVER_EVENT_GROUP = new LazyLoadedValue<>(() -> {
+     public static final Supplier<NioEventLoopGroup> SERVER_EVENT_GROUP = Suppliers.memoize(() -> {
 -        return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Server IO #%d").setDaemon(true).build());
 +        return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Server IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper
      });
-     public static final LazyLoadedValue<EpollEventLoopGroup> SERVER_EPOLL_EVENT_GROUP = new LazyLoadedValue<>(() -> {
+     public static final Supplier<EpollEventLoopGroup> SERVER_EPOLL_EVENT_GROUP = Suppliers.memoize(() -> {
 -        return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).build());
 +        return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper
      });
      final MinecraftServer server;
      public volatile boolean running;
-diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
-+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
-@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
-                 MutableComponent ichatmutablecomponent = Component.translatable("multiplayer.disconnect.invalid_player_data");
-                 // Paper start
-                 if (MinecraftServer.getServer().isDebugging()) {
--                    exception.printStackTrace();
-+                    io.papermc.paper.util.TraceUtil.printStackTrace(exception);
-                 }
-                 // Paper end
- 
 diff --git a/src/main/java/net/minecraft/server/players/OldUsersConverter.java b/src/main/java/net/minecraft/server/players/OldUsersConverter.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/players/OldUsersConverter.java
@@ -644,7 +644,7 @@ diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/org/spigotmc/WatchdogThread.java
 +++ b/src/main/java/org/spigotmc/WatchdogThread.java
-@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
+@@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
                      log.log( Level.SEVERE, "During the run of the server, a plugin set an excessive velocity on an entity" );
                      log.log( Level.SEVERE, "This may be the cause of the issue, or it may be entirely unrelated" );
                      log.log( Level.SEVERE, org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getMessage());
@@ -653,7 +653,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
                      {
                          log.log( Level.SEVERE, "\t\t" + stack );
                      }
-@@ -0,0 +0,0 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
+@@ -0,0 +0,0 @@ public class WatchdogThread extends Thread
          }
          log.log( Level.SEVERE, "\tStack:" );
          //
diff --git a/patches/unapplied/server/Ensure-Entity-AABB-s-are-never-invalid.patch b/patches/server/Ensure-Entity-AABB-s-are-never-invalid.patch
similarity index 87%
rename from patches/unapplied/server/Ensure-Entity-AABB-s-are-never-invalid.patch
rename to patches/server/Ensure-Entity-AABB-s-are-never-invalid.patch
index 9242d2a605..d76f58368c 100644
--- a/patches/unapplied/server/Ensure-Entity-AABB-s-are-never-invalid.patch
+++ b/patches/server/Ensure-Entity-AABB-s-are-never-invalid.patch
@@ -28,9 +28,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    }
 +    public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
 +        // Paper end
-         // Paper start - rewrite chunk system
-         if (this.updatingSectionStatus) {
-             LOGGER.error("Refusing to update position for entity " + this + " to position " + new Vec3(x, y, z) + " since it is processing a section status update", new Throwable());
+         if (this.position.x != x || this.position.y != y || this.position.z != z) {
+             this.position = new Vec3(x, y, z);
+             int i = Mth.floor(x);
 @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
              this.levelCallback.onMove();
          }
diff --git a/patches/unapplied/server/Ensure-EntityRaider-respects-game-and-entity-rules-f.patch b/patches/server/Ensure-EntityRaider-respects-game-and-entity-rules-f.patch
similarity index 100%
rename from patches/unapplied/server/Ensure-EntityRaider-respects-game-and-entity-rules-f.patch
rename to patches/server/Ensure-EntityRaider-respects-game-and-entity-rules-f.patch
diff --git a/patches/unapplied/server/Ensure-safe-gateway-teleport.patch b/patches/server/Ensure-safe-gateway-teleport.patch
similarity index 100%
rename from patches/unapplied/server/Ensure-safe-gateway-teleport.patch
rename to patches/server/Ensure-safe-gateway-teleport.patch
diff --git a/patches/unapplied/server/ExperienceOrbMergeEvent.patch b/patches/server/ExperienceOrbMergeEvent.patch
similarity index 100%
rename from patches/unapplied/server/ExperienceOrbMergeEvent.patch
rename to patches/server/ExperienceOrbMergeEvent.patch
diff --git a/patches/unapplied/server/Expose-game-version.patch b/patches/server/Expose-game-version.patch
similarity index 100%
rename from patches/unapplied/server/Expose-game-version.patch
rename to patches/server/Expose-game-version.patch
diff --git a/patches/unapplied/server/Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch b/patches/server/Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch
similarity index 100%
rename from patches/unapplied/server/Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch
rename to patches/server/Fix-CraftScheduler-runTaskTimerAsynchronously-Plugin.patch
diff --git a/patches/unapplied/server/Fix-Per-World-Difficulty-Remembering-Difficulty.patch b/patches/server/Fix-Per-World-Difficulty-Remembering-Difficulty.patch
similarity index 95%
rename from patches/unapplied/server/Fix-Per-World-Difficulty-Remembering-Difficulty.patch
rename to patches/server/Fix-Per-World-Difficulty-Remembering-Difficulty.patch
index 3776e813db..29b912251b 100644
--- a/patches/unapplied/server/Fix-Per-World-Difficulty-Remembering-Difficulty.patch
+++ b/patches/server/Fix-Per-World-Difficulty-Remembering-Difficulty.patch
@@ -82,7 +82,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 @@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
                  this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
  
-                 this.connection.send(new ClientboundRespawnPacket(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation(), this.getPortalCooldown()));
+                 this.connection.send(new ClientboundRespawnPacket(this.createCommonSpawnInfo(worldserver), (byte) 3));
 -                this.connection.send(new ClientboundChangeDifficultyPacket(this.level().getDifficulty(), this.level().getLevelData().isDifficultyLocked()));
 +                this.connection.send(new ClientboundChangeDifficultyPacket(worldserver.getDifficulty(), this.level().getLevelData().isDifficultyLocked())); // Paper - fix difficulty sync issue
                  PlayerList playerlist = this.server.getPlayerList();
@@ -92,7 +92,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
 +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
+@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
      public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) {
          PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
          if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) {
diff --git a/patches/unapplied/server/Fix-PotionEffect-ignores-icon-flag.patch b/patches/server/Fix-PotionEffect-ignores-icon-flag.patch
similarity index 60%
rename from patches/unapplied/server/Fix-PotionEffect-ignores-icon-flag.patch
rename to patches/server/Fix-PotionEffect-ignores-icon-flag.patch
index 175faa193d..a045239b50 100644
--- a/patches/unapplied/server/Fix-PotionEffect-ignores-icon-flag.patch
+++ b/patches/server/Fix-PotionEffect-ignores-icon-flag.patch
@@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
      @Override
      public boolean addPotionEffect(PotionEffect effect, boolean force) {
--        this.getHandle().addEffect(new MobEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()), EntityPotionEffectEvent.Cause.PLUGIN);
-+        this.getHandle().addEffect(new MobEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.hasIcon()), EntityPotionEffectEvent.Cause.PLUGIN); // Paper - Don't ignore icon
+-        this.getHandle().addEffect(new MobEffectInstance(CraftPotionEffectType.bukkitToMinecraft(effect.getType()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()), EntityPotionEffectEvent.Cause.PLUGIN);
++        this.getHandle().addEffect(new MobEffectInstance(CraftPotionEffectType.bukkitToMinecraft(effect.getType()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.hasIcon()), EntityPotionEffectEvent.Cause.PLUGIN); // Paper - Don't ignore icon
          return true;
      }
  
diff --git a/patches/unapplied/server/Fix-missing-chunks-due-to-integer-overflow.patch b/patches/server/Fix-missing-chunks-due-to-integer-overflow.patch
similarity index 100%
rename from patches/unapplied/server/Fix-missing-chunks-due-to-integer-overflow.patch
rename to patches/server/Fix-missing-chunks-due-to-integer-overflow.patch
diff --git a/patches/unapplied/server/Fix-piston-physics-inconsistency-MC-188840.patch b/patches/server/Fix-piston-physics-inconsistency-MC-188840.patch
similarity index 95%
rename from patches/unapplied/server/Fix-piston-physics-inconsistency-MC-188840.patch
rename to patches/server/Fix-piston-physics-inconsistency-MC-188840.patch
index 439ef42094..e660772089 100644
--- a/patches/unapplied/server/Fix-piston-physics-inconsistency-MC-188840.patch
+++ b/patches/server/Fix-piston-physics-inconsistency-MC-188840.patch
@@ -38,12 +38,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 @@ -0,0 +0,0 @@ public class PistonBaseBlock extends DirectionalBlock {
              }
  
-             for (k = list.size() - 1; k >= 0; --k) {
--                blockposition3 = (BlockPos) list.get(k);
+             for (j = list.size() - 1; j >= 0; --j) {
+-                blockposition3 = (BlockPos) list.get(j);
 -                iblockdata1 = world.getBlockState(blockposition3);
 +                // Paper start - fix a variety of piston desync dupes
 +                boolean allowDesync = io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPistonDuplication;
-+                BlockPos oldPos = blockposition3 = (BlockPos) list.get(k);
++                BlockPos oldPos = blockposition3 = (BlockPos) list.get(j);
 +                iblockdata1 = allowDesync ? world.getBlockState(oldPos) : null;
 +                // Paper end - fix a variety of piston desync dupes
                  blockposition3 = blockposition3.relative(enumdirection1);
@@ -51,18 +51,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
                  BlockState iblockdata2 = (BlockState) Blocks.MOVING_PISTON.defaultBlockState().setValue(PistonBaseBlock.FACING, dir);
  
                  world.setBlock(blockposition3, iblockdata2, 68);
--                world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, (BlockState) list1.get(k), dir, retract, false));
+-                world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, (BlockState) list1.get(j), dir, retract, false));
 +                // Paper start - fix a variety of piston desync dupes
 +                if (!allowDesync) {
 +                    iblockdata1 = world.getBlockState(oldPos);
 +                    map.replace(oldPos, iblockdata1);
 +                }
-+                world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, allowDesync ? list1.get(k) : iblockdata1, dir, retract, false));
++                world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, allowDesync ? list1.get(j) : iblockdata1, dir, retract, false));
 +                if (!allowDesync) {
 +                    world.setBlock(oldPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_MOVE_BY_PISTON | 1024); // set air to prevent later physics updates from seeing this block
 +                }
 +                // Paper end - fix a variety of piston desync dupes
-                 aiblockdata[j++] = iblockdata1;
+                 aiblockdata[i++] = iblockdata1;
              }
  
 diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
diff --git a/patches/unapplied/server/Fix-sand-duping.patch b/patches/server/Fix-sand-duping.patch
similarity index 100%
rename from patches/unapplied/server/Fix-sand-duping.patch
rename to patches/server/Fix-sand-duping.patch
diff --git a/patches/unapplied/server/Fix-villager-trading-demand-MC-163962.patch b/patches/server/Fix-villager-trading-demand-MC-163962.patch
similarity index 100%
rename from patches/unapplied/server/Fix-villager-trading-demand-MC-163962.patch
rename to patches/server/Fix-villager-trading-demand-MC-163962.patch
diff --git a/patches/unapplied/server/Hide-sync-chunk-writes-behind-flag.patch b/patches/server/Hide-sync-chunk-writes-behind-flag.patch
similarity index 100%
rename from patches/unapplied/server/Hide-sync-chunk-writes-behind-flag.patch
rename to patches/server/Hide-sync-chunk-writes-behind-flag.patch
diff --git a/patches/unapplied/server/Implement-Mob-Goal-API.patch b/patches/server/Implement-Mob-Goal-API.patch
similarity index 100%
rename from patches/unapplied/server/Implement-Mob-Goal-API.patch
rename to patches/server/Implement-Mob-Goal-API.patch
diff --git a/patches/unapplied/server/Improve-Arrow-API.patch b/patches/server/Improve-Arrow-API.patch
similarity index 100%
rename from patches/unapplied/server/Improve-Arrow-API.patch
rename to patches/server/Improve-Arrow-API.patch
diff --git a/patches/unapplied/server/Improve-Legacy-Component-serialization-size.patch b/patches/server/Improve-Legacy-Component-serialization-size.patch
similarity index 100%
rename from patches/unapplied/server/Improve-Legacy-Component-serialization-size.patch
rename to patches/server/Improve-Legacy-Component-serialization-size.patch
diff --git a/patches/unapplied/server/Improve-fix-EntityTargetLivingEntityEvent.patch b/patches/server/Improve-fix-EntityTargetLivingEntityEvent.patch
similarity index 100%
rename from patches/unapplied/server/Improve-fix-EntityTargetLivingEntityEvent.patch
rename to patches/server/Improve-fix-EntityTargetLivingEntityEvent.patch
diff --git a/patches/unapplied/server/Inventory-getHolder-method-without-block-snapshot.patch b/patches/server/Inventory-getHolder-method-without-block-snapshot.patch
similarity index 100%
rename from patches/unapplied/server/Inventory-getHolder-method-without-block-snapshot.patch
rename to patches/server/Inventory-getHolder-method-without-block-snapshot.patch
diff --git a/patches/unapplied/server/Maps-shouldn-t-load-chunks.patch b/patches/server/Maps-shouldn-t-load-chunks.patch
similarity index 100%
rename from patches/unapplied/server/Maps-shouldn-t-load-chunks.patch
rename to patches/server/Maps-shouldn-t-load-chunks.patch
diff --git a/patches/unapplied/server/Optimize-Bit-Operations-by-inlining.patch b/patches/server/Optimize-Bit-Operations-by-inlining.patch
similarity index 100%
rename from patches/unapplied/server/Optimize-Bit-Operations-by-inlining.patch
rename to patches/server/Optimize-Bit-Operations-by-inlining.patch
diff --git a/patches/unapplied/server/Optimize-Voxel-Shape-Merging.patch b/patches/server/Optimize-Voxel-Shape-Merging.patch
similarity index 100%
rename from patches/unapplied/server/Optimize-Voxel-Shape-Merging.patch
rename to patches/server/Optimize-Voxel-Shape-Merging.patch
diff --git a/patches/unapplied/server/Optimize-brigadier-child-sorting-performance.patch b/patches/server/Optimize-brigadier-child-sorting-performance.patch
similarity index 100%
rename from patches/unapplied/server/Optimize-brigadier-child-sorting-performance.patch
rename to patches/server/Optimize-brigadier-child-sorting-performance.patch
diff --git a/patches/unapplied/server/Option-for-maximum-exp-value-when-merging-orbs.patch b/patches/server/Option-for-maximum-exp-value-when-merging-orbs.patch
similarity index 100%
rename from patches/unapplied/server/Option-for-maximum-exp-value-when-merging-orbs.patch
rename to patches/server/Option-for-maximum-exp-value-when-merging-orbs.patch
diff --git a/patches/unapplied/server/Paper-dumpitem-command.patch b/patches/server/Paper-dumpitem-command.patch
similarity index 97%
rename from patches/unapplied/server/Paper-dumpitem-command.patch
rename to patches/server/Paper-dumpitem-command.patch
index 8608deff59..4d5fc71282 100644
--- a/patches/unapplied/server/Paper-dumpitem-command.patch
+++ b/patches/server/Paper-dumpitem-command.patch
@@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/io/papermc/paper/command/PaperCommand.java
 +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
 @@ -0,0 +0,0 @@ public final class PaperCommand extends Command {
+         commands.put(Set.of("dumpplugins"), new DumpPluginsCommand());
          commands.put(Set.of("fixlight"), new FixLightCommand());
-         commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand());
          commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());
 +        commands.put(Set.of("dumpitem"), new DumpItemCommand());
  
diff --git a/patches/server/Player.setPlayerProfile-API.patch b/patches/server/Player.setPlayerProfile-API.patch
index aae4f8bf14..dd9ca2ec14 100644
--- a/patches/server/Player.setPlayerProfile-API.patch
+++ b/patches/server/Player.setPlayerProfile-API.patch
@@ -30,15 +30,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
                          // Paper start
 -                        com.destroystokyo.paper.profile.PlayerProfile profile = org.bukkit.Bukkit.createProfile(uniqueId, playerName);
-+                        com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile);
++                        com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(gameprofile);
                          AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile);
                          server.getPluginManager().callEvent(asyncEvent);
                          profile = asyncEvent.getPlayerProfile();
 -                        profile.complete();
 +                        profile.complete(true); // Paper - setPlayerProfileAPI
-                         gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
-                         playerName = gameProfile.getName();
-                         uniqueId = gameProfile.getId();
+                         gameprofile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
+                         playerName = gameprofile.getName();
+                         uniqueId = gameprofile.getId();
 diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
diff --git a/patches/unapplied/server/Potential-bed-API.patch b/patches/server/Potential-bed-API.patch
similarity index 100%
rename from patches/unapplied/server/Potential-bed-API.patch
rename to patches/server/Potential-bed-API.patch
diff --git a/patches/unapplied/server/Prevent-position-desync-in-playerconnection-causing-.patch b/patches/server/Prevent-position-desync-in-playerconnection-causing-.patch
similarity index 94%
rename from patches/unapplied/server/Prevent-position-desync-in-playerconnection-causing-.patch
rename to patches/server/Prevent-position-desync-in-playerconnection-causing-.patch
index a63fe57768..1e26ced1d9 100644
--- a/patches/unapplied/server/Prevent-position-desync-in-playerconnection-causing-.patch
+++ b/patches/server/Prevent-position-desync-in-playerconnection-causing-.patch
@@ -17,7 +17,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
 +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
+@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
  
                              this.player.move(MoverType.PLAYER, new Vec3(d6, d7, d8));
                              this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move
diff --git a/patches/unapplied/server/Prevent-teleporting-dead-entities.patch b/patches/server/Prevent-teleporting-dead-entities.patch
similarity index 92%
rename from patches/unapplied/server/Prevent-teleporting-dead-entities.patch
rename to patches/server/Prevent-teleporting-dead-entities.patch
index df3ef65764..d3a80aee8b 100644
--- a/patches/unapplied/server/Prevent-teleporting-dead-entities.patch
+++ b/patches/server/Prevent-teleporting-dead-entities.patch
@@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
 +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
+@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
      }
  
      public void internalTeleport(double d0, double d1, double d2, float f, float f1, Set<RelativeMovement> set) { // Paper
diff --git a/patches/unapplied/server/Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch b/patches/server/Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch
similarity index 100%
rename from patches/unapplied/server/Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch
rename to patches/server/Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch
diff --git a/patches/unapplied/server/Remove-some-streams-from-structures.patch b/patches/server/Remove-some-streams-from-structures.patch
similarity index 100%
rename from patches/unapplied/server/Remove-some-streams-from-structures.patch
rename to patches/server/Remove-some-streams-from-structures.patch
diff --git a/patches/unapplied/server/Remove-streams-from-classes-related-villager-gossip.patch b/patches/server/Remove-streams-from-classes-related-villager-gossip.patch
similarity index 100%
rename from patches/unapplied/server/Remove-streams-from-classes-related-villager-gossip.patch
rename to patches/server/Remove-streams-from-classes-related-villager-gossip.patch
diff --git a/patches/unapplied/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch b/patches/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
similarity index 100%
rename from patches/unapplied/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
rename to patches/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
diff --git a/patches/unapplied/server/Support-components-in-ItemMeta.patch b/patches/server/Support-components-in-ItemMeta.patch
similarity index 100%
rename from patches/unapplied/server/Support-components-in-ItemMeta.patch
rename to patches/server/Support-components-in-ItemMeta.patch
diff --git a/patches/unapplied/server/Support-old-UUID-format-for-NBT.patch b/patches/server/Support-old-UUID-format-for-NBT.patch
similarity index 90%
rename from patches/unapplied/server/Support-old-UUID-format-for-NBT.patch
rename to patches/server/Support-old-UUID-format-for-NBT.patch
index 7c56e75d4c..719462d721 100644
--- a/patches/unapplied/server/Support-old-UUID-format-for-NBT.patch
+++ b/patches/server/Support-old-UUID-format-for-NBT.patch
@@ -50,14 +50,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/nbt/NbtUtils.java
 +++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
 @@ -0,0 +0,0 @@ public final class NbtUtils {
-         if (nbt.contains("Name", 8)) {
-             string = nbt.getString("Name");
-         }
+     @Nullable
+     public static GameProfile readGameProfile(CompoundTag nbt) {
+         UUID uUID = nbt.hasUUID("Id") ? nbt.getUUID("Id") : Util.NIL_UUID;
 +        // Paper start - support string UUID's
-+        if (nbt.contains("Id", 8)) {
++        if (nbt.contains("Id", Tag.TAG_STRING)) {
 +            uUID = UUID.fromString(nbt.getString("Id"));
 +        }
 +        // Paper end
+         String string = nbt.getString("Name");
  
-         if (nbt.hasUUID("Id")) {
-             uUID = nbt.getUUID("Id");
+         try {
diff --git a/patches/unapplied/server/Use-seed-based-lookup-for-Treasure-Maps-Fixes-lag-fr.patch b/patches/server/Use-seed-based-lookup-for-Treasure-Maps-Fixes-lag-fr.patch
similarity index 100%
rename from patches/unapplied/server/Use-seed-based-lookup-for-Treasure-Maps-Fixes-lag-fr.patch
rename to patches/server/Use-seed-based-lookup-for-Treasure-Maps-Fixes-lag-fr.patch
diff --git a/patches/unapplied/server/Validate-PickItem-Packet-and-kick-for-invalid.patch b/patches/server/Validate-PickItem-Packet-and-kick-for-invalid.patch
similarity index 94%
rename from patches/unapplied/server/Validate-PickItem-Packet-and-kick-for-invalid.patch
rename to patches/server/Validate-PickItem-Packet-and-kick-for-invalid.patch
index cf9556c84a..edcd10c966 100644
--- a/patches/unapplied/server/Validate-PickItem-Packet-and-kick-for-invalid.patch
+++ b/patches/server/Validate-PickItem-Packet-and-kick-for-invalid.patch
@@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
 +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
-@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
+@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
      @Override
      public void handlePickItem(ServerboundPickItemPacket packet) {
          PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
diff --git a/patches/unapplied/server/Villager-Restocks-API.patch b/patches/server/Villager-Restocks-API.patch
similarity index 100%
rename from patches/unapplied/server/Villager-Restocks-API.patch
rename to patches/server/Villager-Restocks-API.patch
diff --git a/patches/unapplied/server/Wait-for-Async-Tasks-during-shutdown.patch b/patches/server/Wait-for-Async-Tasks-during-shutdown.patch
similarity index 98%
rename from patches/unapplied/server/Wait-for-Async-Tasks-during-shutdown.patch
rename to patches/server/Wait-for-Async-Tasks-during-shutdown.patch
index 11897485af..28353e474e 100644
--- a/patches/unapplied/server/Wait-for-Async-Tasks-during-shutdown.patch
+++ b/patches/server/Wait-for-Async-Tasks-during-shutdown.patch
@@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +            this.server.waitForAsyncTasksShutdown(); // Paper
          }
          // CraftBukkit end
-         if (this.getConnection() != null) {
+         this.getConnection().stop();
 diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
diff --git a/patches/unapplied/server/incremental-chunk-and-player-saving.patch b/patches/server/incremental-chunk-and-player-saving.patch
similarity index 98%
rename from patches/unapplied/server/incremental-chunk-and-player-saving.patch
rename to patches/server/incremental-chunk-and-player-saving.patch
index 07ce138b95..f6c1779d91 100644
--- a/patches/unapplied/server/incremental-chunk-and-player-saving.patch
+++ b/patches/server/incremental-chunk-and-player-saving.patch
@@ -112,8 +112,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    // Paper end
 +
      public void save(@Nullable ProgressListener progressListener, boolean flush, boolean savingDisabled) {
-         // Paper start - rewrite chunk system - add close param
-         this.save(progressListener, flush, savingDisabled, false);
+         ServerChunkCache chunkproviderserver = this.getChunkSource();
+ 
 diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
diff --git a/patches/unapplied/server/misc-debugging-dumps.patch b/patches/server/misc-debugging-dumps.patch
similarity index 77%
rename from patches/unapplied/server/misc-debugging-dumps.patch
rename to patches/server/misc-debugging-dumps.patch
index 9725840423..9d77bb0583 100644
--- a/patches/unapplied/server/misc-debugging-dumps.patch
+++ b/patches/server/misc-debugging-dumps.patch
@@ -57,22 +57,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          // Paper end
          this.running = false;
          if (waitForShutdown) {
-diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+diff --git a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
-+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
-@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
-             } catch (Exception exception) {
-                 ServerLoginPacketListenerImpl.LOGGER.error("Couldn't place player in world", exception);
-                 MutableComponent ichatmutablecomponent = Component.translatable("multiplayer.disconnect.invalid_player_data");
-+                // Paper start
-+                if (MinecraftServer.getServer().isDebugging()) {
-+                    exception.printStackTrace();
-+                }
-+                // Paper end
- 
-                 this.connection.send(new ClientboundDisconnectPacket(ichatmutablecomponent));
-                 this.connection.disconnect(ichatmutablecomponent);
+--- a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
++++ b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
+@@ -0,0 +0,0 @@ public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketLis
+             this.connection.resumeInboundAfterProtocolChange();
+         } catch (Exception exception) {
+             ServerConfigurationPacketListenerImpl.LOGGER.error("Couldn't place player in world", exception);
++            // Paper start
++            if (MinecraftServer.getServer().isDebugging()) {
++                exception.printStackTrace();
++            }
++            // Paper end
+             this.connection.send(new ClientboundDisconnectPacket(ServerConfigurationPacketListenerImpl.DISCONNECT_REASON_INVALID_DATA));
+             this.connection.disconnect(ServerConfigurationPacketListenerImpl.DISCONNECT_REASON_INVALID_DATA);
+         }
 diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
diff --git a/patches/unapplied/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch b/patches/unapplied/skipped/Reduce-allocation-of-Vec3D-by-entity-tracker.patch
similarity index 100%
rename from patches/unapplied/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch
rename to patches/unapplied/skipped/Reduce-allocation-of-Vec3D-by-entity-tracker.patch
diff --git a/patches/unapplied/server/Use-distance-map-to-optimise-entity-tracker.patch b/patches/unapplied/skipped/Use-distance-map-to-optimise-entity-tracker.patch
similarity index 100%
rename from patches/unapplied/server/Use-distance-map-to-optimise-entity-tracker.patch
rename to patches/unapplied/skipped/Use-distance-map-to-optimise-entity-tracker.patch