Interface Mob

All Superinterfaces:
Attributable, Audience, CommandSender, Damageable, Entity, Frictional, HoverEventSource<HoverEvent.ShowEntity>, Leashable, LivingEntity, Lootable, Metadatable, Nameable, Permissible, PersistentDataHolder, PersistentDataViewHolder, Pointered, ProjectileSource, ServerOperator, Sound.Emitter
All Known Subinterfaces:
AbstractHorse, AbstractSkeleton, AbstractVillager, Ageable, Allay, Ambient, Animals, Armadillo, Axolotl, Bat, Bee, Blaze, Bogged, Breedable, Breeze, Camel, Cat, CaveSpider, ChestedHorse, Chicken, Cod, Cow, Creaking, CreakingTransient, Creature, Creeper, Dolphin, Donkey, Drowned, ElderGuardian, EnderDragon, Enderman, Endermite, Evoker, Fish, Flying, Fox, Frog, Ghast, Giant, GlowSquid, Goat, Golem, Guardian, Hoglin, Horse, Husk, Illager, Illusioner, IronGolem, Llama, MagmaCube, Monster, Mule, MushroomCow, NPC, Ocelot, Panda, Parrot, Phantom, Pig, Piglin, PiglinAbstract, PiglinBrute, PigZombie, Pillager, PolarBear, PufferFish, Rabbit, Raider, RangedEntity, Ravager, Salmon, SchoolableFish, Sheep, Shulker, Silverfish, Skeleton, SkeletonHorse, Slime, Sniffer, Snowman, Spellcaster, Spider, Squid, Steerable, Stray, Strider, Tadpole, Tameable, TraderLlama, TropicalFish, Turtle, Vex, Villager, Vindicator, WanderingTrader, Warden, WaterMob, Witch, Wither, WitherSkeleton, Wolf, Zoglin, Zombie, ZombieHorse, ZombieVillager

public interface Mob extends LivingEntity, Lootable, Leashable
Represents a Mob. Mobs are living entities with simple AI.
  • Method Details

    • getEquipment

      @NotNull EntityEquipment getEquipment()
      Description copied from interface: LivingEntity
      Gets the inventory with the equipment worn by the living entity.
      Specified by:
      getEquipment in interface LivingEntity
      Returns:
      the living entity's inventory
    • getPathfinder

      @NotNull Pathfinder getPathfinder()
      Enables access to control the pathing of an Entity
      Returns:
      Pathfinding Manager for this entity
    • isInDaylight

      boolean isInDaylight()
      Check if this mob is exposed to daylight
      Returns:
      True if mob is exposed to daylight
    • lookAt

      void lookAt(@NotNull Location location)
      Instruct this Mob to look at a specific Location

      Useful when implementing custom mob goals

      Parameters:
      location - location to look at
    • lookAt

      void lookAt(@NotNull Location location, float headRotationSpeed, float maxHeadPitch)
      Instruct this Mob to look at a specific Location

      Useful when implementing custom mob goals

      Parameters:
      location - location to look at
      headRotationSpeed - head rotation speed
      maxHeadPitch - max head pitch rotation
    • lookAt

      void lookAt(@NotNull @NotNull Entity entity)
      Instruct this Mob to look at a specific Entity

      If a LivingEntity, look at eye location

      Useful when implementing custom mob goals

      Parameters:
      entity - entity to look at
    • lookAt

      void lookAt(@NotNull @NotNull Entity entity, float headRotationSpeed, float maxHeadPitch)
      Instruct this Mob to look at a specific Entity

      If a LivingEntity, look at eye location

      Useful when implementing custom mob goals

      Parameters:
      entity - entity to look at
      headRotationSpeed - head rotation speed
      maxHeadPitch - max head pitch rotation
    • lookAt

      void lookAt(double x, double y, double z)
      Instruct this Mob to look at a specific position

      Useful when implementing custom mob goals

      Parameters:
      x - x coordinate
      y - y coordinate
      z - z coordinate
    • lookAt

      void lookAt(double x, double y, double z, float headRotationSpeed, float maxHeadPitch)
      Instruct this Mob to look at a specific position

      Useful when implementing custom mob goals

      Parameters:
      x - x coordinate
      y - y coordinate
      z - z coordinate
      headRotationSpeed - head rotation speed
      maxHeadPitch - max head pitch rotation
    • getHeadRotationSpeed

      int getHeadRotationSpeed()
      Gets the head rotation speed
      Returns:
      the head rotation speed
    • getMaxHeadPitch

      int getMaxHeadPitch()
      Gets the max head pitch rotation
      Returns:
      the max head pitch rotation
    • setTarget

      void setTarget(@Nullable @Nullable LivingEntity target)
      Instructs this Mob to set the specified LivingEntity as its target.

      Hostile creatures may attack their target, and friendly creatures may follow their target.

      Parameters:
      target - New LivingEntity to target, or null to clear the target
    • getTarget

      Gets the current target of this Mob
      Returns:
      Current target of this creature, or null if none exists
    • setAware

      void setAware(boolean aware)
      Sets whether this mob is aware of its surroundings. Unaware mobs will still move if pushed, attacked, etc. but will not move or perform any actions on their own. Unaware mobs may also have other unspecified behaviours disabled, such as drowning.
      Parameters:
      aware - whether the mob is aware
    • isAware

      boolean isAware()
      Gets whether this mob is aware of its surroundings. Unaware mobs will still move if pushed, attacked, etc. but will not move or perform any actions on their own. Unaware mobs may also have other unspecified behaviours disabled, such as drowning.
      Returns:
      whether the mob is aware
    • getAmbientSound

      @Nullable @Nullable Sound getAmbientSound()
      Get the Sound this mob makes while ambiently existing. This sound may change depending on the current state of the entity, and may also return null under specific conditions. This sound is not constant. For instance, villagers will make different passive noises depending on whether or not they are actively trading with a player, or make no ambient noise while sleeping.
      Returns:
      the ambient sound, or null if this entity is ambiently quiet
    • setLootTable

      default void setLootTable(@Nullable LootTable table, long seed)
      Description copied from interface: Lootable
      Set the loot table and seed for a container or entity at the same time.
      Specified by:
      setLootTable in interface Lootable
      Parameters:
      table - the Loot Table this Container or Mob will have.
      seed - the seed to used to generate loot. Default is 0.
    • isAggressive

      boolean isAggressive()
      Some mobs will raise their arm(s) when aggressive:

      Note: This doesn't always show the actual aggressive state as set by setAggressive(boolean). Panda's are always aggressive if their combined Panda.Gene is Panda.Gene.AGGRESSIVE.

      Returns:
      wether the mob is aggressive or not
    • setAggressive

      void setAggressive(boolean aggressive)
      Some mobs will raise their arm(s) when aggressive, see isAggressive() for full list.
      Parameters:
      aggressive - wether the mob should be aggressive or not
      See Also:
    • isLeftHanded

      boolean isLeftHanded()
      Check if Mob is left-handed
      Returns:
      True if left-handed
    • setLeftHanded

      void setLeftHanded(boolean leftHanded)
      Set if Mob is left-handed
      Parameters:
      leftHanded - True if left-handed
    • getPossibleExperienceReward

      int getPossibleExperienceReward()
      Gets the amount of experience the mob will possibly drop. This value is randomized and it can give different results
      Returns:
      the amount of experience the mob will possibly drop