Minecraft-Console-Client icon indicating copy to clipboard operation
Minecraft-Console-Client copied to clipboard

I need help pls

Open iamkurcze opened this issue 3 years ago • 15 comments

A server that i play on has implemented a GUI captcha. Is there a way to create a c# script that clicks a specific item in Gui? Type of the item depends on name of gui.

iamkurcze avatar Jul 05 '22 08:07 iamkurcze

Unfortunately there is no template for this. You can either write your own C# script and work with the inventory classes or utilize inventory handling and try to solve this captcha with /inventory manually.

Daenges avatar Jul 05 '22 09:07 Daenges

Unfortunately there is no template for this. You can either write your own C# script and work with the inventory classes or utilize inventory handling and try to solve this captcha with /inventory manually.

Sadly i cant code in C#, and the whole point of creating the script is not doing it manually, but i can code in java, also how would u make the script urself ? (Maybe ur idea will help make it on my own)..

iamkurcze avatar Jul 06 '22 11:07 iamkurcze

Currently this repository is a bit cluttered, since the major .Net 5 rework (from .Net Framework 4.8) got merged. Although it is not really necessary for you to know, here is a video that explains what this means.

Normally you would start with Visual Studio and create a new ChatBot in the corresponding folder that inherits from ChatBot.cs. Make sure to change branch to previous, as the ChatBot.cs got removed in the latest commit. I also do not really know what the plan behind this is tbh...

Then you need to add a using MinecraftClient.Inventory; to the top. By inheriting from Chatbot.cs you get some functions to work with inventories, which are explained by comments (example). Apart from that you can read through inventory.cs (provides the usual command handling with /inventory) and the inventory folder. You need to read through some code, but it is pretty similar to Java, so reading itself should not pose a big challenge.

Daenges avatar Jul 06 '22 12:07 Daenges

This function returns all inventories as Container class (Keep in mind that container ID 0 is the player inventory). If you look at the attributes you can see that every container has a Title and a dictionary Items. Just compare the title to item.DisplayName() until you find the correct slot. And then it is only moving this item (here you can take a look into inventory.cs again).

Daenges avatar Jul 06 '22 12:07 Daenges

thx ill try my best

iamkurcze avatar Jul 06 '22 13:07 iamkurcze

Make sure to change branch to previous, as the ChatBot.cs got removed in the latest commit.

@Daenges They are moved to Scripting folder.

ReinforceZwei avatar Jul 06 '22 13:07 ReinforceZwei

also how to preform command like /inventory from c# code ??

iamkurcze avatar Jul 06 '22 13:07 iamkurcze

also how to preform command like /inventory from c# code ??

You don't. Use the appropriate functions gained from using the inventory namespace.

Above I provided sections where you see example usages or explanations for functions that may be useful. If you look into the /inventory file to see example calls.

Daenges avatar Jul 06 '22 14:07 Daenges

oh ok

iamkurcze avatar Jul 06 '22 15:07 iamkurcze

i get this: [MCC] [Script] Script 'RepairStoneGenerator.cs' failed to run (LoadError). [MCC] [Script] System.InvalidOperationException: ID expected

iamkurcze avatar Jul 06 '22 15:07 iamkurcze

I can not debug it currently. As an advice: Try to open it in Visual Studio and create a new class or paste your script into the TestBot.cs (without the head, only the content of your inheriting class into the existing one). There you have more options to debug. Remember to use inventory and add the testbot to the loading list to make it start.

Daenges avatar Jul 06 '22 16:07 Daenges

Everything works perfectly, just last question, how to, using c# code, click a inventory slot. I'd like to achieve the same effect as /inventory container click <slot>, oh and how to preform /inventory container close ?

iamkurcze avatar Jul 07 '22 11:07 iamkurcze

Have a look into the Inventory command file. Here and here.

Daenges avatar Jul 07 '22 11:07 Daenges

Have a look into the Inventory command file. Here and here.

Amazing, how to get the handler ?, cuz im lookin at https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/MinecraftClient/Scripting/ChatBot.cs and i see this: //Handler will be automatically set on bot loading, don't worry about this, idk what to do.. ( to execute handler.CloseInventory(container.ID);)

iamkurcze avatar Jul 07 '22 15:07 iamkurcze

Sorry for keeping you waiting. If you search through the Chatbot functions you see that there is an own implementation for closing and clicking. See different window actions.

Edit: Whoops - messed the links up.

Daenges avatar Jul 12 '22 10:07 Daenges

hey, ive written the bot, but it says that[MCC] Script failed to clean-up idk what to do

iamkurcze avatar Sep 26 '22 16:09 iamkurcze

hey, ive written the bot, but it says that[MCC] Script failed to clean-up idk what to do

That is a normal warning, it should work normally if you don't have a compilation error.

milutinke avatar Sep 27 '22 09:09 milutinke

hey, ive written the bot, but it says that[MCC] Script failed to clean-up idk what to do

That is a normal warning, it should work normally if you don't have a compilation error.

Discussion was continued in #2204

breadbyte avatar Sep 27 '22 12:09 breadbyte

I guess that wraps up this Issue. I'll close it in favor of that one.

milutinke avatar Sep 27 '22 12:09 milutinke