Solved Spawn a mob using its UUID

Discussion in 'Spigot Plugin Development' started by Aracneon, Feb 13, 2018.

  1. Hey guys,

    I'm searching for a while on the internet to get an answer to this question, but I struggle a lot to find my way...

    I'm trying to save an Entity object in a yaml file as well, but I didn't find anyway to do it.
    Using Entity's UUID I may have found a way to passthrought Strings' limits of Yaml files.

    But the problem persists, and I didn't find any way to finally spawn the entity even with its UUID stocked somewhere...

    If any body has a better solution, I'll be glad to hear it =)

    Thanks a lot in advance,
    I hope to hear from you soon !
     
  2. ScarabCoder

    Resource Staff

    Use Entity#getUniqueID() and Bukkit.getEntity(UUID) to keep track of entities across restart.
     
  3. That's a nice tip but it doesn't solve the problem.
    I guess I didn't clearly express myself: the fact is the entity is "dead" or at least the entity doesn't exist when I'm using the code =/...
    That's why I'd like to spawn it, but after some researches, I learned that entity's UUID doesn't keep in mind the entity itself =(...

    So the question still:
    Do you know a way to save an entity (custom tags, inventory, etc... => the Object as well) in a YAML file, and then spawn it anywhere you'd like to ?
     
  4. I smell an XY problem, why are you trying to save an Entity yourself? The entity is already saved in the region files and the server will create the Entity object from this saved data when the chunk in which the entity resides is loaded. At the point the chunk is unloaded the entity's current state will be stored in the region file.

    If you want to save your own extra state against the entity then as @ScarabCoder said you can get the entities UUID and use that as a key for your data.
     
  5. Well, I found a solution by creating my own Entity Object with a serializing and spawning option.

    Thanks a lot for you help guys =)
     

Share This Page