Jump to content

[SOLVED] How to call clickMouse to break blocks in survival and have a delay in breaking in creative


Recommended Posts

Posted (edited)

So basically every time InputUpdateEvent I am calling this method that I created

    public void clickMouse(boolean leftClick) {
        try {

            if(clickMethod == null) {
                clickMethod = ObfuscationReflectionHelper.findMethod(minecraftClass,"func_147116_af"); //clickMouse();
                clickBlockMethod = ObfuscationReflectionHelper.findMethod(minecraftClass,"func_147115_a",boolean.class); //sendClickBlockToController(boolean leftClick);
                clickMethod.setAccessible(true);
                clickBlockMethod.setAccessible(true);
            }

            if(leftClick) {
                clickMethod.invoke(Minecraft.getInstance());
            }

            clickBlockMethod.invoke(Minecraft.getInstance(),leftClick);
        } catch (IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }

However calling it every event makes it so it breaks a block seemingly every tick in creative and in survival it doesn't actually break the block, just creates the block hit particles. I looked into Minecraft's code and saw it had the delays in the methods built-in for the tick time, however they seemed to be skipped. Do I have to implement my own delays? Or am I just missing a call to a function? Should I also stop calling clickMethod after it's been called once until they let go of the trigger? 

Edited by fernthedev
Solved my code, at least for now

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.