From 2e66bc971940124463d3b68d7cf0368af55cea66 Mon Sep 17 00:00:00 2001
From: Bjarne Koll <git@lynxplay.dev>
Date: Tue, 22 Oct 2024 22:38:26 +0200
Subject: [PATCH] More work?

---
 .../server/Add-UnknownCommandEvent.patch      |  2 +-
 ...n-option-to-prevent-player-names-fro.patch |  0
 ...ke-parrots-stay-on-shoulders-despite.patch |  0
 .../server/Basic-PlayerProfile-API.patch      |  0
 .../server/Cap-Entity-Collisions.patch        |  0
 ...-profile-lookups-to-worldgen-threads.patch | 10 +++---
 .../server/Enforce-Sync-Player-Saves.patch    |  0
 ...PI-for-Reason-Source-Triggering-play.patch | 34 +++++++++---------
 .../server/Item-canEntityPickup.patch         | 18 +++++-----
 .../server/PlayerAttemptPickupItemEvent.patch |  0
 ...PlayerPickupItemEvent-setFlyAtPlayer.patch |  0
 .../PlayerTeleportEndGatewayEvent.patch       | 24 +++++++++++++
 ...le-async-calls-to-restart-the-server.patch |  0
 ...rovide-E-TE-Chunk-count-stat-methods.patch |  0
 ...e-CraftScheduler-Async-Task-Debugger.patch |  8 ++---
 .../Shoulder-Entities-Release-API.patch       | 23 ++++++------
 ...urable-option-to-disable-creeper-lin.patch |  2 +-
 .../PlayerTeleportEndGatewayEvent.patch       | 35 -------------------
 18 files changed, 71 insertions(+), 85 deletions(-)
 rename patches/{unapplied => }/server/Add-UnknownCommandEvent.patch (98%)
 rename patches/{unapplied => }/server/Add-configuration-option-to-prevent-player-names-fro.patch (100%)
 rename patches/{unapplied => }/server/Add-option-to-make-parrots-stay-on-shoulders-despite.patch (100%)
 rename patches/{unapplied => }/server/Basic-PlayerProfile-API.patch (100%)
 rename patches/{unapplied => }/server/Cap-Entity-Collisions.patch (100%)
 rename patches/{unapplied => }/server/Do-not-submit-profile-lookups-to-worldgen-threads.patch (92%)
 rename patches/{unapplied => }/server/Enforce-Sync-Player-Saves.patch (100%)
 rename patches/{unapplied => }/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch (92%)
 rename patches/{unapplied => }/server/Item-canEntityPickup.patch (79%)
 rename patches/{unapplied => }/server/PlayerAttemptPickupItemEvent.patch (100%)
 rename patches/{unapplied => }/server/PlayerPickupItemEvent-setFlyAtPlayer.patch (100%)
 create mode 100644 patches/server/PlayerTeleportEndGatewayEvent.patch
 rename patches/{unapplied => }/server/Properly-handle-async-calls-to-restart-the-server.patch (100%)
 rename patches/{unapplied => }/server/Provide-E-TE-Chunk-count-stat-methods.patch (100%)
 rename patches/{unapplied => }/server/Remove-CraftScheduler-Async-Task-Debugger.patch (85%)
 rename patches/{unapplied => }/server/Shoulder-Entities-Release-API.patch (80%)
 rename patches/{unapplied => }/server/provide-a-configurable-option-to-disable-creeper-lin.patch (93%)
 delete mode 100644 patches/unapplied/server/PlayerTeleportEndGatewayEvent.patch

