Incorrect Entity Location After Chunk Unload

Discussion in 'Plugin Development' started by teathiev, Aug 11, 2019.

Thread Status:
Not open for further replies.
  1. Offline


    I have a very odd problem where a saved entity has the incorrect location once it's chunk is unloaded. Perhaps I don't understand how entities work, but my understanding is that a bukkit Entity object persists alongside its in-game entity.

    I am storing my registered Entity objects via a HashMap "petEntityMap", the key is a data class "Pet".

    I'm using Kotlin (sorry) but my snippet to get the location is:
    "AppStateManager" is just a singleton object, "pet" is a Pet object.

    Steps to reproduce the problem:

    1. Get location of entity at Location 1 (X = -354)


    2. Move entity to Location 2 and get location (X = -348)


    3. Warp away or do something similar to unload its chunk

    4. Warp/travel back and move back to Location 1


    Note that Step 4's X coordinate (what should be Location 1) is X = -348 which if that of Location 2 in Step 2

    Can anyone shed light on this issue? Neither the entity nor its location is null, otherwise, I wouldn't get coordinates in Step 4. Are bukkit Entity objects decoupled from game entities on chunk unload and just assigned a new one on chunk load?
    I can't find an explanation of how this works (rather why it doesn't work) anywhere so any help would be appreciated.
    Last edited: Aug 11, 2019
Thread Status:
Not open for further replies.

Share This Page