Interface Mob

All Superinterfaces:
CommandSource, Entity, HoverEventSource<HoverEvent.ShowEntity>, LivingEntity, SchedulerSource, Sound.Emitter, Sound.Source.Provider

public interface Mob extends LivingEntity
A living entity that moves and thinks, whether it is a built-in mob or one a plugin defined.
Since:
0.1.0
  • Method Details

    • definition

      Optional<MobDefinition> definition()
      Returns:
      the definition this mob was built from, empty for a built-in mob
      Since:
      0.1.0
    • goals

      Goals goals()
      Returns:
      the goals driving this mob, mutable
      Since:
      0.1.0
    • target

      @Nullable Player target()
      Returns:
      the player this mob is after, or null
      Since:
      0.1.0
    • setTarget

      void setTarget(@Nullable Player target)
      Sets the player this mob is after.

      A mob re-picks its own target every few ticks among the players within followRange(), so a target set from outside that range is dropped shortly after. Widen setFollowRange(double) first to make it stick.

      Parameters:
      target - the player to chase, or null to clear
      Since:
      0.1.0
    • nearestPlayer

      @Nullable Player nearestPlayer(double maxDistance)
      Parameters:
      maxDistance - the search radius in blocks, negative for unlimited
      Returns:
      the closest player able to be seen by mobs, or null
      Since:
      0.1.0
    • followRange

      double followRange()
      Returns:
      the radius in blocks this mob picks targets within
      Since:
      0.1.0
    • setFollowRange

      void setFollowRange(double range)
      Parameters:
      range - the radius in blocks to pick targets within, negative to restore the default
      Since:
      0.1.0
    • movementSpeed

      double movementSpeed()
      Returns:
      the walking speed this mob uses when no goal overrides it
      Since:
      0.1.0
    • setMoveSpeed

      void setMoveSpeed(double speed)
      Sets the speed the mob walks at this tick.

      The value is cleared at the start of every tick, so a goal moving a mob sets it on each one of its own ticks.

      Parameters:
      speed - the speed in blocks per tick
      Since:
      0.1.0
    • width

      double width()
      Returns:
      the hitbox width in blocks
      Since:
      0.1.0
    • height

      double height()
      Returns:
      the hitbox height in blocks
      Since:
      0.1.0
    • attackDamage

      float attackDamage()
      Returns:
      the damage a hit from this mob deals, 0 when it does not attack
      Since:
      0.1.0
    • onGround

      boolean onGround()
      Returns:
      true when the mob is standing on a block
      Since:
      0.1.0
    • velocityX

      double velocityX()
    • velocityY

      double velocityY()
    • velocityZ

      double velocityZ()
    • setVelocity

      void setVelocity(double x, double y, double z)
      Overwrites the velocity, in blocks per tick.
      Parameters:
      x - the velocity along x
      y - the velocity along y, positive upwards
      z - the velocity along z
      Since:
      0.1.0
    • lookAt

      void lookAt(double x, double y, double z)
      Turns the head and body towards a point.
      Parameters:
      x - the x coordinate to look at
      y - the y coordinate to look at
      z - the z coordinate to look at
      Since:
      0.1.0
    • lookAt

      default void lookAt(Entity entity)
      Parameters:
      entity - the entity to look at
      Since:
      0.1.0
    • distanceSqTo

      double distanceSqTo(Entity other)
      Parameters:
      other - the entity to measure to
      Returns:
      the squared distance between the two entities
      Since:
      0.1.0
    • hasLineOfSightTo

      boolean hasLineOfSightTo(Entity other)
      Parameters:
      other - the entity to look for
      Returns:
      true when no full block stands between the two
      Since:
      0.1.0
    • playSound

      void playSound(Sound.Type sound, float volume, float pitch)
      Plays a sound at this mob, heard by the players tracking it.
      Parameters:
      sound - the sound to play
      volume - the volume, 1 for the usual mob loudness
      pitch - the pitch, between 0.5 and 2
      Since:
      0.1.0
    • behaviours

      List<MobBehaviour> behaviours()
      Returns:
      the behaviours attached to this mob, in the order they were added
      Since:
      0.1.0
    • behaviour

      <T extends MobBehaviour> Optional<T> behaviour(Class<T> type)
      Type Parameters:
      T - the behaviour type
      Parameters:
      type - the behaviour implementation to look for
      Returns:
      the first behaviour of that type, empty when none is attached
      Since:
      0.1.0