From ca892181d9b6b04aa562717614a22d8fbeb297ce Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 22 Dec 2021 12:47:15 +0100 Subject: [PATCH] Configurable max block light for monster spawning (#7129) --- ...max-block-light-for-monster-spawning.patch | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 patches/server/Configurable-max-block-light-for-monster-spawning.patch diff --git a/patches/server/Configurable-max-block-light-for-monster-spawning.patch b/patches/server/Configurable-max-block-light-for-monster-spawning.patch new file mode 100644 index 0000000000..4eaae3353c --- /dev/null +++ b/patches/server/Configurable-max-block-light-for-monster-spawning.patch @@ -0,0 +1,33 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nassim Jahnke +Date: Thu, 16 Dec 2021 09:40:39 +0100 +Subject: [PATCH] Configurable max block light for monster spawning + + +diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java ++++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +@@ -0,0 +0,0 @@ public class PaperWorldConfig { + Integer rate = table.get(columnKey, rowKey); + return rate != null && rate > -1 ? rate : def; + } ++ ++ public int maxBlockLightForMonsterSpawning = -1; ++ private void minBlockLightForMobSpawning() { ++ this.maxBlockLightForMonsterSpawning = getInt("monster-spawn-max-light-level", maxBlockLightForMonsterSpawning); ++ } + } +diff --git a/src/main/java/net/minecraft/world/entity/monster/Monster.java b/src/main/java/net/minecraft/world/entity/monster/Monster.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/monster/Monster.java ++++ b/src/main/java/net/minecraft/world/entity/monster/Monster.java +@@ -0,0 +0,0 @@ public abstract class Monster extends PathfinderMob implements Enemy { + public static boolean isDarkEnoughToSpawn(ServerLevelAccessor world, BlockPos pos, Random random) { + if (world.getBrightness(LightLayer.SKY, pos) > random.nextInt(32)) { + return false; +- } else if (world.getBrightness(LightLayer.BLOCK, pos) > 0) { ++ } else if (world.getBrightness(LightLayer.BLOCK, pos) > (world.getLevel().paperConfig.maxBlockLightForMonsterSpawning >= 0 ? world.getLevel().paperConfig.maxBlockLightForMonsterSpawning : 0)) { // Paper - configurable max block light level + return false; + } else { + int i = world.getLevel().isThundering() ? world.getMaxLocalRawBrightness(pos, 10) : world.getMaxLocalRawBrightness(pos);