Skip to main content

CServer

Struct CServer 

Source
pub struct CServer(pub *const YogServer);
Expand description

A handle to the runtime’s server actions, backed by YogServer fn pointers. Given to every handler as &dyn Server.

Tuple Fields§

§0: *const YogServer

Trait Implementations§

Source§

impl Send for CServer

Source§

impl Server for CServer

Source§

fn broadcast(&self, message: &str)

Broadcast a chat message to all players on the server.
Source§

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).
Source§

fn set_block(&self, dimension: &str, pos: BlockPos, block_id: &str) -> bool

Set the block at pos in dimension to block_id. Returns whether the change was applied. Call from the server thread.
Source§

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.
Source§

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.
Source§

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.
Source§

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.
Source§

fn entity_teleport(&self, uuid: &str, x: f64, y: f64, z: f64) -> bool

Teleport any entity (by UUID) within its current world.
Source§

fn entity_position(&self, uuid: &str) -> Option<(f64, f64, f64)>

Position of an entity, or None if not loaded.
Source§

fn entity_health(&self, uuid: &str) -> Option<f32>

Health of a living entity, or None.
Source§

fn entity_set_health(&self, uuid: &str, health: f32) -> bool

Set a living entity’s health; returns whether it applied.
Source§

fn entity_kill(&self, uuid: &str) -> bool

Remove/kill an entity.
Source§

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.
Source§

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.
Source§

fn entity_remove_effect(&self, uuid: &str, effect_id: &str) -> bool

Remove a single status effect from a living entity.
Source§

fn entity_clear_effects(&self, uuid: &str) -> bool

Clear all active status effects from a living entity.
Source§

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".
Source§

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").
Source§

fn has_block_tag(&self, block_id: &str, tag_id: &str) -> bool

Returns whether block_id belongs to tag_id.
Source§

fn world_time(&self, dimension: &str) -> Option<i64>

Game time in ticks since world creation (never wraps, keeps counting).
Source§

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.
Source§

fn world_is_raining(&self, dimension: &str) -> bool

Whether it is currently raining in the given dimension.
Source§

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).
Source§

fn entity_velocity(&self, uuid: &str) -> Option<(f64, f64, f64)>

Current velocity (vx, vy, vz) of any entity, or None if not loaded.
Source§

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.
Source§

fn entity_add_velocity(&self, uuid: &str, vx: f64, vy: f64, vz: f64) -> bool

Add a velocity impulse (cumulative with existing velocity).
Source§

fn scoreboard_get(&self, objective: &str, player: &str) -> Option<i32>

Score of player on objective, or None if the objective doesn’t exist.
Source§

fn scoreboard_set(&self, objective: &str, player: &str, score: i32) -> bool

Set the score; returns false if the objective doesn’t exist.
Source§

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.
Source§

fn game_dir(&self) -> String

Absolute path of the game / server root directory.
Source§

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.
Source§

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.
Source§

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).
Source§

fn send_actionbar(&self, player: &str, message: &str) -> bool

Send a short message to the action-bar (the line just above the hotbar).
Source§

fn kick_player(&self, player: &str, reason: &str) -> bool

Disconnect player with the given reason message.
Source§

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.
Source§

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.
Source§

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.
Source§

fn bossbar_set_title(&self, id: &str, title: &str) -> bool

Update the displayed title of a boss bar.
Source§

fn bossbar_set_progress(&self, id: &str, progress: f32) -> bool

Set the fill level of a boss bar (0.0 = empty, 1.0 = full).
Source§

fn bossbar_set_color(&self, id: &str, color: &str) -> bool

Change the color of a boss bar (same color names as [bossbar_create]).
Source§

fn bossbar_add_player(&self, id: &str, player: &str) -> bool

Add an online player to the boss bar’s audience.
Source§

fn bossbar_remove_player(&self, id: &str, player: &str) -> bool

Remove a player from the boss bar’s audience.
Source§

fn bossbar_set_visible(&self, id: &str, visible: bool) -> bool

Show or hide a boss bar for all its current audience members.
Source§

fn online_players(&self) -> Vec<String>

Names of all currently connected players.
Source§

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.
Source§

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.
Source§

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).
Source§

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.
Source§

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.
Source§

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.
Source§

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.
Source§

fn entity_get_nbt(&self, uuid: &str) -> Option<String>

SNBT string of the entity’s persistent NBT, or None if not found.
Source§

fn entity_set_nbt(&self, uuid: &str, snbt: &str) -> bool

Merge SNBT data into the entity’s persistent NBT. Returns false if not found.
Source§

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. dx/dy/dz control the spatial spread; speed controls particle velocity.
Source§

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.
Source§

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.
Source§

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.
Source§

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.
Source§

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.
Source§

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.
Source§

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.
Source§

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).
Source§

impl Sync for CServer

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.