pub struct Tracker { /* private fields */ }Expand description
The bot’s entity view on a modern (26.1 / 26.2) connection. Dereferences to the shared Entities.
Implementations§
Source§impl Tracker
impl Tracker
Sourcepub fn tick_seq(&self, id: i32) -> Option<u64>
pub fn tick_seq(&self, id: i32) -> Option<u64>
The entity’s place in the client’s tick list (ClientLevel.tickingEntities, the order
tickEntities runs them in and, within a chunk section, the order getEntities lists
them in): a number that grows with each entity that starts ticking; None while it does
not tick. Entities start ticking when they spawn into a loaded chunk column, when their
column loads, or when they move into a loaded column; they stop when removed or when their
column unloads, and re-enter at the end. The local player (its id from the login packet)
enters first at login and at a dimension change, and last at a respawn in the same
dimension. Several entities entering at the same moment for a column load or a move are
ordered by id (vanilla’s order there follows its section storage). After 2³² − 1 entries
the numbers restart from 1 with the order kept.
Sourcepub fn tick_order(&self) -> Vec<i32>
pub fn tick_order(&self) -> Vec<i32>
The ids of the ticking entities (the local player included) in the client’s tick order
(see Tracker::tick_seq).
Sourcepub fn store_mut(&mut self) -> &mut Entities
pub fn store_mut(&mut self) -> &mut Entities
The shared store, mutable for Entities::drain_events.
Sourcepub fn wants(&self, id: i32) -> bool
pub fn wants(&self, id: i32) -> bool
true when this tracker wants packet id (for a PacketFilter).
Sourcepub fn packet_ids(&self) -> impl Iterator<Item = i32> + '_
pub fn packet_ids(&self) -> impl Iterator<Item = i32> + '_
Every packet id this tracker wants.
Sourcepub fn chunk_loaded(&self, p: [f64; 3]) -> bool
pub fn chunk_loaded(&self, p: [f64; 3]) -> bool
true when the chunk column holding p is loaded (its entities tick).
Sourcepub fn mark_column_loaded(&mut self, x: i32, z: i32)
pub fn mark_column_loaded(&mut self, x: i32, z: i32)
A chunk column became loaded (what a map_chunk packet does here; for a tracker started
while chunks are already loaded): its entities tick again.
Sourcepub fn mark_column_unloaded(&mut self, x: i32, z: i32)
pub fn mark_column_unloaded(&mut self, x: i32, z: i32)
A chunk column was unloaded (unload_chunk): its entities stop ticking.
Sourcepub fn is_ticking(&self, e: &Entity) -> bool
pub fn is_ticking(&self, e: &Entity) -> bool
ClientLevel.isTickingEntity: players always tick, other entities while their chunk
column is loaded.
Sourcepub fn pickable(&self, e: &Entity) -> bool
pub fn pickable(&self, e: &Entity) -> bool
Whether vanilla’s crosshair pick can hit e: its type is pickable (isPickable), it is
not an armor stand marker, and not a spectator (players: tab list game mode 3).
Sourcepub fn game_mode(&self, e: &Entity) -> Option<i32>
pub fn game_mode(&self, e: &Entity) -> Option<i32>
The game mode vanilla’s client knows for player entity e
(AbstractClientPlayer.getPlayerInfo): its tab-list entry (full list or
Config::player_names); an entity that already looked its entry up keeps that entry’s
last game mode after the entry left the tab list. None for other entities, or without a
tab list.
Sourcepub fn is_spectator(&self, e: &Entity) -> bool
pub fn is_spectator(&self, e: &Entity) -> bool
isSpectator of a player entity (game mode 3, see Tracker::game_mode): spectators are
not pickable, not pushable and never on the ground. false for other entities.
Sourcepub fn scoreboard_name<'a>(&'a self, e: &'a Entity) -> Option<&'a str>
pub fn scoreboard_name<'a>(&'a self, e: &'a Entity) -> Option<&'a str>
getScoreboardName (what team rules match): a player’s profile name (the tab-list entry
it spawned with, kept after the entry left), else None; vanilla uses the UUID string
for other entities. Needs the full tab list or Config::player_names.
Sourcepub fn tick(&mut self)
pub fn tick(&mut self)
One client tick of the tracked entities (ClientLevel.tickEntities): every entity in a
loaded chunk takes one interpolation step and one head-rotation step. Call it once per
client tick, after the tick’s crosshair pick (see the module docs). Assumes the
moved interpolation target never collides; use Tracker::tick_with for vanilla’s check.
Sourcepub fn tick_with(&mut self, no_collision: impl FnMut(&Entity, [f64; 6]) -> bool)
pub fn tick_with(&mut self, no_collision: impl FnMut(&Entity, [f64; 6]) -> bool)
Tracker::tick with vanilla’s collision test: when an entity moved since its last
interpolation step (a snap, a teleport, a bed position), the step first moves the target
along, but only if no_collision(entity, box) says the entity’s box at the moved target
([min_x, min_y, min_z, max_x, max_y, max_z]) is free (Level.noCollision: blocks,
collidable entities, world border).
Sourcepub fn tick_early(
&mut self,
id: i32,
no_collision: impl FnMut(&Entity, [f64; 6]) -> bool,
) -> Option<[f64; 3]>
pub fn tick_early( &mut self, id: i32, no_collision: impl FnMut(&Entity, [f64; 6]) -> bool, ) -> Option<[f64; 3]>
Ticks entity id now, ahead of the rest of this client tick (a vehicle ticks before
its passenger: the local player riding a vehicle the server moves reads where the vehicle
is after its tick). The next Tracker::tick_with skips it once. Returns its position
after the tick (None: not tracked).
Sourcepub fn apply(&mut self, raw: &RawPacket) -> Result<Applied, DecodeError>
pub fn apply(&mut self, raw: &RawPacket) -> Result<Applied, DecodeError>
Applies one clientbound play packet.
§Errors
A malformed body (multi-entry packets may be partly applied).
Sourcepub fn apply_body(
&mut self,
packet_id: i32,
body: &Bytes,
) -> Result<Applied, DecodeError>
pub fn apply_body( &mut self, packet_id: i32, body: &Bytes, ) -> Result<Applied, DecodeError>
Methods from Deref<Target = Entities>§
Sourcepub fn get(&self, id: i32) -> Option<&Entity>
pub fn get(&self, id: i32) -> Option<&Entity>
The entity with this id (including the bot’s own entry, see Entities::self_id).
Sourcepub fn iter(&self) -> impl Iterator<Item = &Entity>
pub fn iter(&self) -> impl Iterator<Item = &Entity>
Other entities (the bot’s own entry is skipped), arbitrary order.
Sourcepub fn self_id(&self) -> Option<i32>
pub fn self_id(&self) -> Option<i32>
The bot’s own entity id (from login). Its entry carries metadata, effects, equipment
and riding state, but no position: the client owns its own position.
Sourcepub fn within(&self, p: [f64; 3], radius: f64) -> impl Iterator<Item = &Entity>
pub fn within(&self, p: [f64; 3], radius: f64) -> impl Iterator<Item = &Entity>
Entities whose server position is within radius of p (linear scan).
Sourcepub fn near(&self, p: [f64; 3], radius: f64) -> impl Iterator<Item = &Entity>
pub fn near(&self, p: [f64; 3], radius: f64) -> impl Iterator<Item = &Entity>
Alias of Entities::within.
Sourcepub fn player_info(&self, uuid: &Uuid) -> Option<&PlayerInfo>
pub fn player_info(&self, uuid: &Uuid) -> Option<&PlayerInfo>
The tab list.
Sourcepub fn players(&self) -> impl Iterator<Item = (&Uuid, &PlayerInfo)>
pub fn players(&self) -> impl Iterator<Item = (&Uuid, &PlayerInfo)>
All tab-list entries.
Sourcepub fn player_name(&self, id: i32) -> Option<&str>
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).
Sourcepub fn tab_name(&self, uuid: &Uuid) -> Option<&str>
pub fn tab_name(&self, uuid: &Uuid) -> Option<&str>
Profile name of a tab-list entry (full list or names only).
Sourcepub fn tab_game_mode(&self, uuid: &Uuid) -> Option<i32>
pub fn tab_game_mode(&self, uuid: &Uuid) -> Option<i32>
Game mode of a tab-list entry (full list or names only).