aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0823-Configurable-max-block-light-for-monster-spawning.patch
blob: 22e9f1ed041bfb8199be67618447656383124e83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <jahnke.nassim@gmail.com>
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 aa265bb42daa42e23d3935fa8f81052c1504ef3c..fd584cdfc5ba9dec9806ab50e602a03a58f5c4f7 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -1033,4 +1033,9 @@ 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 457880c9e894a83d88505cf0b7235df919eea591..1d66588cfe94d190a34dc376b4b5bff9461a3529 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Monster.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Monster.java
@@ -90,7 +90,7 @@ 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);