Fix Monster natural spawning problem due to light#11359
Conversation
|
While this PR fixes the issue, I think it is best for us to wait with merging this until we have some mojang input on the linked ticket. |
I opened that ticket today, so doubt it'll be soon... I, for one, will just compile this patch into my own server. |
|
Yea, I agree that it seems to be a leftover. We'll try to get some info on the ticket, your patch certainly works yea, and for most users this change is probably 100% fine, but messing with spawning like this without a way to disable the early out on the Mob instance spawn check might break contraptions we would not want to break. Thank you anyway for the PR, we'll poke around with the linked mojira 👍 |
This fixes the natural spawning problem of monsters due to light, which causes any custom natural spawning light levels (from a datapack altering the dimension type or by changing
paper-world-defaults#monster-spawn-max-light-level) to be completely ignored.The natural spawning code (in
NaturalSpawner) checks the mob's custom spawn rules (Mob#checkSpawnRules), which, for sentient creatures always checks ifPathfinderMob#getWalkTargetValueis 0 or positive. This logic, specifically for monsters, is flawed (except for: Giant, Guardian, Pillager, Silverfish, and Warden), because the value of this function for monsters depends on the light level - in the overworld this means that light levels 7 or below are ok and above 7 are not (which is the default behavior).This PR changes
checkSpawnRules(Monster#checkSpawnRules) to ignore natural spawning (including chunk population) because all monsters already have a custom check for spawning rules inSpawnPlacements. Also fixes #10265.