PaperMC / PaperMC/Paper

Chunk inhabited time doesn't tick if doMobSpawning gamerule is disabled

Open
#12,827 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority: high status: accepted
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 doMobSpawning gamerule.
  • Restart the Paper server.
  • Observe that the inhabited time is no longer incremented; this can be seen by debugging the incrementInhabitedTime method, 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.