Package de.Keyle.MyPet.api.entity
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
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 thatPetManagerround-trips between active and inactive states. "Mutations" return new instances viawithXorBuilder.Pet— the active runtime pet. Extends this interfacenon-sealedso that plugin-side concretes can extend it without being named in the seal.
-
Method Summary
Modifier and TypeMethodDescriptiondefault ComponentMiniMessage-rendered pet name.doublegetExp()Raw accumulated experience points.doubleCurrent health (half-hearts).longEpoch millis of the last time this pet was active in the world.default intgetLevel()Pet's experience level — derived fromgetExp()and the skilltree's XP curve viaExperienceCache.intFollow-distance scale, a step from1(very close) to5(very far).intPersonal-space scale, a step from1(very close) to5(very far).getOwner()The player who owns this pet.Raw pet name in MiniMessage format.The mob type this pet represents (e.g., Wolf, Creeper).intSeconds remaining on the respawn timer.doubleHunger level (1–100).The assigned skilltree, ornullif none is set.getUUID()Globally unique identifier for this pet instance (persisted).This pet's sound-volume override.The world-group this pet belongs to (multi-world isolation).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.booleanIftrue, the pet will auto-spawn on the owner's next login.
-
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
MiniMessage-rendered pet name. Default implementation deserializesgetPetName()viaUtil.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 fromgetExp()and the skilltree's XP curve viaExperienceCache. Returns0if 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
0if the curve has not been computed yet
-
getHealth
double getHealth()Current health (half-hearts). Zero when dead.- Returns:
- current health in half-hearts;
0when 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;
0when alive
-
wantsToRespawn
boolean wantsToRespawn()Iftrue, the pet will auto-spawn on the owner's next login.- Returns:
trueif 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, ornullif none is set.- Returns:
- the assigned skilltree, or
nullif none is set
-
getMinDistanceStep
int getMinDistanceStep()Personal-space scale, a step from1(very close) to5(very far). The block value derives from the pet's hitbox width; seePetDistanceMath.- Returns:
- the min distance step,
1..5
-
getMaxDistanceStep
int getMaxDistanceStep()Follow-distance scale, a step from1(very close) to5(very far). The block value derives from the pet's hitbox width; seePetDistanceMath.- 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 rawgetSkillInfo()blobDispatches over the sealed permits:
PersistedPet: looks up theSkillStateCodecregistered forskillClassand reads the per-skill compound fromskillInfo.Pet(live): asks the liveSkillinstance for its current state viaSkill.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 forskillClass.- Type Parameters:
S- the skill whose state is wantedT- the state record that skill persists- Parameters:
skillClass- the skill api type, e.g.Backpack.classstateClass- the skill's nestedStateclass — must match what the skill's codec /getStateproduces, otherwise returns empty- Returns:
- the skill's state, or empty when the skill has none persisted
-