Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max Light Level monster spawn #10265

Open
GrayR0ot opened this issue Feb 19, 2024 · 5 comments · May be fixed by #11359
Open

Max Light Level monster spawn #10265

GrayR0ot opened this issue Feb 19, 2024 · 5 comments · May be fixed by #11359
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. upstream: vanilla Issue exists in vanilla Minecraft.

Comments

@GrayR0ot
Copy link

Expected behavior

Mobs should spawn if light level is below or equals to configured light level.

Observed/Actual behavior

Entities only spawn at night with a vanilla (0) light level

Steps/models to reproduce

Time set day
Set server max-light setting to 15 or greater

Plugin and Datapack List

No plugin

Paper version

Latest

Other

Here was the pull request that created that feature.
Regarding our recent discord discussion, it's appear to be bugged?

#7129

@GrayR0ot GrayR0ot added status: needs triage type: bug Something doesn't work as it was intended to. labels Feb 19, 2024
@lynxplay
Copy link
Contributor

Basically, the config value right now only overwrites monster_spawn_block_light_limit and not monster_spawn_light_level.

I am unsure if this is intended behavior, but the concept (if intended) would need further description at least in the docs.

@Machine-Maker
Copy link
Member

This is directly configurable with datapacks, just by setting monster_spawn_light_level in the overworld dimension type. Unsure if we want to add a setting to address this.

Either way, I do not think the existing setting should be changed, its initial behavior seems correct, only controlling the block light level, not the ambient light level from the sky.

@DavidTs93
Copy link

DavidTs93 commented Sep 3, 2024

The issue is not just monster_spawn_light_level - I tested by changing all the values to max (monster_spawn_block_light_limit to 15, monster_spawn_light_level to 0-15) and no monster spawns.

I checked the code, and it seems like the problem is (NMS) Mob#checkSpawnRules - for all "sentient" mobs it checks if PathfinderMob#getWalkTargetValue is bigger or equal to 0, but for monsters (except: Giant, Guardian, Pillager, Silverfish, Warden) the value is -(LevelReader#getPathfindingCostFromLightLevels(pos)), which equals LevelReader#getLightLevelDependentMagicValue - 0.5, and as far as I can tell, the value is "proper" ONLY when the light level (in the Overworld) is 7.5 or lower.

The order of calling:

  1. MinecraftServer#tick
  2. ServerLevel#tick
  3. ServerChunkCache#tick
  4. ServerChunkCache#tickChunks
  5. NaturalSpawner#spawnForChunk
  6. NaturalSpawner#spawnCategoryForChunk
  7. NaturalSpawner#spawnCategoryForPosition
  8. NaturalSpawner#isValidPositionForMob
  9. Mob#checkSpawnRules -> PathfinderMob#checkSpawnRules
  10. PathfinderMob#getWalkTargetValue -> Monster#getWalkTargetValue
  11. LevelReader#getPathfindingCostFromLightLevels
  12. LevelReader#getLightLevelDependentMagicValue

The last one, in the Overworld, yields the current light level at a location (sky and block) divided by the max light level (15), and going up this needs to be 0.5 or more to spawn the monster, which only happens when the combined light level is 7.5 or less, i.e. 7-.

Edit: this might not be 100% right, because it seems that monsters DO spawn in higher light levels when changed (with a datapack) but ONLY when not directly under the sky (i.e. blocks above). This doesn't explain why they spawn in ALL light levels even though the range was set to be 12-15...

@DavidTs93 DavidTs93 linked a pull request Sep 5, 2024 that will close this issue
@Machine-Maker
Copy link
Member

This should be a vanilla issue then correct? Did you search on the mojira tracker to see if you could find one?

@DavidTs93
Copy link

DavidTs93 commented Sep 6, 2024

This should be a vanilla issue then correct? Did you search on the mojira tracker to see if you could find one?

Yes, just tested and same behavior in vanilla as well.
Checked the MC Jira and nothing is reported about this.

Edit: create a ticket just in case.

@Machine-Maker Machine-Maker added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. upstream: vanilla Issue exists in vanilla Minecraft. and removed status: needs triage labels Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. upstream: vanilla Issue exists in vanilla Minecraft.
Projects
Status: ✅ Accepted
Development

Successfully merging a pull request may close this issue.

4 participants