Baritone AI pathfinder

Baritone AI pathfinder

72.7k Downloads

How to add this to a 1.12.2 forge project

Doogie13 opened this issue ยท 9 comments

commented

What do you need help with?

Is there an actual guide on adding baritone to a mod? If so, please link it, else, could someone tell me how I would go about doing so?
Much appreciated.

Final checklist

  • I know how to properly use check boxes
  • I have not used any OwO's or UwU's in this issue.
commented

I have fixed this.
First I had to use implementation 'com.github.cabaletta:baritone:1.2.14' instead of implementation "cabaletta:baritone-api:1.2".
Secondly (where I messed up previously), I have to include jitpack.io as a maven repository to get that to work.

repositories {
    maven { url = 'https://jitpack.io/' }
}

dependencies {
    // Baritone library. We do NOT compile this into the jar as we use the API
    // 1.2.14 works better than 1.2.15 for some reason
    implementation 'com.github.cabaletta:baritone:1.2.14'
}

^ for anyone else needing the solution. If you want to bundle Baritone, you may want to add compile "cabaletta:baritone-api:1.2" in the dependencies block

commented

No, there's no guide on how to do it and "just add it to your libraries" usually ends in trouble if you want the runClient to work and is difficult (but much easier) if you only want to compile and test in a normal minecraft install.
If you want an example on how to do it that way look at mods like lambda (don't know whether they have a working runClient task).

If you want to avoid that trouble you can also compile Baritone with a slightly tweaked buildscript so it uses srg names so you can dump that special build into your libs folder and it works like any other mod.

commented

If you want to avoid that trouble you can also compile Baritone with a slightly tweaked buildscript so it uses srg names so you can dump that special build into your libs folder and it works like any other mod.

This sounds promising, would I just have to remove the part where it reobfuscates the jar? I don't want this mod to bundle baritone, so this seems like it would work? - will come back to you

Update: tbh idk how to do that but looking into lambda build.gradle (lambda can do runClient) it uses implementation for 'com.github.cabaletta:baritone:1.2.14' and a maven url of maven { url = 'https://impactdevelopment.github.io/maven/' } which I tried and it "> Could not find com.github.cabaletta:baritone:1.2.14." after trying many locations unrelated to impactdevelopment and - https://impactdevelopment.github.io/maven/com/github/cabaletta/baritone/1.2.14/baritone-1.2.14.pom

Update: I have successfully added Baritone to my project, how would I tweak the baritone build script for baritone to be able to load in a deobfuscated environment?

commented

I have found the solution to having Baritone intergration in my mod without forcing it to be present.
maven { url = 'https://impactdevelopment.github.io/maven/' }
implementation "cabaletta:baritone-api:1.2"

I still need assistance building baritone and preventing it from reobfuscating itself so I can use that jar in my dev environment mods folder

commented
Excerpt from the readme of my own project
This mod needs a srg mapped Baritone build to compile.

To get a srg mapped build get the Baritone source code from https://github.com/cabaletta/baritone and add

reobf.jar.mappingType = 'SEARGE'

to the end of build.gradle to change the mappings, then run a normal build.

For debugging purposes a unoptimized Baritone build can be helpful. To get one you can copy the baritone directory from the baritone-unoptimized jar into any of the baritone-forge jars of the same version.

To compile this project against your Baritone version place the file in libs and build the project using gradle.

Excerpt from the buildscript
runClient {
    args "--tweakClass","org.spongepowered.asm.launch.MixinTweaker"
    jvmArgs "-enableassertions"
}

Since the version of ForgeGradle I'm using (an ancient one) automatically includes jars from ${PROJECT_ROOT}/lib I only had to add the --tweakClass argument to make mixin work and Baritone was working both for compilation and testing. (the -enableassertions is so e.g.

assert state.isValid();

actually throws an error if the state is not valid.

commented

Building with that tacked onto the end of the build.gradle didnt work, unfortunately. Another thing, trying to get proper sources of baritone for use inside my project using

implementation 'com.github.cabaletta:baritone:1.2.15'

has not worked. I don't know exactly where it is supposed to get this jar from but it would allow me to use sources rather than the jar which is meant to be bundled since that breaks a ton of stuff and has no javadoc.

commented

Sorry, I can't help you with that (I just use one of my Baritone workspaces whenever I need the sources/javadoc).
To which buildscript did you add the reobf.jar.mappingType = 'SEARGE'?

commented

I added that as the bottom line of build.gradle which now that I write it out is retarded since iirc there is a buildscript block. Will have to get back to you

commented

No, last line of the file is correct (actually almost any line is fine, but last is a safe and easy location). I asked because you have to add it to Baritones build.gradle and build Baritone with it so you can copy the resulting baritone-api-forge-whatever.jar over to your project to build your project with it. The second change (runClient {args "--tweakClass","org.spongepowered.asm.launch.MixinTweaker"}) is then applied to your build.gradle to correctly load Baritone when using runClient. Don't try getting an unoptimized Forge build before you have the rest working.