From 8df1b4ad214ceea83b03e91f700acf586fcbff34 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 24 Nov 2021 15:26:29 -0800
Subject: [PATCH] more patches done

---
 .../Add-ElderGuardianAppearanceEvent.patch    |  0
 ...mation-to-version-command-on-startup.patch |  0
 ...Add-PlayerSignCommandPreprocessEvent.patch |  0
 .../api/Add-more-LimitedRegion-API.patch      |  0
 .../api/Add-more-line-of-sight-methods.patch  |  0
 .../api/Adds-PlayerArmSwingEvent.patch        |  0
 .../api/Missing-Entity-Behavior-API.patch     |  0
 .../Add-ElderGuardianAppearanceEvent.patch    |  0
 .../server/Add-more-LimitedRegion-API.patch   | 16 ++---
 .../server/Adds-PlayerArmSwingEvent.patch     |  0
 patches/server/Build-system-changes.patch     | 17 +++++
 ...nect-for-book-edit-is-called-on-main.patch |  0
 ...PlayerDropItemEvent-using-wrong-item.patch |  0
 ...SplashEvent-for-water-splash-potions.patch |  8 +--
 ...from-signs-not-firing-command-events.patch |  7 +-
 .../Fix-dangerous-end-portal-logic.patch      |  8 +--
 .../Fix-invulnerable-end-crystals.patch       |  1 -
 ...-of-Block-applyBoneMeal-always-being.patch |  0
 .../server/Line-Of-Sight-Changes.patch        |  0
 .../Make-item-validations-configurable.patch  |  4 +-
 .../server/Missing-Entity-Behavior-API.patch  |  0
 ...e-Biome-Mob-Lookups-for-Mob-Spawning.patch |  2 +-
 ...etChunkIfLoadedImmediately-in-places.patch | 10 +--
 .../server/add-per-world-spawn-limits.patch   |  4 +-
 ...dd-git-branch-and-commit-to-manifest.patch | 27 -------
 ...atus-dataconverter-for-pre-1.13-chun.patch | 72 -------------------
 26 files changed, 46 insertions(+), 130 deletions(-)
 rename patches/{unapplied => }/api/Add-ElderGuardianAppearanceEvent.patch (100%)
 rename patches/{unapplied => }/api/Add-Git-information-to-version-command-on-startup.patch (100%)
 rename patches/{unapplied => }/api/Add-PlayerSignCommandPreprocessEvent.patch (100%)
 rename patches/{unapplied => }/api/Add-more-LimitedRegion-API.patch (100%)
 rename patches/{unapplied => }/api/Add-more-line-of-sight-methods.patch (100%)
 rename patches/{unapplied => }/api/Adds-PlayerArmSwingEvent.patch (100%)
 rename patches/{unapplied => }/api/Missing-Entity-Behavior-API.patch (100%)
 rename patches/{unapplied => }/server/Add-ElderGuardianAppearanceEvent.patch (100%)
 rename patches/{unapplied => }/server/Add-more-LimitedRegion-API.patch (94%)
 rename patches/{unapplied => }/server/Adds-PlayerArmSwingEvent.patch (100%)
 rename patches/{unapplied => }/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch (100%)
 rename patches/{unapplied => }/server/Fix-PlayerDropItemEvent-using-wrong-item.patch (100%)
 rename patches/{unapplied => }/server/Fix-PotionSplashEvent-for-water-splash-potions.patch (90%)
 rename patches/{unapplied => }/server/Fix-commands-from-signs-not-firing-command-events.patch (94%)
 rename patches/{unapplied => }/server/Fix-dangerous-end-portal-logic.patch (94%)
 rename patches/{unapplied => }/server/Fix-invulnerable-end-crystals.patch (99%)
 rename patches/{unapplied => }/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch (100%)
 rename patches/{unapplied => }/server/Line-Of-Sight-Changes.patch (100%)
 rename patches/{unapplied => }/server/Make-item-validations-configurable.patch (94%)
 rename patches/{unapplied => }/server/Missing-Entity-Behavior-API.patch (100%)
 rename patches/{unapplied => }/server/Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch (98%)
 rename patches/{unapplied => }/server/Use-getChunkIfLoadedImmediately-in-places.patch (88%)
 rename patches/{unapplied => }/server/add-per-world-spawn-limits.patch (96%)
 delete mode 100644 patches/unapplied/server/Add-git-branch-and-commit-to-manifest.patch
 delete mode 100644 patches/unapplied/server/Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch

