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). Always None on 26.1,
whose stacks carry data components: see v26_1::item_stack / v26_1::item_count.
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 targeting_margin(&self) -> f32
pub fn targeting_margin(&self) -> f32
How much the crosshair pick grows this entity’s box (vanilla getCollisionBorderSize /
getTargetingMargin, from the type’s size table: 0.1 for most 1.8 types, 0 since 1.9,
1.0 for fireballs); 0 when the type has no size entry.
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.12: spawn / teleport coordinates, after a relative
move the tracked 1/4096 position; 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.
26.1 is different: this is the entity’s current position as the client holds it
(Entity.position()): position packets of interpolated entities (living entities, boats,
minecarts) set a target the entity reaches over 3 calls of v26_1::Tracker::tick, others
move at once. That is the position vanilla’s crosshair pick reads at tick time (with
Entity::bounding_box); the packet coordinates are v26_1::server_position.
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.12 and 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.