Class CustomAI

java.lang.Object
valorless.rarespawns.ai.CustomAI

public class CustomAI extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Hostile(org.bukkit.entity.Animals animal)
    Modifies an Animals entity to behave as a hostile mob.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CustomAI

      public CustomAI()
  • Method Details

    • Hostile

      public static void Hostile(org.bukkit.entity.Animals animal)
      Modifies an Animals entity 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 reconfigure
      player - the player treated as the owner