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

Item Task Scheduling


Recommended Posts

Hello everybody!
I'm writing simple Sorting Visualizer in Scala

I'm currently roadblocked by the Scheduling API, specifically, lack of understanding Minecraft concurrency
Since I've failed to gather any info online, I came here with my question

So, I have Item "Shuffle", purpose of which is to shuffle array made out of concrete columns
I want to make 1 iteration of shuffling every 5 ticks (Not using java.util.Timer or etc. since in my personal opinion tick based approach is more idiomatic)
I'm not really sure how to do that

Gist with highlighted code fragment

Thanks for any feedback!

Link to comment
Share on other sites

Basically there is no concurrency in Minecraft, or very limited. The main data structures such as Level are not threadsafe. If you want to do something every couple of ticks you need to use tick callbacks of which there are various. For items there is inventoryTick which is called every tick while the item is in a player's inventory. You can then use Level#getGameTime as a tick counter.

  • Thanks 1
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 Terms of Use.