Jump to content

1.19.2 - Entity not loading after teleportation to a forceloaded chunk


Povstalec

Recommended Posts

Hello,

I have a block entity that is using entity.teleportTo(x, y, z); to teleport an entity(Armor Stand in this case) into a chunk that's being kept loaded with
ForgeChunkManager.forceChunk(level.getServer().getLevel(Level.OVERWORLD), StargateJourney.MODID, getBlockPos(), level.getChunk(getBlockPos()).getPos().x, level.getChunk(getBlockPos()).getPos().z, true, true);

It works well, however, when I teleport the player alongside the entity, the entity doesn't load. It's still there, because if the player leaves to unload the chunk and then returns, the entity appears where it should.

I've tried fixing it by not forceloading the chunk and the entity loads without problems, but I actually need to have the chunk loaded, because I have a block entity in said chunk, that is ticking(essentially, it's the second end of a teleporter mechanism).

Is there a workaround to load the entity manually or even better, have it never unload in the first place?

Link to comment
Share on other sites

I mean, I don't believe you even need to keep the other chunk loaded, nor really need a block entity. You can just have a capability on the level that links the two spots and whenever a chunk isn't loaded, store the entity in an unloaded cache such that when the chunk is loaded, you add in the entity where it needs to go. You can use the `ChunkEvent$Load` for this. It may cause a deadlock, so you might just want to enqueue the adding back in of the entity using a flag to activate logic on a separate event (e.g. `LevelTickEvent`).

Link to comment
Share on other sites

Technically, yes, I don't neet to keep the chunk loaded, nor do I need the block entity just to teleport stuff there.

But I'm trying to recreate Transport Rings from Stargate, which work by having a platform on each end, that does its own thing. My block entities represent these platforms. Each one takes a different amount of time to get into position animation-wise, so when the first block entity is has already finished its animation, the second entity might still be in the middle of its own animation. Each block entity waits for a certain amount of ticks to change its blockstate at the end of the animation cycle(so that redstone can detect when it's done), so unloading it prematurely/not loading it at all would mean that the blockstate never gets changed and since mysystem works by only allowing block entities to connect to other block entities if they're done animating, the block entity would essentially become inaccesssible until a player loaded it and allowed it to finish its animation.

So unless there's a way to do what I want without a loaded chunk, I'd preferably like to keep the loaded chunk.

I haven't used Capabilities before, so maybe what you told me can be used to fix my problem without getting rid of the loaded chunk, I dunno. I'll see once I learn a bit more about them. But just in case it's not, any other ways to do it?

Link to comment
Share on other sites

5 hours ago, Povstalec said:

But I'm trying to recreate Transport Rings from Stargate, which work by having a platform on each end, that does its own thing. My block entities represent these platforms. Each one takes a different amount of time to get into position animation-wise, so when the first block entity is has already finished its animation, the second entity might still be in the middle of its own animation. Each block entity waits for a certain amount of ticks to change its blockstate at the end of the animation cycle(so that redstone can detect when it's done), so unloading it prematurely/not loading it at all would mean that the blockstate never gets changed and since mysystem works by only allowing block entities to connect to other block entities if they're done animating, the block entity would essentially become inaccesssible until a player loaded it and allowed it to finish its animation.

If I'm understanding correctly, all you are doing is waiting for x amount of time to pass before both can link; you're not actually rendering the other side, correct? In that case, you really could just use a level capability and just have the animation time attached to that, then just check it when teleporting to an unloaded chunk. It seems to me you are using block states to check whether you can teleport (no idea why you're using redstone). You essentially wouldn't need a separate block state anyways if you were just waiting for a given value to be something.

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.



×
×
  • Create New...

Important Information

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