Expand description
Physics-exact path planning and following for the ghast Minecraft Java Edition bot library.
Pathfinder: A* over feet blocks. Moves: walk (incl. step-ups onto slabs and partial blocks), diagonal, jump up, drop down (configurable maximum fall), gap jumps (up to 3 blocks, also one up or down; each validated in the physics), swimming, ladder / vine climbing, doors and fence gates (opened with a click), and optionally digging (also straight down) and placing (filling holes, bridging gaps, towering up). Costs are ticks measured withghast-physics(seeCosts). Unknown (unloaded) blocks are never treated as air: they are impassable, and a goal beyond them yields a partial path.Controller: turns a path into per-tick keys and aim. It picks the keys by simulating the vanilla-exact physics one tick ahead, and turns in whole mouse counts exactly like the client does, so a simulated run and a live run make the same decisions.simulate: runs a path with the controller inghast-physics; the validation tests use it to check every move type on random terrain, andPathfinder::plan_verifieduses it to repair a plan before the bot moves.Follower(featureclient, default): aghast_client::Behaviorhelper that plans, follows, replans on deviations, teleports and blocked moves, all throughTickContext.
use ghast_pathfinder::{Config, Goal, Pathfinder, Version};
let mut world = ghast_physics::v1_8::memory_world();
world.load_chunks(-2, -2, 2, 2);
world.fill_raw([-20, 63, -20], [20, 63, 20], 1 << 4); // stone floor
world.fill_raw([3, 64, -5], [3, 64, 5], 1 << 4); // a low wall to jump over
let pf = Pathfinder::new(Config::default());
let path = pf.plan(Version::V1_8, &world, [0, 64, 0], &Goal::Block([8, 64, 0])).unwrap();
assert!(!path.partial);
assert_eq!(path.steps.last().unwrap().pos, [8, 64, 0]);Structs§
- Budget
- How much work one
Search::stepmay do. - Command
- What the controller wants this tick.
- Config
- Planner options. Build with
Config::defaultand thewith_*methods. - Controller
- Follows a
Pathtick by tick. - Controller
Config - Options of the
Controller. Build withControllerConfig::defaultand thewith_*methods. - Costs
- Measured movement facts of one version (ticks and blocks per tick).
- DigCost
- Digging through blocks (off by default): cost per block in ticks
base + ticks_per_hardness * hardness, blocks harder thanmax_hardnessare never dug. - Follow
Config - Options of the
Follower. Build withFollowConfig::defaultand thewith_*methods. - Follower
- Plans and follows a path from a behaviour’s tick: call
Follower::tickonce per tick fromBehavior::tick. It sets the aim, the movement keys and (for digs) the left button through theTickContext, so the client’s rules hold: rotation in whole mouse counts, actions before the tick’s single movement packet, digs / places only with the sent crosshair on the block. - Observation
- What the follower observes of the player (the client’s
Pose, version-free). - Path
- A planned path.
- Pathfinder
- The path planner. Cheap to clone; holds only its configuration.
- Place
- A block to place before (or during) a step: the new block at
pos, clicked on the face ofagainsttowardpos(againstis a neighbour ofpos: the block below it when filling a hole or towering up, the floor block beside it when bridging). - Search
- A resumable path search (
Pathfinder::search). Owns its state (Send, no borrows), so it can live in a behaviour between ticks. - SimReport
- The result of
simulate. - Simulation
- A resumable
simulate:Simulation::stepruns a slice of ticks, so a follower can verify a long path across several game ticks. Owns its state (no borrows). - Step
- One step of a path: the feet block to reach and how.
Enums§
- Follow
Error - Why following failed.
- Follow
Status - What the
Followeris doing. - Goal
- A path goal. Positions are feet blocks (the block the player’s feet are in).
- Move
Kind - How a step is reached from the previous one.
- Node
Kind - How the player is held up in a node.
- Plan
Error - Why planning failed.
- Progress
- Where the controller is.
- SimOutcome
- How a simulated run ended.
- Version
- The protocol version whose blocks and physics a plan uses.
Traits§
- Block
Source - Read access to raw block states, as the version encodes them on the wire: 1.8
id << 4 | meta, 1.16.5 and 26.1 the global palette id.
Functions§
- simulate
- Runs
pathinworldwith aController: the player starts standing at the first step’s centre, facing the second, and the physics isghast-physics(bit-exact vanilla) for the path’s version. Digs complete after5 + 30 × hardnessticks (a bare hand’s order of magnitude) and places after 4 ticks (a stone block appears); the world itself is not changed.