Chunk not there when requested in ChunkUnloadEvent

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None
    • Environment:

      Mac OS 11.7.0

      Java 22

    • CraftBukkit version 4212-Spigot-146439e-2828725 (MC: 1.21)
    • Yes

      When trying to access the chunk in the Chunk Unload event an error is thrown:

      java.lang.IllegalStateException: Chunk not there when requested: Unloaded chunk

      This happens specifically for my plugin when trying to get the entities in the chunk, though can be reproduced with a basic plugin with the following code:

          @EventHandler(priority = EventPriority.NORMAL)
          public void onChunkUnload(ChunkUnloadEvent event) {
              for (Entity d : event.getChunk().getEntities()) {
                  getLogger().log(Level.INFO, d.getType().toString());
      {{        }}}
      {{    }}}

      No other plugins present except the test plugin with the above code.

            Assignee:
            md_5
            Reporter:
            Eccentric Devotion
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: