From 2253e953c693748e44ab28245621ba34d2a4b226 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 24 Nov 2021 13:30:53 -0800
Subject: [PATCH] more patches

---
 ...essage-to-PlayerAdvancementDoneEvent.patch |  0
 ...Add-EntityBlockStorage-clearEntities.patch |  0
 .../api/Add-EntityInsideBlockEvent.patch      |  0
 .../api/Add-Mob-lookAt-API.patch              |  0
 .../api/Add-PlayerKickEvent-causes.patch      |  0
 ...n-in-sunlight-API-for-Phantoms-and-S.patch |  0
 .../api/Add-basic-Datapack-API.patch          |  0
 ...cause-to-Weather-ThunderChangeEvents.patch |  0
 ...-address-to-AsyncPlayerPreLoginEvent.patch |  0
 .../Attributes-API-for-item-defaults.patch    |  0
 .../{unapplied => }/api/Inventory-close.patch |  0
 .../api/ItemStack-editMeta.patch              |  0
 .../api/ItemStack-repair-check-API.patch      |  0
 ...-missing-hard-depends-not-just-first.patch |  0
 .../api/More-Enchantment-API.patch            |  0
 .../api/More-Lidded-Block-API.patch           |  0
 ...ditions-to-PlayerGameModeChangeEvent.patch |  0
 ...essage-to-PlayerAdvancementDoneEvent.patch |  0
 ...Add-EntityBlockStorage-clearEntities.patch |  0
 .../server/Add-EntityInsideBlockEvent.patch   | 14 ++++-
 .../server/Add-Mob-lookAt-API.patch           |  0
 .../server/Add-PlayerKickEvent-causes.patch   |  0
 .../Add-Unix-domain-socket-support.patch      |  0
 ...n-in-sunlight-API-for-Phantoms-and-S.patch |  0
 .../server/Add-basic-Datapack-API.patch       |  0
 ...cause-to-Weather-ThunderChangeEvents.patch | 19 ++-----
 ...nment-variable-to-disable-server-gui.patch |  0
 ...-address-to-AsyncPlayerPreLoginEvent.patch |  0
 .../Attributes-API-for-item-defaults.patch    |  0
 .../server/Fix-CraftPotionBrewer-cache.patch  |  0
 ...x-and-optimise-world-force-upgrading.patch | 53 ++++++++++---------
 .../server/Inventory-close.patch              |  0
 .../server/ItemStack-repair-check-API.patch   |  0
 .../Limit-item-frame-cursors-on-maps.patch    |  1 -
 .../server/More-Enchantment-API.patch         |  0
 .../server/More-Lidded-Block-API.patch        |  0
 ...ditions-to-PlayerGameModeChangeEvent.patch |  8 +--
 ...CreateEvent-players-and-end-platform.patch |  0
 38 files changed, 51 insertions(+), 44 deletions(-)
 rename patches/{unapplied => }/api/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch (100%)
 rename patches/{unapplied => }/api/Add-EntityBlockStorage-clearEntities.patch (100%)
 rename patches/{unapplied => }/api/Add-EntityInsideBlockEvent.patch (100%)
 rename patches/{unapplied => }/api/Add-Mob-lookAt-API.patch (100%)
 rename patches/{unapplied => }/api/Add-PlayerKickEvent-causes.patch (100%)
 rename patches/{unapplied => }/api/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch (100%)
 rename patches/{unapplied => }/api/Add-basic-Datapack-API.patch (100%)
 rename patches/{unapplied => }/api/Add-cause-to-Weather-ThunderChangeEvents.patch (100%)
 rename patches/{unapplied => }/api/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch (100%)
 rename patches/{unapplied => }/api/Attributes-API-for-item-defaults.patch (100%)
 rename patches/{unapplied => }/api/Inventory-close.patch (100%)
 rename patches/{unapplied => }/api/ItemStack-editMeta.patch (100%)
 rename patches/{unapplied => }/api/ItemStack-repair-check-API.patch (100%)
 rename patches/{unapplied => }/api/List-all-missing-hard-depends-not-just-first.patch (100%)
 rename patches/{unapplied => }/api/More-Enchantment-API.patch (100%)
 rename patches/{unapplied => }/api/More-Lidded-Block-API.patch (100%)
 rename patches/{unapplied => }/api/additions-to-PlayerGameModeChangeEvent.patch (100%)
 rename patches/{unapplied => }/server/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch (100%)
 rename patches/{unapplied => }/server/Add-EntityBlockStorage-clearEntities.patch (100%)
 rename patches/{unapplied => }/server/Add-EntityInsideBlockEvent.patch (94%)
 rename patches/{unapplied => }/server/Add-Mob-lookAt-API.patch (100%)
 rename patches/{unapplied => }/server/Add-PlayerKickEvent-causes.patch (100%)
 rename patches/{unapplied => }/server/Add-Unix-domain-socket-support.patch (100%)
 rename patches/{unapplied => }/server/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch (100%)
 rename patches/{unapplied => }/server/Add-basic-Datapack-API.patch (100%)
 rename patches/{unapplied => }/server/Add-cause-to-Weather-ThunderChangeEvents.patch (94%)
 rename patches/{unapplied => }/server/Add-environment-variable-to-disable-server-gui.patch (100%)
 rename patches/{unapplied => }/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch (100%)
 rename patches/{unapplied => }/server/Attributes-API-for-item-defaults.patch (100%)
 rename patches/{unapplied => }/server/Fix-CraftPotionBrewer-cache.patch (100%)
 rename patches/{unapplied => }/server/Fix-and-optimise-world-force-upgrading.patch (87%)
 rename patches/{unapplied => }/server/Inventory-close.patch (100%)
 rename patches/{unapplied => }/server/ItemStack-repair-check-API.patch (100%)
 rename patches/{unapplied => }/server/Limit-item-frame-cursors-on-maps.patch (99%)
 rename patches/{unapplied => }/server/More-Enchantment-API.patch (100%)
 rename patches/{unapplied => }/server/More-Lidded-Block-API.patch (100%)
 rename patches/{unapplied => }/server/additions-to-PlayerGameModeChangeEvent.patch (91%)
 rename patches/{unapplied => }/server/call-PortalCreateEvent-players-and-end-platform.patch (100%)

