Posted April 1, 20187 yr 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?
April 1, 20187 yr 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/
April 1, 20187 yr 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/
April 2, 20187 yr 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.
April 2, 20187 yr 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.