Started by
DragenSlayor
on
Topic category: Help with MCreator software
Is there any way to wait in between each action in procedures? I'd like to know if theres a way.
Edited by DragenSlayor on Mon, 11/19/2018 - 16:54
Topic category: Help with MCreator software
Is there any way to wait in between each action in procedures? I'd like to know if theres a way.
feather4011, use imgur
This works fine:
Custom Code snippet (You can find this block under the "Advanced" section in your Procedure editor):
try{Thread.sleep(1000);}catch(InterruptedException ex){Thread.currentThread().interrupt();}
The 1000 in the brackets are 1000 milliseconds = 1 second, you can change that to what ever you want!
So if you create a block and put this Procedure into the "Update Tick" section and place this Block somewhere...
You will get two sentences with a 1 second delay inbetween them
darkster, does that freeze the whole game for a second, or does mcreator automatically create a separate thread for the mod? i haven't had a chance to test the code myself.
Minecraft does not freeze
https://stackoverflow.com/questions/24104313/how-to-delay-in-java
I got the Code from here
ok, but have you tested it? because word in the Minecraft modding forums is that Minecraft runs only on one thread, and if you sleep the whole thread, you will freeze the game.
Forge has a scheduler, btw; i don't understand enough to know how to use it yet.
http://www.minecraftforge.net/forum/topic/38751-solved-forge-schedulert…
I test it and I does Freeze the game
I can also verify that thread.sleep freezes the game.
I'm trying to make a cooldown timer that *mostly* works:
If I use the custom code, the game will freeze for 1000 ms * the # of iterations in the while loop. So, in this case, 60 (item 1) * 1000ms or 1 minute. Now, if I get rid of the special code (item 2), the while loop is near instantaneous. I even upped it to 10M and it's still instantaneous. I don't know how to fix this. :/
(PS: I hope the image posts...for some reason, in preview, it's showing up as a broken image link)
Oh, here's the screen shot of what I'm trying. Internet is hard. :/
I know the logic works, because where I put item 2, I tested it by having it spawn a gem for each iteration. Sure enough, got 60 gems as expected. So, I don't know what # to put in item 1 so that it's not an instantaneous completion. And the custom code snippet just freezes the game up.
*shrug*
We're going to have to use the Forge scheduler. Maybe if enough people ask nicely for an event implementation of it, Pylo will put it in the next version :P
OK, I screwed with the code directly this time. It compiles, at least, without errors; but the timer effect is still near instantaneous, so there's no cooldown. :/ I didn't bother with using the procedures GUI in MCreator and just mucked around directly. Maybe if I can figure out the right order of everything, I'll do it that way.
Da code:
I'm not sure what I'm missing. I threw a little bit of code in there to try and debug the issue, and it seems that I've somehow screwed up the while statement? Because it appears the countdown keeps going even after "Cooldown complete" is executed.
Totally confused. I'll look at it again when I have fresh eyes. :P
Did you read the link i posted to the forum discussing how to use the forge TickHandler? That's exactly what you're looking for, as far as schedulers go. It links to a more comprehensive tutorial as well: https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/…