Jump to content

Recommended Posts

Posted

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 :/.
 

Posted

Solved: 

@SubscribeEvent
    public void onPlayerTick(TickEvent.PlayerTickEvent event) {
        if(Status == true){
            KeyBinding.onTick(Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode());
        }

 

  • 6 months later...
Posted
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.

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.