diff --git a/patches/unapplied/api/Add-ElderGuardianAppearanceEvent.patch b/patches/api/Add-ElderGuardianAppearanceEvent.patch
similarity index 100%
rename from patches/unapplied/api/Add-ElderGuardianAppearanceEvent.patch
rename to patches/api/Add-ElderGuardianAppearanceEvent.patch
diff --git a/patches/unapplied/api/Add-Git-information-to-version-command-on-startup.patch b/patches/api/Add-Git-information-to-version-command-on-startup.patch
similarity index 100%
rename from patches/unapplied/api/Add-Git-information-to-version-command-on-startup.patch
rename to patches/api/Add-Git-information-to-version-command-on-startup.patch
diff --git a/patches/unapplied/api/Add-PlayerSignCommandPreprocessEvent.patch b/patches/api/Add-PlayerSignCommandPreprocessEvent.patch
similarity index 100%
rename from patches/unapplied/api/Add-PlayerSignCommandPreprocessEvent.patch
rename to patches/api/Add-PlayerSignCommandPreprocessEvent.patch
diff --git a/patches/unapplied/api/Add-more-LimitedRegion-API.patch b/patches/api/Add-more-LimitedRegion-API.patch
similarity index 100%
rename from patches/unapplied/api/Add-more-LimitedRegion-API.patch
rename to patches/api/Add-more-LimitedRegion-API.patch
diff --git a/patches/unapplied/api/Add-more-line-of-sight-methods.patch b/patches/api/Add-more-line-of-sight-methods.patch
similarity index 100%
rename from patches/unapplied/api/Add-more-line-of-sight-methods.patch
rename to patches/api/Add-more-line-of-sight-methods.patch
diff --git a/patches/unapplied/api/Adds-PlayerArmSwingEvent.patch b/patches/api/Adds-PlayerArmSwingEvent.patch
similarity index 100%
rename from patches/unapplied/api/Adds-PlayerArmSwingEvent.patch
rename to patches/api/Adds-PlayerArmSwingEvent.patch
diff --git a/patches/unapplied/api/Missing-Entity-Behavior-API.patch b/patches/api/Missing-Entity-Behavior-API.patch
similarity index 100%
rename from patches/unapplied/api/Missing-Entity-Behavior-API.patch
rename to patches/api/Missing-Entity-Behavior-API.patch
diff --git a/patches/unapplied/server/Add-ElderGuardianAppearanceEvent.patch b/patches/server/Add-ElderGuardianAppearanceEvent.patch
similarity index 100%
rename from patches/unapplied/server/Add-ElderGuardianAppearanceEvent.patch
rename to patches/server/Add-ElderGuardianAppearanceEvent.patch
diff --git a/patches/unapplied/server/Add-more-LimitedRegion-API.patch b/patches/server/Add-more-LimitedRegion-API.patch
similarity index 94%
rename from patches/unapplied/server/Add-more-LimitedRegion-API.patch
rename to patches/server/Add-more-LimitedRegion-API.patch
index 7aecd21af6..0796fab566 100644
--- a/patches/unapplied/server/Add-more-LimitedRegion-API.patch
+++ b/patches/server/Add-more-LimitedRegion-API.patch
@@ -65,19 +65,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    @Override
 +    public @NotNull BlockState getBlockState(int x, int y, int z) {
 +        BlockEntity entity = getDelegate().getBlockEntity(new BlockPos(x, y, z));
-+        return CraftMetaBlockState.createBlockState(entity.getBlockState().getBukkitMaterial(), entity.save(new CompoundTag()));
++        return CraftMetaBlockState.createBlockState(entity.getBlockState().getBukkitMaterial(), entity.saveWithFullMetadata());
 +    }
 +
 +    @Override
 +    public void scheduleBlockUpdate(int x, int y, int z) {
 +        BlockPos position = new BlockPos(x, y, z);
-+        getDelegate().getBlockTicks().scheduleTick(position, getDelegate().getBlockIfLoaded(position), 0);
++        getDelegate().scheduleTick(position, getDelegate().getBlockIfLoaded(position), 0);
 +    }
 +
 +    @Override
 +    public void scheduleFluidUpdate(int x, int y, int z) {
 +        BlockPos position = new BlockPos(x, y, z);
-+        getDelegate().getLiquidTicks().scheduleTick(position, getDelegate().getFluidState(position).getType(), 0);
++        getDelegate().scheduleTick(position, getDelegate().getFluidState(position).getType(), 0);
 +    }
 +
 +    @Override
