---
title: "baritone"
description: "Pathing, mining, following, building and Baritone's settings and commands from a script."
---

> Documentation Index
> Fetch the complete documentation index at: https://aesthetic-docs.pages.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# baritone

Drives the built-in Baritone, the same pathfinder the `#` chat commands run. Positions are
[vec3](/vec3) floored to the block, and functions that need a world return `nil` outside
one.

:::caution
Call `baritone` from client-thread events such as `tick` or `pre_interaction`, never from
`packet_send` or `packet_receive`.
:::

## Pathing

| Function | Does |
|----------|------|
| `baritone.path_to(goal)` | Sets the goal and starts pathing, like `#goto` |
| `baritone.set_goal(goal)` | Sets the goal without moving, like `#goal`; `nil` clears it |
| `baritone.path()` | Starts pathing to the goal set before, like `#path` |
| `baritone.cancel()` | Stops pathing and every process, like `#stop`. `false` when the current move can't stop yet, mid-jump; it stops right after |
| `baritone.goal()` | The goal Baritone is heading to, or `nil` |
| `baritone.pathing()` | `true` while walking a path, `false` while paused |
| `baritone.calculating()` | `true` while a path is being calculated |
| `baritone.eta()` | Estimated ticks left to the goal, or `nil` |
| `baritone.current_path()` | The path being walked as a list of block [vec3](/vec3), and the index of the node you are on |

`goal` is anything from `baritone.goals` below, or a vec3 meaning that exact block.

## Goals

| Function | Reached |
|----------|---------|
| `baritone.goals.block(pos)` | Feet on this block |
| `baritone.goals.near(pos, range)` | Within `range` blocks of `pos` |
| `baritone.goals.xz(x, z)` | Anywhere in this column, like `#goto x z` |
| `baritone.goals.y(y)` | Anywhere at this height, like `#goto y` |
| `baritone.goals.get_to_block(pos)` | Next to the block, close enough to use it: a chest, a crafting table |
| `baritone.goals.two_blocks(pos)` | Feet or head at `pos` |
| `baritone.goals.run_away(distance, from[, y])` | At least `distance` blocks from `from` horizontally, at height `y` when given |
| `baritone.goals.axis()` | On the nearest axis or diagonal at the `axisHeight` setting, like `#axis` |
| `baritone.goals.any(goal, ...)` | At any of the goals, whichever is closest |
| `baritone.goals.inverted(goal)` | Never: Baritone walks as far from the goal as it can, like `#invert` |

A goal has three methods and compares with `==`, so `baritone.goal() == my_goal` tells whether
Baritone still heads where you sent it. `tostring(goal)` prints it.

| Method | Returns |
|--------|---------|
| `goal:contains(pos)` | `true` when standing at `pos` reaches the goal |
| `goal:heuristic(pos)` | Baritone's cost estimate from `pos` |
| `goal:position()` | The block the goal is centered on, `nil` for `xz`, `y`, `axis`, `any`, … |

## Processes

Starting a process replaces the one running, and `baritone.cancel()` stops any of them.

| Function | Does |
|----------|------|
| `baritone.mine(blocks[, quantity])` | Mines a block id or a list of them until `quantity` drops are in the inventory, like `#mine`. `0` (default) never stops. Ids take state properties: `"minecraft:oak_log[axis=y]"` |
| `baritone.follow(target)` | Follows an [entity](/entity), an entity id, a player name, or every entity a `function(entity)` returns `true` for, like `#follow` |
| `baritone.pickup([items])` | Picks up dropped items, an id or a list of ids, every item by default |
| `baritone.farm([range[, center]])` | Harvests and replants crops within `range` of `center`, like `#farm`. `0` (default) is unlimited, `center` defaults to you |
| `baritone.explore([x, z])` | Explores outward from a column, yours by default |
| `baritone.get_to_block(block)` | Goes to the nearest block with that id, like `#goto <block>` |
| `baritone.build(file[, origin])` | Builds a schematic from the `schematics` folder at `origin`, your feet by default, like `#build`. `false` when the file can't be read |
| `baritone.clear_area(a, b)` | Mines out the box between two corners |
| `baritone.elytra(goal)` | Flies there with an elytra, like `#elytra`. `goal` is a block or `goals.xz`; `false` when elytra flight is unsupported on this system |
| `baritone.active([process])` | `true` while that process runs; without a name, while any of them does |
| `baritone.process()` | What drove Baritone on its last tick, e.g. `"Mining [...]"`, or `nil` when idle |

Process names are `"path"` (`path_to` and `path`), `"mine"`, `"follow"` (`follow` and
`pickup`), `"farm"`, `"explore"`, `"get_to_block"`, `"build"` (`build` and `clear_area`) and
`"elytra"`. `active` sees a process the moment you start it, while `process()` only names it
after Baritone's next tick.

The `follow` filter runs on every nearby entity each tick, so keep it cheap. An error in it
stops following and shows in chat.

## Pausing

| Function | Does |
|----------|------|
| `baritone.pause()` | Pauses Baritone until `baritone.resume()`, like `#pause` |
| `baritone.resume()` | Lifts this script's pause |
| `baritone.paused()` | `true` once the pause took hold. Baritone stops only where it is safe, never mid-jump |

Every script holds its own pause, and Baritone moves again once none is held.
`baritone.cancel()` leaves pauses in place. Reloading a script lifts its pause; still pair
`pause` with `resume` in `disable`.

## Settings

| Function | Does |
|----------|------|
| `baritone.settings.get(name)` | A setting's value |
| `baritone.settings.set(name, value)` | Changes a setting |
| `baritone.settings.reset(name)` | Restores a setting's default |
| `baritone.settings.list()` | Every setting name |
| `baritone.settings.save()` | Writes every changed setting to `baritone/settings.txt` |

Names are the ones `#set` takes, in any case. Booleans, numbers and strings come back as they
are, colors as `0xAARRGGBB`, block and item lists as lists of ids, and anything else as the
text `#set` shows. Whole numbers past 2^53, such as a nether seed, come as strings so they
stay exact. `set` takes the same values, or the text `#set` takes.

Changes last until the game closes unless saved; the next `#set` in chat saves them all too.

## Commands

| Function | Does |
|----------|------|
| `baritone.command(line)` | Runs a Baritone command, with or without the `#` prefix. `false` when there is no such command |

Errors show in chat like typed commands. Litematica (`#litematica`), selections (`#sel`) and
waypoints (`#wp`) go through here.

## Events

`baritone_path` fires at every step of pathing with `type`, one of `"calc_started"`,
`"calc_finished_now_executing"`, `"calc_failed"`, `"next_segment_calc_started"`,
`"next_segment_calc_finished"`, `"continuing_onto_planned_next"`, `"splicing_onto_next_early"`,
`"at_goal"`, `"path_finished_next_still_calculating"`, `"next_calc_failed"`, `"discard_next"`
and `"canceled"`.

```lua
local module = ui.create("pickaxe", "Diamond Run")
local home = baritone.goals.near(vec3(0, 64, 0), 2)

module:event("enable", function()
baritone.mine({ "minecraft:diamond_ore", "minecraft:deepslate_diamond_ore" }, 32)
end)

module:event("tick", function()
if baritone.active() then return end
if home:contains(player:position()) then
    print("Home with diamonds")
    module:set_enabled(false)
else
    baritone.path_to(home)
end
end)

module:event("baritone_path", function(e)
if e.type == "calc_failed" and baritone.active("path") then
    print("No path home")
    module:set_enabled(false)
end
end)

module:event("disable", function()
baritone.cancel()
end)
```

Source: https://aesthetic-docs.pages.dev/baritone/index.md
