Reference
The guest SDK, rustmc-guest
rustmc-guest is the Rust crate a WebAssembly plugin builds against. It lives in the
rustmc-plugins repository, at sdk/ (the crate is sdk/Cargo.toml, the calls are
sdk/src/host.rs, sdk/src/net.rs and sdk/src/lib.rs). This page is generated from that
repository at commit 972ad9c by python tools/gen_api_docs.py --sdk=<checkout>; do not edit
it by hand.
Every host call can be made with host::call(name, fields) (or rustmc_guest::call in the JSON
style), which sends {"call": name, ...fields} and answers Ok(value) or Err(message). The
functions below are typed wrappers over that. A wrapper's fields and answer are the call's: see
the linked call for both.
211 SDK functions make a host call. 47 calls have no typed wrapper and are made with host::call.
| Module | Function | Host calls |
|---|---|---|
host | players() -> Vec<PlayerId> | players |
host | player_name(player: PlayerId) -> Option<String> | player_name |
host | player_uuid(player: PlayerId) -> Option<String> | player_uuid |
host | vitals(player: PlayerId) -> Option<Vitals> | vitals |
host | game_mode(player: PlayerId) -> Option<String> | game_mode |
host | world_of(entity: i64) -> Option<String> | world_of |
host | rotation(entity: i64) -> Option<(f32, f32)> | rotation |
host | position(entity: i64) -> Option<[f64; 3]> | position |
host | player_named(name: &str) -> Option<PlayerId> | player_named |
host | can_see(viewer: PlayerId, subject: PlayerId) -> bool | can_see |
host | allows(player: PlayerId, level: i32) -> bool | allows |
host | refresh_commands(player: PlayerId) -> bool | refresh_commands |
host | latency(player: PlayerId) -> Option<u32> | latency |
host | is_bedrock(player: PlayerId) -> bool | is_bedrock |
host | message(player: PlayerId, text: &str) | message |
host | watch_look(player: PlayerId, on: bool) -> bool | watch_look |
host | watch_input(player: PlayerId, on: bool) -> bool | watch_input |
host | kick(player: PlayerId, reason: &str) -> bool | kick |
host | broadcast(text: &str) | broadcast |
host | log(text: &str) | log |
host | message_text(player: PlayerId, component: &Value, overlay: bool) -> Result<bool, String> | message_text |
host | show_title(player: PlayerId, title: &Value, subtitle: Option<&Value>, times: TitleTimes) -> Result<bool, String> | show_title |
host | show_sidebar(player: PlayerId, title: &Value, lines: &[Value]) -> Result<bool, String> | show_sidebar |
host | hide_sidebar(player: PlayerId) -> bool | hide_sidebar |
host | set_list_name(player: PlayerId, name: Option<&Value>) -> Result<bool, String> | set_list_name |
host | set_list_order(player: PlayerId, order: i32) -> bool | set_list_order |
host | set_tab_header(player: PlayerId, header: &Value, footer: &Value) -> Result<bool, String> | set_tab_header |
host | set_list_name_for(viewer: PlayerId, target: PlayerId, name: Option<&Value>) -> Result<bool, String> | set_list_name_for |
host | set_list_name_for_batch(entries: &[(PlayerId, PlayerId, Option<Value>)]) -> Result<u32, String> | set_list_name_for_batch |
host | set_listed_for(viewer: PlayerId, target: PlayerId, listed: bool) -> bool | set_listed_for |
host | set_listed_for_batch(entries: &[(PlayerId, PlayerId, bool)]) -> Result<u32, String> | set_listed_for_batch |
host | set_list_game_mode_shown_for(viewer: PlayerId, target: PlayerId, mode: Option<&str>) -> bool | set_list_game_mode_shown_for |
host | set_list_game_mode_shown_for_batch(entries: &[(PlayerId, PlayerId, Option<&str>)]) -> Result<u32, String> | set_list_game_mode_shown_for_batch |
host | set_list_latency(target: PlayerId, latency: Option<u32>) -> bool | set_list_latency |
host | set_nametag(player: PlayerId, nametag: Option<&Nametag>) -> Result<bool, String> | set_nametag |
host | set_nametag_batch(entries: &[(PlayerId, Option<Nametag>)]) -> Result<u32, String> | set_nametag_batch |
host | nametags_json(entries: &[(PlayerId, &str)]) -> Result<u32, String> | set_nametag_batch |
host | set_nametag_for(viewer: PlayerId, target: PlayerId, nametag: Option<&Nametag>) -> Result<bool, String> | set_nametag_for |
host | set_nametag_for_batch(entries: &[(PlayerId, PlayerId, Option<Nametag>)]) -> Result<u32, String> | set_nametag_for_batch |
host | list_fake_entries(viewer: PlayerId, entries: &[crate::tab::FakeEntry]) -> Result<bool, String> | list_fake_entries |
host | list_fake_entries_json(viewers: &[(PlayerId, &str)]) -> Result<u32, String> | list_fake_entries_batch |
host | set_below_name(viewer: PlayerId, target: PlayerId, score: Option<&Score>) -> Result<bool, String> | set_below_name |
host | set_below_name_batch(entries: &[(PlayerId, PlayerId, Option<Score>)]) -> Result<u32, String> | set_below_name_batch |
host | set_list_score(viewer: PlayerId, target: PlayerId, score: Option<&Score>) -> Result<bool, String> | set_list_score |
host | set_list_score_batch(entries: &[(PlayerId, PlayerId, Option<Score>)]) -> Result<u32, String> | set_list_score_batch |
host | objective_title(slot: &str, title: &Value) -> Result<bool, String> | objective_title |
host | list_score_render(render: crate::tab::ScoreRender) -> bool | list_score_render |
host | show_sidebar_lines(player: PlayerId, title: &Value, lines: &[SidebarLine]) -> Result<bool, String> | show_sidebar_lines |
host | boss_bar_show(player: PlayerId, id: &str, bar: &BossBar) -> Result<bool, String> | boss_bar_show |
host | boss_bar_hide(player: PlayerId, id: &str) -> bool | boss_bar_hide |
host | sql_submit(setting: &str, statements: &[Value]) -> Result<u64, String> | sql_submit |
host | sql_result(batch: u64) -> Option<Result<Vec<u64>, String>> | sql_result |
host | statistic(player: PlayerId, stat: &str, key: &str) -> Result<Option<i32>, String> | statistic |
host | chat_completions(player: PlayerId, action: &str, words: &[String]) -> Result<bool, String> | chat_completions |
host | broadcast_text(component: &Value) -> Result<u32, String> | broadcast_text |
host | inventory_slot(player: PlayerId, slot: i32) -> Option<Value> | inventory_slot |
host | edit_slot(player: PlayerId, slot: i32, stamp: &str, set: &serde_json::Map<String, Value>, remove: &[&str]) -> Result<String, String> | edit_slot |
host | inventory_cursor(player: PlayerId) -> Option<Value> | inventory_cursor |
host | edit_cursor( player: PlayerId, stamp: &str, set: &serde_json::Map<String, Value>, remove: &[&str], count: Option<i32>, ) -> Result<String, String> | edit_cursor |
host | give_item(player: PlayerId, item: &str, count: i32, components: &serde_json::Map<String, Value>) -> Result<i32, String> | give_item |
host | set_item_cooldown(player: PlayerId, group: &str, ticks: i32) -> bool | set_item_cooldown |
host | item_cooldown(player: PlayerId, group: &str) -> i32 | item_cooldown |
host | capture_chat(player: PlayerId, wait_ms: u64, secret: bool) -> Result<Capture, String> | capture_chat |
host | release_chat(player: PlayerId) -> bool | release_chat |
host | take_slot(player: PlayerId, slot: i32, stamp: Option<&str>) -> Result<Taken, String> | take_slot |
host | give_stack(player: PlayerId, stack: &str, count: i32, spill: bool) -> Result<i32, String> | give_stack |
host | save_player(player: PlayerId) -> bool | save_player |
host | take_item(player: PlayerId, item: &str, count: i32, components: &serde_json::Map<String, Value>) -> Result<i32, String> | take_item |
host | item_count(player: PlayerId, item: &str) -> Result<Option<i32>, String> | item_count |
host | item_count_tagged(player: PlayerId, item: Option<&str>, custom_data: &Value) -> Result<Option<i32>, String> | item_count |
host | item_sum_tagged(player: PlayerId, item: Option<&str>, custom_data: &Value, sum_key: &str) -> Result<Option<i64>, String> | item_sum_where |
host | take_item_tagged(player: PlayerId, item: Option<&str>, count: i32, custom_data: &Value) -> Result<i32, String> | take_item |
host | experience_points(player: PlayerId) -> Option<i32> | experience_points |
host | give_experience(player: PlayerId, points: i32) -> Result<bool, String> | give_experience |
host | play_sound(player: PlayerId, sound: &str, volume: f32, pitch: f32) -> bool | play_sound |
host | set_food(player: PlayerId, food: i32, saturation: f32) -> Result<bool, String> | set_food |
host | set_health(player: PlayerId, health: f32) -> Result<bool, String> | set_health |
host | heal(player: PlayerId, amount: f32) -> Result<Option<f32>, String> | heal |
host | selected_slot(player: PlayerId) -> Option<i32> | selected_slot |
host | set_respawn(player: PlayerId, world: &str, at: [i32; 3], yaw: f32) -> Result<bool, String> | set_respawn |
host | clear_respawn(player: PlayerId) -> bool | clear_respawn |
host | drop_item( world: &str, to: [f64; 3], item: &str, count: i32, components: &serde_json::Map<String, Value>, velocity: Option<[f64; 3]>, ) -> Result<Option<i64>, String> | drop_item |
host | damage_saying(entity: i64, amount: f32, cause: &str, died: &str) | damage_saying |
host | damage_by(entity: i64, amount: f32, cause: &str, attacker: Option<i64>, skip_cooldown: bool) -> Result<bool, String> | damage_by |
host | add_effect(entity: i64, effect: &str, ticks: i32, amplifier: i32) -> bool | add_effect |
host | add_effect_shown(entity: i64, effect: &str, ticks: i32, amplifier: i32, shown: EffectShown) -> bool | add_effect_shown |
host | remove_effect(entity: i64, effect: &str) -> bool | remove_effect |
host | set_attribute_modifier(entity: i64, attribute: &str, id: &str, amount: f64, operation: Operation) -> Result<bool, String> | set_attribute_modifier |
host | remove_attribute_modifier(entity: i64, attribute: &str, id: &str) -> bool | remove_attribute_modifier |
host | player_motion(player: PlayerId) -> Option<Motion> | player_motion |
host | nudge_view(player: PlayerId, dyaw: f32, dpitch: f32) -> bool | nudge_view |
host | is_sneaking(entity: i64) -> bool | is_sneaking |
host | world_spawn(world: &str) -> Option<[f64; 3]> | world_spawn |
host | teleport(player: PlayerId, to: [f64; 3]) -> bool | teleport |
host | particle(world: &str, particle: &str, to: [f64; 3], count: i32, spread: [f64; 3], speed: f32) -> bool | particle |
host | sound_at(world: &str, to: [f64; 3], sound: &str, category: &str, volume: f32, pitch: f32) -> bool | sound_at |
host | tick() -> u64 | tick |
host | now() -> u64 | now |
host | secure_random(length: usize) -> Result<Vec<u8>, String> | secure_random |
host | rsa_generate() -> Result<RsaKeyPair, String> | rsa_generate |
host | rsa_decrypt(private_key: &[u8], block: &[u8]) -> Result<Option<Vec<u8>>, String> | rsa_decrypt |
host | request_restart(reason: &str) -> Result<bool, String> | request_restart |
host | schedule_world_reset(seed: Option<i64>, reason: &str) -> Result<(), String> | schedule_world_reset |
host | cancel_world_reset() -> Result<bool, String> | cancel_world_reset |
host | server_health() -> Value | server_health |
host | profiler(op: &str, interval_ms: u32) -> Result<Value, String> | profiler |
host | block_at(world: &str, at: [i32; 3]) -> Option<String> | block_at |
host | block_state_at(world: &str, at: [i32; 3]) -> Option<String> | block_state_at |
host | set_block(world: &str, at: [i32; 3], block: &str) -> bool | set_block |
host | set_blocks(world: &str, blocks: &[([i32; 3], &str)]) -> Result<u32, String> | set_blocks |
host | read_blocks(world: &str, min: [i32; 3], max: [i32; 3]) -> Result<BlockBox, String> | read_blocks |
host | write_blocks(world: &str, min: [i32; 3], max: [i32; 3], palette: &[String], cells: &[u16]) -> Result<BlocksWritten, String> | write_blocks |
host | check_blocks(palette: &[String]) -> Result<(), String> | check_blocks |
host | set_block_data(world: &str, at: [i32; 3], snbt: &str) -> Result<bool, String> | set_block_data |
host | set_blocks_data(world: &str, entries: &[([i32; 3], &str)]) -> Result<u32, String> | set_blocks_data |
host | block_data(world: &str, at: [i32; 3]) -> Option<String> | block_data |
host | blocks_are(world: &str, positions: &[[i32; 3]], fact: &str) -> Result<Vec<Option<bool>>, String> | blocks_are |
host | players_in(world: &str, min: [f64; 3], max: [f64; 3]) -> Vec<(PlayerId, [f64; 3])> | players_in |
host | entities_in(world: &str, centre: [f64; 3], radius: f64, kinds: &[&str]) -> Result<Vec<EntityNear>, String> | entities_in |
host | container_add(world: &str, at: [i32; 3], item: &str, count: i32) -> i32 | container_add |
host | container_remove(world: &str, at: [i32; 3], item: &str, count: i32) -> i32 | container_remove |
host | block_is(world: &str, at: [i32; 3], fact: &str) -> Option<bool> | block_is |
host | biome_at(world: &str, at: [i32; 3]) -> Option<String> | biome_at |
host | world_ceiling(world: &str) -> Option<i32> | world_ceiling |
host | world_floor(world: &str) -> Option<i32> | world_floor |
host | reserve_blocks(world: &str, states: &[&str], break_ticks: Option<u32>, drops: &[BlockDrop]) -> Result<u32, String> | reserve_blocks |
host | guard_zones(world: &str, put: &[GuardZone], remove: &[u64]) -> Result<u32, String> | guard_zones |
host | guard_hold(held: bool) -> Result<(), String> | guard_hold |
host | release_blocks(world: &str, states: &[&str]) -> Result<u32, String> | release_blocks |
host | raycast(from: RayFrom<'_>, max_distance: f64, filter: &RayFilter) -> Result<Option<RayHit>, String> | raycast |
host | spawn_entity(world: &str, kind: &str, to: [f64; 3], yaw: f32, pitch: f32, nbt: &str) -> Result<Option<i64>, String> | spawn_entity |
host | spawn_entity_for(world: &str, kind: &str, to: [f64; 3], yaw: f32, pitch: f32, nbt: &str, viewers: &[PlayerId]) -> Result<Option<i64>, String> | spawn_entity_for |
host | set_entity_viewers(entity: i64, viewers: &[PlayerId]) -> Result<bool, String> | set_entity_viewers |
host | entity_viewers(entity: i64) -> Option<Vec<PlayerId>> | entity_viewers |
host | set_display(entity: i64, nbt: &str) -> Result<bool, String> | set_display |
host | move_entity(entity: i64, to: [f64; 3], yaw: f32, pitch: f32) -> bool | move_entity |
host | move_entities(moves: &[(i64, [f64; 3], f32)]) -> usize | move_entities |
host | attach_entity(entity: i64, leader: Option<i64>, offset: [f64; 3]) -> bool | attach_entity |
host | remove_entity(entity: i64) -> bool | remove_entity |
host | mount(rider: i64, vehicle: i64) -> bool | mount |
host | dismount(rider: i64) -> bool | dismount |
host | vehicle_of(entity: i64) -> Option<i64> | vehicle_of |
host | passengers(entity: i64) -> Option<Vec<i64>> | passengers |
host | set_passengers(vehicle: i64, riders: &[i64]) -> Result<bool, String> | set_passengers |
host | entity_velocity(entity: i64) -> Option<[f64; 3]> | entity_velocity |
host | set_entity_velocity(entity: i64, velocity: [f64; 3]) -> bool | set_entity_velocity |
host | spawn_creature(world: &str, kind: &str, at: [f64; 3], options: &CreatureOptions) -> Result<Option<i64>, String> | spawn_creature |
host | set_creature_ai(entity: i64, ai: Ai) -> Result<bool, String> | set_creature_ai |
host | creature_order(entity: i64, order: &Order) -> Result<bool, String> | creature_order |
host | creature_state(entity: i64) -> Option<CreatureState> | creature_state |
host | set_creature_drops(entity: i64, drops: Option<(&[BlockDrop], Option<i32>)>) -> Result<bool, String> | set_creature_drops |
host | can_spawn_at(world: &str, kind: &str, at: [i32; 3]) -> Result<bool, String> | can_spawn_at |
host | worlds() -> Vec<String> | worlds |
host | chunk_on_disk(world: &str, chunk_x: i32, chunk_z: i32) -> Option<bool> | chunk_on_disk |
host | world_sidecar(world: &str, name: &str) -> Option<String> | world_sidecar |
host | render_web_map(world: &str) -> Result<bool, String> | render_web_map |
host | web_map_marker(world: &str, id: &str, label: &str, x: i32, z: i32, kind: MarkerKind) -> Result<bool, String> | web_map_marker |
host | web_map_remove_marker(world: &str, id: &str) -> Result<bool, String> | web_map_remove_marker |
host | world_border(world: &str) -> Option<(f64, f64, f64)> | world_border |
host | set_world_border(world: &str, centre_x: f64, centre_z: f64, size: f64) -> bool | set_world_border |
host | queue_chunks(world: &str, chunks: &[(i32, i32)]) -> Option<u32> | queue_chunks |
host | chunks_generated(world: &str) -> Generated | chunks_generated |
host | unqueue_chunks(world: &str) -> u32 | unqueue_chunks |
host | tick_health() -> Option<TickHealth> | tick_health |
host | store(key: &str, value: &str) | store |
host | load(key: &str) -> Option<String> | load |
host | disabled_systems() -> Vec<String> | disabled_systems |
host | settings() -> Value | settings |
host | setting_set(key: &str, value: &Value) -> Result<Value, String> | setting_set |
host | storage_get(table: &str, key: &str) -> Result<Option<Value>, String> | storage_get |
host | storage_put(table: &str, key: &str, value: &Value) -> Result<(), String> | storage_put |
host | storage_outcome(ticket: u64) -> StorageOutcome | storage_outcome |
host | storage_land() -> Result<(), String> | storage_land |
host | storage_scan_raw(table: &str, prefix: &str, after: Option<&str>, limit: u32) -> Result<Vec<u8>, String> | storage_scan |
host | storage_delete(table: &str, key: &str) -> Result<bool, String> | storage_delete |
host | storage_scan(table: &str, prefix: &str, after: Option<&str>, limit: u32) -> Result<Vec<(String, Value)>, String> | storage_scan |
host | storage_count(table: &str, prefix: &str) -> Result<u64, String> | storage_count |
host | storage_migrate(from: &str, to: &str) -> Result<(), String> | storage_migrate |
host | storage_migration() -> Result<Option<Migration>, String> | storage_migration |
host | storage_drop(table: &str) -> Result<bool, String> | storage_drop |
host | storage_backend() -> Result<String, String> | storage_backend |
host | menu_open(player: PlayerId, rows: u8, title: &str, items: &[Value]) -> Result<i32, String> | menu_open |
host | menu_set(player: PlayerId, menu: i32, items: &[Value]) -> Result<bool, String> | menu_set |
host | menu_close(player: PlayerId, menu: i32) -> Result<bool, String> | menu_close |
host | push_pack(player: PlayerId, id: u128, url: &str, hash: &str, required: bool) -> bool | push_pack |
host | pop_pack(player: PlayerId, id: Option<u128>) -> bool | pop_pack |
host | host_pack(name: &str, source: PackSource<'_>) -> Result<HostedPack, String> | host_pack |
host | plugin_call(target: &str, request: Value) -> Result<Value, String> | plugin_call |
host | http_send(grant: &str, method: &str, path: &str, headers: &[(&str, &str)], body: &str) -> Result<u64, String> | http_send |
host | http_result(fetch: u64, offset: usize, length: usize) -> Option<Result<HttpPiece, String>> | http_result |
host | plugin_state(name: &str) -> Option<String> | plugin_state |
host | schematic_list() -> Result<SchematicList, String> | schematic_list |
host | schematic_load(name: &str, keep_unsafe: bool) -> Result<u64, String> | schematic_load |
host | schematic_result(ticket: u64) -> Option<Result<SchematicInfo, String>> | schematic_result |
host | schematic_names(ticket: u64, start: usize, count: usize) -> Result<Vec<Option<String>>, String> | schematic_names |
host | schematic_cells(ticket: u64, start: usize, count: usize) -> Result<Vec<u16>, String> | schematic_cells |
host | schematic_entities(ticket: u64, start: usize, count: usize) -> Result<Vec<([i32; 3], String)>, String> | schematic_entities |
host | schematic_save(name: &str, size: [i32; 3], offset: [i32; 3], overwrite: bool) -> Result<u64, String> | schematic_save |
host | schematic_put(ticket: u64, names: &[&str], cells: &[u16], entities: &[([i32; 3], String)]) -> Result<(), String> | schematic_put |
host | schematic_finish(ticket: u64) -> Result<(), String> | schematic_finish |
host | schematic_close(ticket: u64) | schematic_close |
host | plugin_emit(topic: &str, data: Value) -> u32 | plugin_emit |
(root) | packet_fields(packet: &str, body: &str) -> Result<Value, String> | packet_decode |
(root) | packet_body(packet: &str, fields: &Value) -> Result<String, String> | packet_encode |
(root) | send_packet_hex(player: i64, packet: &str, body: &str) -> Result<bool, String> | send_packet |
net | listen(grant: &str) -> Result<Listening, String> | net_listen |
net | unlisten(grant: &str) -> bool | net_unlisten |
net | poll(max_bytes: usize) -> Vec<Event> | net_poll |
net | send(connection: u64, bytes: &[u8]) -> Result<bool, String> | net_send |
net | respond( connection: u64, status: u16, headers: &[(&str, &str)], body: &[u8], more: bool, ) -> Result<bool, String> | net_respond |
net | close(connection: u64) -> bool | net_close |
Calls with no typed wrapper
air, attribute, ban, banned, block_property, client_brand, damage, destroy_block, enchantment_level, entity_unit, exhaust_for, fire_ticks, fluid_at, game_rule_flag, game_rule_number, give, has_effect, held_item, hidden, http_fetch, inspect_close, inspect_open, is_in_rain, is_on_ground, item_count_where, local_difficulty, may_interact, packet_schemas, pardon, send_payload, set_air, set_fire_ticks, set_game_mode, set_hidden, set_hidden_account, set_slot, set_ticks_frozen, set_time_of_day, storage_put_many, swing_arm, take_held, take_item_where, ticks_frozen, time_of_day, world_border_damage, world_id, worn
From docs/api/reference/guest-sdk.md in the RustMC repository at bbd81209ad.