So, I'm trying to have the player send a message, then wait a certain amount of time, then send another one, etc. I can't figure out how to make them wait in between. I've tried Thread.sleep(1000); but it pauses the entire game. My code right now:
public class AutoVoCoAd extends Module
{
Timer timer = new Timer();
@Override
public void onEnable()
{
for(int counter=0; counter<20; counter++)
{
timer.schedule(new TimerTask() {
public void run() {
Minecraft.getMinecraft().player.sendChatMessage(">Message 1");
Minecraft.getMinecraft().player.sendChatMessage("Message 2");
}
}, 10*1000);
}
}
Maybe instead of trying making the thread sleep you can instead subscribe to the player tick event and have the ticks be your clock. I believe 20 ticks would be one second.
Rollback Post to RevisionRollBack
My Mods:
Working on updating Little Maid Mod to 1.12 with my own twist. I am a Japanese anime fan :3 Teasers here
Blood Baubles - An addon for BloodMagic that adds related Baubles to the game. (Currently on hold)
Blood Magic Wiki - A Blood Mages Choice Encylopedia (Currently on hold)
LazyModder- A libary that makes modding easier. Currently being developed for 1.12)
Deobfuscator - A program used to deobfuscate obfuscated mods.
So, I'm trying to have the player send a message, then wait a certain amount of time, then send another one, etc. I can't figure out how to make them wait in between. I've tried Thread.sleep(1000); but it pauses the entire game. My code right now:
Any help is greatly appreciated!
Maybe instead of trying making the thread sleep you can instead subscribe to the player tick event and have the ticks be your clock. I believe 20 ticks would be one second.
My Mods:
- Happy Coding -
Thanks!