Paper/patches/server/0830-Make-water-animal-spawn-height-configurable.patch

51 lines
2.7 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Brokkonaut <hannos17@gmx.de>
Date: Sat, 18 Dec 2021 08:26:55 +0100
Subject: [PATCH] Make water animal spawn height configurable
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 1161f91ad09fa5b9a769bea1e80a7edb5da76fcf..6ad81087e1ca9c6d7420443318c50bebba451c76 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -416,6 +416,24 @@ public class PaperWorldConfig {
mobSpawnerTickRate = getInt("mob-spawner-tick-rate", 1);
}
+ public Integer waterAnimalMaxSpawnHeight;
+ private void waterAnimalMaxSpawnHeight() {
+ String v = getString("wateranimal-spawn-height.maximum", "default");
+ try {
+ waterAnimalMaxSpawnHeight = Integer.parseInt(v);
+ } catch (NumberFormatException ignored) {
+ }
+ }
+
+ public Integer waterAnimalMinSpawnHeight;
+ private void waterAnimalMinSpawnHeight() {
+ String v = getString("wateranimal-spawn-height.minimum", "default");
+ try {
+ waterAnimalMinSpawnHeight = Integer.parseInt(v);
+ } catch (NumberFormatException ignored) {
+ }
+ }
+
public int containerUpdateTickRate;
private void containerUpdateTickRate() {
containerUpdateTickRate = getInt("container-update-tick-rate", 1);
diff --git a/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java b/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java
2022-03-01 06:43:03 +01:00
index 69f7e034cab1bfd7ca5dffc660b6decd739adf35..c039b896ee85543c26a8ab76640080f539deaa4c 100644
--- a/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java
+++ b/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java
@@ -79,6 +79,10 @@ public abstract class WaterAnimal extends PathfinderMob {
public static boolean checkSurfaceWaterAnimalSpawnRules(EntityType<? extends WaterAnimal> type, LevelAccessor world, MobSpawnType reason, BlockPos pos, Random random) {
int i = world.getSeaLevel();
int j = i - 13;
+ // Paper start
+ i = world.getMinecraftWorld().paperConfig.waterAnimalMaxSpawnHeight != null ? world.getMinecraftWorld().paperConfig.waterAnimalMaxSpawnHeight : i;
+ j = world.getMinecraftWorld().paperConfig.waterAnimalMinSpawnHeight != null ? world.getMinecraftWorld().paperConfig.waterAnimalMinSpawnHeight : j;
+ // Paper end
2022-03-01 06:43:03 +01:00
return pos.getY() >= j && pos.getY() <= i && world.getFluidState(pos.below()).is(FluidTags.WATER) && world.getBlockState(pos.above()).is(Blocks.WATER);
}
}