Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/gradle_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 25
uses: actions/setup-java@v5
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'zulu'
Expand All @@ -31,13 +31,13 @@ jobs:
run: ./gradlew build -Pmod_version="$(git describe --always --tags --first-parent | cut -c2-)"

- name: Archive Artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: dist/

- name: Archive mapping.txt
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
with:
name: Mappings
path: mapping/
7 changes: 3 additions & 4 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v5
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'zulu'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Executing tests
run: ./gradlew test

10 changes: 2 additions & 8 deletions FEATURES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Pathing features

- **Long distance pathing and splicing** Baritone calculates paths in segments, and precalculates the next segment when the current one is about to end, so that it's moving towards the goal at all times.
- **Chunk caching** Baritone simplifies chunks to a compacted internal 2-bit representation (AIR, SOLID, WATER, AVOID) and stores them in RAM for better very-long-distance pathing. There is also an option to save these cached chunks to disk. <a href="https://www.youtube.com/watch?v=dyfYKSubhdc">Example</a>
- **Block breaking** Baritone considers breaking blocks as part of its path. It also takes into account your current tool set and hot bar. For example, if you have a Eff V diamond pick, it may choose to mine through a stone barrier, while if you only had a wood pick it might be faster to climb over it.
Expand All @@ -15,8 +14,7 @@
- **Pigs** It can sort of control pigs. I wouldn't rely on it though.

# Pathing method

Baritone uses A*, with some modifications:
Baritone uses A*, with some modifications:

- **Segmented calculation** Traditional A* calculates until the most promising node is in the goal, however in the environment of Minecraft with a limited render distance, we don't know the environment all the way to our goal. Baritone has three possible ways for path calculation to end: finding a path all the way to the goal, running out of time, or getting to the render distance. In the latter two scenarios, the selection of which segment to actually execute falls to the next item (incremental cost backoff). Whenever the path calculation thread finds that the best / most promising node is at the edge of loaded chunks, it increments a counter. If this happens more than 50 times (configurable), path calculation exits early. This happens with very low render distances. Otherwise, calculation continues until the timeout is hit (also configurable) or we find a path all the way to the goal.
- **Incremental cost backoff** When path calculation exits early without getting all the way to the goal, Baritone it needs to select a segment to execute first (assuming it will calculate the next segment at the end of this one). It uses incremental cost backoff to select the best node by varying metrics, then paths to that node. This is unchanged from MineBot and I made a <a href="https://docs.google.com/document/d/1WVHHXKXFdCR1Oz__KtK8sFqyvSwJN_H4lftkHFgmzlc/edit">write-up</a> that still applies. In essence, it keeps track of the best node by various increasing coefficients, then picks the node with the least coefficient that goes at least 5 blocks from the starting position.
Expand All @@ -29,9 +27,7 @@ Baritone uses A*, with some modifications:
- [Baritone chat control usage](USAGE.md)

# Goals

The pathing goal can be set to any of these options:

- **GoalBlock** one specific block that the player should stand inside at foot level
- **GoalXZ** an X and a Z coordinate, used for long distance pathing
- **GoalYLevel** a Y coordinate
Expand All @@ -42,16 +38,14 @@ The pathing goal can be set to any of these options:

And finally `GoalComposite`. `GoalComposite` is a list of other goals, any one of which satisfies the goal. For example, `mine diamond_ore` creates a `GoalComposite` of `GoalTwoBlocks`s for every diamond ore location it knows of.

# Future features

# Future features
Things it doesn't have yet

- Trapdoors
- Sprint jumping in a 1x2 corridor

See <a href="https://github.com/cabaletta/baritone/issues">issues</a> for more.

