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.

How to spawn Entities as part of a generated structure

Featured Replies

Posted

I want to spawn an entity inside my generated structure, but they keep despawning when the structure gets too far away. In order to avoid this, I am forcing the mobs I find to persist in the world, But this uses a lot of memory, as all of those chunks with the structure get loaded into memory until the mob dies. I am aware that structures such as the end city and woodland mansion do not seem to have this problem. How do I do this?

28 minutes ago, diesieben07 said:

Call EntityLiving::enablePersistence after spawning and the entities will not despawn. 

I think he's saying he already did this but is worried about the memory it takes. So that leads to the question -- why are so many of these structures and entities in the structures getting spawned in the first place? To cause an actual memory problem I'd assume you'd need thousands of these to have been spawned...

 

1 hour ago, ptolemy2002 said:

I am aware that structures such as the end city and woodland mansion do not seem to have this problem. How do I do this?

 

Those entities enable persistence. You can check that by following the call hierarchy for things like the Vindcator you'll see that right after they are constructed the enablePersistence() method is called on them. The end city and woodland mansions are rare structures so there is no problem with too many of them.

 

So the main question is: why do you have so many structures with so many entities that this is a problem? What are you actually trying to do?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

1 hour ago, diesieben07 said:

It does not cause any chunks to stay loaded. It also does not stop the entity from unloading. It simply stops the entity from despawning.

Exactly, I'm not sure why he thinks it will cause memory problems.

 

To the original poster, can you explain more about your concern related to memory issues?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • Author

I thought that the chunks would stay loaded after I spawned the entities, but I see that I have thought wrong. If the original Minecraft structures use it, then I should be fine with this.

When we made "Monsters and Dungeons", we used tileentities, which would spawn the entity and disappear, when a player came close enough.

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.