diff --git a/patches/unapplied/server/Add-UnknownCommandEvent.patch b/patches/server/Add-UnknownCommandEvent.patch
similarity index 98%
rename from patches/unapplied/server/Add-UnknownCommandEvent.patch
rename to patches/server/Add-UnknownCommandEvent.patch
index b798f26e42..16bb297a29 100644
--- a/patches/unapplied/server/Add-UnknownCommandEvent.patch
+++ b/patches/server/Add-UnknownCommandEvent.patch
@@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/commands/Commands.java
 +++ b/src/main/java/net/minecraft/commands/Commands.java
 @@ -0,0 +0,0 @@ public class Commands {
-         commandlistenerwrapper.getServer().getProfiler().push(() -> {
+         Profiler.get().push(() -> {
              return "/" + s;
          });
 -        ContextChain<CommandSourceStack> contextchain = Commands.finishParsing(parseresults, s, commandlistenerwrapper, label); // CraftBukkit
diff --git a/patches/unapplied/server/Add-configuration-option-to-prevent-player-names-fro.patch b/patches/server/Add-configuration-option-to-prevent-player-names-fro.patch
similarity index 100%
rename from patches/unapplied/server/Add-configuration-option-to-prevent-player-names-fro.patch
rename to patches/server/Add-configuration-option-to-prevent-player-names-fro.patch
diff --git a/patches/unapplied/server/Add-option-to-make-parrots-stay-on-shoulders-despite.patch b/patches/server/Add-option-to-make-parrots-stay-on-shoulders-despite.patch
similarity index 100%
rename from patches/unapplied/server/Add-option-to-make-parrots-stay-on-shoulders-despite.patch
rename to patches/server/Add-option-to-make-parrots-stay-on-shoulders-despite.patch
diff --git a/patches/unapplied/server/Basic-PlayerProfile-API.patch b/patches/server/Basic-PlayerProfile-API.patch
similarity index 100%
rename from patches/unapplied/server/Basic-PlayerProfile-API.patch
rename to patches/server/Basic-PlayerProfile-API.patch
diff --git a/patches/unapplied/server/Cap-Entity-Collisions.patch b/patches/server/Cap-Entity-Collisions.patch
similarity index 100%
rename from patches/unapplied/server/Cap-Entity-Collisions.patch
rename to patches/server/Cap-Entity-Collisions.patch
diff --git a/patches/unapplied/server/Do-not-submit-profile-lookups-to-worldgen-threads.patch b/patches/server/Do-not-submit-profile-lookups-to-worldgen-threads.patch
similarity index 92%
rename from patches/unapplied/server/Do-not-submit-profile-lookups-to-worldgen-threads.patch
rename to patches/server/Do-not-submit-profile-lookups-to-worldgen-threads.patch
index 688f4125a3..280801f49c 100644
--- a/patches/unapplied/server/Do-not-submit-profile-lookups-to-worldgen-threads.patch
+++ b/patches/server/Do-not-submit-profile-lookups-to-worldgen-threads.patch
@@ -14,9 +14,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/Util.java
 +++ b/src/main/java/net/minecraft/Util.java
 @@ -0,0 +0,0 @@ public class Util {
-     private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main");
-     private static final ExecutorService IO_POOL = makeIoExecutor("IO-Worker-", false);
-     private static final ExecutorService DOWNLOAD_POOL = makeIoExecutor("Download-", true);
+     private static final TracingExecutor BACKGROUND_EXECUTOR = makeExecutor("Main");
+     private static final TracingExecutor IO_POOL = makeIoExecutor("IO-Worker-", false);
+     private static final TracingExecutor DOWNLOAD_POOL = makeIoExecutor("Download-", true);
 +    // Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
 +    public static final ExecutorService PROFILE_EXECUTOR = Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory() {
 +
@@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
              } else {
                  CompletableFuture<Optional<GameProfile>> completablefuture1 = CompletableFuture.supplyAsync(() -> {
                      return this.get(username);
--                }, Util.backgroundExecutor()).whenCompleteAsync((optional, throwable) -> {
+-                }, Util.backgroundExecutor().forName("getProfile")).whenCompleteAsync((optional, throwable) -> {
 +                }, Util.PROFILE_EXECUTOR).whenCompleteAsync((optional, throwable) -> { // Paper - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
                      this.requests.remove(username);
                  }, this.executor);
@@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
                  ProfileResult profileResult = apiServices.sessionService().fetchProfile(uuid, true);
                  return Optional.ofNullable(profileResult).map(ProfileResult::profile);
              }
--        }, Util.backgroundExecutor());
+-        }, Util.backgroundExecutor().forName("fetchProfile"));
 +        }, Util.PROFILE_EXECUTOR); // Paper - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
      }
  
diff --git a/patches/unapplied/server/Enforce-Sync-Player-Saves.patch b/patches/server/Enforce-Sync-Player-Saves.patch
similarity index 100%
rename from patches/unapplied/server/Enforce-Sync-Player-Saves.patch
rename to patches/server/Enforce-Sync-Player-Saves.patch
diff --git a/patches/unapplied/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch b/patches/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch
similarity index 92%
rename from patches/unapplied/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch
rename to patches/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch
index b1a4130bcb..892664792d 100644
--- a/patches/unapplied/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch
+++ b/patches/server/ExperienceOrbs-API-for-Reason-Source-Triggering-play.patch
@@ -131,11 +131,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
 +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
 @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
