Possibility to use the entity UniqueID
LadyCailinBot opened this issue ยท 6 comments
CMDHELPER-2707 - Reported by Hekta
That would allow to save and find entities easily, the unique id being persistent across server restarts and chunk unloads/loads.
get_unique_id(entityID)
get_entity_id(UniqueID)
http://jd.bukkit.org/rb/apidocs/org/bukkit/entity/Entity.html#getUniqueId()
Comment by LadyCailin
This is a good suggestion. I was unaware of this method. However, I may consider simply switching to make the current entity id be the unique id, assuming there are no serious problems with that, that way you'll never have to worry about it, you can just persist the id returned with all the existing methods.
Comment by jb_aero
I was already experimenting with this in CHDev :)
https://github.com/jb-aero/CHDev/blob/f2a9af67f9b05c689c564b5dd0172ca034428693/src/main/java/com/zeoldcraft/dev/functions/DevFunctions.java#L43
My comment on that though, is it would make it MUCH harder to type a mob's id, and speed is important, say when you want to attach a squid to someone's head before it dries up.
Comment by Tom.Gebbett
You can of course find an entity using all_entities(), first searching at a location, then the world, and finally the entire server. If the entity has been removed, the search can take upwards of 150ms, if it is in the same place, it can take around 0.5ms, this is obviously far more cumbersome than your suggestion. A way to use a more permanent id would be very helpful.
I think the speed concern is a very situational one, and the gains of this system outweigh it. There are ways to accelerate an interface to do what you are suggesting, that don't have to involve the entity id at all.
Comment by jb_aero
@uzalu who are you replying to?
Comment by Tom.Gebbett
@jb_aero First paragraph is an alternative solution, as well as an assertion that the uniqueID system is better, that was in response to the topic in general. Second paragraph was directed at your comment that it would take longer to type the id.
I did not expect this to be a problem, but if you need any other comments explained, feel free to ask me.