@@ -116,7 +116,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +            function.accept((T) entity.getBukkitEntity());
 +        }
 +
-+        getDelegate().addEntity(entity, reason);
++        getDelegate().addFreshEntity(entity, reason);
 +        return (T) entity.getBukkitEntity();
 +    }
 +
@@ -137,7 +137,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 -        return super.getBlockState(x, y, z);
 +        // Paper start
 +        net.minecraft.world.level.block.entity.BlockEntity entity = getHandle().getBlockEntity(new BlockPos(x, y, z));
-+        return org.bukkit.craftbukkit.inventory.CraftMetaBlockState.createBlockState(entity.getBlockState().getBukkitMaterial(), entity.save(new CompoundTag()));
++        return org.bukkit.craftbukkit.inventory.CraftMetaBlockState.createBlockState(entity.getBlockState().getBukkitMaterial(), entity.saveWithFullMetadata());
 +        // Paper end
      }
  
@@ -169,13 +169,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    @Override
 +    public void scheduleBlockUpdate(int x, int y, int z) {
 +        BlockPos position = new BlockPos(x, y, z);
-+        getHandle().getBlockTicks().scheduleTick(position, getHandle().getBlockIfLoaded(position), 0);
++        getHandle().scheduleTick(position, getHandle().getBlockIfLoaded(position), 0);
 +    }
 +
 +    @Override
 +    public void scheduleFluidUpdate(int x, int y, int z) {
 +        BlockPos position = new BlockPos(x, y, z);
-+        getHandle().getLiquidTicks().scheduleTick(position, getHandle().getFluidState(position).getType(), 0);
++        getHandle().scheduleTick(position, getHandle().getFluidState(position).getType(), 0);
 +    }
 +
 +    @Override
@@ -203,7 +203,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
 @@ -0,0 +0,0 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
          for (BlockPos lightPosition : craftData.getLights()) {
-             ((ProtoChunk) chunk).addLight(new BlockPos((x << 4) + lightPosition.getX(), lightPosition.getY(), (z << 4) + lightPosition.getZ())); // PAIL rename addLightBlock
+             ((ProtoChunk) chunk).addLight(new BlockPos((x << 4) + lightPosition.getX(), lightPosition.getY(), (z << 4) + lightPosition.getZ()));
          }
 +
 +        // Paper start
