Class WildAngerCheckRegistry

java.lang.Object
de.Keyle.MyPet.api.entity.leashing.WildAngerCheckRegistry

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

forEntity(LivingEntity) returns the check registered for the given entity's species, or Optional.empty() if no pet class declares one. AngryFlag iterates the result without naming any specific pet type; adding a new angerable species is a one-line static field on its pet class.

ensurePetsLoaded() force-initializes every registered pet class via Class.forName(true) so the registry is fully populated before the first lookup.

  • Method Details

    • ensurePetsLoaded

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

      public static Optional<WildAngerCheck<?>> forEntity(LivingEntity entity)
      Returns the anger check registered for entity's species, or Optional.empty() if no pet class declares one (either the species isn't a MyPet pet type, or its pet class doesn't expose anger semantics).
      Parameters:
      entity - the mob whose species to look up
      Returns:
      the check for that species, or empty if none is declared