Skip to main content

Crate ghast_entity

Crate ghast_entity 

Source
Expand description

Entity tracking for the ghast Minecraft Java Edition client library (1.8.9, 1.12.2, 1.16.5 and 26.1).

v1_8::Tracker / v1_12::Tracker / v1_16_5::Tracker / v26_1::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, and Tracker::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, login and 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§

v1_8
1.8.x (protocol 47) entity tracking.
v1_12
1.12.2 (protocol 340) entity tracking: the first member of the 1.9 – 1.12 family (the packets and client rules below are shared by 1.9 – 1.12; only 1.12.2 is implemented).
v1_16_5
1.16.5 (protocol 754) entity tracking.
v26_1
26.1 (protocol 775) entity tracking.

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.
PlayerInfo
A tab-list entry (#[non_exhaustive]: read-only for callers, fields may be added).

Enums§

Applied
What applying a packet did.
EntityClass
Version-independent classification of an entity.
EntityType
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).
MetaValue
One entity metadata value (union of the 1.8, 1.12.2 and 1.16.5 serializer types; variants marked 1.16 also occur in 1.12 where 1.12 has that serializer).

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).