2022-01-07 11:38:51 +01:00
|
|
|
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
|
2022-06-08 19:39:07 +02:00
|
|
|
index 4933961ab8bc29749c053c6c54c5d2138f2c1742..88938b54b504b10c5cb0d22f2daa5fcb4075e12c 100644
|
2022-01-07 11:38:51 +01:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2022-06-06 02:17:27 +02:00
|
|
|
@@ -426,6 +426,24 @@ public class PaperWorldConfig {
|
2022-01-07 11:38:51 +01:00
|
|
|
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-06-08 14:33:46 +02:00
|
|
|
index 522abd880c1e7f7c9026f0ab6457bc649f11802c..1b6d426b44e200b3634c0a9ac7c3a315841ada40 100644
|
2022-01-07 11:38:51 +01:00
|
|
|
--- 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 {
|
2022-06-08 14:33:46 +02:00
|
|
|
public static boolean checkSurfaceWaterAnimalSpawnRules(EntityType<? extends WaterAnimal> type, LevelAccessor world, MobSpawnType reason, BlockPos pos, RandomSource random) {
|
2022-01-07 11:38:51 +01:00
|
|
|
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);
|
2022-01-07 11:38:51 +01:00
|
|
|
}
|
|
|
|
}
|