-     protected void dropExperience(@Nullable Entity attacker) {
+     protected void dropExperience(ServerLevel world, @Nullable Entity attacker) {
          // CraftBukkit start - Update getExpReward() above if the removed if() changes!
          if (!(this instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time
--            ExperienceOrb.award((ServerLevel) this.level(), this.position(), this.expToDrop);
-+            ExperienceOrb.award((ServerLevel) this.level(), this.position(), this.expToDrop, this instanceof ServerPlayer ? org.bukkit.entity.ExperienceOrb.SpawnReason.PLAYER_DEATH : org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, attacker, this); // Paper
+-            ExperienceOrb.award(world, this.position(), this.expToDrop);
++            ExperienceOrb.award(world, this.position(), this.expToDrop, this instanceof ServerPlayer ? org.bukkit.entity.ExperienceOrb.SpawnReason.PLAYER_DEATH : org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, attacker, this); // Paper
              this.expToDrop = 0;
          }
          // CraftBukkit end
@@ -175,8 +175,8 @@ diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
 +++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
-@@ -0,0 +0,0 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> {
-                 if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
+@@ -0,0 +0,0 @@ public class Fox extends Animal implements VariantHolder<Fox.Variant> {
+                 if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
                      // CraftBukkit start - use event experience
                      if (experience > 0) {
 -                        this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), experience));
@@ -191,7 +191,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 @@ -0,0 +0,0 @@ public class Turtle extends Animal {
              RandomSource randomsource = this.animal.getRandom();
  
-             if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
+             if (getServerLevel((Level) this.level).getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
 -                this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), randomsource.nextInt(7) + 1));
 +                this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), randomsource.nextInt(7) + 1, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper;
              }
