Posted August 18, 20169 yr I've been using this code to execute a bulk operation: while((line = buffered.readLine()) != null) { Minecraft.getMinecraft().thePlayer.sendChatMessage("/party invite " + line ); Thread.sleep(100); It reads 100 lines, which works. However it freezes my Minecraft and because of this the time is not consistent, and so sometimes I get the message "Sending Commands too fast!", making it inconsistent.
August 18, 20169 yr Author this is for you afk mod? count ticks the minecraft client ticks 20 times a second, assuming it is not lagging. This is for another part of it. And how do I count ticks?
August 18, 20169 yr Author depends on where this class of yours is being called. You should probably post the whole class not just part of a method. but you would most likely need to create your own tick variable and make it count up int ticks; ticks++; Whole class: package com.simpleafk; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.nio.charset.Charset; import java.nio.file.CopyOption; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; import java.util.List; import java.util.Timer; import java.util.TimerTask; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; public class wparty extends CommandBase { @Override public String getCommandName() { // TODO Auto-generated method stub return "wparty"; } @Override public String getCommandUsage(ICommandSender sender) { // TODO Auto-generated method stub return "wparty"; } @Override public boolean canCommandSenderUseCommand(ICommandSender icommandsender) { return true; } @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { String path = "config/whitelist.txt"; String line = null; try { FileReader file = new FileReader(path); BufferedReader buffered = new BufferedReader(file); sender.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_AQUA + "People on your invite list: ")); while((line = buffered.readLine()) != null) { Minecraft.getMinecraft().thePlayer.sendChatMessage("/party invite " + line ); Thread.sleep(100); } buffered.close(); } catch (IOException | InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } The file in question is totally fine, just need a better thing for the delay.
August 18, 20169 yr Author ok different question, why do you need the delay? There is a command delay, you can't spam commands, so there needs to be a specific delay, you get kicked off the server if you spam too much, which this definitely does.
August 18, 20169 yr So, you want to not spam commands without freezing your Minecraft (if I understand correctly)? AFAIK, you could put your loop in a new thread, but Minecraft might not allow it. Worth a try anyways. Sup bruh.
August 18, 20169 yr Author So, you want to not spam commands without freezing your Minecraft (if I understand correctly)? AFAIK, you could put your loop in a new thread, but Minecraft might not allow it. Worth a try anyways. But this stuff about counting ticks? Sounds like it would be better.
August 18, 20169 yr Author Welp, the command is only going to run once. You need something that can tick if you need to put a pause in your commands. So you are going to need to make something that can tick and then use something to the likes of: if (ticks % 20 == (20 - 1){ //do stuff } This will fire every second. So adjust the numbers as needed. If it were me, when the command is fired, I would get all the names out the file, put them in a global array list. Have your ticking entity watching said array list, if it != null, then do stuff. Once it iterates through all the names, clear the list. But surely that won't work because of the loop? And that still doesn't give me an actual delay in time.
August 18, 20169 yr Author No you would re-write your command to instead loop to ge tthe names out of the file and add them to an array list. After the loop you would create your entity and pass the list to the entity. The entity could then use the onUpdate() method to iterate through the list at a slower pace using ticks. That seems really complicated, is there any simpler way? I've seen stuff about scheduled executor delays?
August 18, 20169 yr No you would re-write your command to instead loop to ge tthe names out of the file and add them to an array list. After the loop you would create your entity and pass the list to the entity. The entity could then use the onUpdate() method to iterate through the list at a slower pace using ticks. That seems really complicated, is there any simpler way? I've seen stuff about scheduled executor delays? There is no "simpler" way. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.