Attributable
, CommandSender
, Damageable
, Entity
, Metadatable
, Nameable
, Permissible
, PersistentDataHolder
, ProjectileSource
, ServerOperator
AbstractHorse
, AbstractVillager
, Ageable
, Ambient
, Animals
, ArmorStand
, Bat
, Bee
, Blaze
, Cat
, CaveSpider
, ChestedHorse
, Chicken
, Cod
, ComplexLivingEntity
, Cow
, Creature
, Creeper
, Dolphin
, Donkey
, Drowned
, ElderGuardian
, EnderDragon
, Enderman
, Endermite
, Evoker
, Fish
, Flying
, Fox
, Ghast
, Giant
, Golem
, Guardian
, Horse
, HumanEntity
, Husk
, Illager
, Illusioner
, IronGolem
, Llama
, MagmaCube
, Mob
, Monster
, Mule
, MushroomCow
, NPC
, Ocelot
, Panda
, Parrot
, Phantom
, Pig
, PigZombie
, Pillager
, Player
, PolarBear
, PufferFish
, Rabbit
, Raider
, RangedEntity
, Ravager
, Salmon
, Sheep
, Shulker
, Silverfish
, Skeleton
, SkeletonHorse
, Slime
, Snowman
, Spellcaster
, Spider
, Squid
, Stray
, Tameable
, TraderLlama
, TropicalFish
, Turtle
, Vex
, Villager
, Vindicator
, WanderingTrader
, WaterMob
, Witch
, Wither
, WitherSkeleton
, Wolf
, Zombie
, ZombieHorse
, ZombieVillager
public interface LivingEntity extends Attributable, Damageable, ProjectileSource
Entity.Spigot
Modifier and Type | Method | Description |
---|---|---|
boolean |
addPotionEffect(@NotNull PotionEffect effect) |
Adds the given
PotionEffect to the living entity. |
boolean |
addPotionEffect(@NotNull PotionEffect effect,
boolean force) |
Deprecated.
no need to force since multiple effects of the same type are
now supported.
|
boolean |
addPotionEffects(@NotNull Collection<PotionEffect> effects) |
Attempts to add all of the given
PotionEffect to the living
entity. |
void |
attack(@NotNull Entity target) |
Makes this entity attack the given entity with a melee attack.
|
@Nullable ItemStack |
getActiveItem() |
Get's the item being actively "used" or consumed.
|
@NotNull Collection<PotionEffect> |
getActivePotionEffects() |
Returns all currently active
PotionEffect s on the living
entity. |
int |
getArrowsStuck() |
Get the number of arrows stuck in this entity
|
boolean |
getCanPickupItems() |
Gets if the living entity can pick up items.
|
@Nullable EntityEquipment |
getEquipment() |
Gets the inventory with the equipment worn by the living entity.
|
double |
getEyeHeight() |
Gets the height of the living entity's eyes above its Location.
|
double |
getEyeHeight(boolean ignorePose) |
Gets the height of the living entity's eyes above its Location.
|
@NotNull Location |
getEyeLocation() |
Get a Location detailing the current eye position of the living entity.
|
int |
getHandRaisedTime() |
Get how long the players hands have been raised (Charging Bow attack, using a potion, etc)
|
int |
getItemUseRemainingTime() |
Get's remaining time a player needs to keep hands raised with an item to finish using it.
|
@Nullable Player |
getKiller() |
Gets the player identified as the killer of the living entity.
|
double |
getLastDamage() |
Returns the living entity's last damage taken in the current no damage
ticks time.
|
@NotNull List<Block> |
getLastTwoTargetBlocks(@Nullable Set<Material> transparent,
int maxDistance) |
Gets the last two blocks along the living entity's line of sight.
|
@NotNull Entity |
getLeashHolder() |
Gets the entity that is currently leading this entity.
|
@NotNull List<Block> |
getLineOfSight(@Nullable Set<Material> transparent,
int maxDistance) |
Gets all blocks along the living entity's line of sight.
|
int |
getMaximumAir() |
Returns the maximum amount of air the living entity can have, in ticks.
|
int |
getMaximumNoDamageTicks() |
Returns the living entity's current maximum no damage ticks.
|
<T> T |
getMemory(@NotNull MemoryKey<T> memoryKey) |
Returns the value of the memory specified.
|
int |
getNoDamageTicks() |
Returns the living entity's current no damage ticks.
|
@Nullable PotionEffect |
getPotionEffect(@NotNull PotionEffectType type) |
Returns the active
PotionEffect of the specified type. |
int |
getRemainingAir() |
Returns the amount of air that the living entity has remaining, in
ticks.
|
boolean |
getRemoveWhenFarAway() |
Returns if the living entity despawns when away from players or not.
|
int |
getShieldBlockingDelay() |
Get the delay (in ticks) before blocking is effective for this entity
|
default @Nullable Block |
getTargetBlock(int maxDistance) |
Gets the block that the living entity has targeted, ignoring fluids
|
@Nullable Block |
getTargetBlock(int maxDistance,
TargetBlockInfo.FluidMode fluidMode) |
Gets the block that the living entity has targeted
|
@NotNull Block |
getTargetBlock(@Nullable Set<Material> transparent,
int maxDistance) |
Gets the block that the living entity has targeted.
|
@Nullable Block |
getTargetBlockExact(int maxDistance) |
Gets the block that the living entity has targeted.
|
@Nullable Block |
getTargetBlockExact(int maxDistance,
@NotNull FluidCollisionMode fluidCollisionMode) |
Gets the block that the living entity has targeted.
|
default BlockFace |
getTargetBlockFace(int maxDistance) |
Gets the blockface of that block that the living entity has targeted, ignoring fluids
|
BlockFace |
getTargetBlockFace(int maxDistance,
TargetBlockInfo.FluidMode fluidMode) |
Gets the blockface of that block that the living entity has targeted
|
default TargetBlockInfo |
getTargetBlockInfo(int maxDistance) |
Gets information about the block the living entity has targeted, ignoring fluids
|
TargetBlockInfo |
getTargetBlockInfo(int maxDistance,
TargetBlockInfo.FluidMode fluidMode) |
Gets information about the block the living entity has targeted
|
default @Nullable Entity |
getTargetEntity(int maxDistance) |
Gets information about the entity being targeted
|
@Nullable Entity |
getTargetEntity(int maxDistance,
boolean ignoreBlocks) |
Gets information about the entity being targeted
|
default TargetEntityInfo |
getTargetEntityInfo(int maxDistance) |
Gets information about the entity being targeted
|
TargetEntityInfo |
getTargetEntityInfo(int maxDistance,
boolean ignoreBlocks) |
Gets information about the entity being targeted
|
boolean |
hasAI() |
Checks whether an entity has AI.
|
boolean |
hasLineOfSight(@NotNull Entity other) |
Checks whether the living entity has block line of sight to another.
|
boolean |
hasPotionEffect(@NotNull PotionEffectType type) |
Returns whether the living entity already has an existing effect of
the given
PotionEffectType applied to it. |
boolean |
isCollidable() |
Gets if this entity is subject to collisions with other entities.
|
boolean |
isGliding() |
Checks to see if an entity is gliding, such as using an Elytra.
|
boolean |
isHandRaised() |
Whether or not this entity is using or charging an attack (Bow pulled back, drinking potion, eating food)
|
boolean |
isJumping() |
Get entity jump state.
|
boolean |
isLeashed() |
Returns whether the entity is currently leashed.
|
boolean |
isRiptiding() |
Checks to see if an entity is currently using the Riptide enchantment.
|
boolean |
isSleeping() |
Returns whether this entity is slumbering.
|
boolean |
isSwimming() |
Checks to see if an entity is swimming.
|
@Nullable RayTraceResult |
rayTraceBlocks(double maxDistance) |
Performs a ray trace that provides information on the targeted block.
|
@Nullable RayTraceResult |
rayTraceBlocks(double maxDistance,
@NotNull FluidCollisionMode fluidCollisionMode) |
Performs a ray trace that provides information on the targeted block.
|
void |
removePotionEffect(@NotNull PotionEffectType type) |
Removes any effects present of the given
PotionEffectType . |
void |
setAI(boolean ai) |
Sets whether an entity will have AI.
|
void |
setArrowsStuck(int arrows) |
Set the number of arrows stuck in this entity
|
void |
setCanPickupItems(boolean pickup) |
Sets whether or not the living entity can pick up items.
|
void |
setCollidable(boolean collidable) |
Set if this entity will be subject to collisions other entities.
|
void |
setGliding(boolean gliding) |
Makes entity start or stop gliding.
|
void |
setJumping(boolean jumping) |
Set entity jump state
|
void |
setKiller(@Nullable Player killer) |
Sets the player identified as the killer of the living entity.
|
void |
setLastDamage(double damage) |
Sets the damage dealt within the current no damage ticks time period.
|
boolean |
setLeashHolder(@Nullable Entity holder) |
Sets the leash on this entity to be held by the supplied entity.
|
void |
setMaximumAir(int ticks) |
Sets the maximum amount of air the living entity can have, in ticks.
|
void |
setMaximumNoDamageTicks(int ticks) |
Sets the living entity's current maximum no damage ticks.
|
<T> void |
setMemory(@NotNull MemoryKey<T> memoryKey,
T memoryValue) |
Sets the value of the memory specified.
|
void |
setNoDamageTicks(int ticks) |
Sets the living entity's current no damage ticks.
|
void |
setRemainingAir(int ticks) |
Sets the amount of air that the living entity has remaining, in ticks.
|
void |
setRemoveWhenFarAway(boolean remove) |
Sets whether or not the living entity despawns when away from players
or not.
|
void |
setShieldBlockingDelay(int delay) |
Set the delay (in ticks) before blocking is effective for this entity
|
void |
setSwimming(boolean swimming) |
Makes entity start or stop swimming.
|
void |
swingMainHand() |
Makes this entity swing their main hand.
|
void |
swingOffHand() |
Makes this entity swing their off hand.
|
getAttribute
getName, sendMessage, sendMessage, sendMessage, sendMessage
damage, damage, getAbsorptionAmount, getHealth, getMaxHealth, resetMaxHealth, setAbsorptionAmount, setHealth, setMaxHealth
addPassenger, addScoreboardTag, eject, fromMobSpawner, getBoundingBox, getChunk, getEntityId, getEntitySpawnReason, getFacing, getFallDistance, getFireTicks, getHeight, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getNearbyEntities, getOrigin, getPassenger, getPassengers, getPistonMoveReaction, getPortalCooldown, getPose, getScoreboardTags, getServer, getTicksLived, getType, getUniqueId, getVehicle, getVelocity, getWidth, getWorld, hasGravity, isCustomNameVisible, isDead, isEmpty, isGlowing, isInsideVehicle, isInvulnerable, isOnGround, isPersistent, isSilent, isValid, leaveVehicle, playEffect, remove, removePassenger, removeScoreboardTag, setCustomNameVisible, setFallDistance, setFireTicks, setGlowing, setGravity, setInvulnerable, setLastDamageCause, setPassenger, setPersistent, setPortalCooldown, setRotation, setSilent, setTicksLived, setVelocity, spigot, teleport, teleport, teleport, teleport, teleportAsync, teleportAsync
getMetadata, hasMetadata, removeMetadata, setMetadata
getCustomName, setCustomName
addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachment
getPersistentDataContainer
launchProjectile, launchProjectile
isOp, setOp
double getEyeHeight()
double getEyeHeight(boolean ignorePose)
ignorePose
- if set to true, the effects of pose changes, eg
sneaking and gliding will be ignored@NotNull @NotNull Location getEyeLocation()
@NotNull @NotNull List<Block> getLineOfSight(@Nullable @Nullable Set<Material> transparent, int maxDistance)
This list contains all blocks from the living entity's eye position to target inclusive. This method considers all blocks as 1x1x1 in size.
transparent
- Set containing all transparent block Materials (set to
null for only air)maxDistance
- this is the maximum distance to scan (may be limited
by server by at least 100 blocks, no less)@NotNull @NotNull Block getTargetBlock(@Nullable @Nullable Set<Material> transparent, int maxDistance)
This method considers all blocks as 1x1x1 in size. To take exact block
collision shapes into account, see getTargetBlockExact(int,
FluidCollisionMode)
.
transparent
- Set containing all transparent block Materials (set to
null for only air)maxDistance
- this is the maximum distance to scan (may be limited
by server by at least 100 blocks, no less)@Nullable default @Nullable Block getTargetBlock(int maxDistance)
maxDistance
- this is the maximum distance to scan@Nullable @Nullable Block getTargetBlock(int maxDistance, @NotNull TargetBlockInfo.FluidMode fluidMode)
maxDistance
- this is the maximum distance to scanfluidMode
- whether to check fluids or not@Nullable default BlockFace getTargetBlockFace(int maxDistance)
maxDistance
- this is the maximum distance to scan@Nullable BlockFace getTargetBlockFace(int maxDistance, @NotNull TargetBlockInfo.FluidMode fluidMode)
maxDistance
- this is the maximum distance to scanfluidMode
- whether to check fluids or not@Nullable default TargetBlockInfo getTargetBlockInfo(int maxDistance)
maxDistance
- this is the maximum distance to scan@Nullable TargetBlockInfo getTargetBlockInfo(int maxDistance, @NotNull TargetBlockInfo.FluidMode fluidMode)
maxDistance
- this is the maximum distance to scanfluidMode
- whether to check fluids or not@Nullable default @Nullable Entity getTargetEntity(int maxDistance)
maxDistance
- this is the maximum distance to scan@Nullable @Nullable Entity getTargetEntity(int maxDistance, boolean ignoreBlocks)
maxDistance
- this is the maximum distance to scanignoreBlocks
- true to scan through blocks@Nullable default TargetEntityInfo getTargetEntityInfo(int maxDistance)
maxDistance
- this is the maximum distance to scan@Nullable TargetEntityInfo getTargetEntityInfo(int maxDistance, boolean ignoreBlocks)
maxDistance
- this is the maximum distance to scanignoreBlocks
- true to scan through blocks@NotNull @NotNull List<Block> getLastTwoTargetBlocks(@Nullable @Nullable Set<Material> transparent, int maxDistance)
The target block will be the last block in the list. This method considers all blocks as 1x1x1 in size.
transparent
- Set containing all transparent block Materials (set to
null for only air)maxDistance
- this is the maximum distance to scan. This may be
further limited by the server, but never to less than 100 blocks@Nullable @Nullable Block getTargetBlockExact(int maxDistance)
This takes the blocks' precise collision shapes into account. Fluids are ignored.
This may cause loading of chunks! Some implementations may impose artificial restrictions on the maximum distance.
maxDistance
- the maximum distance to scangetTargetBlockExact(int, org.bukkit.FluidCollisionMode)
@Nullable @Nullable Block getTargetBlockExact(int maxDistance, @NotNull @NotNull FluidCollisionMode fluidCollisionMode)
This takes the blocks' precise collision shapes into account.
This may cause loading of chunks! Some implementations may impose artificial restrictions on the maximum distance.
maxDistance
- the maximum distance to scanfluidCollisionMode
- the fluid collision moderayTraceBlocks(double, FluidCollisionMode)
@Nullable @Nullable RayTraceResult rayTraceBlocks(double maxDistance)
This takes the blocks' precise collision shapes into account. Fluids are ignored.
This may cause loading of chunks! Some implementations may impose artificial restrictions on the maximum distance.
maxDistance
- the maximum distance to scannull
if there
is no targeted block in rangerayTraceBlocks(double, FluidCollisionMode)
@Nullable @Nullable RayTraceResult rayTraceBlocks(double maxDistance, @NotNull @NotNull FluidCollisionMode fluidCollisionMode)
This takes the blocks' precise collision shapes into account.
This may cause loading of chunks! Some implementations may impose artificial restrictions on the maximum distance.
maxDistance
- the maximum distance to scanfluidCollisionMode
- the fluid collision modenull
if there
is no targeted block in rangeWorld.rayTraceBlocks(Location, Vector, double, FluidCollisionMode)
int getRemainingAir()
void setRemainingAir(int ticks)
ticks
- amount of air remainingint getMaximumAir()
void setMaximumAir(int ticks)
ticks
- maximum amount of airint getMaximumNoDamageTicks()
This is the maximum duration in which the living entity will not take damage.
void setMaximumNoDamageTicks(int ticks)
ticks
- maximum amount of no damage ticksdouble getLastDamage()
Only damage higher than this amount will further damage the living entity.
void setLastDamage(double damage)
damage
- amount of damageint getNoDamageTicks()
void setNoDamageTicks(int ticks)
ticks
- amount of no damage ticks@Nullable @Nullable Player getKiller()
May be null.
void setKiller(@Nullable @Nullable Player killer)
killer
- playerboolean addPotionEffect(@NotNull @NotNull PotionEffect effect)
PotionEffect
to the living entity.effect
- PotionEffect to be added@Deprecated boolean addPotionEffect(@NotNull @NotNull PotionEffect effect, boolean force)
PotionEffect
to the living entity.
Only one potion effect can be present for a given PotionEffectType
.
effect
- PotionEffect to be addedforce
- whether conflicting effects should be removedboolean addPotionEffects(@NotNull @NotNull Collection<PotionEffect> effects)
PotionEffect
to the living
entity.effects
- the effects to addboolean hasPotionEffect(@NotNull @NotNull PotionEffectType type)
PotionEffectType
applied to it.type
- the potion type to check@Nullable @Nullable PotionEffect getPotionEffect(@NotNull @NotNull PotionEffectType type)
PotionEffect
of the specified type.
If the effect is not present on the entity then null will be returned.
type
- the potion type to checkvoid removePotionEffect(@NotNull @NotNull PotionEffectType type)
PotionEffectType
.type
- the potion type to remove@NotNull @NotNull Collection<PotionEffect> getActivePotionEffects()
PotionEffect
s on the living
entity.PotionEffect
sboolean hasLineOfSight(@NotNull @NotNull Entity other)
This uses the same algorithm that hostile mobs use to find the closest player.
other
- the entity to determine line of sight toboolean getRemoveWhenFarAway()
By default, animals are not removed while other mobs are.
void setRemoveWhenFarAway(boolean remove)
remove
- the removal status@Nullable @Nullable EntityEquipment getEquipment()
void setCanPickupItems(boolean pickup)
pickup
- whether or not the living entity can pick up itemsboolean getCanPickupItems()
boolean isLeashed()
@NotNull @NotNull Entity getLeashHolder() throws IllegalStateException
IllegalStateException
- if not currently leashedboolean setLeashHolder(@Nullable @Nullable Entity holder)
This method has no effect on EnderDragons, Withers, Players, or Bats. Non-living entities excluding leashes will not persist as leash holders.
holder
- the entity to leash this entity to, or null to unleashboolean isGliding()
void setGliding(boolean gliding)
gliding
- True if the entity is gliding.boolean isSwimming()
void setSwimming(boolean swimming)
swimming
- True if the entity is swimming.boolean isRiptiding()
boolean isSleeping()
void setAI(boolean ai)
ai
- whether the mob will have AI or not.boolean hasAI()
void attack(@NotNull @NotNull Entity target)
target
as
appropriate.target
- entity to attack.void swingMainHand()
void swingOffHand()
void setCollidable(boolean collidable)
Note that collisions are bidirectional, so this method would need to be set to false on both the collidee and the collidant to ensure no collisions take place.
collidable
- collision statusboolean isCollidable()
Please note that this method returns only the custom collidable state, not whether the entity is non-collidable for other reasons such as being dead.
@Nullable <T> T getMemory(@NotNull @NotNull MemoryKey<T> memoryKey)
Note that the value is null when the specific entity does not have that value by default.
T
- the type of the return valuememoryKey
- memory to access<T> void setMemory(@NotNull @NotNull MemoryKey<T> memoryKey, @Nullable T memoryValue)
Note that the value will not be persisted when the specific entity does not have that value by default.
T
- the type of the passed valuememoryKey
- the memory to accessmemoryValue
- a typed memory valueint getArrowsStuck()
void setArrowsStuck(int arrows)
arrows
- Number of arrows to stick in this entityint getShieldBlockingDelay()
void setShieldBlockingDelay(int delay)
delay
- Delay in ticks@Nullable @Nullable ItemStack getActiveItem()
int getItemUseRemainingTime()
int getHandRaisedTime()
boolean isHandRaised()
boolean isJumping()
Jump state will be true when the entity has been marked to jump.
void setJumping(boolean jumping)
Setting to true will mark the entity to jump.
Setting to false will unmark the entity to jump but will not stop a jump already in-progress.
jumping
- entity jump stateCopyright © 2020. All rights reserved.