Jump to content

How to spawn Entities as part of a generated structure


ptolemy2002

Recommended Posts

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?

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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/

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.