Things it may not ever have, from most likely to least likely =(

- Boats
- Horses (2x3 path instead of 1x2)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Baritone

<p align="center">
<a href="https://github.com/cabaletta/baritone/releases/"><img src="https://img.shields.io/github/downloads/cabaletta/baritone/total.svg" alt="GitHub All Releases"/></a>
</p>
Expand Down Expand Up @@ -112,14 +111,15 @@ Here are some links to help to get started:
# API

The API is heavily documented, you can find the Javadocs for the latest release [here](https://baritone.leijurv.com/).
Please note that usage of anything located outside of the `baritone.api` package is not supported by the API release
Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release
jar.

Below is an example of basic usage for changing some settings, and then pathing to an X/Z goal.

```java
BaritoneAPI.getSettings().allowSprint.value = true;
BaritoneAPI.getSettings().primaryTimeoutMS.value = 2000L;

BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(10000, 20000));
```

Expand Down
13 changes: 3 additions & 10 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@ The easiest way to install Baritone is to install it as Forge/Neoforge/Fabric mo
Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.

## Prebuilt official releases

Releases are made rarely and are not always up to date with the latest features and bug fixes.

Link to the releases page: [Releases](https://github.com/cabaletta/baritone/releases)

The mapping between Minecraft versions and major Baritone versions is as follows

| Minecraft version | 1.12 | 1.13 | 1.14 | 1.15 | 1.16 | 1.17 | 1.18 | 1.19 | 1.20 | 1.21 | 1.21.4 | 1.21.5 | 1.21.6 - 1.21.8 |
|-------------------|------|------|------|------|------|------|------|------|-------|-------|--------|--------|------------------|
| Baritone version | v1.2 | v1.3 | v1.4 | v1.5 | v1.6 | v1.7 | v1.8 | v1.9 | v1.10 | v1.11 | v1.13 | v1.14 | v1.15 |

Any official release will be GPG signed by leijurv (44A3EA646EADAC6A). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by that public keys of `checksums.txt`.
Any official release will be GPG signed by leijurv (44A3EA646EADAC6A). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by that public keys of `checksums.txt`.

The build is fully deterministic and reproducible, and you can verify that by running `docker build --no-cache -t cabaletta/baritone .` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too).


## Artifacts

Building Baritone will create the final artifacts in the ``dist`` directory. These are the same as the artifacts created in the [releases](https://github.com/cabaletta/baritone/releases).
Expand All @@ -32,7 +31,6 @@ If you want to report a bug and spare us some effort, you want `baritone-unoptim
Otherwise, you want `baritone-standalone-*-VERSION.jar`

Here's what the various qualifiers mean

- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features.
- **Standalone**: Everything is obfuscated. Other mods cannot use Baritone, but you get a bit of extra performance.
- **Unoptimized**: Nothing is obfuscated. This shouldn't be used in production, but is really helpful for crash reports.
Expand All @@ -43,27 +41,24 @@ Here's what the various qualifiers mean
If you build from source you will also find mapping files in the `dist` directory. These contain the renamings done by ProGuard and are useful if you want to read obfuscated stack traces.

## Build it yourself

- Clone or download Baritone

![Image](https://i.imgur.com/kbqBtoN.png)
- If you choose to download, make sure you download the correct branch and extract the ZIP archive.
- Follow one of the instruction sets below, based on your preference

## Command Line

On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.

The recommended Java versions by Minecraft version are

| Minecraft version | Java version |
|-------------------------------|---------------|
| 1.12.2 - 1.16.5 | 8 |
| 1.17.1 | 16 |
| 1.18.2 - 1.20.4 | 17 |
| 1.20.5 - 1.21.8 | 21 |

Download java: <https://adoptium.net/>
Download java: https://adoptium.net/

To check which java version you are using do `java -version` in a command prompt or terminal.

Expand All @@ -80,13 +75,11 @@ and `gradlew build -Pbaritone.forge_build` / `gradlew build -Pbaritone.fabric_bu
for Forge/Fabric instead. And you might have to run `setupDecompWorkspace` first.

## IntelliJ

- Open the project in IntelliJ as a Gradle project
- Refresh the Gradle project (or, to be safe, just restart IntelliJ)
- Depending on the minecraft version, you may need to run `setupDecompWorkspace` or `genIntellijRuns` in order to get everything working

## Github Actions

Most branches have a CI workflow at `.github/workflows/gradle_build.yml`. If you fork this repository and enable actions for your fork
you can push a dummy commit to trigger it and have GitHub build Baritone for you.

Expand Down
12 changes: 6 additions & 6 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Try `#help` I promise it won't just send you back here =)

"wtf where is cleararea" -> look at `#help sel`

"wtf where is goto death, goto waypoint" -> look at `#help wp`
"wtf where is goto death, goto waypoint" -> look at `#help wp`

just look at `#help` lmao

Expand All @@ -33,7 +33,6 @@ Watch this [showcase video](https://youtu.be/CZkLXWo4Fg4)!
To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. To reset a setting to its default value, say `acceptableThrowawayItems reset`. To reset all settings, say `reset`. To see all settings that have been modified from their default values, say `modified`.

Commands in Baritone:

- `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks
- `goal x y z` or `goal x z` or `goal y`, then `path` to set a goal to a certain coordinate then path to it
- `goto x y z` or `goto x z` or `goto y` to go to a certain coordinate (in a single step, starts going immediately)
Expand All @@ -48,7 +47,7 @@ Commands in Baritone:
- `build` to build a schematic. `build blah.schematic` will load `schematics/blah.schematic` and build it with the origin being your player feet. `build blah.schematic x y z` to set the origin. Any of those can be relative to your player (`~ 69 ~-420` would build at x=player x, y=69, z=player z-420).
- `schematica` to build the schematic that is currently open in schematica
- `tunnel` to dig and make a tunnel, 1x2. It will only deviate from the straight line if necessary such as to avoid lava. For a dumber tunnel that is really just cleararea, you can `tunnel 3 2 100`, to clear an area 3 high, 2 wide, and 100 deep.
- `farm` to automatically harvest, replant, or bone meal crops. Use `farm <range>` or `farm <range> <waypoint>` to limit the max distance from the starting point or a waypoint.
- `farm` to automatically harvest, replant, or bone meal crops. Use `farm <range>` or `farm <range> <waypoint>` to limit the max distance from the starting point or a waypoint.
- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).
- `explore x z` to explore the world from the origin of x,z. Leave out x and z to default to player feet. This will continually path towards the closest chunk to the origin that it's never seen before. `explorefilter filter.json` with optional invert can be used to load in a list of chunks to load.
- `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start.
Expand All @@ -68,7 +67,6 @@ Commands in Baritone:
All the settings and documentation are <a href="https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/Settings.java">here</a>. If you find HTML easier to read than Javadoc, you can look <a href="https://baritone.leijurv.com/baritone/api/Settings.html#field.detail">here</a>.

There are about a hundred settings, but here are some fun / interesting / important ones that you might want to look at changing in normal usage of Baritone. The documentation for each can be found at the above links.

- `allowBreak`
- `allowSprint`
- `allowPlace`
Expand All @@ -88,10 +86,12 @@ There are about a hundred settings, but here are some fun / interesting / import
- `mineScanDroppedItems`
- `allowDiagonalAscend`




# Troubleshooting / common issues

## Why doesn't Baritone respond to any of my chat commands?

This could be one of many things.

First, make sure it's actually installed. An easy way to check is seeing if it created the folder `baritone` in your Minecraft folder.
Expand All @@ -101,7 +101,7 @@ Second, make sure that you're using the prefix properly, and that chat control i
For example, Impact disables direct chat control. (i.e. anything typed in chat without a prefix will be ignored and sent publicly). **This is a saved setting**, so if you run Impact once, `chatControl` will be off from then on, **even in other clients**.
So you'll need to use the `#` prefix or edit `baritone/settings.txt` in your Minecraft folder to undo that (specifically, remove the line `chatControl false` then restart your client).

## Why can I do `.goto x z` in Impact but nowhere else? Why can I do `-path to x z` in KAMI but nowhere else?

## Why can I do `.goto x z` in Impact but nowhere else? Why can I do `-path to x z` in KAMI but nowhere else?
These are custom commands that they added; those aren't from Baritone.
The equivalent you're looking for is `goto x z`.
19 changes: 10 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ allprojects {
apply plugin: "xyz.wagyourtail.unimined"
apply plugin: "maven-publish"

base {
archivesName = rootProject.archives_base_name
}
archivesBaseName = rootProject.archives_base_name

def vers = ""
/*def vers = ""
try {
vers = 'git describe --always --tags --first-parent --dirty'.execute().text.trim()
} catch (Exception e) {
Expand All @@ -36,11 +34,14 @@ allprojects {
} else {
version = vers.substring(1)
println "Detected version " + version
}
}*/

version = rootProject.mod_version
group = rootProject.maven_group

sourceCompatibility = targetCompatibility = JavaVersion.toVersion(project.java_version)

java {
sourceCompatibility = JavaVersion.toVersion(project.java_version)
toolchain {
languageVersion.set(JavaLanguageVersion.of(sourceCompatibility.majorVersion.toInteger()))
}
Expand Down Expand Up @@ -95,6 +96,8 @@ allprojects {

mappings {
mojmap()

devFallbackNamespace "official"
}
}

Expand All @@ -113,9 +116,7 @@ unimined.minecraft {
defaultRemapJar = false
}

base {
archivesName = archivesName.get() + "-common"
}
archivesBaseName = archivesBaseName + "-common"

sourceSets {
api {
Expand Down
11 changes: 6 additions & 5 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
repositories {
mavenLocal()
maven {
name = 'WagYourMaven'
url = 'https://maven.wagyourtail.xyz/releases'
name = 'WagYourMavenSnapshots'
url = 'https://maven.wagyourtail.xyz/snapshots'
}
maven {
name = 'WagYourMaven Snapshots'
url = 'https://maven.wagyourtail.xyz/snapshots'
name = 'WagYourMaven'
url = 'https://maven.wagyourtail.xyz/releases'
}
maven {
name = 'ForgeMaven'
Expand All @@ -44,6 +44,7 @@ dependencies {
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0'
implementation group: 'commons-io', name: 'commons-io', version: '2.7'

// TODO: pin to a stable Unimined release once published.
implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '1.4.2-SNAPSHOT'
implementation group: 'xyz.wagyourtail.unimined.mapping', name: 'unimined-mapping-library-jvm', version: '1.2.2'
}
}
16 changes: 9 additions & 7 deletions buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@
package baritone.gradle.task;

import baritone.gradle.util.Determinizer;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskCollection;
import org.gradle.api.tasks.compile.ForkOptions;
import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.internal.jvm.Jvm;
import org.gradle.jvm.toolchain.JavaLanguageVersion;
import org.gradle.jvm.toolchain.JavaLauncher;
import org.gradle.jvm.toolchain.JavaToolchainService;
import xyz.wagyourtail.unimined.api.UniminedExtension;
import xyz.wagyourtail.unimined.api.minecraft.MinecraftConfig;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.io.*;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
Expand Down Expand Up @@ -94,8 +97,7 @@ private void processArtifact() throws Exception {
private void downloadProguard() throws Exception {
Path proguardZip = getTemporaryFile(String.format(PROGUARD_ZIP, proguardVersion));
if (!Files.exists(proguardZip)) {
String downloadAddress = String.format("https://github.com/Guardsquare/proguard/releases/download/v%s/proguard-%s.zip", proguardVersion, proguardVersion);
write(new URI(downloadAddress).toURL().openStream(), proguardZip);
write(new URL(String.format("https://github.com/Guardsquare/proguard/releases/download/v%s/proguard-%s.zip", proguardVersion, proguardVersion)).openStream(), proguardZip);
}
}

Expand Down Expand Up @@ -173,7 +175,7 @@ private void generateConfigs() throws Exception {
}

private Stream<File> acquireDependencies() {
return getProject().getExtensions().getByType(JavaPluginExtension.class).getSourceSets().findByName("main").getCompileClasspath().getFiles()
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("main").getCompileClasspath().getFiles()
.stream()
.filter(File::isFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void determinize(String inputPath, String outputPath, List<File> t
clone.setTime(42069);
jos.putNextEntry(clone);
if (entry.getName().endsWith(".refmap.json")) {
JsonElement json = JsonParser.parseReader(new InputStreamReader(jarFile.getInputStream(entry)));
JsonElement json = new JsonParser().parse(new InputStreamReader(jarFile.getInputStream(entry)));
jos.write(writeSorted(json).getBytes());
} else if (entry.getName().equals("META-INF/MANIFEST.MF") && doForgeReplacementOfMetaInf) { // only replace for forge jar
ByteArrayOutputStream cancer = new ByteArrayOutputStream();
Expand Down
Loading