pub trait Server {
Show 108 methods
// Required methods
fn broadcast(&self, message: &str);
fn get_block(&self, dimension: &str, pos: BlockPos) -> Option<String>;
fn set_block(&self, dimension: &str, pos: BlockPos, block_id: &str) -> bool;
fn give_item(&self, player: &str, item_id: &str, count: u32) -> bool;
fn teleport(&self, player: &str, x: f64, y: f64, z: f64) -> bool;
fn send_to_player(
&self,
player: &str,
channel: &str,
payload: &[u8],
) -> bool;
fn send_to_server(&self, channel: &str, payload: &[u8]) -> bool;
fn entity_teleport(&self, uuid: &str, x: f64, y: f64, z: f64) -> bool;
fn entity_position(&self, uuid: &str) -> Option<(f64, f64, f64)>;
fn entity_health(&self, uuid: &str) -> Option<f32>;
fn entity_set_health(&self, uuid: &str, health: f32) -> bool;
fn entity_kill(&self, uuid: &str) -> bool;
fn spawn_entity(
&self,
entity_type: &str,
dimension: &str,
x: f64,
y: f64,
z: f64,
) -> Option<String>;
fn entity_add_effect(
&self,
uuid: &str,
effect_id: &str,
duration_ticks: i32,
amplifier: u8,
show_particles: bool,
) -> bool;
fn entity_remove_effect(&self, uuid: &str, effect_id: &str) -> bool;
fn entity_clear_effects(&self, uuid: &str) -> bool;
fn drop_loot(
&self,
table_id: &str,
dimension: &str,
x: f64,
y: f64,
z: f64,
) -> bool;
fn has_item_tag(&self, item_id: &str, tag_id: &str) -> bool;
fn has_block_tag(&self, block_id: &str, tag_id: &str) -> bool;
fn world_time(&self, dimension: &str) -> Option<i64>;
fn world_set_time(&self, dimension: &str, time: i64) -> bool;
fn world_is_raining(&self, dimension: &str) -> bool;
fn world_set_weather(
&self,
dimension: &str,
raining: bool,
duration_ticks: i32,
) -> bool;
fn entity_velocity(&self, uuid: &str) -> Option<(f64, f64, f64)>;
fn entity_set_velocity(&self, uuid: &str, vx: f64, vy: f64, vz: f64) -> bool;
fn entity_add_velocity(&self, uuid: &str, vx: f64, vy: f64, vz: f64) -> bool;
fn scoreboard_get(&self, objective: &str, player: &str) -> Option<i32>;
fn scoreboard_set(&self, objective: &str, player: &str, score: i32) -> bool;
fn scoreboard_add(
&self,
objective: &str,
player: &str,
delta: i32,
) -> Option<i32>;
fn play_sound(
&self,
dimension: &str,
x: f64,
y: f64,
z: f64,
sound_id: &str,
volume: f32,
pitch: f32,
) -> bool;
fn play_sound_to_player(
&self,
player: &str,
sound_id: &str,
volume: f32,
pitch: f32,
) -> bool;
fn send_title(
&self,
player: &str,
title: &str,
subtitle: &str,
fadein: i32,
stay: i32,
fadeout: i32,
) -> bool;
fn send_actionbar(&self, player: &str, message: &str) -> bool;
fn entity_rotation(&self, uuid: &str) -> Option<(f32, f32)>;
fn kick_player(&self, player: &str, reason: &str) -> bool;
fn set_gamemode(&self, player: &str, gamemode: &str) -> bool;
fn bossbar_create(
&self,
id: &str,
title: &str,
color: &str,
style: &str,
) -> bool;
fn bossbar_remove(&self, id: &str) -> bool;
fn bossbar_set_title(&self, id: &str, title: &str) -> bool;
fn bossbar_set_progress(&self, id: &str, progress: f32) -> bool;
fn bossbar_set_color(&self, id: &str, color: &str) -> bool;
fn bossbar_add_player(&self, id: &str, player: &str) -> bool;
fn bossbar_remove_player(&self, id: &str, player: &str) -> bool;
fn bossbar_set_visible(&self, id: &str, visible: bool) -> bool;
fn game_dir(&self) -> String;
fn online_players(&self) -> Vec<String>;
fn get_block_nbt(&self, dimension: &str, pos: BlockPos) -> Option<String>;
fn set_block_nbt(&self, dimension: &str, pos: BlockPos, snbt: &str) -> bool;
fn get_inventory_slot(
&self,
dimension: &str,
pos: BlockPos,
slot: u32,
) -> Option<(String, u32, String)>;
fn set_inventory_slot(
&self,
dimension: &str,
pos: BlockPos,
slot: u32,
item_id: &str,
count: u32,
snbt: &str,
) -> bool;
fn player_inventory(&self, player: &str) -> Vec<(u32, String, u32)>;
fn player_set_slot(
&self,
player: &str,
slot: u32,
item_id: &str,
count: u32,
) -> bool;
fn teleport_to_dim(
&self,
player: &str,
dimension: &str,
x: f64,
y: f64,
z: f64,
) -> bool;
fn entity_teleport_to_dim(
&self,
uuid: &str,
dimension: &str,
x: f64,
y: f64,
z: f64,
) -> bool;
fn world_entity_count(&self, dimension: &str, entity_type: &str) -> i32;
fn entity_get_nbt(&self, uuid: &str) -> Option<String>;
fn entity_set_nbt(&self, uuid: &str, snbt: &str) -> bool;
fn spawn_particles(
&self,
dimension: &str,
x: f64,
y: f64,
z: f64,
particle_type: &str,
count: i32,
dx: f64,
dy: f64,
dz: f64,
speed: f64,
) -> bool;
fn entity_attribute_get(
&self,
uuid: &str,
attribute_id: &str,
) -> Option<f64>;
fn entity_attribute_set(
&self,
uuid: &str,
attribute_id: &str,
value: f64,
) -> bool;
fn get_held_item_nbt(&self, player: &str) -> Option<String>;
fn set_held_item_nbt(&self, player: &str, snbt: &str) -> bool;
fn get_offhand_item_nbt(&self, player: &str) -> Option<String>;
fn set_offhand_item_nbt(&self, player: &str, snbt: &str) -> bool;
fn get_slot_item(
&self,
player: &str,
slot: u32,
) -> Option<(String, u32, String)>;
fn set_slot_item(
&self,
player: &str,
slot: u32,
item_id: &str,
count: u32,
snbt: &str,
) -> bool;
fn entity_info(&self, uuid: &str) -> Option<EntityInfo>;
fn entities_in_box(
&self,
dimension: &str,
min: (f64, f64, f64),
max: (f64, f64, f64),
) -> Vec<String>;
fn raycast_block(
&self,
dimension: &str,
from: (f64, f64, f64),
to: (f64, f64, f64),
) -> Option<BlockHit>;
fn raycast_entity(
&self,
dimension: &str,
from: (f64, f64, f64),
to: (f64, f64, f64),
exclude: &str,
) -> Option<String>;
fn block_info(&self, dimension: &str, pos: BlockPos) -> Option<BlockInfo>;
fn break_block(
&self,
dimension: &str,
pos: BlockPos,
drop: bool,
breaker: &str,
) -> bool;
fn place_block_from_slot(
&self,
player: &str,
slot: u32,
dimension: &str,
pos: BlockPos,
) -> bool;
fn bonemeal(&self, dimension: &str, pos: BlockPos) -> bool;
fn explode(
&self,
dimension: &str,
x: f64,
y: f64,
z: f64,
power: f32,
fire: bool,
source: &str,
) -> bool;
fn tellraw(&self, player: &str, json: &str) -> bool;
fn entity_damage(
&self,
uuid: &str,
amount: f32,
damage_type: &str,
attacker: &str,
) -> bool;
fn entity_set_fire_ticks(&self, uuid: &str, ticks: i32) -> bool;
fn player_add_xp(&self, player: &str, amount: i32) -> bool;
fn player_set_may_fly(&self, player: &str, may_fly: bool) -> bool;
fn player_info(&self, player: &str) -> Option<PlayerInfo>;
fn spawn_item(
&self,
dimension: &str,
pos: (f64, f64, f64),
vel: (f64, f64, f64),
item_id: &str,
count: u32,
snbt: &str,
) -> Option<String>;
fn item_entity_stack(&self, uuid: &str) -> Option<(String, u32, String)>;
fn item_entity_set_stack(
&self,
uuid: &str,
item_id: &str,
count: u32,
snbt: &str,
) -> bool;
fn actionbar_json(&self, player: &str, json: &str) -> bool;
fn use_item_on_block(
&self,
dimension: &str,
pos: BlockPos,
face: Face,
item_id: &str,
player: &str,
) -> bool;
fn pour_fluid(
&self,
dimension: &str,
pos: BlockPos,
bucket_item_id: &str,
) -> bool;
fn has_entity_tag(&self, entity_type: &str, tag_id: &str) -> bool;
fn item_block(&self, item_id: &str) -> Option<String>;
fn place_feature(
&self,
dimension: &str,
pos: BlockPos,
feature_id: &str,
) -> bool;
fn set_item_cooldown(&self, player: &str, item_id: &str, ticks: u32) -> bool;
fn entity_vehicle(&self, uuid: &str) -> Option<String>;
fn entity_passengers(&self, uuid: &str) -> Vec<String>;
fn entity_mount(&self, rider: &str, vehicle: &str, force: bool) -> bool;
fn entity_dismount(&self, uuid: &str) -> bool;
fn entity_set_dimensions(
&self,
uuid: &str,
size: Option<(f32, f32, f32)>,
) -> bool;
fn entity_set_fall_distance(&self, uuid: &str, distance: f32) -> bool;
fn redstone_signal(&self, dimension: &str, pos: BlockPos) -> Option<u8>;
fn redstone_power(&self, dimension: &str, pos: BlockPos) -> Option<u8>;
fn set_redstone_output(
&self,
dimension: &str,
pos: BlockPos,
level: u8,
) -> bool;
fn get_block_state(&self, dimension: &str, pos: BlockPos) -> Option<String>;
fn set_block_state(
&self,
dimension: &str,
pos: BlockPos,
state: &str,
) -> bool;
fn world_is_thundering(&self, dimension: &str) -> bool;
fn world_set_thunder(
&self,
dimension: &str,
thundering: bool,
duration_ticks: i32,
) -> bool;
fn fill_region(
&self,
dimension: &str,
from: BlockPos,
to: BlockPos,
state: &str,
) -> Option<u32>;
fn scan_region(
&self,
dimension: &str,
from: BlockPos,
to: BlockPos,
) -> Vec<(BlockPos, String)>;
// Provided methods
fn block_property(
&self,
dimension: &str,
pos: BlockPos,
name: &str,
) -> Option<String> { ... }
fn set_block_properties(
&self,
dimension: &str,
pos: BlockPos,
properties: &str,
) -> bool { ... }
}Expand description
Low-level capabilities the Yog runtime exposes to mods (the engine contract).
The runtime provides the concrete implementation, backed by JNI calls into
the Java host; this crate stays JVM-free. Higher-level, ergonomic wrappers
live in the domain crates (e.g. yog-world’s World).
Dimensions are identified by their registry id string, e.g.
"minecraft:overworld".
Required Methods§
Sourcefn get_block(&self, dimension: &str, pos: BlockPos) -> Option<String>
fn get_block(&self, dimension: &str, pos: BlockPos) -> Option<String>
Registry id of the block at pos in dimension
(e.g. "minecraft:stone"), or None if the dimension/position is
unavailable. Call from the server thread (e.g. an event handler).
Sourcefn set_block(&self, dimension: &str, pos: BlockPos, block_id: &str) -> bool
fn set_block(&self, dimension: &str, pos: BlockPos, block_id: &str) -> bool
Set the block at pos in dimension to block_id — a registry id
or, like /setblock, a state ("minecraft:water_cauldron[level=3]").
Returns whether the change was applied. Call from the server thread.
Sourcefn give_item(&self, player: &str, item_id: &str, count: u32) -> bool
fn give_item(&self, player: &str, item_id: &str, count: u32) -> bool
Give count of item_id to the named player. Returns whether it worked
(player online, item valid). Call from the server thread.
Sourcefn teleport(&self, player: &str, x: f64, y: f64, z: f64) -> bool
fn teleport(&self, player: &str, x: f64, y: f64, z: f64) -> bool
Teleport the named player to (x, y, z) in their current world. Returns
whether it worked. Call from the server thread.
Sourcefn send_to_player(&self, player: &str, channel: &str, payload: &[u8]) -> bool
fn send_to_player(&self, player: &str, channel: &str, payload: &[u8]) -> bool
Send a raw-byte packet to the named player on channel (server → client).
Returns whether the player was online. Payload is opaque bytes — no NBT.
Sourcefn send_to_server(&self, channel: &str, payload: &[u8]) -> bool
fn send_to_server(&self, channel: &str, payload: &[u8]) -> bool
Send a raw-byte packet to the server on channel (client → server).
Only works in a client context; returns whether it was sent.
Sourcefn entity_teleport(&self, uuid: &str, x: f64, y: f64, z: f64) -> bool
fn entity_teleport(&self, uuid: &str, x: f64, y: f64, z: f64) -> bool
Teleport any entity (by UUID) within its current world.
Sourcefn entity_position(&self, uuid: &str) -> Option<(f64, f64, f64)>
fn entity_position(&self, uuid: &str) -> Option<(f64, f64, f64)>
Position of an entity, or None if not loaded.
Sourcefn entity_health(&self, uuid: &str) -> Option<f32>
fn entity_health(&self, uuid: &str) -> Option<f32>
Health of a living entity, or None.
Sourcefn entity_set_health(&self, uuid: &str, health: f32) -> bool
fn entity_set_health(&self, uuid: &str, health: f32) -> bool
Set a living entity’s health; returns whether it applied.
Sourcefn entity_kill(&self, uuid: &str) -> bool
fn entity_kill(&self, uuid: &str) -> bool
Remove/kill an entity.
Sourcefn spawn_entity(
&self,
entity_type: &str,
dimension: &str,
x: f64,
y: f64,
z: f64,
) -> Option<String>
fn spawn_entity( &self, entity_type: &str, dimension: &str, x: f64, y: f64, z: f64, ) -> Option<String>
Spawn an entity of entity_type (e.g. minecraft:pig) at a position;
returns its UUID, or None on failure.
Sourcefn entity_add_effect(
&self,
uuid: &str,
effect_id: &str,
duration_ticks: i32,
amplifier: u8,
show_particles: bool,
) -> bool
fn entity_add_effect( &self, uuid: &str, effect_id: &str, duration_ticks: i32, amplifier: u8, show_particles: bool, ) -> bool
Apply a status effect to a living entity. effect_id is a registry id
such as "minecraft:speed" or "minecraft:regeneration". amplifier is
0-based (0 = level I). Returns false if the entity or effect is unknown.
Sourcefn entity_remove_effect(&self, uuid: &str, effect_id: &str) -> bool
fn entity_remove_effect(&self, uuid: &str, effect_id: &str) -> bool
Remove a single status effect from a living entity.
Sourcefn entity_clear_effects(&self, uuid: &str) -> bool
fn entity_clear_effects(&self, uuid: &str) -> bool
Clear all active status effects from a living entity.
Sourcefn drop_loot(
&self,
table_id: &str,
dimension: &str,
x: f64,
y: f64,
z: f64,
) -> bool
fn drop_loot( &self, table_id: &str, dimension: &str, x: f64, y: f64, z: f64, ) -> bool
Roll a loot table and spawn the resulting item entities in the world.
table_id is the namespaced id, e.g. "minecraft:entities/zombie".
Sourcefn has_item_tag(&self, item_id: &str, tag_id: &str) -> bool
fn has_item_tag(&self, item_id: &str, tag_id: &str) -> bool
Returns whether item_id (e.g. "minecraft:stone") belongs to tag_id
(e.g. "minecraft:planks").
Sourcefn has_block_tag(&self, block_id: &str, tag_id: &str) -> bool
fn has_block_tag(&self, block_id: &str, tag_id: &str) -> bool
Returns whether block_id belongs to tag_id.
Sourcefn world_time(&self, dimension: &str) -> Option<i64>
fn world_time(&self, dimension: &str) -> Option<i64>
Game time in ticks since world creation (never wraps, keeps counting).
Sourcefn world_set_time(&self, dimension: &str, time: i64) -> bool
fn world_set_time(&self, dimension: &str, time: i64) -> bool
Set the time-of-day (0 = dawn, 6000 = noon, 12000 = dusk, 18000 = midnight). Only changes the visual time, not the absolute world age.
Sourcefn world_is_raining(&self, dimension: &str) -> bool
fn world_is_raining(&self, dimension: &str) -> bool
Whether it is currently raining in the given dimension.
Sourcefn world_set_weather(
&self,
dimension: &str,
raining: bool,
duration_ticks: i32,
) -> bool
fn world_set_weather( &self, dimension: &str, raining: bool, duration_ticks: i32, ) -> bool
Start or stop rain. duration_ticks controls how long the weather lasts
(use 0 for a server-chosen default duration).
Sourcefn entity_velocity(&self, uuid: &str) -> Option<(f64, f64, f64)>
fn entity_velocity(&self, uuid: &str) -> Option<(f64, f64, f64)>
Current velocity (vx, vy, vz) of any entity, or None if not loaded.
Sourcefn entity_set_velocity(&self, uuid: &str, vx: f64, vy: f64, vz: f64) -> bool
fn entity_set_velocity(&self, uuid: &str, vx: f64, vy: f64, vz: f64) -> bool
Set the velocity of any entity. Returns false if not loaded.
Sourcefn entity_add_velocity(&self, uuid: &str, vx: f64, vy: f64, vz: f64) -> bool
fn entity_add_velocity(&self, uuid: &str, vx: f64, vy: f64, vz: f64) -> bool
Add a velocity impulse (cumulative with existing velocity).
Sourcefn scoreboard_get(&self, objective: &str, player: &str) -> Option<i32>
fn scoreboard_get(&self, objective: &str, player: &str) -> Option<i32>
Score of player on objective, or None if the objective doesn’t exist.
Sourcefn scoreboard_set(&self, objective: &str, player: &str, score: i32) -> bool
fn scoreboard_set(&self, objective: &str, player: &str, score: i32) -> bool
Set the score; returns false if the objective doesn’t exist.
Sourcefn scoreboard_add(
&self,
objective: &str,
player: &str,
delta: i32,
) -> Option<i32>
fn scoreboard_add( &self, objective: &str, player: &str, delta: i32, ) -> Option<i32>
Add delta to the score (negative = subtract). Returns the new score,
or None if the objective doesn’t exist.
Sourcefn play_sound(
&self,
dimension: &str,
x: f64,
y: f64,
z: f64,
sound_id: &str,
volume: f32,
pitch: f32,
) -> bool
fn play_sound( &self, dimension: &str, x: f64, y: f64, z: f64, sound_id: &str, volume: f32, pitch: f32, ) -> bool
Play a sound at (x, y, z) in dimension. sound_id is a registry id
(e.g. "minecraft:entity.player.levelup"). All players within range hear
it. Returns false if the dimension is unknown.
Sourcefn play_sound_to_player(
&self,
player: &str,
sound_id: &str,
volume: f32,
pitch: f32,
) -> bool
fn play_sound_to_player( &self, player: &str, sound_id: &str, volume: f32, pitch: f32, ) -> bool
Play a sound at the named player’s current position. All players nearby
(including the target) hear it. Returns false if the player is offline.
Sourcefn send_title(
&self,
player: &str,
title: &str,
subtitle: &str,
fadein: i32,
stay: i32,
fadeout: i32,
) -> bool
fn send_title( &self, player: &str, title: &str, subtitle: &str, fadein: i32, stay: i32, fadeout: i32, ) -> bool
Send a title+subtitle screen to a player. Pass empty strings to omit either line. Timings are in ticks (20 ticks = 1 second).
Sourcefn send_actionbar(&self, player: &str, message: &str) -> bool
fn send_actionbar(&self, player: &str, message: &str) -> bool
Send a short message to the action-bar (the line just above the hotbar).
Sourcefn entity_rotation(&self, uuid: &str) -> Option<(f32, f32)>
fn entity_rotation(&self, uuid: &str) -> Option<(f32, f32)>
Yaw and pitch (degrees) of an entity by UUID, or None if it does not
exist. Minecraft convention: yaw 0 = south, positive pitch looks down.
Sourcefn kick_player(&self, player: &str, reason: &str) -> bool
fn kick_player(&self, player: &str, reason: &str) -> bool
Disconnect player with the given reason message.
Sourcefn set_gamemode(&self, player: &str, gamemode: &str) -> bool
fn set_gamemode(&self, player: &str, gamemode: &str) -> bool
Change a player’s game mode. gamemode is one of "survival",
"creative", "adventure", "spectator" (or the abbreviations
"s", "c", "a", "sp"). Returns false if the player is offline
or gamemode is unrecognised.
Sourcefn bossbar_create(
&self,
id: &str,
title: &str,
color: &str,
style: &str,
) -> bool
fn bossbar_create( &self, id: &str, title: &str, color: &str, style: &str, ) -> bool
Create a new boss bar identified by id (a namespaced id such as
"mymod:progress"). color: "pink" / "blue" / "red" / "green" /
"yellow" / "purple" / "white". style: "progress" /
"notched_6" / "notched_10" / "notched_12" / "notched_20".
Returns false if a bar with that id already exists.
Sourcefn bossbar_remove(&self, id: &str) -> bool
fn bossbar_remove(&self, id: &str) -> bool
Remove a boss bar (also removes it from all players). Returns false if
the bar doesn’t exist.
Sourcefn bossbar_set_title(&self, id: &str, title: &str) -> bool
fn bossbar_set_title(&self, id: &str, title: &str) -> bool
Update the displayed title of a boss bar.
Sourcefn bossbar_set_progress(&self, id: &str, progress: f32) -> bool
fn bossbar_set_progress(&self, id: &str, progress: f32) -> bool
Set the fill level of a boss bar (0.0 = empty, 1.0 = full).
Sourcefn bossbar_set_color(&self, id: &str, color: &str) -> bool
fn bossbar_set_color(&self, id: &str, color: &str) -> bool
Change the color of a boss bar (same color names as [bossbar_create]).
Sourcefn bossbar_add_player(&self, id: &str, player: &str) -> bool
fn bossbar_add_player(&self, id: &str, player: &str) -> bool
Add an online player to the boss bar’s audience.
Sourcefn bossbar_remove_player(&self, id: &str, player: &str) -> bool
fn bossbar_remove_player(&self, id: &str, player: &str) -> bool
Remove a player from the boss bar’s audience.
Sourcefn bossbar_set_visible(&self, id: &str, visible: bool) -> bool
fn bossbar_set_visible(&self, id: &str, visible: bool) -> bool
Show or hide a boss bar for all its current audience members.
Sourcefn online_players(&self) -> Vec<String>
fn online_players(&self) -> Vec<String>
Names of all currently connected players.
Sourcefn get_block_nbt(&self, dimension: &str, pos: BlockPos) -> Option<String>
fn get_block_nbt(&self, dimension: &str, pos: BlockPos) -> Option<String>
SNBT string of the block entity at pos (e.g. chest contents, furnace
state, sign text). Returns None if there is no block entity there.
Sourcefn set_block_nbt(&self, dimension: &str, pos: BlockPos, snbt: &str) -> bool
fn set_block_nbt(&self, dimension: &str, pos: BlockPos, snbt: &str) -> bool
Write snbt data into the block entity at pos and mark it dirty.
Returns false if there is no block entity at that position.
Sourcefn get_inventory_slot(
&self,
dimension: &str,
pos: BlockPos,
slot: u32,
) -> Option<(String, u32, String)>
fn get_inventory_slot( &self, dimension: &str, pos: BlockPos, slot: u32, ) -> Option<(String, u32, String)>
(item_id, count, snbt) of one slot of the block container at pos
— a Yog inventory block (see yog_inventory::InventoryDef), a chest,
any container. snbt is "{}" when the item carries no data.
None if the slot is empty or there’s no container there.
Sourcefn set_inventory_slot(
&self,
dimension: &str,
pos: BlockPos,
slot: u32,
item_id: &str,
count: u32,
snbt: &str,
) -> bool
fn set_inventory_slot( &self, dimension: &str, pos: BlockPos, slot: u32, item_id: &str, count: u32, snbt: &str, ) -> bool
Puts count of item_id, carrying snbt ("" for none), into one
slot of the block container at pos; count == 0 empties it.
false if there’s no container there (or the item id is unknown).
Sourcefn player_inventory(&self, player: &str) -> Vec<(u32, String, u32)>
fn player_inventory(&self, player: &str) -> Vec<(u32, String, u32)>
All occupied inventory slots of an online player.
Returns one entry per occupied slot: (slot_index, item_id, count).
Sourcefn player_set_slot(
&self,
player: &str,
slot: u32,
item_id: &str,
count: u32,
) -> bool
fn player_set_slot( &self, player: &str, slot: u32, item_id: &str, count: u32, ) -> bool
Set (or clear when count == 0) one inventory slot of an online player.
Sourcefn teleport_to_dim(
&self,
player: &str,
dimension: &str,
x: f64,
y: f64,
z: f64,
) -> bool
fn teleport_to_dim( &self, player: &str, dimension: &str, x: f64, y: f64, z: f64, ) -> bool
Teleport a player to (x, y, z) in a different (or same) dimension.
Sourcefn entity_teleport_to_dim(
&self,
uuid: &str,
dimension: &str,
x: f64,
y: f64,
z: f64,
) -> bool
fn entity_teleport_to_dim( &self, uuid: &str, dimension: &str, x: f64, y: f64, z: f64, ) -> bool
Teleport any entity (by UUID) to (x, y, z) in dimension.
Sourcefn world_entity_count(&self, dimension: &str, entity_type: &str) -> i32
fn world_entity_count(&self, dimension: &str, entity_type: &str) -> i32
Number of loaded entities of entity_type (e.g. "minecraft:zombie")
in dimension. Returns -1 if the dimension or entity type is unknown.
Sourcefn entity_get_nbt(&self, uuid: &str) -> Option<String>
fn entity_get_nbt(&self, uuid: &str) -> Option<String>
SNBT string of the entity’s persistent NBT, or None if not found.
Sourcefn entity_set_nbt(&self, uuid: &str, snbt: &str) -> bool
fn entity_set_nbt(&self, uuid: &str, snbt: &str) -> bool
Merge SNBT data into the entity’s persistent NBT. Returns false if not found.
Sourcefn spawn_particles(
&self,
dimension: &str,
x: f64,
y: f64,
z: f64,
particle_type: &str,
count: i32,
dx: f64,
dy: f64,
dz: f64,
speed: f64,
) -> bool
fn spawn_particles( &self, dimension: &str, x: f64, y: f64, z: f64, particle_type: &str, count: i32, dx: f64, dy: f64, dz: f64, speed: f64, ) -> bool
Spawn count particles at (x, y, z) in dimension.
particle_type is a particle id or, like /particle, an id with its
options ("minecraft:dust 1 0.5 0 1").
dx/dy/dz control the spatial spread; speed controls particle velocity.
Sourcefn entity_attribute_get(&self, uuid: &str, attribute_id: &str) -> Option<f64>
fn entity_attribute_get(&self, uuid: &str, attribute_id: &str) -> Option<f64>
Get the base value of an attribute on a living entity.
attribute_id e.g. "minecraft:generic.max_health".
Returns None if the entity or attribute is not found.
Sourcefn entity_attribute_set(
&self,
uuid: &str,
attribute_id: &str,
value: f64,
) -> bool
fn entity_attribute_set( &self, uuid: &str, attribute_id: &str, value: f64, ) -> bool
Set the base value of an attribute. Returns false if not found.
Sourcefn get_held_item_nbt(&self, player: &str) -> Option<String>
fn get_held_item_nbt(&self, player: &str) -> Option<String>
SNBT string of the item currently held in the player’s main hand.
Returns None if the player is offline or holding air.
Sourcefn set_held_item_nbt(&self, player: &str, snbt: &str) -> bool
fn set_held_item_nbt(&self, player: &str, snbt: &str) -> bool
Merge snbt data into the NBT of the item in the player’s main hand.
Returns false if the player is offline or holding air.
Sourcefn get_offhand_item_nbt(&self, player: &str) -> Option<String>
fn get_offhand_item_nbt(&self, player: &str) -> Option<String>
SNBT of the item in the player’s off hand.
Returns None if offline or holding air.
Sourcefn set_offhand_item_nbt(&self, player: &str, snbt: &str) -> bool
fn set_offhand_item_nbt(&self, player: &str, snbt: &str) -> bool
Merge snbt into the NBT of the player’s off-hand item.
Returns false if offline or holding air.
Sourcefn get_slot_item(
&self,
player: &str,
slot: u32,
) -> Option<(String, u32, String)>
fn get_slot_item( &self, player: &str, slot: u32, ) -> Option<(String, u32, String)>
Full item stack at inventory slot: (item_id, count, nbt_snbt).
nbt_snbt is "{}" when the item has no NBT.
Returns None if the player is offline or the slot is empty.
Sourcefn set_slot_item(
&self,
player: &str,
slot: u32,
item_id: &str,
count: u32,
snbt: &str,
) -> bool
fn set_slot_item( &self, player: &str, slot: u32, item_id: &str, count: u32, snbt: &str, ) -> bool
Replace inventory slot. Pass count == 0 to clear the slot.
snbt is merged into the new item’s NBT (pass "" for no NBT).
Sourcefn entity_info(&self, uuid: &str) -> Option<EntityInfo>
fn entity_info(&self, uuid: &str) -> Option<EntityInfo>
Type, position, size and kind of a loaded entity, or None if no
entity has that uuid.
Sourcefn entities_in_box(
&self,
dimension: &str,
min: (f64, f64, f64),
max: (f64, f64, f64),
) -> Vec<String>
fn entities_in_box( &self, dimension: &str, min: (f64, f64, f64), max: (f64, f64, f64), ) -> Vec<String>
Uuids of the entities whose bounding boxes touch the box min–max
in dimension.
Sourcefn raycast_block(
&self,
dimension: &str,
from: (f64, f64, f64),
to: (f64, f64, f64),
) -> Option<BlockHit>
fn raycast_block( &self, dimension: &str, from: (f64, f64, f64), to: (f64, f64, f64), ) -> Option<BlockHit>
The first block with a collision shape on the segment from–to
(fluids are ignored).
Sourcefn raycast_entity(
&self,
dimension: &str,
from: (f64, f64, f64),
to: (f64, f64, f64),
exclude: &str,
) -> Option<String>
fn raycast_entity( &self, dimension: &str, from: (f64, f64, f64), to: (f64, f64, f64), exclude: &str, ) -> Option<String>
The nearest pickable entity whose (slightly inflated) bounding box the
segment from–to crosses, other than exclude (a uuid, or "")
and whatever it rides.
Sourcefn block_info(&self, dimension: &str, pos: BlockPos) -> Option<BlockInfo>
fn block_info(&self, dimension: &str, pos: BlockPos) -> Option<BlockInfo>
State, hardness, fluid and redstone power of the block at pos.
Sourcefn break_block(
&self,
dimension: &str,
pos: BlockPos,
drop: bool,
breaker: &str,
) -> bool
fn break_block( &self, dimension: &str, pos: BlockPos, drop: bool, breaker: &str, ) -> bool
Break the block at pos as breaker (a player name, or ""):
plays the break effects and, if drop, drops its loot as if mined
with an empty hand. Returns false for air and unbreakable blocks.
Sourcefn place_block_from_slot(
&self,
player: &str,
slot: u32,
dimension: &str,
pos: BlockPos,
) -> bool
fn place_block_from_slot( &self, player: &str, slot: u32, dimension: &str, pos: BlockPos, ) -> bool
Place the block item in the player’s inventory slot at pos, as if
the player clicked the block below it: the item’s own placement
rules apply and one item is used up (unless creative).
Sourcefn bonemeal(&self, dimension: &str, pos: BlockPos) -> bool
fn bonemeal(&self, dimension: &str, pos: BlockPos) -> bool
Apply bone meal to the block at pos. Returns whether it grew.
Sourcefn explode(
&self,
dimension: &str,
x: f64,
y: f64,
z: f64,
power: f32,
fire: bool,
source: &str,
) -> bool
fn explode( &self, dimension: &str, x: f64, y: f64, z: f64, power: f32, fire: bool, source: &str, ) -> bool
An explosion of power (TNT is 4) at pos, caused by entity
source (a uuid, or ""); fire sets fires like a ghast fireball.
Sourcefn tellraw(&self, player: &str, json: &str) -> bool
fn tellraw(&self, player: &str, json: &str) -> bool
A system chat message to one player, like /tellraw: json is a
JSON text component, so it can hold translation keys
({"translate":"mymod.msg","with":["x"]}) that each client shows in
its own language.
Sourcefn entity_damage(
&self,
uuid: &str,
amount: f32,
damage_type: &str,
attacker: &str,
) -> bool
fn entity_damage( &self, uuid: &str, amount: f32, damage_type: &str, attacker: &str, ) -> bool
Hurt an entity. damage_type is a damage type id
("minecraft:magic", "minecraft:drown", …; "" picks one from
the attacker: player attack, mob attack, or magic without one), and
attacker the uuid of the entity responsible (or ""). An unknown
damage type falls back to magic. Returns whether it took the damage.
Sourcefn entity_set_fire_ticks(&self, uuid: &str, ticks: i32) -> bool
fn entity_set_fire_ticks(&self, uuid: &str, ticks: i32) -> bool
Set an entity on fire for ticks (0 puts it out).
Sourcefn player_add_xp(&self, player: &str, amount: i32) -> bool
fn player_add_xp(&self, player: &str, amount: i32) -> bool
Give (or, negative, take) experience points.
Sourcefn player_set_may_fly(&self, player: &str, may_fly: bool) -> bool
fn player_set_may_fly(&self, player: &str, may_fly: bool) -> bool
Let a player fly (creative-style) or take it away (also stops them flying). Game mode changes reset it.
Sourcefn player_info(&self, player: &str) -> Option<PlayerInfo>
fn player_info(&self, player: &str) -> Option<PlayerInfo>
Game mode, selected slot, experience, air and flight of a player.
Sourcefn spawn_item(
&self,
dimension: &str,
pos: (f64, f64, f64),
vel: (f64, f64, f64),
item_id: &str,
count: u32,
snbt: &str,
) -> Option<String>
fn spawn_item( &self, dimension: &str, pos: (f64, f64, f64), vel: (f64, f64, f64), item_id: &str, count: u32, snbt: &str, ) -> Option<String>
Drop an item stack into the world with velocity vel; snbt is the
stack’s NBT ("" for none). Returns the item entity’s uuid.
Sourcefn item_entity_stack(&self, uuid: &str) -> Option<(String, u32, String)>
fn item_entity_stack(&self, uuid: &str) -> Option<(String, u32, String)>
The stack inside a dropped item entity: (item_id, count, snbt).
Sourcefn item_entity_set_stack(
&self,
uuid: &str,
item_id: &str,
count: u32,
snbt: &str,
) -> bool
fn item_entity_set_stack( &self, uuid: &str, item_id: &str, count: u32, snbt: &str, ) -> bool
Replace the stack inside a dropped item entity (count == 0 removes
the entity).
Sourcefn actionbar_json(&self, player: &str, json: &str) -> bool
fn actionbar_json(&self, player: &str, json: &str) -> bool
An action-bar message (the line above the hotbar) from a JSON text
component, like tellraw: translation keys show
in each client’s own language.
Sourcefn use_item_on_block(
&self,
dimension: &str,
pos: BlockPos,
face: Face,
item_id: &str,
player: &str,
) -> bool
fn use_item_on_block( &self, dimension: &str, pos: BlockPos, face: Face, item_id: &str, player: &str, ) -> bool
Use one item_id (a fresh single item, nothing is taken from anyone)
on the face of the block at pos, as player (a name, or "" for
nobody): flint and steel lights it, a shovel puts out a campfire, a
hoe tills it… Returns whether the item did something.
Sourcefn pour_fluid(
&self,
dimension: &str,
pos: BlockPos,
bucket_item_id: &str,
) -> bool
fn pour_fluid( &self, dimension: &str, pos: BlockPos, bucket_item_id: &str, ) -> bool
Empty the fluid of a bucket item ("minecraft:water_bucket") at pos
the way a player would: it waterlogs a waterloggable block, replaces
a replaceable one, and evaporates where water can’t exist. Returns
whether any fluid was placed.
Sourcefn has_entity_tag(&self, entity_type: &str, tag_id: &str) -> bool
fn has_entity_tag(&self, entity_type: &str, tag_id: &str) -> bool
Whether an entity type ("minecraft:zombie") is in tag_id
("minecraft:skeletons").
Sourcefn item_block(&self, item_id: &str) -> Option<String>
fn item_block(&self, item_id: &str) -> Option<String>
The block an item places ("minecraft:torch" for the torch item), or
None if it isn’t a block item.
Sourcefn place_feature(
&self,
dimension: &str,
pos: BlockPos,
feature_id: &str,
) -> bool
fn place_feature( &self, dimension: &str, pos: BlockPos, feature_id: &str, ) -> bool
Place a configured feature ("minecraft:oak", or a datapack’s own
data/<ns>/worldgen/configured_feature/*.json) at pos, the way
a growing sapling places its tree. Returns whether it was placed.
Sourcefn set_item_cooldown(&self, player: &str, item_id: &str, ticks: u32) -> bool
fn set_item_cooldown(&self, player: &str, item_id: &str, ticks: u32) -> bool
Puts item_id on cooldown for an online player for ticks (the
grey sweep over it in the hotbar; using it waits). false if the
player is offline or the item unknown.
Sourcefn entity_vehicle(&self, uuid: &str) -> Option<String>
fn entity_vehicle(&self, uuid: &str) -> Option<String>
What an entity rides — a boat, a horse, a minecart — if anything.
Sourcefn entity_passengers(&self, uuid: &str) -> Vec<String>
fn entity_passengers(&self, uuid: &str) -> Vec<String>
What rides an entity directly.
Sourcefn entity_mount(&self, rider: &str, vehicle: &str, force: bool) -> bool
fn entity_mount(&self, rider: &str, vehicle: &str, force: bool) -> bool
Seats rider on vehicle; force: even on one that wouldn’t take
it (a full boat, a mob that doesn’t carry riders).
Sourcefn entity_dismount(&self, uuid: &str) -> bool
fn entity_dismount(&self, uuid: &str) -> bool
Gets an entity off what it rides; false if it rode nothing.
Sourcefn entity_set_dimensions(
&self,
uuid: &str,
size: Option<(f32, f32, f32)>,
) -> bool
fn entity_set_dimensions( &self, uuid: &str, size: Option<(f32, f32, f32)>, ) -> bool
Gives the entity its own hitbox — Some((width, height, eye height)) in blocks — or vanilla’s again (None); it stays till
changed, through pose changes. The server side: the clients are told
with yog_api::body::set_dimensions (the mod’s own packet). false
if there’s no such entity.
Sourcefn entity_set_fall_distance(&self, uuid: &str, distance: f32) -> bool
fn entity_set_fall_distance(&self, uuid: &str, distance: f32) -> bool
Sets how far the entity has fallen — fall damage counts it when it
lands (0: none). false if there’s no such entity.
Sourcefn redstone_signal(&self, dimension: &str, pos: BlockPos) -> Option<u8>
fn redstone_signal(&self, dimension: &str, pos: BlockPos) -> Option<u8>
The strongest signal the block at pos gives off (a lever, a torch,
dust: its power); None if it isn’t a redstone source.
Sourcefn redstone_power(&self, dimension: &str, pos: BlockPos) -> Option<u8>
fn redstone_power(&self, dimension: &str, pos: BlockPos) -> Option<u8>
The redstone power the block at pos receives from its neighbours
(0–15); None if the dimension doesn’t exist.
Sourcefn set_redstone_output(&self, dimension: &str, pos: BlockPos, level: u8) -> bool
fn set_redstone_output(&self, dimension: &str, pos: BlockPos, level: u8) -> bool
Sets the power (0–15) the block at pos gives off — a block
declared a redstone source (BlockDef::redstone_source,
"redstone": true in its .yblock). Neighbours update.
Sourcefn get_block_state(&self, dimension: &str, pos: BlockPos) -> Option<String>
fn get_block_state(&self, dimension: &str, pos: BlockPos) -> Option<String>
The full state of the block at pos: its id and properties,
"minecraft:repeater[delay=2,facing=east,locked=false,powered=false]".
Sourcefn set_block_state(&self, dimension: &str, pos: BlockPos, state: &str) -> bool
fn set_block_state(&self, dimension: &str, pos: BlockPos, state: &str) -> bool
Places a block in a full state, as /setblock writes it
("minecraft:repeater[delay=2,facing=east]"; unset properties take
their defaults). false if it doesn’t parse.
Sourcefn world_is_thundering(&self, dimension: &str) -> bool
fn world_is_thundering(&self, dimension: &str) -> bool
Whether a thunderstorm is going on in dimension.
Sourcefn world_set_thunder(
&self,
dimension: &str,
thundering: bool,
duration_ticks: i32,
) -> bool
fn world_set_thunder( &self, dimension: &str, thundering: bool, duration_ticks: i32, ) -> bool
Starts (true) or ends a thunderstorm; duration_ticks 0 = a
server-chosen length.
Sourcefn fill_region(
&self,
dimension: &str,
from: BlockPos,
to: BlockPos,
state: &str,
) -> Option<u32>
fn fill_region( &self, dimension: &str, from: BlockPos, to: BlockPos, state: &str, ) -> Option<u32>
Sets every block of the box between from and to (inclusive, any
corners) to state ("minecraft:barrier", "minecraft:air", a full
state) in one call. How many blocks changed; None if the dimension
or state is unknown.
Sourcefn scan_region(
&self,
dimension: &str,
from: BlockPos,
to: BlockPos,
) -> Vec<(BlockPos, String)>
fn scan_region( &self, dimension: &str, from: BlockPos, to: BlockPos, ) -> Vec<(BlockPos, String)>
Every non-air block of the box between from and to with its full
state (see Server::get_block_state) — one call for a whole area.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".