Jump to content

[1.10.2] How to summon an entity from an unloaded chunk?


ATotalGit

Recommended Posts

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?

Link to comment
Share on other sites

/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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.