Class BukkitBrain

java.lang.Object
me.gamercoder215.mobchip.bukkit.BukkitBrain
All Implemented Interfaces:
EntityBrain

public class BukkitBrain extends Object implements EntityBrain
Bukkit Implementation of EntityBrain
See Also:
  • Method Details

    • getBrain

      @Nullable public static @Nullable EntityBrain getBrain(@Nullable @Nullable Mob m)
      Get the EntityBrain of this Mob.
      Parameters:
      m - Mob to get
      Returns:
      EntityBrain
    • getBrain

      @Nullable public static @Nullable DragonBrain getBrain(@Nullable @Nullable EnderDragon d)
      Gets the DragonBrain of this EnderDragon.
      Parameters:
      d - EnderDragon to get
      Returns:
      DragonBrain
    • registerSensor

      public static void registerSensor(@NotNull @NotNull Sensor<?> sensor) throws IllegalArgumentException
      Registers a Sensor.
      Parameters:
      sensor - Sensor to Register
      Throws:
      IllegalArgumentException - if sensor is already registered with this key
    • isSensorRegistered

      public static boolean isSensorRegistered(@NotNull @NotNull Sensor<?> sensor)
      Checks whether this sensor is registered.
      Parameters:
      sensor - Sensor to check
      Returns:
      true if registered, false otherwise
    • isSensorRegistered

      public static boolean isSensorRegistered(@NotNull @NotNull NamespacedKey key)
      Checks whether a sensor is registered with this key.
      Parameters:
      key - NamespacedKey of the Sensor
      Returns:
      true if registered, false otherwise
    • getRegisteredSensor

      @Nullable public static @Nullable Sensor<?> getRegisteredSensor(@NotNull @NotNull NamespacedKey key)
      Fetches the Sensor registered with this key.
      Parameters:
      key - NamespacedKey of the Sensor
      Returns:
      Sensor Registered, or null if not found
    • getGoalAI

      @NotNull public @NotNull EntityAI getGoalAI()
      Get the Entity AI associated with this Brain.
      Specified by:
      getGoalAI in interface EntityBrain
      Returns:
      Entity AI
    • getAttributeInstance

      @NotNull public @NotNull AttributeInstance getAttributeInstance(@NotNull @NotNull Attribute a)
      Fetches the MobChip Attribute Instance.
      Specified by:
      getAttributeInstance in interface EntityBrain
      Parameters:
      a - Attribute to use
      Returns:
      AttributeInstance
    • getTargetAI

      @NotNull public @NotNull EntityAI getTargetAI()
      Get the Entity Target AI associated with this Brain.
      Specified by:
      getTargetAI in interface EntityBrain
      Returns:
      Entity Target AI
    • createNavigation

      @NotNull public @NotNull EntityNavigation createNavigation()
      Creates new Entity Navigation associated with this Brain.
      Specified by:
      createNavigation in interface EntityBrain
      Returns:
      Created Entity Navigation
    • getController

      @NotNull public @NotNull EntityController getController()
      Get the Entity Controller associated with this Brain.
      Specified by:
      getController in interface EntityBrain
      Returns:
      Entity Controller
    • getScheduleManager

      @NotNull public @NotNull EntityScheduleManager getScheduleManager()
      Gets the EntityScheduleManager associated with this Brain.
      Specified by:
      getScheduleManager in interface EntityBrain
      Returns:
      EntityScheduleManager
    • getBehaviors

      public EntityBehavior getBehaviors()
      Get the Entity's Scheduling Manager associated with this Brain.
      Specified by:
      getBehaviors in interface EntityBrain
      Returns:
      Schedule Manager
    • getBody

      @NotNull public @NotNull EntityBody getBody()
      Fetches the Entity Body Editor.
      Specified by:
      getBody in interface EntityBrain
      Returns:
      Entity Body Editor
    • getCombatTracker

      @NotNull public @NotNull EntityCombatTracker getCombatTracker()
      Description copied from interface: EntityBrain
      Fetches the Entity's Combat Tracker.
      Specified by:
      getCombatTracker in interface EntityBrain
      Returns:
      Entity Combat Tracker
    • getSenses

      @NotNull public @NotNull EntitySenses getSenses()
      Description copied from interface: EntityBrain
      Fetches this Entity's Senses.
      Specified by:
      getSenses in interface EntityBrain
      Returns:
      Entity Senses
    • setMemory

      public <T> void setMemory(@NotNull @NotNull Memory<T> memory, @Nullable T value) throws IllegalArgumentException
      Sets a permanent memory into this entity's brain.
      Specified by:
      setMemory in interface EntityBrain
      Type Parameters:
      T - Memory Type
      Parameters:
      memory - Memory to change
      value - Value of new memory, null to remove
      Throws:
      IllegalArgumentException - if the value is not suitable for this memory
    • setMemory

      public <T> void setMemory(@NotNull @NotNull Memory<T> memory, @Nullable T value, long expire) throws IllegalArgumentException
      Sets a temporary memory into this entity's brain.

      Removing ANY memory should be using setMemory(Memory, Object) with null as the second parameter.

      Specified by:
      setMemory in interface EntityBrain
      Type Parameters:
      T - Memory Type
      Parameters:
      memory - Memory to change
      value - Value of new memory
      expire - How many ticks until this memory will be forgotten/removed
      Throws:
      IllegalArgumentException - if the value is not suitable for this memory / ticks amount is invalid
    • getMemory

      @Nullable public <T> T getMemory(@NotNull @NotNull Memory<T> memory)
      Fetch the Memory that is stored in this Entity's Brain.
      Specified by:
      getMemory in interface EntityBrain
      Type Parameters:
      T - Memory Type
      Parameters:
      memory - Memory to fetch
      Returns:
      Found value as an object, null if not present
    • getExpiration

      public long getExpiration(@NotNull @NotNull Memory<?> memory)
      Get the expiration date of this Memory.
      Specified by:
      getExpiration in interface EntityBrain
      Parameters:
      memory - Memory to fetch
      Returns:
      Found expiration date, or 0 if no expiration or not found
    • containsMemory

      public boolean containsMemory(@NotNull @NotNull Memory<?> memory)
      Whether this Brain contains this memory.
      Specified by:
      containsMemory in interface EntityBrain
      Parameters:
      memory - Memory to fetch
      Returns:
      true if contains, else false
    • removeMemory

      public void removeMemory(@NotNull @NotNull Memory<?> memory)
      Description copied from interface: EntityBrain
      Removes a Memory from this EntityBrain.
      Specified by:
      removeMemory in interface EntityBrain
      Parameters:
      memory - Memory to remove
    • getMemoryStatus

      public MemoryStatus getMemoryStatus(@NotNull @NotNull Memory<?> memory)
      Description copied from interface: EntityBrain
      Fetches the status of a Memory.
      Specified by:
      getMemoryStatus in interface EntityBrain
      Parameters:
      memory - Memory to fetch
      Returns:
      Memory Status inside the brain.
    • isInRestriction

      public boolean isInRestriction()
      Whether this Entity is in its restriction area.
      Specified by:
      isInRestriction in interface EntityBrain
      Returns:
      true if inside, else false
    • setRestrictionArea

      public void setRestrictionArea(Location center, int radius)
      Sets the Restriction Area for this Entity.
      Specified by:
      setRestrictionArea in interface EntityBrain
      Parameters:
      center - Location center
      radius - Radius of restriction center
    • clearRestrictionArea

      public void clearRestrictionArea()
      Clears this Entity's Restriction Area.
      Specified by:
      clearRestrictionArea in interface EntityBrain
    • getRestrictionArea

      public Location getRestrictionArea()
      Gets the current restriction area.
      Specified by:
      getRestrictionArea in interface EntityBrain
      Returns:
      Restriction Area
    • hasRestriction

      public boolean hasRestriction()
      Whether this entity has a restriction area.
      Specified by:
      hasRestriction in interface EntityBrain
      Returns:
      true if it has a restriction area, else false
    • getRestrictionRadius

      public int getRestrictionRadius()
      Fetch the current restriction radius for this entity.
      Specified by:
      getRestrictionRadius in interface EntityBrain
      Returns:
      Restriction Radius
    • canSee

      public boolean canSee(@Nullable @Nullable Entity en)
      Whether this Mob can see another Entity.
      Specified by:
      canSee in interface EntityBrain
      Parameters:
      en - Entity to test
      Returns:
      true if entity can see, else false
    • getEntity

      @NotNull public @NotNull Mob getEntity()
      Get the Entity that this Brain relates to.
      Specified by:
      getEntity in interface EntityBrain
      Returns:
      Entity of this brain