Skip to content

Commit c3d812d

Browse files
authored
Make water animal spawn height configurable (#7135)
1 parent 9a47cf1 commit c3d812d

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Brokkonaut <hannos17@gmx.de>
3+
Date: Sat, 18 Dec 2021 08:26:55 +0100
4+
Subject: [PATCH] Make water animal spawn height configurable
5+
6+
7+
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
8+
index 5a5db15493cd9b83815c36487c2f38cb8ac76f3a..cd5a7bac92a1e733d69340f09bc35906138a6ce3 100644
9+
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
10+
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
11+
@@ -385,6 +385,24 @@ public class PaperWorldConfig {
12+
mobSpawnerTickRate = getInt("mob-spawner-tick-rate", 1);
13+
}
14+
15+
+ public Integer waterAnimalMaxSpawnHeight;
16+
+ private void waterAnimalMaxSpawnHeight() {
17+
+ String v = getString("wateranimal-spawn-height.maximum", "default");
18+
+ try {
19+
+ waterAnimalMaxSpawnHeight = Integer.parseInt(v);
20+
+ } catch (NumberFormatException ignored) {
21+
+ }
22+
+ }
23+
+
24+
+ public Integer waterAnimalMinSpawnHeight;
25+
+ private void waterAnimalMinSpawnHeight() {
26+
+ String v = getString("wateranimal-spawn-height.minimum", "default");
27+
+ try {
28+
+ waterAnimalMinSpawnHeight = Integer.parseInt(v);
29+
+ } catch (NumberFormatException ignored) {
30+
+ }
31+
+ }
32+
+
33+
public int containerUpdateTickRate;
34+
private void containerUpdateTickRate() {
35+
containerUpdateTickRate = getInt("container-update-tick-rate", 1);
36+
diff --git a/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java b/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java
37+
index 6963cf94909a74522706c984d063faeba0e76112..c3bba52a5c7a618fd9731045268fa9ccebff14f4 100644
38+
--- a/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java
39+
+++ b/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java
40+
@@ -79,6 +79,10 @@ public abstract class WaterAnimal extends PathfinderMob {
41+
public static boolean checkSurfaceWaterAnimalSpawnRules(EntityType<? extends WaterAnimal> type, LevelAccessor world, MobSpawnType reason, BlockPos pos, Random random) {
42+
int i = world.getSeaLevel();
43+
int j = i - 13;
44+
+ // Paper start
45+
+ i = world.getMinecraftWorld().paperConfig.waterAnimalMaxSpawnHeight != null ? world.getMinecraftWorld().paperConfig.waterAnimalMaxSpawnHeight : i;
46+
+ j = world.getMinecraftWorld().paperConfig.waterAnimalMinSpawnHeight != null ? world.getMinecraftWorld().paperConfig.waterAnimalMinSpawnHeight : j;
47+
+ // Paper end
48+
return world.getFluidState(pos.below()).is(FluidTags.WATER) && world.getBlockState(pos.above()).is(Blocks.WATER) && pos.getY() >= j && pos.getY() <= i;
49+
}
50+
}

0 commit comments

Comments
 (0)