@@ -203,22 +203,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
 @@ -0,0 +0,0 @@ public class EnderDragon extends Mob implements Enemy {
  
-         if (this.level() instanceof ServerLevel) {
+         if (world instanceof ServerLevel worldserver) {
              if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && true) {  // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp
--                ExperienceOrb.award((ServerLevel) this.level(), this.position(), Mth.floor((float) short0 * 0.08F));
-+                ExperienceOrb.award((ServerLevel) this.level(), this.position(), Mth.floor((float) short0 * 0.08F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, this.lastHurtByPlayer, this); // Paper
+-                ExperienceOrb.award(worldserver, this.position(), Mth.floor((float) short0 * 0.08F));
++                ExperienceOrb.award(worldserver, this.position(), Mth.floor((float) short0 * 0.08F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, this.lastHurtByPlayer, this); // Paper
              }
  
              if (this.dragonDeathTime == 1 && !this.isSilent()) {
 @@ -0,0 +0,0 @@ public class EnderDragon extends Mob implements Enemy {
-         this.move(MoverType.SELF, new Vec3(0.0D, 0.10000000149011612D, 0.0D));
-         if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel) {
-             if (true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp
--                ExperienceOrb.award((ServerLevel) this.level(), this.position(), Mth.floor((float) short0 * 0.2F));
-+                ExperienceOrb.award((ServerLevel) this.level(), this.position(), Mth.floor((float) short0 * 0.2F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, this.lastHurtByPlayer, this); // Paper
-             }
+             if (world instanceof ServerLevel) {
+                 ServerLevel worldserver = (ServerLevel) world; // CraftBukkit - decompile error
+                 if (true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp
+-                    ExperienceOrb.award(worldserver, this.position(), Mth.floor((float) short0 * 0.2F));
++                    ExperienceOrb.award(worldserver, this.position(), Mth.floor((float) short0 * 0.2F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, this.lastHurtByPlayer, this); // Paper
+                 }
  
-             if (this.dragonFight != null) {
+                 if (this.dragonFight != null) {
 diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -328,7 +328,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +                spawnData -> new net.minecraft.world.entity.ExperienceOrb(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), 0, org.bukkit.entity.ExperienceOrb.SpawnReason.CUSTOM, null, null) // Paper
          ));
          register(new EntityTypeData<>(EntityType.AREA_EFFECT_CLOUD, AreaEffectCloud.class, CraftAreaEffectCloud::new, spawnData -> new net.minecraft.world.entity.AreaEffectCloud(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z())));
-         register(new EntityTypeData<>(EntityType.EGG, Egg.class, CraftEgg::new, spawnData -> new ThrownEgg(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z())));
+         register(new EntityTypeData<>(EntityType.EGG, Egg.class, CraftEgg::new, spawnData -> new ThrownEgg(spawnData.minecraftWorld(), spawnData.x(), spawnData.y(), spawnData.z(), new net.minecraft.world.item.ItemStack(Items.EGG))));
 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java
diff --git a/patches/unapplied/server/Item-canEntityPickup.patch b/patches/server/Item-canEntityPickup.patch
similarity index 79%
rename from patches/unapplied/server/Item-canEntityPickup.patch
rename to patches/server/Item-canEntityPickup.patch
index 5bcfed7b9f..d340c18824 100644
--- a/patches/unapplied/server/Item-canEntityPickup.patch
+++ b/patches/server/Item-canEntityPickup.patch
@@ -9,17 +9,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/net/minecraft/world/entity/Mob.java
 +++ b/src/main/java/net/minecraft/world/entity/Mob.java
 @@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
-                 ItemEntity entityitem = (ItemEntity) iterator.next();
+                     ItemEntity entityitem = (ItemEntity) iterator.next();
  
-                 if (!entityitem.isRemoved() && !entityitem.getItem().isEmpty() && !entityitem.hasPickUpDelay() && this.wantsToPickUp(entityitem.getItem())) {
-+                    // Paper start - Item#canEntityPickup
-+                    if (!entityitem.canMobPickup) {
-+                        continue;
-+                    }
-+                    // Paper end - Item#canEntityPickup
-                     this.pickUpItem(entityitem);
+                     if (!entityitem.isRemoved() && !entityitem.getItem().isEmpty() && !entityitem.hasPickUpDelay() && this.wantsToPickUp(worldserver, entityitem.getItem())) {
++                        // Paper start - Item#canEntityPickup
++                        if (!entityitem.canMobPickup) {
++                            continue;
++                        }
++                        // Paper end - Item#canEntityPickup
+                         this.pickUpItem(worldserver, entityitem);
+                     }
                  }
-             }
 diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
diff --git a/patches/unapplied/server/PlayerAttemptPickupItemEvent.patch b/patches/server/PlayerAttemptPickupItemEvent.patch
similarity index 100%
rename from patches/unapplied/server/PlayerAttemptPickupItemEvent.patch
rename to patches/server/PlayerAttemptPickupItemEvent.patch
diff --git a/patches/unapplied/server/PlayerPickupItemEvent-setFlyAtPlayer.patch b/patches/server/PlayerPickupItemEvent-setFlyAtPlayer.patch
similarity index 100%
rename from patches/unapplied/server/PlayerPickupItemEvent-setFlyAtPlayer.patch
rename to patches/server/PlayerPickupItemEvent-setFlyAtPlayer.patch
diff --git a/patches/server/PlayerTeleportEndGatewayEvent.patch b/patches/server/PlayerTeleportEndGatewayEvent.patch
new file mode 100644
index 0000000000..a491e3f2d5
--- /dev/null
+++ b/patches/server/PlayerTeleportEndGatewayEvent.patch
@@ -0,0 +1,24 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <aikar@aikar.co>
+Date: Sat, 31 Dec 2016 21:44:50 -0500
+Subject: [PATCH] PlayerTeleportEndGatewayEvent
+
+Allows you to access the Gateway being used in a teleport event
+Fix the offset used for player teleportation
+
+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
++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
+@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
+             PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleportTarget), teleportTarget.relatives());
+             Location exit = (worldserver == null) ? null : CraftLocation.toBukkit(absolutePosition.position(), worldserver.getWorld(), absolutePosition.yRot(), absolutePosition.xRot());
+             PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, teleportTarget.cause());
++            // Paper start - gateway-specific teleport event
++            if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.serverLevel().getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) {
++                tpEvent = new com.destroystokyo.paper.event.player.PlayerTeleportEndGatewayEvent(this.getBukkitEntity(), enter, exit, new org.bukkit.craftbukkit.block.CraftEndGateway(this.serverLevel().getWorld(), theEndGatewayBlockEntity));
++            }
++            // Paper end - gateway-specific teleport event
+             Bukkit.getServer().getPluginManager().callEvent(tpEvent);
+             Location newExit = tpEvent.getTo();
+             if (tpEvent.isCancelled() || newExit == null) {
diff --git a/patches/unapplied/server/Properly-handle-async-calls-to-restart-the-server.patch b/patches/server/Properly-handle-async-calls-to-restart-the-server.patch
similarity index 100%
rename from patches/unapplied/server/Properly-handle-async-calls-to-restart-the-server.patch
rename to patches/server/Properly-handle-async-calls-to-restart-the-server.patch
diff --git a/patches/unapplied/server/Provide-E-TE-Chunk-count-stat-methods.patch b/patches/server/Provide-E-TE-Chunk-count-stat-methods.patch
similarity index 100%
rename from patches/unapplied/server/Provide-E-TE-Chunk-count-stat-methods.patch
rename to patches/server/Provide-E-TE-Chunk-count-stat-methods.patch
diff --git a/patches/unapplied/server/Remove-CraftScheduler-Async-Task-Debugger.patch b/patches/server/Remove-CraftScheduler-Async-Task-Debugger.patch
similarity index 85%
rename from patches/unapplied/server/Remove-CraftScheduler-Async-Task-Debugger.patch
rename to patches/server/Remove-CraftScheduler-Async-Task-Debugger.patch
index f39e6390ef..2f353c5788 100644
--- a/patches/unapplied/server/Remove-CraftScheduler-Async-Task-Debugger.patch
+++ b/patches/server/Remove-CraftScheduler-Async-Task-Debugger.patch
@@ -16,8 +16,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
                  }
                  this.parsePending();
              } else {
--                this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass()));
-+                // this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper
+-                this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(this.currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass()));
++                // this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(this.currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper
                  this.executor.execute(new com.destroystokyo.paper.ServerSchedulerReportingWrapper(task)); // Paper
                  // We don't need to parse pending
                  // (async tasks must live with race-conditions if they attempt to cancel between these few lines of code)
