Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

addScheduledTask


stepsword
 Share

Recommended Posts

Just now, stepsword said:

Is this normal?

If you are using Minecraft#addScheduledTask yes. You probably want WorldServer#addScheduledTask

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 minute ago, stepsword said:

Ahh, thanks so much.

Well depending on what you are doing there might be a better way to run code on the next tick.

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

32 minutes ago, Animefan8888 said:

Well depending on what you are doing there might be a better way to run code on the next tick.

Still working on that load chunk -> teleport entity bit. I wanted to make sure the chunk was loaded and also have access to the variables in the function that loads the chunk. Maybe its possible without the next-tick bit though, couldn't really find information on whether forceChunk happens right away or queues the chunk up for loading

Link to comment
Share on other sites

6 minutes ago, stepsword said:

Maybe its possible without the next-tick bit though, couldn't really find information on whether forceChunk happens right away or queues the chunk up for loading 

If I'm not mistaken I don't think you should use forceChunk as that is meant for persistent chunk loading. So if you were to just do something along the lines of Chunk chunk = World#getChunkAt(...); Which should load the chunk immediately. Then you can get the entity either from the chunk or from the world. Then move the Entity. And the chunk will unload just like that.

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

5 minutes ago, Animefan8888 said:

If I'm not mistaken I don't think you should use forceChunk as that is meant for persistent chunk loading. So if you were to just do something along the lines of Chunk chunk = World#getChunkAt(...); Which should load the chunk immediately. Then you can get the entity either from the chunk or from the world. Then move the Entity. And the chunk will unload just like that.

Haha - I learned that the hard way actually, while trying to get the Chunk to check isLoaded() I called getChunkAt().. which loads the chunk. That said, I do have one command planned where it would be useful to keep the chunk loaded so I'm trying to get it working with tickets for this one which will be simpler to test than the other one.

Edited by stepsword
Link to comment
Share on other sites

As an update: something I think wasn't immediately clear to me is that forceChunk seems to be only for chunks which are already loaded? i.e. if you call forceChunk on an unloaded chunk, nothing happens - you have to load it, then call forceChunk to keep it loaded. I haven't done a lot of testing of this theory to confirm if it's true, but based on the usage of getPersistentChunks() by Forge, I think it's true.

 

This is in the "unload chunks" method. I guess this probably isn't a problem for most people but in case someone stumbles on this later looking for why their forceChunks on a remote location isn't working, it could be because forceChunks only prevents loaded things from being unloaded, so they have to be loaded first for forceChunks to actually work.

 

if (!this.droppedChunksSet.isEmpty())
{
    for (ChunkPos forced : this.world.getPersistentChunks().keySet())
    {
Edited by stepsword
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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.