Jump to content

Entities in unloaded chunks


stepsword

Recommended Posts

23 minutes ago, stepsword said:

but I'm storing a reference to the "Entity" object somewhere, what happens to the object? Can I still teleport the entity and do other entity things with it?

If you mean you have an instance of an Entity then yes you should. It shouldn't be Garbage Collected, but it won't be the same entity as the one that is loaded later when the chunk is loaded.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 hour ago, Animefan8888 said:

If you mean you have an instance of an Entity then yes you should. It shouldn't be Garbage Collected, but it won't be the same entity as the one that is loaded later when the chunk is loaded.

Thanks - a couple follow ups (and yes, I did mean an instance of an Entity): 

If I teleport the entity out of an unloaded chunk, does the chunk automatically remove it from its "saved" data?

Is there a right way to keep track of entities that may be in unloaded chunks? I was under the impression that there's no world-wide "get Entity by UUID" and the getEntityById method requires an AABB. Mainly if I have an instance of Entity *now* and I want to sync it up with the instance of Entity when the chunk is loaded later, is there a right way to do that?

Link to comment
Share on other sites

1 minute ago, stepsword said:

If I teleport the entity out of an unloaded chunk, does the chunk automatically remove it from its "saved" data?

No it won't. You'll have to teleport it out before the chunk unloads.

 

3 minutes ago, stepsword said:

Is there a right way to keep track of entities that may be in unloaded chunks?

Nope because they are unloaded.

 

3 minutes ago, stepsword said:

Mainly if I have an instance of Entity *now* and I want to sync it up with the instance of Entity when the chunk is loaded later, is there a right way to do that?

Yes if you give that entity a UUID that is also saved and loaded. And you access that data when the Entity joins the world(EntityJoinWorldEvent). But then you will have to make sure to save the entity that you have an instance of when it changes and hasn't been synced because the entity in question hasn't been reloaded.

Let's just ask this question. What are you trying to do?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

20 minutes ago, Animefan8888 said:

No it won't. You'll have to teleport it out before the chunk unloads.

 

Nope because they are unloaded.

 

Yes if you give that entity a UUID that is also saved and loaded. And you access that data when the Entity joins the world(EntityJoinWorldEvent). But then you will have to make sure to save the entity that you have an instance of when it changes and hasn't been synced because the entity in question hasn't been reloaded.

Let's just ask this question. What are you trying to do?

Thanks, that makes sense - I never thought of making my own UUID and saving it.

 

I'm trying to create behavior for a summoned pet, but I also wanted to make it possible to give the pet commands remotely, so the chunk might be unloaded when the command is given. I hadn't actually started coding anything for it cause I wanted to understand the limitations before I jumped in. I was planning to have most commands just fail for unloaded chunks, but a teleport command would be the exception for that, so I'll probably delete the entity when it joins the world if it's got a duplicate UUID of another entity. Thanks again!

Link to comment
Share on other sites

What if:

  1. The entity gets unloaded
  2. The player teleports it to them (it gets cloned)
  3. The new one gets unloaded
  4. The player goes to the chunk where the old one (from (1) is)?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 minute ago, Draco18s said:

What if:

  1. The entity gets unloaded
  2. The player teleports it to them (it gets cloned)
  3. The new one gets unloaded
  4. The player goes to the chunk where the old one (from (1) is)?

That's a good point, thanks.. Hadn't considered that. Maybe I'll add to the player capability a "last known position" for their pet and just delete it if it's not within a few blocks on the EntityJoinEvent. They're meant to be expendable anyway

Link to comment
Share on other sites

As an update to this I think what I will do is force load the chunk of the user's stored pet when I'm issuing commands, and then replace the stored pet with the one with a matching UUID loaded in the chunk - I think that solves the major issues since I won't be teleporting things out of unloaded chunks anymore.

Link to comment
Share on other sites

1 minute ago, stepsword said:

As an update to this I think what I will do is force load the chunk of the user's stored pet when I'm issuing commands, and then replace the stored pet with the one with a matching UUID loaded in the chunk - I think that solves the major issues since I won't be teleporting things out of unloaded chunks anymore.

