Skip to main content

Entity

Struct Entity 

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

Source

pub fn new(server: &'a dyn Server, uuid: impl Into<String>) -> Entity<'a>

Bind to the entity with this UUID on server.

Source

pub fn uuid(&self) -> &str

Source

pub fn teleport(&self, x: f64, y: f64, z: f64) -> bool

Teleport to (x, y, z) within the entity’s current world.

Source

pub fn position(&self) -> Option<(f64, f64, f64)>

Current position, or None if the entity isn’t loaded.

Source

pub fn health(&self) -> Option<f32>

Health (living entities only), or None.

Source

pub fn set_health(&self, health: f32) -> bool

Set health (living entities only); returns whether it applied.

Source

pub fn kill(&self) -> bool

Remove/kill the entity.

Source

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

Source

pub fn remove_effect(&self, effect_id: &str) -> bool

Remove a single status effect.

Source

pub fn clear_effects(&self) -> bool

Clear all active status effects.

Source

pub fn velocity(&self) -> Option<(f64, f64, f64)>

Current velocity (vx, vy, vz), or None if not loaded.

Source

pub fn set_velocity(&self, vx: f64, vy: f64, vz: f64) -> bool

Set velocity directly (replaces current velocity).

Source

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

Source

pub fn get_nbt(&self) -> Option<String>

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

Source

pub fn set_nbt(&self, snbt: &str) -> bool

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

Source

pub fn attribute_get(&self, attribute_id: &str) -> Option<f64>

Base value of an attribute (e.g. "minecraft:generic.max_health"), or None.

Source

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