Class TargetSelector

java.lang.Object
net.minestom.server.entity.ai.TargetSelector
Direct Known Subclasses:
ClosestEntityTarget, LastEntityDamagerTarget

public abstract class TargetSelector
extends java.lang.Object
The target selector is called each time the entity receives an "attack" instruction without having a target.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected EntityCreature entityCreature  
  • Constructor Summary

    Constructors 
    Constructor Description
    TargetSelector​(EntityCreature entityCreature)  
  • Method Summary

    Modifier and Type Method Description
    abstract Entity findTarget()
    Finds the target.
    EntityCreature getEntityCreature()
    Gets the entity linked to this target selector.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

  • Method Details

    • findTarget

      @Nullable public abstract Entity findTarget()
      Finds the target.

      Returning null means that this target selector didn't find any entity, the next TargetSelector will be called until the end of the list or an entity is found.

      Returns:
      the target, null if not any
    • getEntityCreature

      @NotNull public EntityCreature getEntityCreature()
      Gets the entity linked to this target selector.
      Returns:
      the entity