Jump to content

Recommended Posts

Posted

Hey all,

I'm wondering if there's a way to forceload a chunk instantly in 1.18.2.  I'm updating an older mod from 1.16, and in that version of the game I was able to do so just by calling

serverWorld.forceChunk(chunkPos.x, chunkPos.z, false);

which would then enable me to access the Chunk at that location and get a list of the entities inside it (which is my end goal here as well).  However, although in 1.18 I still have the ability to call

serverLevel.setChunkForced(chunkPos.x, chunkPos.z, false);

it no longer seems to load the chunk immediately, but instead (from my understanding) submits a ticket to load it on the next tick.  This is problematic for my use case, as my goal is to load the chunk, access an entity within it, and then deload the chunk on completion, which I can no longer do in a single tick with this method.  LevelChunks also don't seem to contain a list of entities anymore in 1.18, and seem to have less automated functions connected to them, which could I suppose also be the source of my issue.

Is there a way to load a chunk instantaneously from its coordinates and immediately access the entities within it?

Posted
37 minutes ago, Xoroshio said:

Just call level.getChunk(x, y);

After that you can get the entities. Dont worry about the return value, the method loads the chunk.

Huh, well that's more straightforward than I expected.  Good to know, thanks!

Entity here is still coming back null, though.  Do I need to retrieve the entity differently?  Right now I'm doing it like this-

serverLevel.getChunk(chunkPos.x, chunkPos.z);
Entity entity = serverLevel.getEntity(uuidIn);

 

Posted
3 hours ago, Xoroshio said:

Ahhhh idk. Been awhile. How do you know the entity is in the chunk.

I'm saving and storing the position at a different point.  I know it's accurate in my testing cases because I'm also displaying the entity's coordinates, and if I manually teleport to them I can verify the entity is there.

Posted (edited)
1 hour ago, Xoroshio said:

My guess would be that you are not getting the chunk coordinates right, or getChunk dosnt work.

I've tried multiple ways to get the chunk coordinates and none of them have worked, so I'm guessing it may be getChunk().  Is there another way to forcibly load a chunk on that same tick?

If all else fails I guess I can just delay my action by a tick, but that's a pain in the butt and makes it more complex to provide appropriate feedback...

Also welcome, Zander.  If you're searching for a similar solution, I hope this (eventually) helps you too 😅

Edited by JayZX535

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.