Jump to content

5 second wait timer


Kore

Recommended Posts

Alright, so in my mod I am implementing a block that disappears for 5 secs then reappears(sorta like the portable hole) does anyone know how to make a Thread that can do this wwithout freezing the game?

The Korecraft Mod

Link to comment
Share on other sites

well, another "waiting" topic :D

 

read this:

http://www.minecraftforge.net/forum/index.php/topic,5964.0.html

^whole topic, there are two approaches to this problem ;)

 

it would be possible to do this via threads, but you'd have to manage synchronization. also spawning thread for each block/group of blocks just to put them to sleep doesn't seem right, when you can do the same with tick handler without overhead from the threads creation.

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

I don't know how to do this with just a block, but if you're willing to have a tile entity then you can simply use the updateEntity() method to increment a timer with every tick. 20 ticks = 1 second, so it would reappear after the timer reached 100. The actual change could be handled with metadata, where 0 is normal and 1 is invisible/non-collidable.

Link to comment
Share on other sites

@nerdboy64 that sounds considerably easier to implement than using threads or custom queue/calendar. also using TEs' NBT tags for saves is a nice and easy, definitely better than going over all the threads and signalizing them to stop waiting and to send the main thread remaining time...

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

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.