Baritone AI pathfinder

Baritone AI pathfinder

72.7k Downloads

BaritoneAPI executing command displays message but does nothing

bebeli555 opened this issue · 11 comments

commented

So when you try to execute a command with the BaritoneAPI like this for example:
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("goto 0 100 0");

It displays the message saying "Going to x y z" but it doesn't start moving or show the path. Just shows the message and thats all. Also the method returns true.

Am i doing something wrong or is this a bug?

commented

@L1ving I tried that and it seems that it only works if i have the baritone-api-forge-1.2.10.jar in my mods folder with the mod. If you try to run the mod alone without the api jar then it will only display the message and do nothing but if you have the api jar also then it will work without any change in the code.

I tried kami blue and it seems to work alone without the need of the api jar. Maybe its because i don't have the mixin in my dependencies and it might need that to work.

It's weird that it doesn't give any error message tho.

commented

You need the Baritone API in the classpath in order to use the Baritone API... ie, "included" in some way, whether you install the baritone forge api jar or you include the Baritone API in your own mod's jar...

commented

I have it included in the jar. I also tried including the whole baritone from the jitpack repo but got the same problem. I can call the methods and all but its just that when i try to execute a command to make it walk somewhere for example it displays the message saying ”Going to coords” but it never moves or renders the path. It also happens with the snippet you linked.

But then if i have the api jar in the mods folder also then it works for some reason. Maybe it runs into some weird issue in the 1.2 version that is in the classpath after it sends the message. Well ill try to debug it tomorrow

commented

But then if i have the api jar in the mods folder also then it works for some reason.

Then you are likely not including the API properly.

commented

kami's baritone command thing looks very bad/hacky/🗿🧠, running commands via code like you had: BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("goto 0 100 0"); is a much better approach imo, just Make sure it's running on the "main" thread, if it's directly on a chat listener without some kind of CompletableFuture, that should work; if you're unsure try using Minecraft.execute(() -> {}) to put it on the main thread.

about the jar confusion.
the api jar is the proper one to be using, it is "standalone" in the sense that you don't need any other jars for baritone to work, by comparison, the standalone jar has an obfuscated api.

commented

kami's baritone command thing looks very bad/hacky/moyaibrain, running commands via code like you had:

It is literally the same way Impact client does it, assuming you're talking about KAMI Blue, which is very different from KAMI.

The reasoning behind changing the setting state while running commands is so the function will still work if the user decides to disable chat control.

I do agree the vararg is weird and I've been wanting to refactor all of our message utils as they're very java oriented as they were originally wrote, but I have been very busy as of late.

commented

The reasoning behind changing the setting state while running commands is so the function will still work if the user decides to disable chat control.

String FORCE_COMMAND_PREFIX = String.format("<<%s>>", UUID.randomUUID().toString());

yeah so, umm.

commented

Ask leij

commented

See this snippet for an example of how to execute Baritone commands with code, it's ported from Impact

commented

Even through you have got that example, I strongly recommend that you don't control it through commands use

BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(BlockPos)
commented

Well this is the error im getting now when u try to send "path" command to it. If u send a goto command then theres no error but it wont do anything expect send the message.

My build.gradle is fine and i also tried it with the older forge gradle version and still the same issue. It makes no sense

[15:21:13] [Client thread/INFO] [minecraft/GuiNewChat]: [CHAT] [Baritone] > path [15:21:13] [Client thread/INFO] [minecraft/GuiNewChat]: [CHAT] [Baritone] An unhandled exception occurred. The error is in your game's log, please report this at https://github.com/cabaletta/baritone/issues [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: baritone.api.command.exception.CommandUnhandledException: java.lang.NullPointerException [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at baritone.command.manager.CommandManager$ExecutionWrapper.execute(CommandManager.java:143) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at baritone.command.manager.CommandManager$ExecutionWrapper.access$000(CommandManager.java:127) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at baritone.command.manager.CommandManager.execute(CommandManager.java:83) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at baritone.command.BaritoneChatControl.runCommand(BaritoneChatControl.java:145) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at baritone.command.BaritoneChatControl.onSendChatMessage(BaritoneChatControl.java:73) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at baritone.event.GameEventHandler.lambda$onSendChatMessage$2(GameEventHandler.java:69) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:895) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at baritone.event.GameEventHandler.onSendChatMessage(GameEventHandler.java:69) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_15_AutoBot_onChat_ClientChatEvent.invoke(.dynamic) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraftforge.event.ForgeEventFactory.onClientSendMessage(ForgeEventFactory.java:436) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraft.client.gui.GuiScreen.sendChatMessage(GuiScreen.java:416) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraft.client.gui.GuiScreen.sendChatMessage(GuiScreen.java:411) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraft.client.gui.GuiChat.keyTyped(GuiChat.java:109) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraft.client.gui.GuiScreen.handleKeyboardInput(GuiScreen.java:558) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:512) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraft.client.Minecraft.runTick(Minecraft.java:1759) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1098) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraft.client.Minecraft.run(Minecraft.java:398) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraft.client.main.Main.main(Main.java:118) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at java.lang.reflect.Method.invoke(Method.java:498) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at java.lang.reflect.Method.invoke(Method.java:498) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraftforge.legacydev.Main.start(Main.java:86) [15:21:13] [Client thread/INFO] [STDERR]: [baritone.api.command.exception.CommandUnhandledException:handle:44]: at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29) [15:21:13] [Client thread/INFO] [STDERR]: [java.lang.Throwable:printStackTrace:635]: Caused by: java.lang.NullPointerException [15:21:13] [Client thread/INFO] [STDERR]: [java.lang.Throwable:printStackTrace:635]: at baritone.cache.WorldScanner.repack(WorldScanner.java:122) [15:21:13] [Client thread/INFO] [STDERR]: [java.lang.Throwable:printStackTrace:635]: at baritone.cache.WorldScanner.repack(WorldScanner.java:116) [15:21:13] [Client thread/INFO] [STDERR]: [java.lang.Throwable:printStackTrace:635]: at baritone.command.defaults.PathCommand.execute(PathCommand.java:41) [15:21:13] [Client thread/INFO] [STDERR]: [java.lang.Throwable:printStackTrace:635]: at baritone.command.manager.CommandManager$ExecutionWrapper.execute(CommandManager.java:140) [15:21:13] [Client thread/INFO] [STDERR]: [java.lang.Throwable:printStackTrace:635]: ... 33 more