@@ -25,8 +25,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          this.pending.addAll(temp);
          temp.clear();
          MinecraftTimings.bukkitSchedulerFinishTimer.stopTiming(); // Paper
--        this.debugHead = this.debugHead.getNextHead(currentTick);
-+        //this.debugHead = this.debugHead.getNextHead(currentTick); // Paper
+-        this.debugHead = this.debugHead.getNextHead(this.currentTick);
++        //this.debugHead = this.debugHead.getNextHead(this.currentTick); // Paper
      }
  
      private void addTask(final CraftTask task) {
diff --git a/patches/unapplied/server/Shoulder-Entities-Release-API.patch b/patches/server/Shoulder-Entities-Release-API.patch
similarity index 80%
rename from patches/unapplied/server/Shoulder-Entities-Release-API.patch
rename to patches/server/Shoulder-Entities-Release-API.patch
index 755ee1c640..f1c9e77ada 100644
--- a/patches/unapplied/server/Shoulder-Entities-Release-API.patch
+++ b/patches/server/Shoulder-Entities-Release-API.patch
@@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
      }
  
-+    // Paper start
++    // Paper start - release entity api
 +    public Entity releaseLeftShoulderEntity() {
 +        Entity entity = this.respawnEntityOnShoulder0(this.getShoulderEntityLeft());
 +        if (entity != null) {
@@ -28,42 +28,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        }
 +        return entity;
 +    }
-+    // Paper - maintain old signature
++    // Paper end - release entity api
 +
      private boolean respawnEntityOnShoulder(CompoundTag nbttagcompound) { // CraftBukkit void->boolean
--        if (!this.level().isClientSide && !nbttagcompound.isEmpty()) {
++    // Paper start - release entity api - return entity - overload
 +        return this.respawnEntityOnShoulder0(nbttagcompound) != null;
 +    }
 +
-+    // Paper - return entity
 +    private Entity respawnEntityOnShoulder0(CompoundTag nbttagcompound) { // CraftBukkit void->boolean
-+        if (!this.level().isClientSide && nbttagcompound != null && !nbttagcompound.isEmpty()) {
-             return EntityType.create(nbttagcompound, this.level()).map((entity) -> { // CraftBukkit
++    // Paper end - release entity api - return entity - overload
+         if (!this.level().isClientSide && !nbttagcompound.isEmpty()) {
+             return EntityType.create(nbttagcompound, this.level(), EntitySpawnReason.LOAD).map((entity) -> { // CraftBukkit
                  if (entity instanceof TamableAnimal) {
-                     ((TamableAnimal) entity).setOwnerUUID(this.uuid);
+@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity {
                  }
  
                  entity.setPos(this.getX(), this.getY() + 0.699999988079071D, this.getZ());
 -                return ((ServerLevel) this.level()).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
 -            }).orElse(true); // CraftBukkit
-+                boolean addedToWorld = ((ServerLevel) this.level()).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
-+                return addedToWorld ? entity : null;
-+            }).orElse(null); // CraftBukkit // Paper - true -> null
++                return ((ServerLevel) this.level()).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY) ? entity : null; // CraftBukkit // Paper start - release entity api - return entity
++            }).orElse(null); // CraftBukkit // Paper end - release entity api - return entity
          }
  
 -        return true; // CraftBukkit
 +        return null; // Paper - return null
      }
