Class ClosestEntityTarget

java.lang.Object
net.minestom.server.entity.ai.TargetSelector
net.minestom.server.entity.ai.target.ClosestEntityTarget

public class ClosestEntityTarget extends TargetSelector
Target the closest targetable entity (based on the target predicate)
  • Constructor Details

    • ClosestEntityTarget

      @SafeVarargs @Deprecated public ClosestEntityTarget(@NotNull @NotNull EntityCreature entityCreature, float range, @NotNull @NotNull Class<? extends LivingEntity>... entitiesTarget)
      Parameters:
      entityCreature - the entity (self)
      range - the maximum range the entity can target others within
      entitiesTarget - the entities to target by class
    • ClosestEntityTarget

      public ClosestEntityTarget(@NotNull @NotNull EntityCreature entityCreature, double range, @NotNull @NotNull Predicate<Entity> targetPredicate)
      Parameters:
      entityCreature - the entity (self)
      range - the maximum range the entity can target others within
      targetPredicate - the predicate used to check if the other entity can be targeted
  • Method Details

    • findTarget

      public Entity findTarget()
      Description copied from class: TargetSelector
      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.

      Specified by:
      findTarget in class TargetSelector
      Returns:
      the target, null if not any