Skip to main content

Entities

Struct Entities 

Source
pub struct Entities { /* private fields */ }
Expand description

The tracked entities and tab list (queries are the same for every version).

Implementations§

Source§

impl Entities

Source

pub fn get(&self, id: i32) -> Option<&Entity>

The entity with this id (including the bot’s own entry, see Entities::self_id).

Source

pub fn len(&self) -> usize

Number of tracked entities (including the bot’s own entry).

Source

pub fn is_empty(&self) -> bool

true when nothing is tracked.

Source

pub fn iter(&self) -> impl Iterator<Item = &Entity>

Other entities (the bot’s own entry is skipped), arbitrary order.

Source

pub fn self_id(&self) -> Option<i32>

The bot’s own entity id (from login). Its entry carries metadata, equipment, riding state and effects as far as the Config keeps them, but no position: the client owns its own position. The ghast client tracks entities with Config::effects and Config::equipment off: use TickContext::effects for the bot’s own effects.

Source

pub fn me(&self) -> Option<&Entity>

The bot’s own entry (see Entities::self_id for what it carries).

Source

pub fn within(&self, p: [f64; 3], radius: f64) -> impl Iterator<Item = &Entity>

Entities whose server position is within radius of p (linear scan).

Source

pub fn near(&self, p: [f64; 3], radius: f64) -> impl Iterator<Item = &Entity>

Alias of Entities::within.

Source

pub fn player_info(&self, uuid: &Uuid) -> Option<&PlayerInfo>

The tab list.

Source

pub fn players(&self) -> impl Iterator<Item = (&Uuid, &PlayerInfo)>

All tab-list entries.

Source

pub fn player_name(&self, id: i32) -> Option<&str>

Name of a player entity (from the tab list: the full one, or the names-only one of Config::player_names).

Source

pub fn tab_name(&self, uuid: &Uuid) -> Option<&str>

Profile name of a tab-list entry (full list or names only).

Source

pub fn client_motion(&self, id: i32) -> Option<[f64; 3]>

The motion (getDeltaMovement) of the client copy of entity id when its type is one of Config::motion_types: zero once it has run out (or was never set), None for other types and unknown ids. Modern (26.x) trackers only.

Source

pub fn tab_uuid(&self, name: &str) -> Option<Uuid>

The uuid of the tab-list entry (full list or names only) with profile name name.

Source

pub fn tab_game_mode(&self, uuid: &Uuid) -> Option<i32>

Game mode of a tab-list entry (full list or names only).

Source

pub fn tab_len(&self) -> usize

Number of tab-list entries kept (full list or names only).

Source

pub fn config(&self) -> Config

The configuration.

Source

pub fn drain_events(&mut self) -> Drain<'_, Event> ⓘ

Takes the queued events (keeps the buffer’s capacity).

Source

pub fn clear(&mut self)

Removes every entity (keeps the tab list and the bot’s id).

Source

pub fn set_tick(&mut self, now: u64)

Sets the clock that stamps Entity::position_tick, Entity::spawn_tick and Entity::last_hurt_tick (the ghast client sets it to the tick in which the behaviour first sees the packets that follow).

Source

pub fn tick(&self) -> u64

The clock set with Entities::set_tick.

Trait Implementations§

Source§

impl Clone for Entities

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Entities

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Entities

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Entities

§

impl Freeze for Entities

§

impl Move for Entities

§

impl RefUnwindSafe for Entities

§

impl Send for Entities
where RawTable<(i32, Entity)>: Send, &'static [u16]: Send, RawVecInner: Send, RawTable<(Uuid, PlayerInfo)>: Send, RawTable<(Uuid, TabLite)>: Send, RawTable<(Uuid, Box<str>)>: Send, BoxRaw<str>: Send, Bytes: Send, RawTable<(i32, Stepped)>: Send, RawTable<(i32, [i32; 3])>: Send, RawTable<(i32, [f64; 3])>: Send,

§

impl Sync for Entities
where RawTable<(i32, Entity)>: Sync, RawVecInner: Sync, RawTable<(Uuid, PlayerInfo)>: Sync, RawTable<(Uuid, TabLite)>: Sync, RawTable<(Uuid, Box<str>)>: Sync, BoxRaw<str>: Sync, Bytes: Sync, RawTable<(i32, Stepped)>: Sync, RawTable<(i32, [i32; 3])>: Sync, RawTable<(i32, [f64; 3])>: Sync,

§

impl Unpin for Entities
where *const u8 is !null: Unpin, &'static VanillaEntitySize: Unpin, Box<[(u8, MetaValue)]>: Unpin, Box<[Option<Item>; 8]>: Unpin, Box<Links>: Unpin, Box<Client>: Unpin, Box<State>: Unpin, &'static [u16]: Unpin, Box<str>: Unpin, *const u8: Unpin, Align8<*mut ()>: Unpin, &'static Vtable: Unpin,

§

impl UnsafeUnpin for Entities

§

impl UnwindSafe for Entities

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.