based on my previous experience in scripting, I believe you need to somehow call the baritone api to make it work, or somehow find a dirty way to call the function that parses the chat. Client.displayChatMessage should only show the chat in the client side instead of tries to send to the server, I am not aware which level baritone deals with the #command. Below is my attempt to ask claude-3-5 to write the script to call the baritone api, it is likely that it's not going to work because I did not feed the baritone doc into it, so it might make up some none-existent api or outdated api. Look only in the 4th section and find what might be useful to you.
For the ReferenceError: 'Player' is not defined maybe try mc.player. And further look into this https://maven.fabricmc.net/docs/yarn-1.20.4+build.3/index.html for other references.
Looks like that we might need a better scripting experience now, I have not yet look into that area carefully in the next gen.
I do appreciate if you can give futher feedback and your work on these, will be quite happy to help.
Continue session transcript UserAssistanthow do I call other baritone's api in fabric with a graaljs environment without explictly any binding into js context and instead use the polygot and Java.type and other graaljs things?
To call other Baritone's API in Fabric with a GraalJS environment without explicitly binding to the JS context, you can use GraalJS's Polyglot features and Java.type. Here's a general approach:
Ensure you have the necessary dependencies:
GraalJS Fabric BaritoneIn your Fabric mod, set up the GraalJS engine and create a context:
import org.graalvm.polyglot.*; // In your mod's initialization Context context = Context.newBuilder("js") .allowAllAccess(true) .build(); Load and evaluate your JavaScript code: context.eval("js", "your_javascript_code_here"); In your JavaScript code, you can use Java.type to access Java classes, including Baritone's API: // Example JavaScript code var BaritoneBridge = Java.type('baritone.api.BaritoneAPI'); var Settings = Java.type('baritone.api.Settings'); // Get the player's Baritone instance var baritone = BaritoneBridge.getProvider().getPrimaryBaritone(); // Access settings var settings = baritone.getSettings(); // Use Baritone's API function moveToBlock(x, y, z) { baritone.getPathingBehavior().cancelEverything(); baritone.getCustomGoalProcess().setGoalAndPath(new Java.type('baritone.api.pathing.goals.GoalBlock')(x, y, z)); } // Example usage moveToBlock(100, 64, 100); To call JavaScript functions from Java, you can use: Value jsFunction = context.eval("js", "moveToBlock"); jsFunction.execute(100, 64, 100);This approach allows you to use Baritone's API in your JavaScript code without explicitly binding it to the JS context. Instead, you're using GraalJS's Java.type to access Java classes and methods directly.
Remember to handle exceptions and properly close the GraalJS context when you're done:
context.close();Also, make sure you have the necessary permissions and that Baritone is properly initialized in your Fabric environment before attempting to use its API.