Jump to content

[1.7.10] Asynchronous World Explosion


novemcinctus

Recommended Posts

I need to create a delayed explosion, but don't want to halt the execution of the main thread. I tried using java.util.Timer.schedule but ran into some concurrency issues (specifically IllegalStateExceptions). Does the world have a lock associated with it? If not, is there a better way to create a delayed explosion without stalling everything?

 

Link to comment
Share on other sites

A generic tick handler.  Every tick it can check and decrement timers for any 'delayed explosion entries'.  Any that are supposed to explode can then be made to explode.

 

Or, if you have a block, you can schedule a block event/callback.

 

Or, if you have a tile-entity you can use internal varialbes/onUpdate code.

 

Or, if you have an entity you can decrement a variable in the entity/onUpdate code.

 

There is not necessarily a thread-lock, however there are multiple issues with trying to manipulate data across threads (cache coherency, stale data, yadda, etc... multiple books can and have been written on the subject).  You can't just jump in and muck about with another threads data.

 

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



×
×
  • Create New...

Important Information

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