That idea would work, but here's another idea. Don't let the entity become unloaded in the chunk. Remove the entity from the chunk before it unloads. Then make sure to save them in a World Capability. This might be better??? Because loading chunks is actually quite intensive.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

4 minutes ago, Animefan8888 said:

That idea would work, but here's another idea. Don't let the entity become unloaded in the chunk. Remove the entity from the chunk before it unloads. Then make sure to save them in a World Capability. This might be better??? Because loading chunks is actually quite intensive.

Even if it's just the chunk the entity is in when a player wants to give a command? I figured one chunk extra per player wouldn't be too bad since like 400 chunks are loaded for each player at a given time anyway. 

 

 

Link to comment
Share on other sites

12 minutes ago, stepsword said:

As an update to this I think what I will do is force load the chunk of the user's stored pet when I'm issuing commands,

You would end up loading the chunk basically every time you issue the command. Though I guess one chunk and only to teleport the Entity out of there wouldn't be that bad.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Just now, Animefan8888 said:

You would end up loading the chunk basically every time you issue the command. Though I guess one chunk and only to teleport the Entity out of there wouldn't be that bad.

Yea, I think it will be not intensive based on the little I've read of chunk loading - I'm not planning to have many commands, just one or two (like teleport and blow up the nearest creature) and they're going to be very simple things that wouldn't be used in quick succession. I wasn't planning to give the player full control of the pet like "move to XYZ" or anything that would require micromanaging. 

Link to comment
Share on other sites

11 hours ago, Animefan8888 said:

You would end up loading the chunk basically every time you issue the command. Though I guess one chunk and only to teleport the Entity out of there wouldn't be that bad.

Mystcraft would do this when non-player entities were teleported to Myst dimensions via a portal. It really isn't that intensive.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Make a test without chameleon or storagedrawers
    • In August, during one of the most challenging periods of my life, I was introduced to REMOTE CYBAR RECOVERY by Mr. Johnny. I had recently experienced a devastating loss involving $760,000 worth of Bitcoin. This significant amount of money had been acquired by selling my shares, and I had invested it in Bitcoin, only to have it stolen. Each day felt like a battle as I faced the overwhelming possibility of losing everything I had worked so hard to accumulate. It was an emotional and financial crisis that left me feeling hopeless and desperate, Mr.. Johnny, who had faced a similar situation himself, shared his experience with me. he had also lost access to his digital wallet and had turned to REMOTE CYBAR RECOVERY for assistance. To his relief, they were able to help him recover the wallet password and regain access to his funds. Hearing her positive account of their service provided me with a glimmer of hope, and I decided to reach out to REMOTE CYBAR RECOVERY. From the moment I made contact with them, I knew I had made the right decision. Their response was prompt and professional, which immediately put my mind at ease. The team demonstrated exceptional expertise and dedication throughout the process. They worked tirelessly to address my concerns and meticulously followed up on every detail related to my case. In less than 4 days, a period that felt both incredibly short and incredibly long due to the stress I was under, my funds were fully deposited back into my account. The speed and efficiency with which REMOTE CYBAR RECOVERY handled my case were nothing short of remarkable. Their success in recovering my stolen funds was a relief beyond words and significantly alleviated the financial and emotional strain I had been enduring. The expertise and professionalism exhibited by REMOTE CYBAR RECOVERY. were beyond measure. They provided not only a solution to a complex problem but also restored my confidence in the possibility of recovering from such a dire situation. Their service was a beacon of hope during one of the darkest times in my life, and I am deeply grateful I cannot recommend REMOTE CYBAR RECOVERY highly enough. Their knowledge, responsiveness, and effectiveness in handling cases of this nature are truly commendable. If you ever face a situation where you have lost access to your digital assets or find yourself in need of recovery services, REMOTE CYBAR RECOVERY is a resource you should definitely consider. Their support can make a world of difference, as it did for me. EMAIL S U P P O R T @ R E M O T E C Y B A R R E C O V E R Y . C O M WHATS/APP + 1 7 2 5 2 2 4 2 5 9 7 WEBSITE https:// remote cybarrecovery . com/
    • That might be saved in the NBT of the villager? I'm not sure.
    • That would work too, I guess.
  • Topics

×
×
  • Create New...

Important Information

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