Chunk inhabited time doesn't tick if doMobSpawning gamerule is disabled
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Expected behavior
The "InhabitedTime" chunk field should be incremented each tick that a player is within a chunk.
Observed/Actual behavior
When the gamerule doMobSpawning is off, the inhabited time is not incremented.
Steps/models to reproduce
- Start Paper with any world, it shouldn't matter if it's existing or new.
- Disable the
doMobSpawninggamerule. - Restart the Paper server.
- Observe that the inhabited time is no longer incremented; this can be seen by debugging the
incrementInhabitedTimemethod, or by checking the NBT of new chunks and seeing the field be zero.
Plugin and Datapack List
This can be reproduced without any plugins.
Paper version
This server is running Paper version 1.21.7-DEV (2025-07-11T13:01:44Z) (Implementing API version 1.21.7-R0.1-SNAPSHOT)
You are running a development version without access to version information
Previous version: 1.21.6-DEV (MC: 1.21.6)
Other
After debugging this issue, I found that the problem seems to be caused by checking for the existence or cancellation of the PlayerNaturallySpawnCreaturesEvent event, within the ChunkMap#isChunkNearPlayer method. This method is used for ticking the chunks around the player, which includes the incrementing of the inhabited time. So when doMobSpawning is off, the event mentioned never gets constructed and is always null. It looks like the specific check was added with 1.21.5 https://github.com/PaperMC/Paper/blob/f00727c57e564f3a8cb875183a54142feb693db7/paper-server/patches/features/0015-Moonrise-optimisation-patches.patch#L25247
While this could be considered intentional, as the vanilla use of inhabited time is for mob difficulty, it is different than the behavior of a vanilla server. We (and others) use this field for filtering chunks that a server has generated, but a player has not been near, so we can prune those chunks and save storage.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining ChunkMap#isChunkNearPlayer and the referenced Moonrise optimisation patch, then trace how it controls chunk ticking and incrementInhabitedTime. Reproduce with doMobSpawning disabled and verify that a player's chunk inhabited time increments as it does on a vanilla server.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100