Hey, I already tried this with a loop. I loop through every single entity in a chunk and if an entity has a specific entity id I do my stuff. But is there another way to get a specific entity by the id?
phips99 You can try to get the entity by it's uuid. I believe there is a function for that (called from a world), but I'm not too sure.
phips99 This should work just fine. Code: Chunk c = null; // = someChunk; UUID id = null; // = someUUID; for (Entity e: c.getEntities()) { if (e.getUniqueId() == id) { // stuff } }
phips99 hmm, then your only option is looping through the enities in a world. However, if you spawn the entities by yourself, you could store their id in a List or Map, and call them from there, which saves some resources. Assist The OP asked for a way without a loop, but you are right about that. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
KevoSoftworks Yeah, sorry. Noticed it right after I posted that. They should make a getEntityById() method in World class, though that would be the same as looping through them and comparing ids.