Interface Skill

All Known Subinterfaces:
Armor, Backpack, Beacon, Behavior, Bleed, Camouflage, Climb, Control, Damage, Fire, Fishing, Heal, Knockback, Life, Lightning, Lumberjack, Mining, Pickup, Poison, Potion, Ranged, Ride, Scale, Shield, Slow, Sniff, Sprint, Stomp, Taunt, Thorns, Toolbox, Wither

public interface Skill
Base interface for all pet skills in the MyPet skill system.

Each skill has a name (derived from the SkillName annotation on its implementation class), belongs to a specific pet, and can be activated/deactivated as the pet gains levels and receives upgrades from its Skilltree.

Skills report their current status through toPrettyComponent(String) (for display to the player) and may optionally expose internal state via getState().

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Absorbs a previously persisted SkillState back into the live skill's mutable fields.
    default String
    Returns the internal name of this skill, as declared in its SkillName annotation.
    default Component
    getName(String locale)
    Returns the localized display name of this skill for the given locale.
    Returns the pet that owns this skill instance.
    default Optional<? extends SkillState>
    Returns this skill's current runtime state as a typed SkillState record, or Optional.empty() if the skill has no persisted state worth exposing (the default — most skills' behavior is fully driven by skilltree upgrade levels).
    Returns the message components to display to the player when this skill receives an upgrade.
    boolean
    Returns true if this skill has been activated (i.e., at least one upgrade has been applied).
    void
    Resets this skill to its initial inactive state, undoing all upgrades.
    Builds a human-readable component summarizing this skill's current state for display in the pet's skill info panel.
  • Method Details

    • getName

      default String getName()
      Returns the internal name of this skill, as declared in its SkillName annotation.
      Returns:
      the skill name, or null if the annotation is missing
    • getName

      default Component getName(String locale)
      Returns the localized display name of this skill for the given locale.

      If the skill's SkillName annotation specifies a translationNode, the localized component for that node is returned. Falls back to the annotation's value() if no node is defined.

      Parameters:
      locale - the locale code to translate into
      Returns:
      the display name component, or null if the annotation is missing
    • getPet

      Pet getPet()
      Returns the pet that owns this skill instance.
      Returns:
      the pet this skill instance belongs to
    • isActive

      boolean isActive()
      Returns true if this skill has been activated (i.e., at least one upgrade has been applied).
      Returns:
      true if the skilltree has granted this skill at the pet's level
    • reset

      void reset()
      Resets this skill to its initial inactive state, undoing all upgrades.
    • toPrettyComponent

      Component toPrettyComponent(String locale)
      Builds a human-readable component summarizing this skill's current state for display in the pet's skill info panel.
      Parameters:
      locale - the player's locale code for translation
      Returns:
      a formatted text component
    • getUpgradeMessage

      Component[] getUpgradeMessage()
      Returns the message components to display to the player when this skill receives an upgrade.
      Returns:
      an array of text components (one per line), or an empty array if silent
    • getState

      default Optional<? extends SkillState> getState()
      Returns this skill's current runtime state as a typed SkillState record, or Optional.empty() if the skill has no persisted state worth exposing (the default — most skills' behavior is fully driven by skilltree upgrade levels).

      Implementations should construct a fresh, immutable record each call from their current fields. Used by StoredPet#skillState on the live-pet branch (the persisted-pet branch consults the registered SkillStateCodec instead). A skill that registers a codec must also implement this method — MyPet calls getState() to obtain the state the codec serializes to NBT.

      Returns:
      the state to persist, or empty when this skill stores nothing
    • applyState

      default void applyState(SkillState state)
      Absorbs a previously persisted SkillState back into the live skill's mutable fields. Called by MyPet on activation (and on pet-type change) when a SkillStateCodec is registered for this skill — the codec produces the state from NBT, this method writes it onto the skill instance.

      Codec-using skills should narrow state to their registered state type and apply it. The default is a no-op so skills that don't persist mutable runtime state can ignore it entirely.

      Parameters:
      state - the previously persisted state to restore