Class PetGoalRetention
PetGoalInstaller
should keep on the live mob at spawn time, instead of stripping every goal
via Bukkit.getMobGoals().removeAllGoals(mob).
The default behavior — when no PetGoalRetention is declared for a
pet type — is to strip every vanilla goal. This works for pets whose vanilla
AI MyPet replaces entirely with its own goals (Wolf, Pig, Camel, etc.). But
some pet types have vanilla goals that are uniquely valuable (e.g., Phantom's
PhantomCircleAroundAnchorGoal translates the per-tick
setAnchorLocation into orbit motion via moveTargetPoint;
stripping it leaves the phantom flying toward Vec3.ZERO). Declaring a
retention list keeps those goals intact.
Declared as a static field on the matching PetXxx class:
public static final PetGoalRetention GOAL_RETENTION = new PetGoalRetention(
"Phantom",
"phantom_circle_around_anchor");
Construction self-registers with PetGoalRetentionRegistry.
PetGoalInstaller consults the registry per spawned pet and removes
only the goals whose key isn't in the retention set.
Goal names are the path part of the vanilla GoalKey's
NamespacedKey (i.e., the snake_case identifier without the
minecraft: namespace). Match by name avoids per-mob Goal
subclass typing concerns and is stable across Mojang's occasional
reorganization of vanilla goal classes.
The set of names is stored in declaration order (a LinkedHashSet)
for stable log output if the installer ever logs retained goals.
-
Constructor Summary
ConstructorsConstructorDescriptionPetGoalRetention(String petType, String... goalKeyNames) Declares the goals to keep for one pet type, registering itself as it is built. -
Method Summary
Modifier and TypeMethodDescriptionReturns the goals to keep, in declaration order.petType()Returns the pet type this declaration applies to.
-
Constructor Details
-
PetGoalRetention
Declares the goals to keep for one pet type, registering itself as it is built.- Parameters:
petType- the pet type these goals belong togoalKeyNames- namespaced vanilla goal keys to keep on the live mob
-
-
Method Details
-
petType
Returns the pet type this declaration applies to.- Returns:
- the pet type name
-
goalKeyNames
Returns the goals to keep, in declaration order.- Returns:
- an immutable set of vanilla goal-key names
-