diff --git a/patches/unapplied/server/Adds-PlayerArmSwingEvent.patch b/patches/server/Adds-PlayerArmSwingEvent.patch
similarity index 100%
rename from patches/unapplied/server/Adds-PlayerArmSwingEvent.patch
rename to patches/server/Adds-PlayerArmSwingEvent.patch
diff --git a/patches/server/Build-system-changes.patch b/patches/server/Build-system-changes.patch
index 99d620d478..63bca1ce94 100644
--- a/patches/server/Build-system-changes.patch
+++ b/patches/server/Build-system-changes.patch
@@ -21,6 +21,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      implementation("com.googlecode.json-simple:json-simple:1.1.1") {
          // This includes junit transitively for whatever reason
          isTransitive = false
+@@ -0,0 +0,0 @@ tasks.jar {
+         val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
+         val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
+         val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
++        val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper
+         attributes(
+             "Main-Class" to "org.bukkit.craftbukkit.Main",
+             "Implementation-Title" to "CraftBukkit",
+@@ -0,0 +0,0 @@ tasks.jar {
+             "Specification-Title" to "Bukkit",
+             "Specification-Version" to project.version,
+             "Specification-Vendor" to "Bukkit Team",
++            "Git-Branch" to gitBranch, // Paper
++            "Git-Commit" to gitHash, // Paper
+         )
+         for (tld in setOf("net", "com", "org")) {
+             attributes("$tld/bukkit", "Sealed" to true)
 @@ -0,0 +0,0 @@ relocation {
      }
  }
diff --git a/patches/unapplied/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch b/patches/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch
similarity index 100%
rename from patches/unapplied/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch
rename to patches/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch
diff --git a/patches/unapplied/server/Fix-PlayerDropItemEvent-using-wrong-item.patch b/patches/server/Fix-PlayerDropItemEvent-using-wrong-item.patch
similarity index 100%
rename from patches/unapplied/server/Fix-PlayerDropItemEvent-using-wrong-item.patch
rename to patches/server/Fix-PlayerDropItemEvent-using-wrong-item.patch
diff --git a/patches/unapplied/server/Fix-PotionSplashEvent-for-water-splash-potions.patch b/patches/server/Fix-PotionSplashEvent-for-water-splash-potions.patch
similarity index 90%
rename from patches/unapplied/server/Fix-PotionSplashEvent-for-water-splash-potions.patch
rename to patches/server/Fix-PotionSplashEvent-for-water-splash-potions.patch
index 88b9363181..cad7f00541 100644
--- a/patches/unapplied/server/Fix-PotionSplashEvent-for-water-splash-potions.patch
+++ b/patches/server/Fix-PotionSplashEvent-for-water-splash-potions.patch
@@ -18,14 +18,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          if (!list.isEmpty()) {
              Iterator iterator = list.iterator();
 @@ -0,0 +0,0 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
-                 double d0 = this.distanceToSqr(entityliving);
+                 double d0 = this.distanceToSqr((Entity) entityliving);
  
                  if (d0 < 16.0D && entityliving.isSensitiveToWater()) {
--                    entityliving.hurt(DamageSource.indirectMagic(entityliving, this.getOwner()), 1.0F);
+-                    entityliving.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F);
 +                    // Paper start
 +                    double intensity = 1.0D - Math.sqrt(d0) / 4.0D;
 +                    affected.put(entityliving.getBukkitLivingEntity(), intensity);
-+                    // entityliving.damageEntity(DamageSource.c(entityliving, this.getShooter()), 1.0F); // Paper - moved down
++                    // entityliving.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F); // Paper - moved down
                  }
              }
          }
@@ -43,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          Iterator iterator1 = list1.iterator();
  
 @@ -0,0 +0,0 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
-                     double d0 = this.distanceToSqr(entityliving);
+                     double d0 = this.distanceToSqr((Entity) entityliving);
  
                      if (d0 < 16.0D) {
 +                        // Paper - diff on change, used when calling the splash event for water splash potions
diff --git a/patches/unapplied/server/Fix-commands-from-signs-not-firing-command-events.patch b/patches/server/Fix-commands-from-signs-not-firing-command-events.patch
similarity index 94%
rename from patches/unapplied/server/Fix-commands-from-signs-not-firing-command-events.patch
rename to patches/server/Fix-commands-from-signs-not-firing-command-events.patch
index 7dab3af016..c065426c9f 100644
--- a/patches/unapplied/server/Fix-commands-from-signs-not-firing-command-events.patch
+++ b/patches/server/Fix-commands-from-signs-not-firing-command-events.patch
@@ -23,7 +23,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        showSignClickCommandFailureMessagesToPlayer = getBoolean("show-sign-click-command-failure-msgs-to-player", showSignClickCommandFailureMessagesToPlayer);
 +    }
  }
