Class EntityCreature

All Implemented Interfaces:
Sound.Emitter, HoverEventSource<HoverEvent.ShowEntity>, Shape, EntityAI, NavigableEntity, EventHandler<EntityEvent>, EquipmentHandler, Snapshotable, Taggable, TagReadable, TagWritable, AcquirableSource<Entity>, Tickable, Schedulable, Viewable

public class EntityCreature extends LivingEntity implements NavigableEntity, EntityAI
  • Constructor Details

    • EntityCreature

      public EntityCreature(@NotNull @NotNull EntityType entityType, @NotNull @NotNull UUID uuid)
      Constructor which allows to specify an UUID. Only use if you know what you are doing!
    • EntityCreature

      public EntityCreature(@NotNull @NotNull EntityType entityType)
  • 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 CompletableFuture<Void> setInstance(@NotNull @NotNull Instance instance, @NotNull @NotNull Pos spawnPosition)
      Description copied from class: Entity
      Changes the entity instance, i.e. spawns it.
      Overrides:
      setInstance in class Entity
      Parameters:
      instance - the new instance of the entity
      spawnPosition - the spawn position for the entity.
      Returns:
      a CompletableFuture called once the entity's instance has been set, this is due to chunks needing to load
    • kill

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

      public int getRemovalAnimationDelay()
      Gets the kill animation delay before vanishing the entity.
      Returns:
      the removal animation delay in milliseconds, 0 if not any
    • setRemovalAnimationDelay

      public void setRemovalAnimationDelay(int removalAnimationDelay)
      Changes the removal animation delay of the entity.

      Testing shows that 1000 is the minimum value to display the death particles.

      Parameters:
      removalAnimationDelay - the new removal animation delay in milliseconds, 0 to remove it
    • getAIGroups

      public Collection<EntityAIGroup> getAIGroups()
      Description copied from interface: EntityAI
      Gets the AI groups of this entity.
      Specified by:
      getAIGroups in interface EntityAI
      Returns:
      a modifiable collection of AI groups of this entity.
    • getTarget

      @Nullable public @Nullable Entity getTarget()
      Gets the entity target.
      Returns:
      the entity target, can be null if not any
    • setTarget

      public void setTarget(@Nullable @Nullable Entity target)
      Changes the entity target.
      Parameters:
      target - the new entity target, null to remove
    • getNavigator

      @NotNull public @NotNull Navigator getNavigator()
      Specified by:
      getNavigator in interface NavigableEntity
    • attack

      public void attack(@NotNull @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 @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
    • acquirable

      @Experimental @NotNull public @NotNull Acquirable<? extends EntityCreature> acquirable()
      Description copied from interface: AcquirableSource
      Obtains an Acquirable. To safely perform operations on this object, the user must call Acquirable.sync(Consumer) or Acquirable.lock() (followed by a subsequent unlock) on the Acquirable instance.
      Specified by:
      acquirable in interface AcquirableSource<Entity>
      Overrides:
      acquirable in class LivingEntity
      Returns:
      an Acquirable which can be used to synchronize access to this object