MCCTeam / Minecraft-Console-Client

Lightweight console for Minecraft chat and automated scripts
https://mccteam.github.io
Other
1.67k stars 402 forks source link

Is it possible to hold right click? #1563

Closed ImLostTbh closed 3 years ago

ImLostTbh commented 3 years ago

So I'm playing on a server where afk fish farms are allowed, but bots that fish for you are against the rules. So I'm wondering if there's a command to make MCC hold down the right click button so I can use it with a fish farm to automate it while not having to have the whole game open.

ORelio commented 3 years ago

If server rules forbid fishing bots, why would they allow automated fishing farms? To answer your question, I'm not sure. There is no "right click" in Minecraft protocol, the game automatically chooses the correct action to perform. In your case, that could be "use item". You can indeed "use item" in a loop, e.g. using a script.

ImLostTbh commented 3 years ago

Thanks, I've gotten the script to work, but I know almost nothing about coding/scripting, how would I make it so the script will repeat until I type a command to cancel it?

ReinforceZwei commented 3 years ago

repeat until I type a command to cancel it?

This will require using the ChatBot API if you want to control the script by command. Save the script with file name ended with .cs

//MCCScript 1.0
MCC.LoadBot(new UseRod());

//MCCScript Extensions
public class UseRod : ChatBot
{
    private bool enabled = false;
    public override void Initialize()
    {
        RegisterChatBotCommand("userod", "UseItem repeatly", "start, stop", CommandHandler);
        LogToConsole("Loaded");
    }

    public string CommandHandler(string cmd, string[] args)
    {
        if (args.Length >= 1)
        {
            switch (args[0])
            {
                case "start": enabled = true; break;
                case "stop": enabled = false; break;
            }
            return "Switched to " + args[0];
        }
        else
        {
            return "Current: " + (enabled ? "running" : "stopped") + ". Use /userod start|stop to switch";
        }
    }

    public override void Update()
    {
        if (enabled)
            UseItemInHand();
    }
}

Control the script with command, image