- 
 diff --git a/src/main/java/io/papermc/paper/commands/DelegatingCommandSource.java b/src/main/java/io/papermc/paper/commands/DelegatingCommandSource.java
 new file mode 100644
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
@@ -110,7 +109,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        // Paper start - send messages back to the player
 +        CommandSource commandSource = this.level.paperConfig.showSignClickCommandFailureMessagesToPlayer ? new io.papermc.paper.commands.DelegatingCommandSource(this) {
 +            @Override
-+            public void sendMessage(net.minecraft.network.chat.Component message, java.util.UUID sender) {
++            public void sendMessage(Component message, UUID sender) {
 +                player.sendMessage(message, sender);
 +            }
 +
@@ -121,8 +120,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        } : this;
 +        // Paper end
          // CraftBukkit - this
--        return new CommandSourceStack(this, Vec3.atCenterOf((Vec3i) this.worldPosition), Vec2.ZERO, (ServerLevel) this.level, 2, s, (Component) object, this.level.getServer(), player);
-+        return new CommandSourceStack(commandSource, Vec3.atCenterOf((Vec3i) this.worldPosition), Vec2.ZERO, (ServerLevel) this.level, 2, s, (Component) object, this.level.getServer(), player); // Paper
+-        return new CommandSourceStack(this, Vec3.atCenterOf(this.worldPosition), Vec2.ZERO, (ServerLevel) this.level, 2, s, (Component) object, this.level.getServer(), player);
++        return new CommandSourceStack(commandSource, Vec3.atCenterOf(this.worldPosition), Vec2.ZERO, (ServerLevel) this.level, 2, s, (Component) object, this.level.getServer(), player); // Paper
      }
  
      public DyeColor getColor() {
diff --git a/patches/unapplied/server/Fix-dangerous-end-portal-logic.patch b/patches/server/Fix-dangerous-end-portal-logic.patch
similarity index 94%
rename from patches/unapplied/server/Fix-dangerous-end-portal-logic.patch
rename to patches/server/Fix-dangerous-end-portal-logic.patch
index 96dbe3d64e..9dc7912ca7 100644
--- a/patches/unapplied/server/Fix-dangerous-end-portal-logic.patch
+++ b/patches/server/Fix-dangerous-end-portal-logic.patch
@@ -14,9 +14,9 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/entity/Entity.java
 +++ b/src/main/java/net/minecraft/world/entity/Entity.java
-@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
+@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
      }
-     // Paper end - optimise entity tracking
+     // Paper end
  
 +    // Paper start - make end portalling safe
 +    public BlockPos portalBlock;
@@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +            return;
 +        }
 +
