Core concepts
World and entities
After this page you can read and name any block the server has sent, get its collision shape, and find the players and mobs around the bot.
Reading blocks
Every session keeps the chunks the server sends in a ghast-world store. Behaviours read it
through ctx.world(), a &dyn WorldView
(docs):
| method | returns |
|---|---|
raw_block(x, y, z) | Option<u32>: the version's raw block state, None when the column is not loaded |
is_column_loaded(cx, cz) | whether the server sent that chunk column and has not unloaded it |
block_query(x, y, z) | dig and place facts (air, hardness, tool group, ray box), None when not loaded |
column(cx, cz) | the whole stored column, for bulk reads without a call per block |
loaded_columns() counts the loaded columns, and build_height() gives (min_y, height) on
26.x, where the height depends on the dimension (the overworld is (-64, 384)). It is None
on 1.8.9 to 1.16.5, which have a fixed 0..256 world.
let p = ctx.pose.pos;
let below = new;
match ctx.world.raw_block
A lookup costs about 4 ns per block for a physics-like 3×4×3 box and 10 to 12 ns at random
positions over 441 columns (x86-64 WSL2 dev machine, release build, as measured in the
ghast-world README).
Loaded is not air
raw_block returns None for a column the bot does not have. Never treat that as air. A bot
that does will walk into a hole that is really a floor, or dig into a wall it thinks is open.
The whole stack keeps the distinction: the ext helpers fail with Error::NotLoaded, and the
path finder treats unknown blocks as impassable and returns a partial path
that ends at the loaded edge.
Only the physics maps unloaded to air, because the vanilla client's empty chunk does, and movement must match it (see Accuracy).
What the store keeps besides block states is set when you build the client. Light and block entities (sign text, chest data, ...) are off by default:
let client = new
.world_config;
Block states and shapes
The raw value depends on the version. On 1.8.9 and 1.12.2 it is id << 4 | meta; on 1.16.5
and 26.x it is the global palette id. Decode it with the matching ghast::data module
(v1_8, v1_12, v1_16_5, v26_1, v26_2, v26_3):
The block_probe example has the full match over every version. If you use the
ext helpers, ghast::ext::Block::new(version, raw).name() does this for you.
On 1.16.5 and 26.x a state has named properties, and it prints in vanilla's string form:
use ;
let stairs = parse.unwrap;
assert_eq!;
for b in stairs.voxel_shape.boxes
println!; // minecraft:oak_stairs[facing=east,half=bottom,...]
Collision shapes come from the same tables: voxel_shape() on 26.x, shape() and
collision() on the older versions. Shapes that depend on neighbours (fences, panes, walls,
stairs, chests), on an entity or on a block entity are never presented as static: on the older
versions Collision::dependency says what else is needed and the boxes are only the isolated
shape. The physics resolves them from neighbouring states; the world itself keeps no
connection state. Every isolated 1.8 shape matches the vanilla oracle bit for bit.
Entities are opt-in
Without a request, the client drops entity packets before decoding them, and
ctx.entities() returns None. Ask for them in interests:
| interest | gives |
|---|---|
Interests::ENTITIES | the tracker: positions, boxes, metadata, equipment, effects |
Interests::ENTITY_TRACKING | the same without the generic metadata store, about 450 bytes less per entity |
Interests::PLAYER_LIST | the tab list on top: player names and UUIDs |
Interests::ENTITY_EVENTS | spawn, removal, hurt, metadata, ... events in ctx.events().entities() |
Without tracking, the crosshair is a pure block pick and nothing pushes the bot. Interests can change mid-session, but a tracker started late is empty until the server sends the entities again.
Finding players and mobs
The store (docs)
has get(id), iter() (which skips the bot), within(pos, r), players() for the tab list
and me() for the bot's own entry. An Entity gives position(), yaw(), pitch(),
head_yaw(), velocity() (the last value the server sent), on_ground(), vehicle(),
passengers(), equipment(slot), effects(), metadata() and the vanilla
bounding_box().
Typed metadata reads are per version, because the indices differ:
ghast::entity::v1_8::health(e), ghast::entity::v26_3::health(e), custom_name, flags,
and on 26.x entity_type(e) gives the registry entry with its name.
Positions are what the vanilla client holds. On 1.8.9 to 1.16.5 that is the server position
with each version's fixed-point rules (1/32 on 1.8, 1/4096 later). On 26.x the tracker runs the
client's interpolation, checked against the real 26.1 client: 0 diffs over 8.66 M compared
fields. The bot's own entry has no position: the client owns it, so read
ctx.pose().
Tracking is cheap: about 25 ns per packet on 1.8 and 40 ns on 26.1 with everything on, and a
26.1 player with its spawn metadata takes 520 bytes (x86-64 WSL, bench in the ghast-entity
README).