Interface StoredPet

All Known Subinterfaces:
Pet, PetAmphibiousEntity, PetAquaticEntity, PetBaby, PetEquipment, PetFlyingEntity, PetInteractionGate, PetLightningConvertible, PetMetamorphic, PetNaturalDrop, PetSittable, PetSunSensitive, PetSwimmingEntity, PetWaterSensitive, PetZombifiable
All Known Implementing Classes:
PersistedPet

public sealed interface StoredPet permits PersistedPet, Pet
Read-only view of a pet at rest. Sealed: the only permitted implementations are
  • PersistedPet — the immutable record that the repository loads from disk and that PetManager round-trips between active and inactive states. "Mutations" return new instances via withX or Builder.
  • Pet — the active runtime pet. Extends this interface non-sealed so that plugin-side concretes can extend it without being named in the seal.
  • Method Details

    • getUUID

      UUID getUUID()
      Globally unique identifier for this pet instance (persisted).
      Returns:
      this pet's persistent unique id
    • getOwner

      MyPetPlayer getOwner()
      The player who owns this pet.
      Returns:
      the pet's owner
    • getPetType

      PetType getPetType()
      The mob type this pet represents (e.g., Wolf, Creeper).
      Returns:
      the species this pet is
    • getPetName

      String getPetName()
      Raw pet name in MiniMessage format.
      Returns:
      the raw name, in MiniMessage form
    • getDisplayName

      default Component getDisplayName()
      MiniMessage-rendered pet name. Default implementation deserializes getPetName() via Util.SANITIZED_MINIMESSAGE; both implementations were previously identical.
      Returns:
      the name rendered for display
    • getWorldGroup

      String getWorldGroup()
      The world-group this pet belongs to (multi-world isolation).
      Returns:
      the world group this pet belongs to
    • getExp

      double getExp()
      Raw accumulated experience points.
      Returns:
      the raw accumulated experience
    • getLevel

      default int getLevel()
      Pet's experience level — derived from getExp() and the skilltree's XP curve via ExperienceCache. Returns 0 if the cache has no curve loaded for this pet's world group / type (e.g., before skilltrees have finished loading, or for a pet whose world group has no configured curve).
      Returns:
      the pet's level, or 0 if the curve has not been computed yet
    • getHealth

      double getHealth()
      Current health (half-hearts). Zero when dead.
      Returns:
      current health in half-hearts; 0 when dead
    • getSaturation

      double getSaturation()
      Hunger level (1–100). Drains over time; restored by feeding.
      Returns:
      the hunger level, from 1 to 100
    • getRespawnTime

      int getRespawnTime()
      Seconds remaining on the respawn timer. Zero when alive.
      Returns:
      seconds left on the respawn timer; 0 when alive
    • wantsToRespawn

      boolean wantsToRespawn()
      If true, the pet will auto-spawn on the owner's next login.
      Returns:
      true if the pet returns on the owner's next login
    • getLastUsed

      long getLastUsed()
      Epoch millis of the last time this pet was active in the world.
      Returns:
      epoch milliseconds of the pet's last activity
    • getSkilltree

      Skilltree getSkilltree()
      The assigned skilltree, or null if none is set.
      Returns:
      the assigned skilltree, or null if none is set
    • getMinDistanceStep

      int getMinDistanceStep()
      Personal-space scale, a step from 1 (very close) to 5 (very far). The block value derives from the pet's hitbox width; see PetDistanceMath.
      Returns:
      the min distance step, 1..5
    • getMaxDistanceStep

      int getMaxDistanceStep()
      Follow-distance scale, a step from 1 (very close) to 5 (very far). The block value derives from the pet's hitbox width; see PetDistanceMath.
      Returns:
      the max distance step, 1..5
    • getVolume

      OptionalDouble getVolume()
      This pet's sound-volume override.
      Returns:
      the override in [0, 1], or empty when this pet inherits its owner's setting
    • skillState

      default <S extends Skill, T extends SkillState> Optional<T> skillState(Class<S> skillClass, Class<T> stateClass)
      Typed access to a skill's persisted or live state. Replaces the pre-4.0.0 raw getSkillInfo() blob

      Dispatches over the sealed permits:

      • PersistedPet: looks up the SkillStateCodec registered for skillClass and reads the per-skill compound from skillInfo.
      • Pet (live): asks the live Skill instance for its current state via Skill.getState().

      Returns Optional.empty() if the skill isn't registered with the pet, the skill has no state to expose, or (persisted only) no codec is registered for skillClass.

      Type Parameters:
      S - the skill whose state is wanted
      T - the state record that skill persists
      Parameters:
      skillClass - the skill api type, e.g. Backpack.class
      stateClass - the skill's nested State class — must match what the skill's codec / getState produces, otherwise returns empty
      Returns:
      the skill's state, or empty when the skill has none persisted