Posted June 6, 20178 yr If I have an entity that was in a chunk that then unloaded, is there a way that I can move it to a loaded chunk if I have its UUID? I can't just spawn another, because the entity is supposed to be unique. If I did that, the entity in the unloaded chunk would remain and once it was loaded again, there would be two such entities. I can't load the chunk then teleport the entity because I don't know how to reliably tell which chunk the entity is in. Any suggestions?
June 6, 20178 yr if you know what type of entity it is you could use /tp @e[type=typeofentityitis] @p which will tp all of that type of entity to you probably also it...
June 6, 20178 yr Author /tp has no effect on unloaded entities (otherwise it would bring all the zombies that were in unloaded chunks to you when you did /tp @e[type=Zombie] @p) I'm currently thinking that I'll use a global database of entity data, with entries for each entity indexed by the entity's UUID. writeEntityToNBT is overridden to update this table with the entity's current coordinates when called. When the entity associated with a given UUID is summoned, I can look up the correct chunk by looking at the table to find the coordinates stored for that UUID. Then load the chunk and teleport the entity. Does this sound like a feasible approach? Also how do you load a chunk remotely? Thanks for your input.
June 6, 20178 yr Do you think you could do something to your entity so it could keep its chunk (and maybe the chunks right around it) loaded? The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
June 6, 20178 yr Author Depending on how I did that, it'd be 1 to 9 chunks kept loaded per entity. I'd prefer to avoid putting too much extra stress on the server. I'm also not sure what advantage that has over loading the chunk when I need to teleport the entity. Thanks for the suggestion, though.
June 7, 20178 yr For one unique entity, 1 or 9 chunks is trivial. The difference is how you store the entity's location. If you know you want to store that in some static world data, then you don't need the chunks. If you might prefer to avoid creating static world data, then keeping chunks loaded would mean that this mob would always be found in a search of loaded entities, so some previously mentioned standard utils would succeed. Yet another option is to never allow this entity to stay in a chunk that is being unloaded (unless the server itself is going down). Since every world has a spawning area that is always loaded while the world is running, you could park this special entity there until needed elsewhere. Perhaps you could fashion a subterranean vault beneath your world's spawn point. Alternatively, you could let this entity prowl the spawning area but remain passive while in those chunks. Edited June 7, 20178 yr by jeffryfisher The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.