ghast-viewer 0.4.9

Bot screen for ghast bots: a live 3D view of the bot's world in the browser, with recordings and replays
Documentation

ghast-viewer

A bot screen for bots built on ghast: a live 3D view of the bot's world in the browser (first person, third person or a free camera), plus recordings, a dash cam and replays on the same page.

  • Read-only. The viewer wraps your behaviour and reads the bot in after_tick; it never writes to the game connection. The page can only send clock pings, flow-control ACKs and playback controls.
  • Free while nobody watches. No frames are built and no columns copied until a page is open; the server stops itself after an idle timeout.
  • One per bot. Each bot serves its own page on its own port, on 127.0.0.1 by default, optionally protected by a token.
  • No game assets in the crate. Textures and block models are built at run time from the vanilla client jar, downloaded from Mojang's servers into a local .cache/ghast-viewer (feature download, on by default), or read from a local copy (ViewerConfig::client_jar).
  • 1.8.9, 26.1 and 26.2 sessions are drawn (26.1 / 26.2 with the v26_1 / v26_2 features, on by default). The page draws with the 1.8.9 assets: a 26.x world is mapped onto them (blocks and items 1.8 has keep their state, newer ones become a look-alike, see ghast_viewer::v26_1 and v26_2), and the page shows the 256 rows of the dimension around the bot (it moves the window and redraws when the bot leaves it). Entities are listed from the 26.x tracker (mob models where 1.8 has the mob, else a box of the entity's size; dropped items show their stack); other entities' held items and armour, chest lids, particles, weather, experience and other players' block cracks are 1.8-only. Text is never a stand-in: the header names the game ("26.1 (drawn with 1.8.9 assets)") and the real height, the top panel names the held item and the armour, each hotbar slot's tooltip has the real name, count, enchantments, durability and id; stand-in icons carry a "≈" mark, durability bars come from the real damage, and entities or dropped items drawn with a stand-in get a name tag with their real name.

Use

Through the facade crate:

cargo add ghast --features viewer     # ghast::viewer

or on its own: cargo add ghast-viewer.

use ghast::viewer::{Viewer, ViewerConfig};
use ghast::{Account, Client, GameVersion, Idle};

let viewer = Viewer::new(ViewerConfig::new("Bot").port(8090));
let addr = viewer.start().await?;
println!("open http://{addr}/");
let client = Client::new("127.0.0.1:25565".parse()?, GameVersion::V1_8_9, Account::offline("Bot")?)
    .world_config(ghast::viewer::world_config());
let mut behaviour = viewer.watch(Idle);
client.run(&mut behaviour).await?;

The integration guide (INTEGRATION.md) covers ports, tokens, recordings, the dash cam and costs. The wire protocol between server and page is in docs/protocol.md.

Examples

cargo run -p ghast-viewer --release --example afk_viewer -- 127.0.0.1:25565 ViewerBot 8090
cargo run -p ghast-viewer --release --example dashcam_nearby -- 127.0.0.1:25565 ViewerBot 8090 <token> replays
cargo run -p ghast-viewer --example dump_assets -- --download assets-out

Web client

The page (TypeScript, WebGL2) lives in web/; its built files in web/dist/ are committed and embedded in the crate, so cargo build needs no Node. See web/README.md to rebuild or test it.

Licence

MIT OR Apache-2.0.