pub struct Entity<'a> { /* private fields */ }Expand description
A handle to one entity by UUID, bound to a Server.
Implementations§
Source§impl<'a> Entity<'a>
impl<'a> Entity<'a>
Sourcepub fn new(server: &'a dyn Server, uuid: impl Into<String>) -> Entity<'a>
pub fn new(server: &'a dyn Server, uuid: impl Into<String>) -> Entity<'a>
Bind to the entity with this UUID on server.
pub fn uuid(&self) -> &str
Sourcepub fn teleport(&self, x: f64, y: f64, z: f64) -> bool
pub fn teleport(&self, x: f64, y: f64, z: f64) -> bool
Teleport to (x, y, z) within the entity’s current world.
Sourcepub fn position(&self) -> Option<(f64, f64, f64)>
pub fn position(&self) -> Option<(f64, f64, f64)>
Current position, or None if the entity isn’t loaded.
Sourcepub fn set_health(&self, health: f32) -> bool
pub fn set_health(&self, health: f32) -> bool
Set health (living entities only); returns whether it applied.
Sourcepub fn add_effect(
&self,
effect_id: &str,
duration_ticks: i32,
amplifier: u8,
show_particles: bool,
) -> bool
pub fn add_effect( &self, effect_id: &str, duration_ticks: i32, amplifier: u8, show_particles: bool, ) -> bool
Apply a status effect. effect_id is a registry id like
"minecraft:speed". amplifier is 0-based (0 = level I).
Sourcepub fn remove_effect(&self, effect_id: &str) -> bool
pub fn remove_effect(&self, effect_id: &str) -> bool
Remove a single status effect.
Sourcepub fn clear_effects(&self) -> bool
pub fn clear_effects(&self) -> bool
Clear all active status effects.
Sourcepub fn velocity(&self) -> Option<(f64, f64, f64)>
pub fn velocity(&self) -> Option<(f64, f64, f64)>
Current velocity (vx, vy, vz), or None if not loaded.
Sourcepub fn set_velocity(&self, vx: f64, vy: f64, vz: f64) -> bool
pub fn set_velocity(&self, vx: f64, vy: f64, vz: f64) -> bool
Set velocity directly (replaces current velocity).
Sourcepub fn add_velocity(&self, vx: f64, vy: f64, vz: f64) -> bool
pub fn add_velocity(&self, vx: f64, vy: f64, vz: f64) -> bool
Add an impulse to the current velocity (e.g. launch upward: add_velocity(0, 1, 0)).
Sourcepub fn get_nbt(&self) -> Option<String>
pub fn get_nbt(&self) -> Option<String>
SNBT string of the entity’s persistent NBT, or None if not found.
Sourcepub fn set_nbt(&self, snbt: &str) -> bool
pub fn set_nbt(&self, snbt: &str) -> bool
Merge SNBT data into the entity’s persistent NBT. Returns false if not found.
Sourcepub fn attribute_get(&self, attribute_id: &str) -> Option<f64>
pub fn attribute_get(&self, attribute_id: &str) -> Option<f64>
Base value of an attribute (e.g. "minecraft:generic.max_health"), or None.
Sourcepub fn attribute_set(&self, attribute_id: &str, value: f64) -> bool
pub fn attribute_set(&self, attribute_id: &str, value: f64) -> bool
Set the base value of an attribute. Returns false if not found.