-+        ResourceKey<Level> resourcekey = world.getTypeKey() == DimensionType.END_LOCATION ? Level.OVERWORLD : Level.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
++        ResourceKey<Level> resourcekey = world.getTypeKey() == LevelStem.END ? Level.OVERWORLD : Level.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
 +        ServerLevel worldserver = world.getServer().getLevel(resourcekey);
 +
 +        org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(this.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
@@ -52,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      public Entity(EntityType<?> type, Level world) {
          this.id = Entity.ENTITY_COUNTER.incrementAndGet();
          this.passengers = ImmutableList.of();
-@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
+@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
              }
  
              this.processPortalCooldown();
diff --git a/patches/unapplied/server/Fix-invulnerable-end-crystals.patch b/patches/server/Fix-invulnerable-end-crystals.patch
similarity index 99%
rename from patches/unapplied/server/Fix-invulnerable-end-crystals.patch
rename to patches/server/Fix-invulnerable-end-crystals.patch
index 5deaf9cda9..f12c9a6682 100644
--- a/patches/unapplied/server/Fix-invulnerable-end-crystals.patch
+++ b/patches/server/Fix-invulnerable-end-crystals.patch
@@ -19,7 +19,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        fixInvulnerableEndCrystalExploit = getBoolean("unsupported-settings.fix-invulnerable-end-crystal-exploit", fixInvulnerableEndCrystalExploit);
 +    }
  }
- 
 diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
diff --git a/patches/unapplied/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch b/patches/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch
similarity index 100%
rename from patches/unapplied/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch
rename to patches/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch
diff --git a/patches/unapplied/server/Line-Of-Sight-Changes.patch b/patches/server/Line-Of-Sight-Changes.patch
similarity index 100%
rename from patches/unapplied/server/Line-Of-Sight-Changes.patch
rename to patches/server/Line-Of-Sight-Changes.patch
diff --git a/patches/unapplied/server/Make-item-validations-configurable.patch b/patches/server/Make-item-validations-configurable.patch
similarity index 94%
rename from patches/unapplied/server/Make-item-validations-configurable.patch
rename to patches/server/Make-item-validations-configurable.patch
index 8ad9940241..ea9b4d0284 100644
--- a/patches/unapplied/server/Make-item-validations-configurable.patch
+++ b/patches/server/Make-item-validations-configurable.patch
@@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
 +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
 @@ -0,0 +0,0 @@ public class PaperConfig {
-         enableBrigadierConsoleHighlighting = getBoolean("settings.console.enable-brigadier-highlighting", enableBrigadierConsoleHighlighting);
-         enableBrigadierConsoleCompletions = getBoolean("settings.console.enable-brigadier-completions", enableBrigadierConsoleCompletions);
+         config.set("settings.unsupported-settings.allow-headless-pistons-readme", "This setting controls if players should be able to create headless pistons.");
+         allowHeadlessPistons = getBoolean("settings.unsupported-settings.allow-headless-pistons", false);
      }
 +
 +    public static int itemValidationDisplayNameLength = 8192;
diff --git a/patches/unapplied/server/Missing-Entity-Behavior-API.patch b/patches/server/Missing-Entity-Behavior-API.patch
similarity index 100%
rename from patches/unapplied/server/Missing-Entity-Behavior-API.patch
rename to patches/server/Missing-Entity-Behavior-API.patch
diff --git a/patches/unapplied/server/Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch b/patches/server/Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch
similarity index 98%
rename from patches/unapplied/server/Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch
rename to patches/server/Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch
index ebf886f2c3..d62ea59491 100644
--- a/patches/unapplied/server/Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch
+++ b/patches/server/Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch
@@ -54,4 +54,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        // Paper end
          private final Map<EntityType<?>, MobSpawnSettings.MobSpawnCost> mobSpawnCosts = Maps.newLinkedHashMap();
          private float creatureGenerationProbability = 0.1F;
-         private boolean playerCanSpawn;
+ 
diff --git a/patches/unapplied/server/Use-getChunkIfLoadedImmediately-in-places.patch b/patches/server/Use-getChunkIfLoadedImmediately-in-places.patch
similarity index 88%
rename from patches/unapplied/server/Use-getChunkIfLoadedImmediately-in-places.patch
rename to patches/server/Use-getChunkIfLoadedImmediately-in-places.patch
index 8d3c0a6d92..7d5b387654 100644
--- a/patches/unapplied/server/Use-getChunkIfLoadedImmediately-in-places.patch
+++ b/patches/server/Use-getChunkIfLoadedImmediately-in-places.patch
@@ -19,7 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper
      }
  