diff --git a/patches/unapplied/api/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch b/patches/api/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
similarity index 100%
rename from patches/unapplied/api/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
rename to patches/api/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
diff --git a/patches/unapplied/api/Add-EntityBlockStorage-clearEntities.patch b/patches/api/Add-EntityBlockStorage-clearEntities.patch
similarity index 100%
rename from patches/unapplied/api/Add-EntityBlockStorage-clearEntities.patch
rename to patches/api/Add-EntityBlockStorage-clearEntities.patch
diff --git a/patches/unapplied/api/Add-EntityInsideBlockEvent.patch b/patches/api/Add-EntityInsideBlockEvent.patch
similarity index 100%
rename from patches/unapplied/api/Add-EntityInsideBlockEvent.patch
rename to patches/api/Add-EntityInsideBlockEvent.patch
diff --git a/patches/unapplied/api/Add-Mob-lookAt-API.patch b/patches/api/Add-Mob-lookAt-API.patch
similarity index 100%
rename from patches/unapplied/api/Add-Mob-lookAt-API.patch
rename to patches/api/Add-Mob-lookAt-API.patch
diff --git a/patches/unapplied/api/Add-PlayerKickEvent-causes.patch b/patches/api/Add-PlayerKickEvent-causes.patch
similarity index 100%
rename from patches/unapplied/api/Add-PlayerKickEvent-causes.patch
rename to patches/api/Add-PlayerKickEvent-causes.patch
diff --git a/patches/unapplied/api/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch b/patches/api/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch
similarity index 100%
rename from patches/unapplied/api/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch
rename to patches/api/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch
diff --git a/patches/unapplied/api/Add-basic-Datapack-API.patch b/patches/api/Add-basic-Datapack-API.patch
similarity index 100%
rename from patches/unapplied/api/Add-basic-Datapack-API.patch
rename to patches/api/Add-basic-Datapack-API.patch
diff --git a/patches/unapplied/api/Add-cause-to-Weather-ThunderChangeEvents.patch b/patches/api/Add-cause-to-Weather-ThunderChangeEvents.patch
similarity index 100%
rename from patches/unapplied/api/Add-cause-to-Weather-ThunderChangeEvents.patch
rename to patches/api/Add-cause-to-Weather-ThunderChangeEvents.patch
diff --git a/patches/unapplied/api/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch b/patches/api/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch
similarity index 100%
rename from patches/unapplied/api/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch
rename to patches/api/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch
diff --git a/patches/unapplied/api/Attributes-API-for-item-defaults.patch b/patches/api/Attributes-API-for-item-defaults.patch
similarity index 100%
rename from patches/unapplied/api/Attributes-API-for-item-defaults.patch
rename to patches/api/Attributes-API-for-item-defaults.patch
diff --git a/patches/unapplied/api/Inventory-close.patch b/patches/api/Inventory-close.patch
similarity index 100%
rename from patches/unapplied/api/Inventory-close.patch
rename to patches/api/Inventory-close.patch
diff --git a/patches/unapplied/api/ItemStack-editMeta.patch b/patches/api/ItemStack-editMeta.patch
similarity index 100%
rename from patches/unapplied/api/ItemStack-editMeta.patch
rename to patches/api/ItemStack-editMeta.patch
diff --git a/patches/unapplied/api/ItemStack-repair-check-API.patch b/patches/api/ItemStack-repair-check-API.patch
similarity index 100%
rename from patches/unapplied/api/ItemStack-repair-check-API.patch
rename to patches/api/ItemStack-repair-check-API.patch
diff --git a/patches/unapplied/api/List-all-missing-hard-depends-not-just-first.patch b/patches/api/List-all-missing-hard-depends-not-just-first.patch
similarity index 100%
rename from patches/unapplied/api/List-all-missing-hard-depends-not-just-first.patch
rename to patches/api/List-all-missing-hard-depends-not-just-first.patch
diff --git a/patches/unapplied/api/More-Enchantment-API.patch b/patches/api/More-Enchantment-API.patch
similarity index 100%
rename from patches/unapplied/api/More-Enchantment-API.patch
rename to patches/api/More-Enchantment-API.patch
diff --git a/patches/unapplied/api/More-Lidded-Block-API.patch b/patches/api/More-Lidded-Block-API.patch
similarity index 100%
rename from patches/unapplied/api/More-Lidded-Block-API.patch
rename to patches/api/More-Lidded-Block-API.patch
diff --git a/patches/unapplied/api/additions-to-PlayerGameModeChangeEvent.patch b/patches/api/additions-to-PlayerGameModeChangeEvent.patch
similarity index 100%
rename from patches/unapplied/api/additions-to-PlayerGameModeChangeEvent.patch
rename to patches/api/additions-to-PlayerGameModeChangeEvent.patch
diff --git a/patches/unapplied/server/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch b/patches/server/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
similarity index 100%
rename from patches/unapplied/server/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
rename to patches/server/Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
diff --git a/patches/unapplied/server/Add-EntityBlockStorage-clearEntities.patch b/patches/server/Add-EntityBlockStorage-clearEntities.patch
similarity index 100%
rename from patches/unapplied/server/Add-EntityBlockStorage-clearEntities.patch
rename to patches/server/Add-EntityBlockStorage-clearEntities.patch
diff --git a/patches/unapplied/server/Add-EntityInsideBlockEvent.patch b/patches/server/Add-EntityInsideBlockEvent.patch
similarity index 94%
rename from patches/unapplied/server/Add-EntityInsideBlockEvent.patch
rename to patches/server/Add-EntityInsideBlockEvent.patch
index 15a1c14b79..501225f56a 100644
--- a/patches/unapplied/server/Add-EntityInsideBlockEvent.patch
+++ b/patches/server/Add-EntityInsideBlockEvent.patch
@@ -28,6 +28,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          if (!world.isClientSide) {
              int i = this.getSignalForState(state);
  
+diff --git a/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java b/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java
++++ b/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java
+@@ -0,0 +0,0 @@ public class BigDripleafBlock extends HorizontalDirectionalBlock implements Bone
+ 
+     @Override
+     public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
++        if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
+         if (!world.isClientSide) {
+             if (state.getValue(BigDripleafBlock.TILT) == Tilt.NONE && BigDripleafBlock.canEntityTilt(pos, entity) && !world.hasNeighborSignal(pos)) {
+                 // CraftBukkit start - tilt dripleaf
 diff --git a/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java b/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java
@@ -110,7 +122,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
 +        if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
          if (world instanceof ServerLevel && !entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions() && Shapes.joinIsNotEmpty(Shapes.create(entity.getBoundingBox().move((double) (-pos.getX()), (double) (-pos.getY()), (double) (-pos.getZ()))), state.getShape(world, pos), BooleanOp.AND)) {
-             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 = ((ServerLevel) world).getServer().getLevel(resourcekey);
 diff --git a/src/main/java/net/minecraft/world/level/block/HoneyBlock.java b/src/main/java/net/minecraft/world/level/block/HoneyBlock.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
diff --git a/patches/unapplied/server/Add-Mob-lookAt-API.patch b/patches/server/Add-Mob-lookAt-API.patch
similarity index 100%
rename from patches/unapplied/server/Add-Mob-lookAt-API.patch
rename to patches/server/Add-Mob-lookAt-API.patch
diff --git a/patches/unapplied/server/Add-PlayerKickEvent-causes.patch b/patches/server/Add-PlayerKickEvent-causes.patch
similarity index 100%
rename from patches/unapplied/server/Add-PlayerKickEvent-causes.patch
rename to patches/server/Add-PlayerKickEvent-causes.patch
diff --git a/patches/unapplied/server/Add-Unix-domain-socket-support.patch b/patches/server/Add-Unix-domain-socket-support.patch
similarity index 100%
rename from patches/unapplied/server/Add-Unix-domain-socket-support.patch
rename to patches/server/Add-Unix-domain-socket-support.patch
diff --git a/patches/unapplied/server/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch b/patches/server/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch
similarity index 100%
rename from patches/unapplied/server/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch
rename to patches/server/Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch
diff --git a/patches/unapplied/server/Add-basic-Datapack-API.patch b/patches/server/Add-basic-Datapack-API.patch
similarity index 100%
rename from patches/unapplied/server/Add-basic-Datapack-API.patch
rename to patches/server/Add-basic-Datapack-API.patch
diff --git a/patches/unapplied/server/Add-cause-to-Weather-ThunderChangeEvents.patch b/patches/server/Add-cause-to-Weather-ThunderChangeEvents.patch
similarity index 94%
rename from patches/unapplied/server/Add-cause-to-Weather-ThunderChangeEvents.patch
rename to patches/server/Add-cause-to-Weather-ThunderChangeEvents.patch
index e0e07a9f3e..628b61d498 100644
--- a/patches/unapplied/server/Add-cause-to-Weather-ThunderChangeEvents.patch
+++ b/patches/server/Add-cause-to-Weather-ThunderChangeEvents.patch
@@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
              this.oThunderLevel = this.thunderLevel;
 @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
  
-     private void stopWeather() {
+     private void resetWeatherCycle() {
          // CraftBukkit start
 -        this.serverLevelData.setRaining(false);
 +        this.serverLevelData.setRaining(false, org.bukkit.event.weather.WeatherChangeEvent.Cause.SLEEP); // Paper - when passing the night
@@ -58,29 +58,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        // Paper start
 +        this.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.UNKNOWN);
 +    }
-+    public void setThundering(boolean flag, org.bukkit.event.weather.ThunderChangeEvent.Cause cause) {
++    public void setThundering(boolean thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause cause) {
 +        // Paper end
          // CraftBukkit start
--        if (this.thundering == thundering) {
-+        if (this.thundering == flag) {
+         if (this.thundering == thundering) {
              return;
-         }
+@@ -0,0 +0,0 @@ public class PrimaryLevelData implements ServerLevelData, WorldData {
  
          org.bukkit.World world = Bukkit.getWorld(this.getLevelName());
          if (world != null) {
 -            ThunderChangeEvent thunder = new ThunderChangeEvent(world, thundering);
-+            ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag, cause); // Paper
++            ThunderChangeEvent thunder = new ThunderChangeEvent(world, thundering, cause); // Paper
              Bukkit.getServer().getPluginManager().callEvent(thunder);
              if (thunder.isCancelled()) {
                  return;
-             }
-         }
-         // CraftBukkit end
--        this.thundering = thundering;
-+        this.thundering = flag;
-     }
- 
-     @Override
 @@ -0,0 +0,0 @@ public class PrimaryLevelData implements ServerLevelData, WorldData {
  
      @Override
diff --git a/patches/unapplied/server/Add-environment-variable-to-disable-server-gui.patch b/patches/server/Add-environment-variable-to-disable-server-gui.patch
similarity index 100%
rename from patches/unapplied/server/Add-environment-variable-to-disable-server-gui.patch
rename to patches/server/Add-environment-variable-to-disable-server-gui.patch
diff --git a/patches/unapplied/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch b/patches/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch
similarity index 100%
rename from patches/unapplied/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch
rename to patches/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch
diff --git a/patches/unapplied/server/Attributes-API-for-item-defaults.patch b/patches/server/Attributes-API-for-item-defaults.patch
similarity index 100%
rename from patches/unapplied/server/Attributes-API-for-item-defaults.patch
rename to patches/server/Attributes-API-for-item-defaults.patch
diff --git a/patches/unapplied/server/Fix-CraftPotionBrewer-cache.patch b/patches/server/Fix-CraftPotionBrewer-cache.patch
similarity index 100%
rename from patches/unapplied/server/Fix-CraftPotionBrewer-cache.patch
rename to patches/server/Fix-CraftPotionBrewer-cache.patch
diff --git a/patches/unapplied/server/Fix-and-optimise-world-force-upgrading.patch b/patches/server/Fix-and-optimise-world-force-upgrading.patch
similarity index 87%
rename from patches/unapplied/server/Fix-and-optimise-world-force-upgrading.patch
rename to patches/server/Fix-and-optimise-world-force-upgrading.patch
index 4dc49d66d0..a7ddac1179 100644
--- a/patches/unapplied/server/Fix-and-optimise-world-force-upgrading.patch
+++ b/patches/server/Fix-and-optimise-world-force-upgrading.patch
@@ -37,15 +37,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +package io.papermc.paper.world;
 +
 +import com.mojang.datafixers.DataFixer;
++import com.mojang.serialization.Codec;
 +import net.minecraft.SharedConstants;
 +import net.minecraft.nbt.CompoundTag;
 +import net.minecraft.resources.ResourceKey;
 +import net.minecraft.util.worldupdate.WorldUpgrader;
 +import net.minecraft.world.level.ChunkPos;
++import net.minecraft.world.level.Level;
++import net.minecraft.world.level.chunk.ChunkGenerator;
 +import net.minecraft.world.level.chunk.storage.ChunkStorage;
 +import net.minecraft.world.level.chunk.storage.RegionFileStorage;
 +import net.minecraft.world.level.dimension.DimensionType;
 +import net.minecraft.world.level.dimension.LevelStem;
++import net.minecraft.world.level.levelgen.WorldGenSettings;
 +import net.minecraft.world.level.storage.DimensionDataStorage;
 +import net.minecraft.world.level.storage.LevelStorageSource;
 +import org.apache.logging.log4j.LogManager;
@@ -53,6 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +import java.io.File;
 +import java.io.IOException;
 +import java.text.DecimalFormat;
++import java.util.Optional;
 +import java.util.concurrent.ExecutorService;
 +import java.util.concurrent.Executors;
 +import java.util.concurrent.ThreadFactory;
@@ -70,10 +75,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    private final File worldDir;
 +    private final ExecutorService threadPool;
 +    private final DataFixer dataFixer;
++    private final Optional<ResourceKey<Codec<? extends ChunkGenerator>>> generatorKey;
 +    private final boolean removeCaches;
 +
 +    public ThreadedWorldUpgrader(final ResourceKey<LevelStem> dimensionType, final ResourceKey<DimensionType> worldKey, final String worldName, final File worldDir, final int threads,
-+                                 final DataFixer dataFixer, final boolean removeCaches) {
++                                 final DataFixer dataFixer, final Optional<ResourceKey<Codec<? extends ChunkGenerator>>> generatorKey, final boolean removeCaches) {
 +        this.dimensionType = dimensionType;
 +        this.worldKey = worldKey;
 +        this.worldName = worldName;
@@ -94,11 +100,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +            }
 +        });
 +        this.dataFixer = dataFixer;
++        this.generatorKey = generatorKey;
 +        this.removeCaches = removeCaches;
 +    }
 +
 +    public void convert() {
-+        final File worldFolder = LevelStorageSource.getFolder(this.worldDir, this.dimensionType);
++        final File worldFolder = LevelStorageSource.getStorageFolder(this.worldDir.toPath(), this.dimensionType).toFile();
 +        final DimensionDataStorage worldPersistentData = new DimensionDataStorage(new File(worldFolder, "data"), this.dataFixer);
 +
 +        final File regionFolder = new File(worldFolder, "region");
@@ -116,12 +123,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        LOGGER.info("Starting conversion now for world " + this.worldName);
 +
 +        final WorldInfo info = new WorldInfo(() -> worldPersistentData,
-+                new ChunkStorage(regionFolder, this.dataFixer, false), this.removeCaches, this.worldKey);
++                new ChunkStorage(regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey);
 +
 +        long expectedChunks = (long)regionFiles.length * (32L * 32L);
 +
 +        for (final File regionFile : regionFiles) {
-+            final ChunkPos regionPos = RegionFileStorage.getRegionFileCoordinates(regionFile);
++            final ChunkPos regionPos = RegionFileStorage.getRegionFileCoordinates(regionFile.toPath());
 +            if (regionPos == null) {
 +                expectedChunks -= (32L * 32L);
 +                continue;
@@ -161,16 +168,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        public final Supplier<DimensionDataStorage> persistentDataSupplier;
 +        public final ChunkStorage loader;
 +        public final boolean removeCaches;
-+        public final ResourceKey<DimensionType> worldKey;
++        public final ResourceKey<LevelStem> worldKey;
++        public final Optional<ResourceKey<Codec<? extends ChunkGenerator>>> generatorKey;
 +        public final AtomicLong convertedChunks = new AtomicLong();
 +        public final AtomicLong modifiedChunks = new AtomicLong();
 +
 +        private WorldInfo(final Supplier<DimensionDataStorage> persistentDataSupplier, final ChunkStorage loader, final boolean removeCaches,
-+                          final ResourceKey<DimensionType> worldKey) {
++                          final ResourceKey<LevelStem> worldKey, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> generatorKey) {
 +            this.persistentDataSupplier = persistentDataSupplier;
 +            this.loader = loader;
 +            this.removeCaches = removeCaches;
 +            this.worldKey = worldKey;
++            this.generatorKey = generatorKey;
 +        }
 +    }
 +
@@ -194,7 +203,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +            final Supplier<DimensionDataStorage> persistentDataSupplier = this.worldInfo.persistentDataSupplier;
 +            final ChunkStorage loader = this.worldInfo.loader;
 +            final boolean removeCaches = this.worldInfo.removeCaches;
-+            final ResourceKey<DimensionType> worldKey = this.worldInfo.worldKey;
++            final ResourceKey<LevelStem> worldKey = this.worldInfo.worldKey;
 +
 +            for (int cz = regionCZ; cz < (regionCZ + 32); ++cz) {
 +                for (int cx = regionCX; cx < (regionCX + 32); ++cx) {
@@ -210,7 +219,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +
 +                        final int versionBefore = ChunkStorage.getVersion(chunkNBT);
 +
-+                        chunkNBT = loader.getChunkData(worldKey, persistentDataSupplier, chunkNBT, chunkPos, null);
++                        chunkNBT = loader.upgradeChunkTag(worldKey, persistentDataSupplier, chunkNBT, this.worldInfo.generatorKey, chunkPos, null);
 +
 +                        boolean modified = versionBefore < SharedConstants.getCurrentVersion().getWorldVersion();
 +
@@ -253,17 +262,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      // Paper end
  
 +    // Paper start - fix and optimise world upgrading
-+    public static void convertWorldButItWorks(ResourceKey<LevelStem> dimensionType, ResourceKey<DimensionType> worldKey, net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess worldSession,
-+                                              DataFixer dataFixer, boolean removeCaches) {
++    public static void convertWorldButItWorks(net.minecraft.resources.ResourceKey<net.minecraft.world.level.dimension.LevelStem> dimensionType, net.minecraft.resources.ResourceKey<net.minecraft.world.level.dimension.DimensionType> worldKey, net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess worldSession,
++                                              DataFixer dataFixer, Optional<net.minecraft.resources.ResourceKey<com.mojang.serialization.Codec<? extends net.minecraft.world.level.chunk.ChunkGenerator>>> generatorKey, boolean removeCaches) {
 +        int threads = Runtime.getRuntime().availableProcessors() * 3 / 8;
-+        final ThreadedWorldUpgrader worldUpgrader = new ThreadedWorldUpgrader(dimensionType, worldKey, worldSession.getLevelId(), worldSession.levelPath.toFile(), threads, dataFixer, removeCaches);
++        final ThreadedWorldUpgrader worldUpgrader = new ThreadedWorldUpgrader(dimensionType, worldKey, worldSession.getLevelId(), worldSession.levelPath.toFile(), threads, dataFixer, generatorKey, removeCaches);
 +        worldUpgrader.convert();
 +    }
 +    // Paper end - fix and optimise world upgrading
 +
-     public static void forceUpgrade(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, boolean eraseCache, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<DimensionType>> worlds) { // CraftBukkit
+     public static void forceUpgrade(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, boolean eraseCache, BooleanSupplier continueCheck, WorldGenSettings generatorOptions) {
          Main.LOGGER.info("Forcing world upgrade! {}", session.getLevelId()); // CraftBukkit
-         WorldUpgrader worldupgrader = new WorldUpgrader(session, dataFixer, worlds, eraseCache);
+         WorldUpgrader worldupgrader = new WorldUpgrader(session, dataFixer, generatorOptions, eraseCache);
 diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -275,9 +284,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 -            if (this.options.has("forceUpgrade")) {
 -                net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), this.options.has("eraseCache"), () -> {
 -                    return true;
--                }, worlddata.worldGenSettings().dimensions().entrySet().stream().map((entry1) -> {
--                    return ResourceKey.create(Registry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry1.getKey()).location());
--                }).collect(ImmutableSet.toImmutableSet()));
+-                }, worlddata.worldGenSettings());
 -            }
 +            // Paper - move down
  
@@ -290,7 +297,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +            // Paper start - fix and optimise world upgrading
 +            if (options.has("forceUpgrade")) {
 +                net.minecraft.server.Main.convertWorldButItWorks(
-+                        dimensionKey, Level.getDimensionKey(dimensionmanager), worldSession, DataFixers.getDataFixer(), options.has("eraseCache")
++                        dimensionKey, Level.getDimensionKey(dimensionmanager), worldSession, DataFixers.getDataFixer(), chunkgenerator.getTypeNameForDataFixer(), options.has("eraseCache")
 +                );
 +            }
 +            // Paper end - fix and optimise world upgrading
@@ -326,8 +333,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      }
  
      // Paper start
-+    public static ChunkPos getRegionFileCoordinates(File file) {
-+        String fileName = file.getName();
++    public static @Nullable ChunkPos getRegionFileCoordinates(Path file) {
++        String fileName = file.getFileName().toString();
 +        if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
 +            return null;
 +        }
@@ -358,14 +365,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 @@ -0,0 +0,0 @@ public final class CraftServer implements Server {
          }
          worlddata.checkName(name);
-         worlddata.setModdedInfo(this.console.getServerModName(), this.console.getModdedStatus().isPresent());
+         worlddata.setModdedInfo(this.console.getServerModName(), this.console.getModdedStatus().shouldReportAsModified());
 -
 -        if (console.options.has("forceUpgrade")) {
 -            net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), console.options.has("eraseCache"), () -> {
 -                return true;
--            }, worlddata.worldGenSettings().dimensions().entrySet().stream().map((entry) -> {
--                return ResourceKey.create(Registry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry.getKey()).location());
--            }).collect(ImmutableSet.toImmutableSet()));
+-            }, worlddata.worldGenSettings());
 -        }
 +        // Paper - move down
  
@@ -378,7 +383,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        // Paper start - fix and optimise world upgrading
 +        if (console.options.has("forceUpgrade")) {
 +            net.minecraft.server.Main.convertWorldButItWorks(
-+                actualDimension, net.minecraft.world.level.Level.getDimensionKey(dimensionmanager), worldSession, DataFixers.getDataFixer(), console.options.has("eraseCache")
++                actualDimension, net.minecraft.world.level.Level.getDimensionKey(dimensionmanager), worldSession, DataFixers.getDataFixer(), chunkgenerator.getTypeNameForDataFixer(), console.options.has("eraseCache")
 +            );
 +        }
 +        // Paper end - fix and optimise world upgrading
diff --git a/patches/unapplied/server/Inventory-close.patch b/patches/server/Inventory-close.patch
similarity index 100%
rename from patches/unapplied/server/Inventory-close.patch
rename to patches/server/Inventory-close.patch
diff --git a/patches/unapplied/server/ItemStack-repair-check-API.patch b/patches/server/ItemStack-repair-check-API.patch
similarity index 100%
rename from patches/unapplied/server/ItemStack-repair-check-API.patch
rename to patches/server/ItemStack-repair-check-API.patch
diff --git a/patches/unapplied/server/Limit-item-frame-cursors-on-maps.patch b/patches/server/Limit-item-frame-cursors-on-maps.patch
similarity index 99%
rename from patches/unapplied/server/Limit-item-frame-cursors-on-maps.patch
rename to patches/server/Limit-item-frame-cursors-on-maps.patch
index aac43baa02..998b423b14 100644
--- a/patches/unapplied/server/Limit-item-frame-cursors-on-maps.patch
+++ b/patches/server/Limit-item-frame-cursors-on-maps.patch
@@ -18,7 +18,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        mapItemFrameCursorLimit = getInt("map-item-frame-cursor-limit", mapItemFrameCursorLimit);
 +    }
  }
