Expand description
Entity tracking for the ghast Minecraft Java Edition client library (1.8.9 and 1.16.5).
v1_8::Tracker / v1_16_5::Tracker take raw clientbound play packets
(ghast_protocol::RawPacket) and keep every entity the server announced, keyed by id:
type, UUID, server position (exactly as the vanilla client tracks it from the packets,
with each version’s fixed-point rules), rotation, last velocity, on-ground, riding / leash
links, and optionally metadata, equipment, effects and the tab list.
- Cheap. Packets are parsed by hand straight from the packet body; movement, look,
teleport, velocity, head-rotation and destroy packets do not allocate. Lookups are one hash
of the id. Parts nobody needs are switched off in
Config, andTracker::wants(id)/packet_ids()tell the client which packets it can drop before decoding. - Vanilla semantics. Spawns replace an existing id, unknown types spawn nothing, moves
for unknown ids are ignored,
loginand world changes clear everything, pickups remove the item (1.16: when its stack runs out), riding follows each version’s rules. - Never panics on server data: malformed bodies return a
ghast_protocol::DecodeError.
use ghast_entity::{Config, v1_8::Tracker};
let tracker = Tracker::new(Config::default());
assert!(tracker.get(42).is_none());Modules§
Structs§
- Config
- What the tracker keeps. Everything off costs nothing beyond position tracking; packets for a disabled part are not parsed (and the client should not even decode them, see the version modules’ packet id lists).
- Effect
- An active status effect as the server reported it.
- Entities
- The tracked entities and tab list (queries are the same for every version).
- Entity
- A tracked entity, as the vanilla client knows it from the server’s packets.
- Item
- An item stack (equipment, item entities, metadata).
- Metadata
- The metadata of one entity:
(index, value)pairs, at most one per index, in arrival order. - Player
Info - A tab-list entry (
#[non_exhaustive]: read-only for callers, fields may be added).
Enums§
- Applied
- What applying a packet did.
- Entity
Class - Version-independent classification of an entity.
- Entity
Type - What kind of entity this is, in the id space of the packet that spawned it.
- Event
- A change notification (only queued with
Config::events). - Meta
Value - One entity metadata value (union of the 1.8 and 1.16.5 serializer types).
Constants§
- EQUIPMENT_
SLOTS - Number of equipment slots kept (1.16: main hand, off hand, feet, legs, chest, head; 1.8: held, boots, leggings, chestplate, helmet in slots 0..=4).