Skip to main content

basalt_api/components/
identity.rs

1//! Entity identity and state components.
2
3use crate::components::Component;
4
5/// Minecraft entity type ID.
6///
7/// Maps to the registry entity type (e.g., 147 = player in 1.21.4).
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub struct EntityKind {
10    /// Registry type ID.
11    pub type_id: u32,
12}
13impl Component for EntityKind {}
14
15/// Hit points for damageable entities.
16#[derive(Debug, Clone, Copy, PartialEq)]
17pub struct Health {
18    /// Current health.
19    pub current: f32,
20    /// Maximum health.
21    pub max: f32,
22}
23impl Component for Health {}
24
25/// Links an entity to a player connection.
26///
27/// Present on player entities to map between the ECS entity and
28/// the player's network state (UUID, username, output channel).
29#[derive(Debug, Clone, PartialEq, Eq)]
30pub struct PlayerRef {
31    /// Player UUID (from Mojang or offline-mode).
32    pub uuid: basalt_types::Uuid,
33    /// Player display name.
34    pub username: String,
35}
36impl Component for PlayerRef {}
37
38/// Marker component for sneaking state.
39///
40/// Added when a player starts sneaking, removed when they stop.
41/// Used by the block interaction system to determine whether
42/// right-click should interact with the clicked block or place
43/// a block instead.
44pub struct Sneaking;
45impl Component for Sneaking {}