- 
 diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
diff --git a/patches/unapplied/server/More-Enchantment-API.patch b/patches/server/More-Enchantment-API.patch
similarity index 100%
rename from patches/unapplied/server/More-Enchantment-API.patch
rename to patches/server/More-Enchantment-API.patch
diff --git a/patches/unapplied/server/More-Lidded-Block-API.patch b/patches/server/More-Lidded-Block-API.patch
similarity index 100%
rename from patches/unapplied/server/More-Lidded-Block-API.patch
rename to patches/server/More-Lidded-Block-API.patch
diff --git a/patches/unapplied/server/additions-to-PlayerGameModeChangeEvent.patch b/patches/server/additions-to-PlayerGameModeChangeEvent.patch
similarity index 91%
rename from patches/unapplied/server/additions-to-PlayerGameModeChangeEvent.patch
rename to patches/server/additions-to-PlayerGameModeChangeEvent.patch
index 195076d6e9..c6056477db 100644
--- a/patches/unapplied/server/additions-to-PlayerGameModeChangeEvent.patch
+++ b/patches/server/additions-to-PlayerGameModeChangeEvent.patch
@@ -55,11 +55,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 -        if (!this.gameMode.changeGameModeForPlayer(gameMode)) {
 -            return false;
 +        // Paper start - Add cause and nullable message to event
-+        PlayerGameModeChangeEvent event = this.setGameMode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null);
++        org.bukkit.event.player.PlayerGameModeChangeEvent event = this.setGameMode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null);
 +        return event == null ? false : event.isCancelled();
 +    }
