Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

  • Author

Well somehow I changed some code and accidentally fixed my issue. Thanks to anyone who was going to try to help though :) 

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.