pub trait EntityContext {
// Required methods
fn spawn_dropped_item(
&self,
x: i32,
y: i32,
z: i32,
item_id: i32,
count: i32,
);
fn broadcast_block_change(&self, x: i32, y: i32, z: i32, block_state: i32);
fn broadcast_entity_moved(
&self,
entity_id: i32,
x: f64,
y: f64,
z: f64,
yaw: f32,
pitch: f32,
on_ground: bool,
);
fn broadcast_player_joined(&self);
fn broadcast_player_left(&self);
fn broadcast_raw(&self, msg: BroadcastMessage);
fn broadcast_block_action(
&self,
x: i32,
y: i32,
z: i32,
action_id: u8,
action_param: u8,
block_id: i32,
);
}Expand description
Entity management: spawn, despawn, broadcast.
Required Methods§
Sourcefn spawn_dropped_item(&self, x: i32, y: i32, z: i32, item_id: i32, count: i32)
fn spawn_dropped_item(&self, x: i32, y: i32, z: i32, item_id: i32, count: i32)
Spawns a dropped item entity at the given block coordinates.
Sourcefn broadcast_block_change(&self, x: i32, y: i32, z: i32, block_state: i32)
fn broadcast_block_change(&self, x: i32, y: i32, z: i32, block_state: i32)
Broadcasts a block change to all connected players.
Sourcefn broadcast_entity_moved(
&self,
entity_id: i32,
x: f64,
y: f64,
z: f64,
yaw: f32,
pitch: f32,
on_ground: bool,
)
fn broadcast_entity_moved( &self, entity_id: i32, x: f64, y: f64, z: f64, yaw: f32, pitch: f32, on_ground: bool, )
Broadcasts an entity movement to all connected players.
Sourcefn broadcast_player_joined(&self)
fn broadcast_player_joined(&self)
Broadcasts that the current player has joined the server.
The server constructs the broadcast payload (including skin data) from the context’s player state.
Sourcefn broadcast_player_left(&self)
fn broadcast_player_left(&self)
Broadcasts that the current player has left the server.
Sourcefn broadcast_raw(&self, msg: BroadcastMessage)
fn broadcast_raw(&self, msg: BroadcastMessage)
Sends a raw broadcast message to all connected players.
Prefer the typed broadcast methods when possible. This method is for server-internal broadcasts that don’t have typed wrappers.
Sourcefn broadcast_block_action(
&self,
x: i32,
y: i32,
z: i32,
action_id: u8,
action_param: u8,
block_id: i32,
)
fn broadcast_block_action( &self, x: i32, y: i32, z: i32, action_id: u8, action_param: u8, block_id: i32, )
Broadcasts a BlockAction packet to all connected players.
Used for state-change animations driven by plugins (chest
lid open/close, door swing, note-block pitch chime, etc.).
The meaning of action_id and action_param is block-specific
— see the wiki for the full table.