接口 LivingEntity
- 所有超级接口:
Attributable
,CommandSender
,Damageable
,Entity
,Metadatable
,Nameable
,Permissible
,ProjectileSource
,ServerOperator
- 所有已知子接口:
AbstractHorse
,Ageable
,Ambient
,Animals
,ArmorStand
,Bat
,Blaze
,CaveSpider
,ChestedHorse
,Chicken
,ComplexLivingEntity
,Cow
,Creature
,Creeper
,Donkey
,ElderGuardian
,EnderDragon
,Enderman
,Endermite
,Evoker
,Flying
,Ghast
,Giant
,Golem
,Guardian
,Horse
,HumanEntity
,Husk
,Illager
,Illusioner
,IronGolem
,Llama
,MagmaCube
,Monster
,Mule
,MushroomCow
,NPC
,Ocelot
,Parrot
,Pig
,PigZombie
,Player
,PolarBear
,Rabbit
,Sheep
,Shulker
,Silverfish
,Skeleton
,SkeletonHorse
,Slime
,Snowman
,Spellcaster
,Spider
,Squid
,Stray
,Vex
,Villager
,Vindicator
,WaterMob
,Witch
,Wither
,WitherSkeleton
,Wolf
,Zombie
,ZombieHorse
,ZombieVillager
-
方法概要
修饰符和类型方法说明boolean
addPotionEffect
(PotionEffect effect) 向生物实体添加指定的PotionEffect
(药水效果)。boolean
addPotionEffect
(PotionEffect effect, boolean force) 向生物实体添加指定的PotionEffect
(药水效果)。boolean
addPotionEffects
(Collection<PotionEffect> effects) 尝试向生物实体添加所有指定的PotionEffect
(药水效果)。返回当前作用于生物实体的所有PotionEffect
。boolean
获取生物实体是否能捡拾物品。获取生物实体穿戴的装备背包栏。double
获取生物实体眼睛离脚高度。double
getEyeHeight
(boolean ignorePose) 获取生物实体眼睛离脚高度。获取生物实体眼睛的详细方位的Location对象。获取击杀指定生物实体的玩家。double
返回生物实体在当前无伤害时间最后受到的伤害。getLastTwoTargetBlocks
(Set<Material> transparent, int maxDistance) 获取沿生物实体视线上最后两个方块。获取当前牵引此实体的实体。getLineOfSight
(Set<Material> transparent, int maxDistance) 获取沿生物实体视线上的所有方块。int
返回生物实体所能拥有的氧气最大值,单位为tick。int
返回生物实体当前最大无伤害时间,单位为tick。int
返回生物实体当前无伤害时间,单位为tick。返回指定类型的有效PotionEffect
。int
返回生物实体剩余的氧气值,单位为tick。boolean
返回生物实体是否会在远离玩家时消失。getTargetBlock
(Set<Material> transparent, int maxDistance) 获取生物实体的目标方块。boolean
hasAI()
检查实体是否具有AI。boolean
hasLineOfSight
(Entity other) 检查生物实体是否阻挡另一个的视线。boolean
返回生物实体是否已经存在一个指定的PotionEffectType
效果。boolean
Gets if this entity is subject to collisions with other entities.boolean
检查实体是否正在滑翔,如正在使用滑翔翼。boolean
返回实体当前是否被拴住。void
移除当前所有指定的PotionEffectType
效果。void
setAI
(boolean ai) 设置实体是否具有AI。void
setCanPickupItems
(boolean pickup) 设置生物实体是否能捡拾物品.void
setCollidable
(boolean collidable) 设置实体 Set if this entity will be subject to collisions other entities.void
setGliding
(boolean gliding) 使实体开始或停止滑翔。void
setLastDamage
(double damage) 设置当前无伤害时间段内处理的伤害。boolean
setLeashHolder
(Entity holder) 设置握持拴绳的实体。void
setMaximumAir
(int ticks) 设置生物实体所能拥有的氧气最大值,单位为tick。void
setMaximumNoDamageTicks
(int ticks) 设置生物实体当前当前最大无伤害时间,单位为tick。void
setNoDamageTicks
(int ticks) 设置生物实体当前无伤害时间,单位为tick。void
setRemainingAir
(int ticks) 设置生物实体剩余的氧气值,单位为tick。void
setRemoveWhenFarAway
(boolean remove) 设置生物实体是否会在远离玩家时消失。从接口继承的方法 org.bukkit.attribute.Attributable
getAttribute
从接口继承的方法 org.bukkit.command.CommandSender
getName, sendMessage, sendMessage
从接口继承的方法 org.bukkit.entity.Damageable
damage, damage, getHealth, getMaxHealth, resetMaxHealth, setHealth, setMaxHealth
从接口继承的方法 org.bukkit.entity.Entity
addPassenger, addScoreboardTag, eject, getEntityId, getFallDistance, getFireTicks, getHeight, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getNearbyEntities, getPassenger, getPassengers, getPistonMoveReaction, getPortalCooldown, getScoreboardTags, getServer, getTicksLived, getType, getUniqueId, getVehicle, getVelocity, getWidth, getWorld, hasGravity, isCustomNameVisible, isDead, isEmpty, isGlowing, isInsideVehicle, isInvulnerable, isOnGround, isSilent, isValid, leaveVehicle, playEffect, remove, removePassenger, removeScoreboardTag, setCustomNameVisible, setFallDistance, setFireTicks, setGlowing, setGravity, setInvulnerable, setLastDamageCause, setPassenger, setPortalCooldown, setSilent, setTicksLived, setVelocity, teleport, teleport, teleport, teleport
从接口继承的方法 org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadata
从接口继承的方法 org.bukkit.Nameable
getCustomName, setCustomName
从接口继承的方法 org.bukkit.permissions.Permissible
addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachment
从接口继承的方法 org.bukkit.projectiles.ProjectileSource
launchProjectile, launchProjectile
从接口继承的方法 org.bukkit.permissions.ServerOperator
isOp, setOp
-
方法详细资料
-
getEyeHeight
double getEyeHeight()获取生物实体眼睛离脚高度。 原文: Gets the height of the living entity's eyes above its Location.- 返回:
- 生物实体眼睛离脚高度
-
getEyeHeight
double getEyeHeight(boolean ignorePose) 获取生物实体眼睛离脚高度。 原文: Gets the height of the living entity's eyes above its Location.- 参数:
ignorePose
- 若为true则会无视姿势改变的效果,例如潜行和滑翔- 返回:
- 生物实体眼睛离脚高度
-
getEyeLocation
Location getEyeLocation()获取生物实体眼睛的详细方位的Location对象。 原文: Get a Location detailing the current eye position of the living entity.- 返回:
- 生物实体眼睛的详细方位的Location对象
-
getLineOfSight
获取沿生物实体视线上的所有方块。这个列表包含生物实体眼睛到目标位置的所有方块。 原文: Gets all blocks along the living entity's line of sight.
This list contains all blocks from the living entity's eye position to target inclusive.
- 参数:
transparent
- 将包含的所有透明方块的ID的哈希表(设置为null则只包含空气)maxDistance
- 扫描的最大距离(可能被服务器限制,但至少为100个方块)- 返回:
- 包含沿生物实体视线上的所有方块的列表
-
getTargetBlock
获取生物实体的目标方块。 原文: Gets the block that the living entity has targeted.- 参数:
transparent
- 将包含的所有透明方块的ID的哈希表(设置为null则只包含空气)maxDistance
- 扫描的最大距离(可能被服务器限制,但至少为100个方块)- 返回:
- block 生物实体的目标方块
-
getLastTwoTargetBlocks
获取沿生物实体视线上最后两个方块。目标方块将是列表中最后的方块。 原文: Gets the last two blocks along the living entity's line of sight.
The target block will be the last block in the list.
- 参数:
transparent
- 将包含的所有透明方块的ID的哈希表(设置为null则只包含空气)maxDistance
- 扫描的最大距离。可能被服务器限制,但不会低于100个方块- 返回:
- 包含沿生物实体视线上最后两个方块的列表
-
getRemainingAir
int getRemainingAir()返回生物实体剩余的氧气值,单位为tick。 原文: Returns the amount of air that the living entity has remaining, in ticks.- 返回:
- 剩余的氧气值
-
setRemainingAir
void setRemainingAir(int ticks) 设置生物实体剩余的氧气值,单位为tick。 原文: Sets the amount of air that the living entity has remaining, in ticks.- 参数:
ticks
- 剩余的氧气值
-
getMaximumAir
int getMaximumAir()返回生物实体所能拥有的氧气最大值,单位为tick。 原文: Returns the maximum amount of air the living entity can have, in ticks.- 返回:
- 氧气最大值
-
setMaximumAir
void setMaximumAir(int ticks) 设置生物实体所能拥有的氧气最大值,单位为tick。 原文: Sets the maximum amount of air the living entity can have, in ticks.- 参数:
ticks
- 氧气最大值
-
getMaximumNoDamageTicks
int getMaximumNoDamageTicks()返回生物实体当前最大无伤害时间,单位为tick。即生物实体不会受到伤害的最大持续时间。 原文: Returns the living entity's current maximum no damage ticks.
This is the maximum duration in which the living entity will not take damage.
- 返回:
- 最大无伤害时间,单位为tick
-
setMaximumNoDamageTicks
void setMaximumNoDamageTicks(int ticks) 设置生物实体当前当前最大无伤害时间,单位为tick。 原文: Sets the living entity's current maximum no damage ticks.- 参数:
ticks
- 最大无伤害时间,单位为tick
-
getLastDamage
double getLastDamage()返回生物实体在当前无伤害时间最后受到的伤害。只有当伤害高于这个数值时生物实体才会进一步受到伤害。
Returns the living entity's last damage taken in the current no damage ticks time.
Only damage higher than this amount will further damage the living entity.
- 返回:
- 上一个无伤害时间段内受到的伤害
-
setLastDamage
void setLastDamage(double damage) 设置当前无伤害时间段内处理的伤害。 原文: Sets the damage dealt within the current no damage ticks time period.- 参数:
damage
- 伤害总量
-
getNoDamageTicks
int getNoDamageTicks()返回生物实体当前无伤害时间,单位为tick。 原文: Returns the living entity's current no damage ticks.- 返回:
- 无伤害时间,单位为tick
-
setNoDamageTicks
void setNoDamageTicks(int ticks) 设置生物实体当前无伤害时间,单位为tick。 原文: Sets the living entity's current no damage ticks.- 参数:
ticks
- 无伤害时间,单位为tick
-
getKiller
Player getKiller()获取击杀指定生物实体的玩家。可能为空。 原文: Gets the player identified as the killer of the living entity.
May be null.
- 返回:
- 击杀指定生物实体的玩家,如果找不到则返回null
-
addPotionEffect
向生物实体添加指定的PotionEffect
(药水效果)。一个指定的
PotionEffectType
(药水效果类型)只能有一种药水效果存在。 原文: Adds the givenPotionEffect
to the living entity.Only one potion effect can be present for a given
PotionEffectType
.- 参数:
effect
- 添加的药水效果- 返回:
- 效果是否添加
-
addPotionEffect
向生物实体添加指定的PotionEffect
(药水效果)。一个指定的
PotionEffectType
(药水效果类型)只能有一种药水效果存在。 原文: Adds the givenPotionEffect
to the living entity.Only one potion effect can be present for a given
PotionEffectType
.- 参数:
effect
- 添加的药水效果force
- 是否移除冲突的效果- 返回:
- 效果是否添加
-
addPotionEffects
尝试向生物实体添加所有指定的PotionEffect
(药水效果)。 原文: Attempts to add all of the givenPotionEffect
to the living entity.- 参数:
effects
- 添加的效果- 返回:
- 所有效果是否添加
-
hasPotionEffect
返回生物实体是否已经存在一个指定的PotionEffectType
效果。 原文: Returns whether the living entity already has an existing effect of the givenPotionEffectType
applied to it.- 参数:
type
- 检查的药水类型- 返回:
- 是否有指定的药水效果作用于生物实体
-
getPotionEffect
返回指定类型的有效PotionEffect
。如果效果不存在则会返回null。 原文: Returns the active
PotionEffect
of the specified type.If the effect is not present on the entity then null will be returned.
- 参数:
type
- 检查的药水类型- 返回:
- 作用于实体的效果,如果没有则返回null。
-
removePotionEffect
移除当前所有指定的PotionEffectType
效果。 原文: Removes any effects present of the givenPotionEffectType
.- 参数:
type
- 移除的药水类型
-
getActivePotionEffects
Collection<PotionEffect> getActivePotionEffects()返回当前作用于生物实体的所有PotionEffect
。 原文: Returns all currently activePotionEffect
s on the living entity.- 返回:
- 一个
PotionEffect
的集合
-
hasLineOfSight
检查生物实体是否阻挡另一个的视线。(???)这使用了与敌对怪物用于寻找最近玩家相同的算法。 原文: Checks whether the living entity has block line of sight to another.
This uses the same algorithm that hostile mobs use to find the closest player.
- 参数:
other
- 确定视线的实体(???)- 返回:
- 如果存在视线则返回true,否则返回false
-
getRemoveWhenFarAway
boolean getRemoveWhenFarAway()返回生物实体是否会在远离玩家时消失。默认情况下,动物不会被移除而怪物会。 原文: Returns if the living entity despawns when away from players or not.
By default, animals are not removed while other mobs are.
- 返回:
- 如果生物实体会在远离玩家时消失则返回true
-
setRemoveWhenFarAway
void setRemoveWhenFarAway(boolean remove) 设置生物实体是否会在远离玩家时消失。 原文: Sets whether or not the living entity despawns when away from players or not.- 参数:
remove
- 移除状态
-
getEquipment
EntityEquipment getEquipment()获取生物实体穿戴的装备背包栏。 原文: Gets the inventory with the equipment worn by the living entity.- 返回:
- 生物实体的背包栏
-
setCanPickupItems
void setCanPickupItems(boolean pickup) 设置生物实体是否能捡拾物品.原文: Sets whether or not the living entity can pick up items.
- 参数:
pickup
- 生物实体是否能捡拾物品
-
getCanPickupItems
boolean getCanPickupItems()获取生物实体是否能捡拾物品。 原文: Gets if the living entity can pick up items.- 返回:
- 生物实体是否能捡拾物品
-
isLeashed
boolean isLeashed()返回实体当前是否被拴住。 原文: Returns whether the entity is currently leashed.- 返回:
- 实体是否被拴住
-
getLeashHolder
获取当前牵引此实体的实体。 原文: Gets the entity that is currently leading this entity.- 返回:
- 握持拴绳的实体
- 抛出:
IllegalStateException
- 如果当前实体没被拴住则抛出错误
-
setLeashHolder
设置握持拴绳的实体。此方法对末影龙,凋零,玩家或蝙蝠无效。除拴绳外的非生物实体将不会像握持拴绳者一样坚持。(???) 原文: Sets the leash on this entity to be held by the supplied entity.
This method has no effect on EnderDragons, Withers, Players, or Bats. Non-living entities excluding leashes will not persist as leash holders.
- 参数:
holder
- 握持拴绳的实体- 返回:
- 操作是否成功
-
isGliding
boolean isGliding()检查实体是否正在滑翔,如正在使用滑翔翼。 原文: Checks to see if an entity is gliding, such as using an Elytra.- 返回:
- 如果实体正在滑翔则返回true。
-
setGliding
void setGliding(boolean gliding) 使实体开始或停止滑翔。即使没有装备滑翔翼也会生效,但会在被服务器立即恢复(后面的无能为力) Makes entity start or stop gliding. This will work even if an Elytra is not equipped, but will be reverted by the server immediately after unless an event-cancelling mechanism is put in place.- 参数:
gliding
- 实体滑翔则为true
-
setAI
void setAI(boolean ai) 设置实体是否具有AI。 原文: Sets whether an entity will have AI.- 参数:
ai
- 怪物是否具有AI。
-
hasAI
boolean hasAI()检查实体是否具有AI。 原文: Checks whether an entity has AI.- 返回:
- 如果实体具有AI则返回true,否则返回false。
-
setCollidable
void setCollidable(boolean collidable) 设置实体 Set if this entity will be subject to collisions other entities.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 status
-
isCollidable
boolean isCollidable()Gets if this entity is subject to collisions with other entities.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.
- 返回:
- collision status
-