MeteorDevelopment / meteor-client

Based Minecraft utility mod.
https://meteorclient.com
GNU General Public License v3.0
2.14k stars 795 forks source link

[Suggestion] Baritone scripting #1350

Open NoNameLmao opened 3 years ago

NoNameLmao commented 3 years ago

Describe the feature It would work like any other script, but for baritone. Start with a command, then when a goal is reached/complete, automatically move on to another command.

Example I know, this was meant to be "Screenshot" but I don't know how to demonstrate it via any screenshot, GIF, video. Have some text

(Current goal: None)

script start test1 mine 6 diamond_ore (script) (mining) [Baritone] Have 6 valid items mine 9 gold_ore (script) [Baritone] Have 9 valid items

My thoughts on implementation I think it could be done through giving baritone commands then monitoring the completion of the goal, once it was done - move to the other command in script. I also think having a script folder in .minecraft, with Meteor reading scripts from .txt files inside and just doing commands would be cool and useful.

MunchyG commented 3 years ago

this would be epic for

sel ca sel shift all down 4 (or expand) sel ca

so you can leave it to mine large sel areas instead of having to keep an eye on it and shifting it down all the time

C10udburst commented 3 years ago

Although for now it's fairly bare-bones, you can use meteor-python-addon to make scripts that interact with baritone.

Implementation of your example:

from mcapi import baritone, event_listener
from meteordevelopment.meteorclient.events.entity.player import PickItemsEvent
from net.minecraft.item import Items

diamond_count = 0
gold_count = 0

def on_pickup(event):
    # Increase the appropriate counter
    item_type = event.itemStack.getItem()
    if item_type.equals(Items.DIAMOND):
        diamond_count += event.count
    elif item.type.equals(Items.RAW_GOLD):
        gold_count += event.count

    if diamond_count >= 6:
        baritone("mine gold_ore")
    if gold_count >= 9:
        baritone("stop")

# Make on_pickup run everytime an item is picked up
event_listener(on_pickup, PickupItemsEvent)

baritone("mine diamond_ore")

It is a bit bigger than your pseudocode, but it's the only currently feasible solution, as baritone events aren't sent to meteor's event bus.

lnee94 commented 3 years ago

yes using python does work i think op wont's more of a shell scripting langueg where it would type in stuff to a modded chat (so to post stuff to public chat you would haft to do chat "hello" or something) if you would have a look at the syntax of bash you would get a better idea.