From b3386c382b42bbd0632120f4a7766de8b7092e99 Mon Sep 17 00:00:00 2001
From: Noah van der Aa <ndvdaa@gmail.com>
Date: Fri, 10 Jun 2022 00:48:46 +0200
Subject: [PATCH] Make slime spawn checks use tag again and rename config
 option (#7910)

---
 .../server/Add-configurable-height-for-slime-spawn.patch    | 6 +++---
 ...x-slime-spawners-not-spawning-outside-slime-chunks.patch | 4 ++--
 patches/server/Paper-config-files.patch                     | 5 +++--
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/patches/server/Add-configurable-height-for-slime-spawn.patch b/patches/server/Add-configurable-height-for-slime-spawn.patch
index e4776cd7cc..d6f4ec872b 100644
--- a/patches/server/Add-configurable-height-for-slime-spawn.patch
+++ b/patches/server/Add-configurable-height-for-slime-spawn.patch
@@ -14,9 +14,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          if (world.getDifficulty() != Difficulty.PEACEFUL) {
 -            if (world.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) && pos.getY() > 50 && pos.getY() < 70 && random.nextFloat() < 0.5F && random.nextFloat() < world.getMoonBrightness() && world.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) {
 +            // Paper start - Replace rules for Height in Swamp Biome
-+            final double maxHeightSwamp = world.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.swampBiome.maximum;
-+            final double minHeightSwamp = world.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.swampBiome.minimum;
-+            if (world.getBiome(pos).is(net.minecraft.world.level.biome.Biomes.SWAMP) && pos.getY() > minHeightSwamp && pos.getY() < maxHeightSwamp && random.nextFloat() < 0.5F && random.nextFloat() < world.getMoonBrightness() && world.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) {
++            final double maxHeightSwamp = world.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.maximum;
++            final double minHeightSwamp = world.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.minimum;
++            if (world.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) && pos.getY() > minHeightSwamp && pos.getY() < maxHeightSwamp && random.nextFloat() < 0.5F && random.nextFloat() < world.getMoonBrightness() && world.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) {
 +                // Paper end
                  return checkMobSpawnRules(type, world, spawnReason, pos, random);
              }
diff --git a/patches/server/Fix-slime-spawners-not-spawning-outside-slime-chunks.patch b/patches/server/Fix-slime-spawners-not-spawning-outside-slime-chunks.patch
index 720246593f..26688633df 100644
--- a/patches/server/Fix-slime-spawners-not-spawning-outside-slime-chunks.patch
+++ b/patches/server/Fix-slime-spawners-not-spawning-outside-slime-chunks.patch
@@ -20,5 +20,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +            }
 +            // Paper end
              // Paper start - Replace rules for Height in Swamp Biome
-             final double maxHeightSwamp = world.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.swampBiome.maximum;
-             final double minHeightSwamp = world.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.swampBiome.minimum;
+             final double maxHeightSwamp = world.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.maximum;
+             final double minHeightSwamp = world.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.minimum;
diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch
index 7b29effbd8..f476cf11bf 100644
--- a/patches/server/Paper-config-files.patch
+++ b/patches/server/Paper-config-files.patch
@@ -1444,9 +1444,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +
 +            public class SlimeSpawnHeight extends ConfigurationPart {
 +
-+                public SwampBiome swampBiome;
++                public SurfaceSpawnableSlimeBiome surfaceBiome;
 +
-+                public class SwampBiome extends ConfigurationPart {
++                public class SurfaceSpawnableSlimeBiome extends ConfigurationPart {
 +                    public double maximum = 70;
 +                    public double minimum = 50;
 +                }
@@ -3244,6 +3244,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        moveFromRoot(builder, "spawn-limits", "entities", "spawning");
 +        moveFromRoot(builder, "despawn-ranges", "entities", "spawning");
 +        moveFromRoot(builder, "wateranimal-spawn-height", "entities", "spawning");
++        builder.addAction(path("slime-spawn-height", "swamp-biome"), TransformAction.rename("surface-biome"));
 +        moveFromRoot(builder, "slime-spawn-height", "entities", "spawning");
 +        moveFromRoot(builder, "wandering-trader", "entities", "spawning");
 +        moveFromRoot(builder, "all-chunks-are-slime-chunks", "entities", "spawning");