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

getEntities() not working as expected

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Minor
    • Resolution: Fixed
    • None
    • None
    • None
    • This server is running CraftBukkit version 3133-Spigot-66f9d3c-3fa79d3 (MC: 1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)
    • Yes

    Description

      When loading chunks, the entities in those chunks are not loaded anymore!

      I'm using World#loadChunk or Chunk#load to load unloaded/inactive chunks.
      It returns 'true'... so chunk is loaded.

      But i can't get the entities from that chunk using Chunk#getEntities or World#getEntitiesByClasses etc.

      Checking again a few ticks later some of the entities can be found.

       

      TestCode:

      Location testLoc=new Location(world,800,90,-1500);
      Chunk testChunk=world.getChunkAt(testLoc);
      testChunk.load();
      Entity[] enderman=testChunk.getEntities();
      logger.warning("Found Entities before spawn #:"+enderman.length);
      world.spawnEntity(testLoc, EntityType.ENDERMAN);
      testChunk.unload();
      testChunk.load();
      enderman=testChunk.getEntities();
      logger.warning("Found Entities after spawn #:"+enderman.length);
      

      Calling this multiple times results in the following output:

      [15:31:14] [Server thread/WARN]: [plugin] Found Entities before spawn #:0
      [15:31:14] [Server thread/WARN]: [plugin] Found Entities after spawn #:0
      [15:31:14] [Server thread/WARN]: [plugin] Found Entities before spawn #:0
      [15:31:14] [Server thread/WARN]: [plugin] Found Entities after spawn #:2 
      [15:31:14] [Server thread/WARN]: [plugin] Found Entities before spawn #:2 
      [15:31:14] [Server thread/WARN]: [plugin] Found Entities after spawn #:3
      

      With servers running 1.16 or older, the result is like this:

      [15:39:33] [Server thread/WARN]: [plugin] Found Entities before spawn #:0 
      [15:39:33] [Server thread/WARN]: [plugin] Found Entities after spawn #:1
      [15:39:33] [Server thread/WARN]: [plugin] Found Entities before spawn #:1
      [15:39:33] [Server thread/WARN]: [plugin] Found Entities after spawn #:2
      [15:39:33] [Server thread/WARN]: [plugin] Found Entities before spawn #:2
      [15:39:33] [Server thread/WARN]: [plugin] Found Entities after spawn #:3 
      

      Attachments

        Issue Links

          Activity

            People

              DerFrZocker Marvin Rieple
              Jeppa Jeppa
              Votes:
              10 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: