public interface LivingEntity extends Attributable, Entity, Damageable, ProjectileSource
限定符和类型 | 方法和说明 |
---|---|
boolean |
addPotionEffect(PotionEffect effect)
向生物实体添加指定的
PotionEffect (药水效果)。 |
boolean |
addPotionEffect(PotionEffect effect,
boolean force)
向生物实体添加指定的
PotionEffect (药水效果)。 |
boolean |
addPotionEffects(java.util.Collection<PotionEffect> effects)
尝试向生物实体添加所有指定的
PotionEffect (药水效果)。 |
java.util.Collection<PotionEffect> |
getActivePotionEffects()
返回当前作用于生物实体的所有
PotionEffect 。 |
boolean |
getCanPickupItems()
获取生物实体是否能捡拾物品。
|
EntityEquipment |
getEquipment()
获取生物实体穿戴的装备背包栏。
|
double |
getEyeHeight()
获取生物实体眼睛离脚高度。
|
double |
getEyeHeight(boolean ignorePose)
获取生物实体眼睛离脚高度。
|
Location |
getEyeLocation()
获取生物实体眼睛的详细方位的Location对象。
|
Player |
getKiller()
获取击杀指定生物实体的玩家。
|
double |
getLastDamage()
返回生物实体在当前无伤害时间最后受到的伤害。
|
java.util.List<Block> |
getLastTwoTargetBlocks(java.util.Set<Material> transparent,
int maxDistance)
获取沿生物实体视线上最后两个方块。
|
Entity |
getLeashHolder()
获取当前牵引此实体的实体。
|
java.util.List<Block> |
getLineOfSight(java.util.Set<Material> transparent,
int maxDistance)
获取沿生物实体视线上的所有方块。
|
int |
getMaximumAir()
返回生物实体所能拥有的氧气最大值,单位为tick。
|
int |
getMaximumNoDamageTicks()
返回生物实体当前最大无伤害时间,单位为tick。
|
int |
getNoDamageTicks()
返回生物实体当前无伤害时间,单位为tick。
|
PotionEffect |
getPotionEffect(PotionEffectType type)
返回指定类型的有效
PotionEffect 。 |
int |
getRemainingAir()
返回生物实体剩余的氧气值,单位为tick。
|
boolean |
getRemoveWhenFarAway()
返回生物实体是否会在远离玩家时消失。
|
Block |
getTargetBlock(java.util.Set<Material> transparent,
int maxDistance)
获取生物实体的目标方块。
|
boolean |
hasAI()
检查实体是否具有AI。
|
boolean |
hasLineOfSight(Entity other)
检查生物实体是否阻挡另一个的视线。
|
boolean |
hasPotionEffect(PotionEffectType type)
返回生物实体是否已经存在一个指定的
PotionEffectType 效果。 |
boolean |
isCollidable()
Gets if this entity is subject to collisions with other entities.
|
boolean |
isGliding()
检查实体是否正在滑翔,如正在使用滑翔翼。
|
boolean |
isLeashed()
返回实体当前是否被拴住。
|
void |
removePotionEffect(PotionEffectType type)
移除当前所有指定的
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)
设置生物实体是否会在远离玩家时消失。
|
getAttribute
damage, damage, getHealth, getMaxHealth, resetMaxHealth, setHealth, setMaxHealth
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
getMetadata, hasMetadata, removeMetadata, setMetadata
getName, sendMessage, sendMessage
addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachment
isOp, setOp
getCustomName, setCustomName
launchProjectile, launchProjectile
double getEyeHeight()
double getEyeHeight(boolean ignorePose)
ignorePose
- 若为true则会无视姿势改变的效果,例如潜行和滑翔Location getEyeLocation()
java.util.List<Block> getLineOfSight(java.util.Set<Material> transparent, int maxDistance)
这个列表包含生物实体眼睛到目标位置的所有方块。 原文: 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个方块)Block getTargetBlock(java.util.Set<Material> transparent, int maxDistance)
transparent
- 将包含的所有透明方块的ID的哈希表(设置为null则只包含空气)maxDistance
- 扫描的最大距离(可能被服务器限制,但至少为100个方块)java.util.List<Block> getLastTwoTargetBlocks(java.util.Set<Material> transparent, int maxDistance)
目标方块将是列表中最后的方块。 原文: 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个方块int getRemainingAir()
void setRemainingAir(int ticks)
ticks
- 剩余的氧气值int getMaximumAir()
void setMaximumAir(int ticks)
ticks
- 氧气最大值int getMaximumNoDamageTicks()
即生物实体不会受到伤害的最大持续时间。 原文: Returns the living entity's current maximum no damage ticks.
This is the maximum duration in which the living entity will not take damage.
void setMaximumNoDamageTicks(int ticks)
ticks
- 最大无伤害时间,单位为tickdouble 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.
void setLastDamage(double damage)
damage
- 伤害总量int getNoDamageTicks()
void setNoDamageTicks(int ticks)
ticks
- 无伤害时间,单位为tickPlayer getKiller()
可能为空。 原文: Gets the player identified as the killer of the living entity.
May be null.
boolean addPotionEffect(PotionEffect effect)
PotionEffect
(药水效果)。
一个指定的PotionEffectType
(药水效果类型)只能有一种药水效果存在。
原文:
Adds the given PotionEffect
to the living entity.
Only one potion effect can be present for a given PotionEffectType
.
effect
- 添加的药水效果boolean addPotionEffect(PotionEffect effect, boolean force)
PotionEffect
(药水效果)。
一个指定的PotionEffectType
(药水效果类型)只能有一种药水效果存在。
原文:
Adds the given PotionEffect
to the living entity.
Only one potion effect can be present for a given PotionEffectType
.
effect
- 添加的药水效果force
- 是否移除冲突的效果boolean addPotionEffects(java.util.Collection<PotionEffect> effects)
PotionEffect
(药水效果)。
原文:
Attempts to add all of the given PotionEffect
to the living
entity.effects
- 添加的效果boolean hasPotionEffect(PotionEffectType type)
PotionEffectType
效果。
原文:
Returns whether the living entity already has an existing effect of
the given PotionEffectType
applied to it.type
- 检查的药水类型PotionEffect getPotionEffect(PotionEffectType type)
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
- 检查的药水类型void removePotionEffect(PotionEffectType type)
PotionEffectType
效果。
原文:
Removes any effects present of the given PotionEffectType
.type
- 移除的药水类型java.util.Collection<PotionEffect> getActivePotionEffects()
PotionEffect
。
原文:
Returns all currently active PotionEffect
s on the living
entity.PotionEffect
的集合boolean hasLineOfSight(Entity other)
这使用了与敌对怪物用于寻找最近玩家相同的算法。 原文: 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
- 确定视线的实体(???)boolean getRemoveWhenFarAway()
默认情况下,动物不会被移除而怪物会。 原文: Returns if the living entity despawns when away from players or not.
By default, animals are not removed while other mobs are.
void setRemoveWhenFarAway(boolean remove)
remove
- 移除状态EntityEquipment getEquipment()
void setCanPickupItems(boolean pickup)
原文: Sets whether or not the living entity can pick up items.
pickup
- 生物实体是否能捡拾物品boolean getCanPickupItems()
boolean isLeashed()
Entity getLeashHolder() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- 如果当前实体没被拴住则抛出错误boolean setLeashHolder(Entity holder)
此方法对末影龙,凋零,玩家或蝙蝠无效。除拴绳外的非生物实体将不会像握持拴绳者一样坚持。(???) 原文: 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
- 握持拴绳的实体boolean isGliding()
void setGliding(boolean gliding)
gliding
- 实体滑翔则为truevoid setAI(boolean ai)
ai
- 怪物是否具有AI。boolean hasAI()
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.