Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

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

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

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.

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

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.