-+    // Paper end
  
      @Override
-     public abstract boolean isSpectator();
 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
 @@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
-         this.getHandle().getCooldowns().addCooldown(CraftItemType.bukkitToMinecraft(material), ticks);
+         this.getHandle().getCooldowns().addCooldown(CraftItemStack.asNMSCopy(item), ticks);
      }
  
 +    // Paper start
diff --git a/patches/unapplied/server/provide-a-configurable-option-to-disable-creeper-lin.patch b/patches/server/provide-a-configurable-option-to-disable-creeper-lin.patch
similarity index 93%
rename from patches/unapplied/server/provide-a-configurable-option-to-disable-creeper-lin.patch
rename to patches/server/provide-a-configurable-option-to-disable-creeper-lin.patch
index 255cf954ea..e5e8462222 100644
--- a/patches/unapplied/server/provide-a-configurable-option-to-disable-creeper-lin.patch
+++ b/patches/server/provide-a-configurable-option-to-disable-creeper-lin.patch
@@ -9,7 +9,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java
 +++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
-@@ -0,0 +0,0 @@ public class Creeper extends Monster implements PowerableMob {
+@@ -0,0 +0,0 @@ public class Creeper extends Monster {
      private void spawnLingeringCloud() {
          Collection<MobEffectInstance> collection = this.getActiveEffects();
  
diff --git a/patches/unapplied/server/PlayerTeleportEndGatewayEvent.patch b/patches/unapplied/server/PlayerTeleportEndGatewayEvent.patch
deleted file mode 100644
index 7f0fd91903..0000000000
--- a/patches/unapplied/server/PlayerTeleportEndGatewayEvent.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Aikar <aikar@aikar.co>
-Date: Sat, 31 Dec 2016 21:44:50 -0500
-Subject: [PATCH] PlayerTeleportEndGatewayEvent
-
-Allows you to access the Gateway being used in a teleport event
-Fix the offset used for player teleportation
-
-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
-+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
-@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
-             ResourceKey<LevelStem> resourcekey = worldserver1.getTypeKey();
- 
-             if (worldserver != null && worldserver.dimension() == worldserver1.dimension()) { // CraftBukkit
-+                // Paper start - gateway-specific teleport event
-+                if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.serverLevel().getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) {
-+                    Location to = CraftLocation.toBukkit(teleportTarget.pos(), this.serverLevel().getWorld(), teleportTarget.yRot(), teleportTarget.xRot());
-+                    final com.destroystokyo.paper.event.player.PlayerTeleportEndGatewayEvent event = new com.destroystokyo.paper.event.player.PlayerTeleportEndGatewayEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), to, new org.bukkit.craftbukkit.block.CraftEndGateway(to.getWorld(), theEndGatewayBlockEntity));
-+                    if (!event.callEvent() || event.getTo() == null) {
-+                        return null;
-+                    }
-+                    this.connection.teleport(event.getTo());
-+                } else {
-+                    // Paper end - gateway-specific teleport event
-                 boolean result = this.connection.teleport(teleportTarget.pos().x, teleportTarget.pos().y, teleportTarget.pos().z, teleportTarget.yRot(), teleportTarget.xRot(), teleportTarget.cause());
-                 if (!result) {
-                     return null;
-                 }
-                 // CraftBukkit end
-+                } // Paper
-                 this.connection.resetPosition();
-                 teleportTarget.postDimensionTransition().onTransition(this);
-                 return this;