pub struct Entity { /* private fields */ }Expand description
A tracked entity, as the vanilla client knows it from the server’s packets.
Implementations§
Source§impl Entity
impl Entity
Sourcepub fn entity_type(&self) -> EntityType
pub fn entity_type(&self) -> EntityType
Type.
Sourcepub fn class(&self) -> EntityClass
pub fn class(&self) -> EntityClass
Version-independent class.
Sourcepub fn item(&self) -> Option<&Item>
pub fn item(&self) -> Option<&Item>
The stack of an item entity (from metadata; None before the server sent it or when
metadata is not tracked; 1.16 always keeps it for item entities).
Sourcepub fn dimensions(&self) -> Option<EntityDimensions>
pub fn dimensions(&self) -> Option<EntityDimensions>
Vanilla client-side dimensions: the type’s size from ghast-data (checked against the
oracle), with the variant the client applies from metadata (baby, slime size, wither
skeleton, elder guardian, small / marker armor stand, 1.16 player pose). None for
hanging entities (paintings, item frames, leash knots), whose box comes from facing.
Variants vanilla applies on the entity’s next client tick are applied immediately, and the old-min-corner quirk after a resize is not modelled.
Sourcepub fn bounding_box(&self) -> Option<[f64; 6]>
pub fn bounding_box(&self) -> Option<[f64; 6]>
Vanilla bounding box at the server position, [min_x, min_y, min_z, max_x, max_y, max_z] (bit-exact EntityDimensions::bounding_box).
Sourcepub fn position(&self) -> [f64; 3]
pub fn position(&self) -> [f64; 3]
The server position: exactly the coordinates the vanilla client tracks from the
packets (1.8: serverPos / 32.0; 1.16: the packet coordinates, rel moves applied in
1/4096 fixed point). The rendered position interpolates towards this over 3 ticks in
vanilla; a bot does not need that.
Sourcepub fn fixed_position(&self) -> [i32; 3]
pub fn fixed_position(&self) -> [i32; 3]
1.8 only: the raw server position in 1/32 blocks ([0; 3] in 1.16).
Sourcepub fn yaw(&self) -> f32
pub fn yaw(&self) -> f32
Body yaw in degrees as vanilla computes it from the angle byte (b * 360 / 256f).
Sourcepub fn head_yaw(&self) -> f32
pub fn head_yaw(&self) -> f32
Head yaw in degrees (from entity_head_rotation; mobs also at spawn).
Sourcepub fn velocity(&self) -> [f64; 3]
pub fn velocity(&self) -> [f64; 3]
Last velocity the server sent (blocks per tick), from the spawn packet or
entity_velocity. Not integrated over time.
Sourcepub fn data(&self) -> i32
pub fn data(&self) -> i32
Spawn data: object data (1.8 objects / 1.16 spawn_entity), experience orb value,
painting direction.
Sourcepub fn passengers(&self) -> &[i32]
pub fn passengers(&self) -> &[i32]
Entities riding this one (1.8: at most one).
Sourcepub fn leash_holder(&self) -> Option<i32>
pub fn leash_holder(&self) -> Option<i32>
Entity holding this one’s leash.