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 rotation(&self) -> Option<(f32, f32)>
pub fn rotation(&self) -> Option<(f32, f32)>
Current position, or None if the entity isn’t loaded.
Yaw and pitch in degrees, or None if the entity does not exist.
Sourcepub fn look_vector(&self) -> Option<(f64, f64, f64)>
pub fn look_vector(&self) -> Option<(f64, f64, f64)>
Unit look vector derived from yaw/pitch (Minecraft convention).
pub fn position(&self) -> Option<(f64, f64, f64)>
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.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Entity<'a>
impl<'a> !Send for Entity<'a>
impl<'a> !Sync for Entity<'a>
impl<'a> !UnwindSafe for Entity<'a>
impl<'a> Freeze for Entity<'a>
impl<'a> Unpin for Entity<'a>
impl<'a> UnsafeUnpin for Entity<'a>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.