[SPIGOT-6860] Chunk#getInhabitedTime() Javadoc is incorrect Created: 21/Dec/21  Updated: 23/Sep/22  Resolved: 23/Sep/22

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: HexedHero Assignee: Parker Hawke
Resolution: Fixed Votes: 0
Labels: chunk, inhabited, javadocs, time

Version: This server is running CraftBukkit version 3369-Spigot-8965a50-2a2caa7 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Chunk.html#getInhabitedTime() states that "Note that the time is incremented once per tick per player in the chunk." however this seems to be incorrect, looking at NMS the chunk inhabited time is increased if a player is nearby for mobs to spawn not if they are inside the chunk. I confirmed this by making a small plugin to spam the inhabited time for the chunk at 0, 0 and moved around it. The time increases if I'm outside of the chunk.

        Chunk chunk = Bukkit.getWorld("world").getChunkAt(0, 0);
        Random random = new Random();
        Bukkit.getScheduler().runTaskTimer(this, () -> {
            for (int x = 0; x <= 15; ++x) {
                for (int y = 0; y <= 255; ++y) {
                    for (int z = 0; z <= 15; ++z) {
                        if (random.nextBoolean()) {
                            chunk.getBlock(x, y, z).getWorld().spawnParticle(Particle.TOTEM, chunk.getBlock(x, y, z).getLocation(), 1, 0, 0, 0, 0);
                        }
                    }
                }
            }
            Bukkit.broadcastMessage("Time: " + chunk.getInhabitedTime());
        }, 60, 5); 


Generated at Fri Apr 11 15:30:12 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.