Posted June 28, 20214 yr Hey, i tried different ways to force player to hold down left click but i couldn't acquire what i wanted, here are the ways i tried to do: I put that code on scheduled timer (Did not work): package com.example.examplemod; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import java.util.TimerTask; public class LeftClick extends TimerTask { @Override public void run() { long oldTime = System.currentTimeMillis(); while (System.currentTimeMillis() - oldTime < 33000) { KeyBinding.onTick(Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode()); } try { Thread.sleep(0); } catch (InterruptedException e) { e.printStackTrace(); } } } Tried that and did not work either: KeyBinding.setKeyBindState(keyCodes[0], true); Tried to loop that and the game just crashed right away: KeyBinding.onTick(Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode()); and few other things :/.
June 28, 20214 yr Author Solved: @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { if(Status == true){ KeyBinding.onTick(Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode()); }
December 30, 20213 yr On 6/28/2021 at 1:45 PM, ImNotSwarley said: Solved: @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { if(Status == true){ KeyBinding.onTick(Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode()); } Hey man can you explain a little bit ? im trying to do same thing but i dont know how to implament your code into my code. Can you give me a source of this code ?
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.