LivingEntity
LivingEntity
Section titled “LivingEntity”Package:
com.hypixel.hytale.server.core.entity
public abstract class LivingEntity extends EntityAbstract base class for entities that are “alive” — entities with health, inventories, stat modifiers, and fall damage mechanics. Extends Entity with inventory management, item durability tracking, breathing logic, and stat modifier infrastructure.
Player is the primary concrete subclass. NPC and mob entity types also extend LivingEntity.
Methods
Section titled “Methods”Inventory
Section titled “Inventory”protected abstract Inventory createDefaultInventory();Creates the default inventory for this entity type. Each subclass defines its own inventory layout and capacity. Called during entity initialization when no saved inventory data is available.
public Inventory getInventory()Returns this entity’s current inventory.
@Nonnullpublic Inventory setInventory(Inventory inventory)Replaces this entity’s inventory with the given inventory. Returns the previous inventory.
@Nonnullpublic Inventory setInventory(Inventory inventory, boolean ensureCapacity)Replaces this entity’s inventory. When ensureCapacity is true, the new inventory is validated to have at least the capacity required by this entity type. Returns the previous inventory.
Breathing
Section titled “Breathing”public boolean canBreathe(@Nonnull Ref<EntityStore> ref, @Nonnull BlockMaterial breathingMaterial, int fluidId, @Nonnull ComponentAccessor<EntityStore> componentAccessor)Returns whether this entity can breathe in the given material and fluid context. Used by the suffocation/drowning system to determine whether the entity should take breathing damage. The default implementation checks the entity’s breathing capabilities against the block material at its head position.
Item Durability
Section titled “Item Durability”public boolean canDecreaseItemStackDurability(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor)Returns whether this entity’s item usage should consume durability. Some game modes or entity states may disable durability loss.
@Nullablepublic ItemStackSlotTransaction decreaseItemStackDurability(@Nonnull Ref<EntityStore> ref, @Nullable ItemStack itemStack, int inventoryId, int slotId, @Nonnull ComponentAccessor<EntityStore> componentAccessor)Decreases the durability of the item stack at the specified inventory slot. Returns an ItemStackSlotTransaction representing the change, or null if durability could not be decreased (item is null, entity cannot decrease durability, or item has no durability).
@Nullablepublic ItemStackSlotTransaction updateItemStackDurability(@Nonnull Ref<EntityStore> ref, @Nonnull ItemStack itemStack, ItemContainer container, int slotId, double durabilityChange, @Nonnull ComponentAccessor<EntityStore> componentAccessor)Applies a durability change (positive or negative) to the given item stack. Handles item breaking when durability reaches zero. Returns an ItemStackSlotTransaction representing the change, or null if the update could not be applied.
Stat Modifiers
Section titled “Stat Modifiers”@Nonnullpublic StatModifiersManager getStatModifiersManager()Returns the stat modifiers manager for this entity. StatModifiersManager tracks active stat modifiers (e.g., speed boosts, damage buffs, resistance effects) and computes effective stat values by combining base stats with active modifiers.
Fall Damage
Section titled “Fall Damage”public double getCurrentFallDistance()Returns the current accumulated fall distance in blocks. Fall distance accumulates while the entity is falling and resets when the entity lands. Used by the fall damage system to calculate damage on landing. The damage calculation considers the entity’s stat modifiers (e.g., fall damage resistance).
Serialization
Section titled “Serialization”LivingEntity has a BuilderCodec CODEC that extends Entity.CODEC with additional fields for inventory state, stat modifiers, and fall distance tracking.
Related Types
Section titled “Related Types”- Entity — parent class providing identity, lifecycle, and world membership
- Player — concrete player entity extending
LivingEntity Inventory— container for the entity’s itemsItemStack— a stack of items within an inventoryItemStackSlotTransaction— records an inventory slot mutation for durability changesItemContainer— abstraction over inventory containersBlockMaterial— block material used in breathing checksStatModifiersManager— manages active stat modifiers and effective stat computation- Store — the
EntityStorecontaining this entity’s component data - Ref — entity reference passed to most methods
- ComponentType — type key for ECS component access