Class PetGoalRetentionRegistry

java.lang.Object
de.Keyle.MyPet.api.goal.PetGoalRetentionRegistry

public final class PetGoalRetentionRegistry extends Object
Central registry of every PetGoalRetention declared as a static field on a pet class. Populated as a side effect of each declaration's constructor, which fires during the pet class's <clinit>.

goalNamesFor(Pet) returns the union of every vanilla goal-key name registered for the pet's type. PetGoalInstaller consults this at spawn time — if the set is empty (no retention declared), it falls back to the default removeAllGoals(mob) behavior; otherwise it iterates the live mob's goals and removes only those whose key isn't in the set.

Adding a new retention is a one-line PetGoalRetention static field on the relevant PetXxx class.

ensurePetsLoaded() force-initializes every registered pet class via Class.forName(true) so the registry is fully populated before the first spawn-side iteration. Same shape as the other pet-class registries in this package family.

  • Method Details

    • ensurePetsLoaded

      public static void ensurePetsLoaded()
      Force-initializes every registered pet class via Class.forName(true) so each one's static PetGoalRetention field initializers fire and register with this registry. Idempotent; runs once per JVM.
    • goalNamesFor

      public static Set<String> goalNamesFor(Pet pet)
      Returns the union of every vanilla goal-key name registered for pet's type. Empty set when no retentions are declared.
      Parameters:
      pet - the pet whose type to look up
      Returns:
      the goal keys to keep on that pet's mob