1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

[SOLVED] Create a temporary entity

Discussion in 'Development' started by Muqsit, Mar 21, 2017.

  1. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Supposedly, I have full (public) access to an entity class (I can modify what ever I like to); How do I close() it on server shutdown. I'd not like the server to respawn it on startup.
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    close the entity before it saves to the level
     
    Muqsit likes this.
  3. xBeastMode

    xBeastMode Shog Chips

    Messages:
    0
    Close the entity onDisable()? All plugins are disabled on shutdown.
     
  4. PocketKiller

    PocketKiller Slime

    Messages:
    83
    GitHub:
    iPocket
    The server disables plugins first, then saves worlds.
    Which means, you can "kill" or "close" the entity while the plugin is disabling.
     
    jasonwynn10 likes this.
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    That does work but not all the time. It's like a random out of 5 occurrence that it will fail to.
     
  6. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    You need to close the entity before the entity's chunk is saved to disk, and make sure you set the chunk as changed to make sure the chunk is saved without your entity. I'm not certain how the timing of this will play with plugins.

    This may get even more dicey in the future when threaded level I/O is implemented.

    I think this may be lacking in the current API. Feel free to open an issue or PR to suggest the ability to mark an entity as temporary as a possible addition.
     
    Last edited: Mar 21, 2017
  7. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    You could overwrite Entity::saveNBT() and make sure the entities compound tag is completely empty, you could also kill the entity when the server tries to spawn it again; purely up to you.
     
    Muqsit likes this.
  8. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Why have the server do more effort to load it if it's only going to die? close it when your plugin disables.
     
  9. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Keep an array of each entities id and onDisable close each one
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.