Skip to main content

PlayerContext

Trait PlayerContext 

Source
pub trait PlayerContext {
    // Required methods
    fn uuid(&self) -> Uuid;
    fn entity_id(&self) -> i32;
    fn username(&self) -> &str;
    fn yaw(&self) -> f32;
    fn pitch(&self) -> f32;
    fn position(&self) -> (f64, f64, f64);
    fn teleport(&self, x: f64, y: f64, z: f64, yaw: f32, pitch: f32);
    fn set_gamemode(&self, mode: Gamemode);
    fn registered_commands(&self) -> Vec<(String, String)>;
}
Expand description

Player identity and state.

Required Methods§

Source

fn uuid(&self) -> Uuid

Returns the UUID of the player who triggered this action.

Source

fn entity_id(&self) -> i32

Returns the entity ID of the player.

Source

fn username(&self) -> &str

Returns the username of the player.

Source

fn yaw(&self) -> f32

Returns the player’s current yaw rotation (horizontal, degrees).

Source

fn pitch(&self) -> f32

Returns the player’s current pitch rotation (vertical, degrees).

Source

fn position(&self) -> (f64, f64, f64)

Returns the player’s current world position. Captured at context-construction time — stale by the next tick.

Source

fn teleport(&self, x: f64, y: f64, z: f64, yaw: f32, pitch: f32)

Teleports the current player to the given coordinates.

Source

fn set_gamemode(&self, mode: Gamemode)

Changes the current player’s gamemode.

Source

fn registered_commands(&self) -> Vec<(String, String)>

Returns a list of (name, description) for all registered commands.

Implementors§