Class EntityCreature

java.lang.Object
All Implemented Interfaces:
DataContainer, EventHandler, EquipmentHandler, PermissionHandler, Viewable
Direct Known Subclasses:
EntityBat, EntityBee, EntityBlaze, EntityCat, EntityCaveSpider, EntityChicken, EntityCow, EntityCreeper, EntityDolphin, EntityEndermite, EntityFox, EntityGhast, EntityGiant, EntityGuardian, EntityIronGolem, EntityMooshroom, EntityOcelot, EntityPanda, EntityPhantom, EntityPig, EntityPolarBear, EntityRabbit, EntitySilverfish, EntitySlime, EntitySnowman, EntitySpider, EntityWitch, EntityZombie, EntityZombifiedPiglin

public abstract class EntityCreature
extends LivingEntity
  • Field Details

  • Constructor Details

  • Method Details

    • update

      public void update​(long time)
      Description copied from class: Entity
      Called each tick.
      Overrides:
      update in class LivingEntity
      Parameters:
      time - time of the update in milliseconds
    • setInstance

      public void setInstance​(@NotNull Instance instance)
      Description copied from class: Entity
      Changes the entity instance.
      Overrides:
      setInstance in class Entity
      Parameters:
      instance - the new instance of the entity
    • spawn

      public void spawn()
      Description copied from class: Entity
      Called when a new instance is set.
      Specified by:
      spawn in class Entity
    • kill

      public void kill()
      Description copied from class: LivingEntity
      Kills the entity, trigger the EntityDeathEvent event.
      Overrides:
      kill in class LivingEntity
    • addViewer

      public boolean addViewer​(@NotNull Player player)
      Description copied from interface: Viewable
      Adds a viewer.
      Specified by:
      addViewer in interface Viewable
      Overrides:
      addViewer in class Entity
      Parameters:
      player - the viewer to add
      Returns:
      true if the player has been added, false otherwise (could be because he is already a viewer)
    • getGoalSelectors

      @NotNull public java.util.List<GoalSelector> getGoalSelectors()
      Gets the goal selectors of this entity.
      Returns:
      a modifiable list containing the entity goal selectors
    • getTargetSelectors

      @NotNull public java.util.List<TargetSelector> getTargetSelectors()
      Gets the target selectors of this entity.
      Returns:
      a modifiable list containing the entity target selectors
    • getTarget

      @Nullable public Entity getTarget()
      Gets the entity target.
      Returns:
      the entity target
    • setTarget

      public void setTarget​(@NotNull Entity target)
      Changes the entity target.
      Parameters:
      target - the new entity target
    • getItemInMainHand

      @NotNull public ItemStack getItemInMainHand()
      Description copied from interface: EquipmentHandler
      Gets the ItemStack in main hand.
      Returns:
      the ItemStack in main hand
    • setItemInMainHand

      public void setItemInMainHand​(@NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the main hand ItemStack.
      Parameters:
      itemStack - the main hand ItemStack
    • getItemInOffHand

      @NotNull public ItemStack getItemInOffHand()
      Description copied from interface: EquipmentHandler
      Gets the ItemStack in off hand.
      Returns:
      the item in off hand
    • setItemInOffHand

      public void setItemInOffHand​(@NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the off hand ItemStack.
      Parameters:
      itemStack - the off hand ItemStack
    • getHelmet

      @NotNull public ItemStack getHelmet()
      Description copied from interface: EquipmentHandler
      Gets the helmet.
      Returns:
      the helmet
    • setHelmet

      public void setHelmet​(@NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the helmet.
      Parameters:
      itemStack - the helmet
    • getChestplate

      @NotNull public ItemStack getChestplate()
      Description copied from interface: EquipmentHandler
      Gets the chestplate.
      Returns:
      the chestplate
    • setChestplate

      public void setChestplate​(@NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the chestplate.
      Parameters:
      itemStack - the chestplate
    • getLeggings

      @NotNull public ItemStack getLeggings()
      Description copied from interface: EquipmentHandler
      Gets the leggings.
      Returns:
      the leggings
    • setLeggings

      public void setLeggings​(@NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the leggings.
      Parameters:
      itemStack - the leggings
    • getBoots

      @NotNull public ItemStack getBoots()
      Description copied from interface: EquipmentHandler
      Gets the boots.
      Returns:
      the boots
    • setBoots

      public void setBoots​(@NotNull ItemStack itemStack)
      Description copied from interface: EquipmentHandler
      Changes the boots.
      Parameters:
      itemStack - the boots
    • attack

      public void attack​(@NotNull Entity target, boolean swingHand)
      Calls a EntityAttackEvent with this entity as the source and target as the target.
      Parameters:
      target - the entity target
      swingHand - true to swing the entity main hand, false otherwise
    • attack

      public void attack​(@NotNull Entity target)
      Calls a EntityAttackEvent with this entity as the source and target as the target.

      This does not trigger the hand animation.

      Parameters:
      target - the entity target
    • jump

      public void jump​(float height)
    • setPathTo

      public boolean setPathTo​(@Nullable Position position)
      Retrieves the path to position and ask the entity to follow the path.

      Can be set to null to reset the pathfinder.

      The position is cloned, if you want the entity to continually follow this position object you need to call this when you want the path to update.

      Parameters:
      position - the position to find the path to, null to reset the pathfinder
      Returns:
      true if a path has been found
    • getPathPosition

      @Nullable public Position getPathPosition()
      Gets the target pathfinder position.
      Returns:
      the target pathfinder position, null if there is no one
    • moveTowards

      public void moveTowards​(@NotNull Position direction, float speed)
      Used to move the entity toward direction in the X and Z axis Gravity is still applied but the entity will not attempt to jump Also update the yaw/pitch of the entity to look along 'direction'
      Parameters:
      direction - the targeted position
      speed - define how far the entity will move
    • getPathingEntity

      @NotNull public PFPathingEntity getPathingEntity()
      Gets the pathing entity.

      Used by the pathfinder.

      Returns:
      the pathing entity