Package valorless.rarespawns.ai
Class CustomAI
java.lang.Object
valorless.rarespawns.ai.CustomAI
Version 2 of CustomAI, allowing usage across multiple versions instead of only one.
Provides custom AI modifications for animals by injecting and overriding
their goal/target selectors using reflection. This can turn normally passive
entities into hostile ones capable of attacking players and performing combat actions.
This implementation relies heavily on reflection to remain compatible across multiple Minecraft versions. NMS (net.minecraft.server) classes and methods are dynamically resolved at runtime.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidHostile(org.bukkit.entity.Animals animal) Modifies anAnimalsentity to behave as a hostile mob.static voidTamed(org.bukkit.entity.Mob mob, org.bukkit.entity.Player player) Test method, not to be used.
Configures a mob to behave as if tamed by the given player.
-
Constructor Details
-
CustomAI
public CustomAI()
-
-
Method Details
-
Hostile
public static void Hostile(org.bukkit.entity.Animals animal) Modifies anAnimalsentity to behave as a hostile mob.The method:
- Removes default passive AI goals (such as Avoid and Panic).
- Adds targeting logic to attack players.
- Adds melee attack behavior (and leap attack for foxes).
- Schedules a repeating damage task to simulate attacks.
- Parameters:
animal- The animal to transform into a hostile entity.
-
Tamed
@TestOnly @MarkedForRemoval @DoNotCall public static void Tamed(org.bukkit.entity.Mob mob, org.bukkit.entity.Player player) Test method, not to be used.
Configures a mob to behave as if tamed by the given player.Replaces goals/targets via reflection to follow the owner, defend the owner when attacked, and use melee combat. Also schedules a repeating combat task to apply damage and swing animation when in range.
- Parameters:
mob- the mob to reconfigureplayer- the player treated as the owner
-