-+    public PlayerGameModeChangeEvent setGameMode(GameType gameMode, PlayerGameModeChangeEvent.Cause cause, net.kyori.adventure.text.Component message) {
-+        PlayerGameModeChangeEvent event = this.gameMode.changeGameModeForPlayer(gameMode, cause, message);
++    public org.bukkit.event.player.PlayerGameModeChangeEvent setGameMode(GameType gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause cause, net.kyori.adventure.text.Component message) {
++        org.bukkit.event.player.PlayerGameModeChangeEvent event = this.gameMode.changeGameModeForPlayer(gameMode, cause, message);
 +        if (event == null || event.isCancelled()) {
 +            // Paper end
 +            return null;
@@ -81,7 +81,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      public void loadGameTypes(@Nullable CompoundTag nbt) {
 +        // Paper start
 +        if (this.server.getForcedGameType() != null && this.server.getForcedGameType() != ServerPlayer.readPlayerMode(nbt, "playerGameType")) {
-+            if (new PlayerGameModeChangeEvent(this.getBukkitEntity(), GameMode.getByValue(this.server.getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) {
++            if (new org.bukkit.event.player.PlayerGameModeChangeEvent(this.getBukkitEntity(), org.bukkit.GameMode.getByValue(this.server.getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) {
 +                this.gameMode.setGameModeForPlayer(this.server.getForcedGameType(), GameType.DEFAULT_MODE);
 +            } else {
 +                this.gameMode.setGameModeForPlayer(ServerPlayer.readPlayerMode(nbt,"playerGameType"), ServerPlayer.readPlayerMode(nbt, "previousPlayerGameType"));
diff --git a/patches/unapplied/server/call-PortalCreateEvent-players-and-end-platform.patch b/patches/server/call-PortalCreateEvent-players-and-end-platform.patch
similarity index 100%
rename from patches/unapplied/server/call-PortalCreateEvent-players-and-end-platform.patch
rename to patches/server/call-PortalCreateEvent-players-and-end-platform.patch