Skip to main content

Crate ghast_viewer

Crate ghast_viewer 

Source
Expand description

A bot screen for bots built on ghast: a live 3D view of the bot’s world in the browser, plus recordings and replays.

  • Viewer: one per bot. Viewer::watch wraps the bot’s behaviour so each client tick feeds the viewer (read-only: it never writes to the connection), Viewer::start serves the page over HTTP + WebSocket (127.0.0.1 by default).
  • Zero cost while nobody watches: no frames are built and no columns copied; the server stops itself after ViewerConfig::idle without a page.
  • Textures and models are taken at run time from the vanilla client jar (downloaded from Mojang’s servers into a local cache, or ViewerConfig::client_jar); nothing of the game is shipped with this crate.
  • FeedRecorder writes what a page would receive to disk; DashCam keeps the last minutes in memory and saves them on DashCam::clip; recordings play back on the same page (/?replay=<name>).
use ghast_client::{Account, Client, GameVersion, Idle};
use ghast_viewer::{Viewer, ViewerConfig};

let viewer = Viewer::new(ViewerConfig::new("Steve").port(8080));
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("Steve")?)
    .world_config(ghast_viewer::world_config());
let mut behaviour = viewer.watch(Idle);
client.run(&mut behaviour).await?;

Wire protocol: docs/protocol.md. 1.8.9, 26.1, 26.2 and 26.3 (features v26_1, v26_2, v26_3, mapped onto the 1.8.9 assets, see v26_1) sessions are drawn.

Re-exports§

pub use dashcam::DashCam;
pub use dashcam::DashCamOptions;
pub use feed::BotView;
pub use feed::now_ms;
pub use record::FeedRecorder;
pub use record::ReplayMeta;
pub use record::list_recordings;
pub use record::prune_recordings;

Modules§

assets
The page’s files: the web bundle (embedded at build time from web/dist), the block data and the texture pack (built at run time from the vanilla client jar and cached on disk), all served under content-hashed names (v2/app.<hash>.js, …) so pages cache them for good.
blocks18
1.8 block facts the asset builder needs: blocks whose variant lives in the metadata (the page’s mesher picks "v=<n>,<key>" entries for them), and the blockstates file of a block name when it differs.
dashcam
Dash cam: the last minutes are always in memory, and DashCam::clip (the app decides when, e.g. a player came near) puts them on disk as a recording with a little more after it.
entities
What the page needs to know about an entity: its 1.8 name, kind, size, the stack it shows, its model variant, looks (baby, armour, armour stand pose) and state flags.
feed
The world feed: turns what the bot knows (pose, world, entities, inventory, a few raw packets) into protocol frames, once per client tick, shared by every page and recording.
hub
The hub: one feed per bot and the streams (pages, recordings) that read it.
protocol
The bot screen wire protocol (see docs/protocol.md).
record
Recordings: what a page would have received, written to disk while the bot plays, and played back later on the same page (crate::replay).
replay
Playing a recording to one page.
skins
Player skins and capes.
stream
One page connection (or a recording) as the feed sees it.
tiles
Block entities the page draws: sign text, skulls, banners and flower pots, converted from the block entities ghast keeps per column (WorldConfig::with_block_entities(true)).
v26_1
26.1 sessions on the page: 26.1 blocks, items and entity types mapped onto the 1.8 assets the page draws with (the shared modern mapping, see the module items). Exact where 1.8 has the block or item (pre-flattening id:meta from minecraft-data’s legacy table, matched property by property); blocks and items added later become a look-alike (new woods → old woods, deepslate → stone, copper → orange terracotta, concrete → stained clay, any stair / slab / fence / door … → a 1.8 one of the same shape); anything else degrades to stone (a full cube), a stone slab (a low shape), water / lava (a fluid) or air (no collision).
v26_2
26.2 sessions on the page: 26.2 blocks, items and entity types mapped onto the 1.8 assets the page draws with (the shared modern mapping, see the module items). Exact where 1.8 has the block or item (pre-flattening id:meta from minecraft-data’s legacy table, matched property by property); blocks and items added later become a look-alike (new woods → old woods, deepslate → stone, copper → orange terracotta, concrete → stained clay, any stair / slab / fence / door … → a 1.8 one of the same shape); anything else degrades to stone (a full cube), a stone slab (a low shape), water / lava (a fluid) or air (no collision).
v26_3
26.3 sessions on the page: 26.3 blocks, items and entity types mapped onto the 1.8 assets the page draws with (the shared modern mapping, see the module items). Exact where 1.8 has the block or item (pre-flattening id:meta from minecraft-data’s legacy table, matched property by property); blocks and items added later become a look-alike (new woods → old woods, deepslate → stone, copper → orange terracotta, concrete → stained clay, any stair / slab / fence / door … → a 1.8 one of the same shape); anything else degrades to stone (a full cube), a stone slab (a low shape), water / lava (a fluid) or air (no collision).

Structs§

Viewer
The bot screen of one bot. Cheap to clone (a handle).
ViewerConfig
Viewer options.
ViewerStatus
Viewer state.
Watched
A behaviour that also feeds a Viewer. It only reads the tick context: it never writes to the connection and does not change the bot’s timing. While nobody watches it adds a handful of rare packets to the filter (weather, experience, block entities) and does nothing else.

Enums§

EntityTracking
When the viewer has ghast track entities (Interests::ENTITIES, PLAYER_LIST, PLAYER_SKINS).

Functions§

world_config
The world settings a watched client should use (light for shading, biomes for grass and leaf colours, block entities for sign text, skulls, banners and flower pots): Client::new(..).world_config(ghast_viewer::world_config()).