-     // Paper start
+     @Override
 diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -44,13 +44,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    // Paper start
 +    @Override
 +    public boolean hasChunk(int chunkX, int chunkZ) {
-+        return ((ServerLevel) this).getChunkIfLoaded(chunkX, chunkZ) != null;
++        return this.getChunkIfLoaded(chunkX, chunkZ) != null;
 +    }
 +    // Paper end
 +
-     public ResourceKey<DimensionType> getTypeKey() {
-         return this.typeKey;
-     }
+     public abstract ResourceKey<LevelStem> getTypeKey();
+ 
+     protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, final DimensionType dimensionmanager, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env) {
 @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
  
          for (int l1 = j; l1 <= l; ++l1) {
diff --git a/patches/unapplied/server/add-per-world-spawn-limits.patch b/patches/server/add-per-world-spawn-limits.patch
similarity index 96%
rename from patches/unapplied/server/add-per-world-spawn-limits.patch
rename to patches/server/add-per-world-spawn-limits.patch
index b1719bf010..95ab8c262e 100644
--- a/patches/unapplied/server/add-per-world-spawn-limits.patch
+++ b/patches/server/add-per-world-spawn-limits.patch
@@ -9,10 +9,10 @@ diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/m
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
 +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-@@ -0,0 +0,0 @@ import net.minecraft.world.entity.EntityType;
+@@ -0,0 +0,0 @@ import net.minecraft.world.Difficulty;
+ import net.minecraft.world.entity.EntityType;
  import net.minecraft.world.entity.monster.Vindicator;
  import net.minecraft.world.entity.monster.Zombie;
- import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode;
 +import net.minecraft.world.level.NaturalSpawner;
  import org.bukkit.Bukkit;
  import org.bukkit.configuration.file.YamlConfiguration;
diff --git a/patches/unapplied/server/Add-git-branch-and-commit-to-manifest.patch b/patches/unapplied/server/Add-git-branch-and-commit-to-manifest.patch
deleted file mode 100644
index 82199dd787..0000000000
--- a/patches/unapplied/server/Add-git-branch-and-commit-to-manifest.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Professor Bloodstone <git@bloodstone.dev>
-Date: Sun, 20 Jun 2021 01:14:41 +0200
-Subject: [PATCH] Add git branch and commit to manifest
-
-
-diff --git a/build.gradle.kts b/build.gradle.kts
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/build.gradle.kts
-+++ b/build.gradle.kts
-@@ -0,0 +0,0 @@ tasks.jar {
-         val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
-         val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
-         val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
-+        val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper
-         attributes(
-             "Main-Class" to "org.bukkit.craftbukkit.Main",
-             "Implementation-Title" to "CraftBukkit",
-@@ -0,0 +0,0 @@ tasks.jar {
-             "Specification-Version" to project.version,
-             "Specification-Vendor" to "Bukkit Team",
-             "Multi-Release" to "true", // Paper
-+            "Git-Branch" to gitBranch, // Paper
-+            "Git-Commit" to gitHash, // Paper
-         )
-         for (tld in setOf("net", "com", "org")) {
-             attributes("$tld/bukkit", "Sealed" to true)
diff --git a/patches/unapplied/server/Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch b/patches/unapplied/server/Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch
deleted file mode 100644
index f115e487fc..0000000000
--- a/patches/unapplied/server/Fix-incorrect-status-dataconverter-for-pre-1.13-chun.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Spottedleaf <Spottedleaf@users.noreply.github.com>
-Date: Mon, 10 May 2021 15:46:57 -0700
-Subject: [PATCH] Fix incorrect status dataconverter for pre 1.13 chunks
-
-Vanilla was setting non-populated OR non-lit chunks to empty, but
-really this is just completely wrong. It should be set to "carved"
-at minmum, because pre 1.13 chunks went through 3 distinct stages
-of generation: carving, population, and lighting - in this order.
-There is no "empty" status, because a chunk was simply carved
-or it didn't exist. So mapping any chunk data to empty is simply
-invalid.
-
-If the chunk is terrain populated, then obviously it must be at
-minmum "decorated." If the chunk is lit and populated, then it is marked
-"mobs_spawned" (which is what Vanilla is doing, and this is the last
-stage before moving to full so it looks correct).
-
-So now here is a table representing the new status conversion:
-
-Chunk is lit        Chunk is populated       Vanilla
-     F                       F                empty
-     T                       F                empty
-     F                       T                empty
-     T                       T             mobs_spawned
-
-Chunk is lit        Chunk is populated         Paper
-     F                       F                carved
-     T                       F                carved
-     F                       T              decorated
-     T                       T             mobs_spawned
-
-This should fix some problems converting old data, as the
-changes here are going to prevent the chunk from being regenerated
-incorrectly.
-
-diff --git a/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java b/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java
-+++ b/src/main/java/net/minecraft/util/datafix/fixes/ChunkToProtochunkFix.java
-@@ -0,0 +0,0 @@ public class ChunkToProtochunkFix extends DataFix {
-         OpticFinder<?> opticFinder2 = DSL.fieldFinder("TileTicks", type5);
-         return TypeRewriteRule.seq(this.fixTypeEverywhereTyped("ChunkToProtoChunkFix", type, this.getOutputSchema().getType(References.CHUNK), (typed) -> {
-             return typed.updateTyped(opticFinder, type4, (typedx) -> {
--                Optional<? extends Stream<? extends Dynamic<?>>> optional = typedx.getOptionalTyped(opticFinder2).flatMap((typed) -> {
--                    return typed.write().result();
-+                Optional<? extends Stream<? extends Dynamic<?>>> optional = typedx.getOptionalTyped(opticFinder2).flatMap((it) -> { // Paper - remap fix
-+                    return it.write().result(); // Paper - remap fix
-                 }).flatMap((dynamicx) -> {
-                     return dynamicx.asStreamOpt().result();
-                 });
-                 Dynamic<?> dynamic = typedx.get(DSL.remainderFinder());
--                boolean bl = dynamic.get("TerrainPopulated").asBoolean(false) && (!dynamic.get("LightPopulated").asNumber().result().isPresent() || dynamic.get("LightPopulated").asBoolean(false));
--                dynamic = dynamic.set("Status", dynamic.createString(bl ? "mobs_spawned" : "empty"));
-+                // Paper start - fix incorrect status conversion
-+                // Vanilla is setting chunks to incorrect status here, they should be using at minimum carved.
-+                // for populated chunks, it should be at minimum decorated
-+                // and for lit and populated, mobs_spawned is correct (technically mobs_spawned should be for populated,
-+                // but if it's not lit then it can't be set above lit)
-+                final boolean terrainPopulated = dynamic.get("TerrainPopulated").asBoolean(false);
-+                final boolean lightPopulated = dynamic.get("LightPopulated").asBoolean(false) || dynamic.get("LightPopulated").asNumber().result().isPresent();
-+                final String newStatus = !terrainPopulated ? "carved" : (lightPopulated ? "mobs_spawned" : "decorated");
-+
-+                dynamic = dynamic.set("Status", dynamic.createString(newStatus));
-+                // Paper end - fix incorrect status conversion
-                 dynamic = dynamic.set("hasLegacyStructureData", dynamic.createBoolean(true));
-                 Dynamic<?> dynamic3;
--                if (bl) {
-+                if (true) { // Paper - fix incorrect status conversion
-                     Optional<ByteBuffer> optional2 = dynamic.get("Biomes").asByteBufferOpt().result();
-                     if (optional2.isPresent()) {
-                         ByteBuffer byteBuffer = optional2.get();