Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6860

Chunk#getInhabitedTime() Javadoc is incorrect

XMLWordPrintable

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

      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); 

            2008Choco Parker Hawke
            HexedHero HexedHero
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: