接口 LivingEntity
- 所有超级接口:
Attributable
,CommandSender
,Damageable
,Entity
,Metadatable
,Nameable
,Permissible
,PersistentDataHolder
,ProjectileSource
,ServerOperator
- 所有已知子接口:
AbstractHorse
,AbstractSkeleton
,AbstractVillager
,Ageable
,Allay
,Ambient
,Animals
,Armadillo
,ArmorStand
,Axolotl
,Bat
,Bee
,Blaze
,Bogged
,Breedable
,Breeze
,Camel
,Cat
,CaveSpider
,ChestedHorse
,Chicken
,Cod
,ComplexLivingEntity
,Cow
,Creature
,Creeper
,Dolphin
,Donkey
,Drowned
,ElderGuardian
,EnderDragon
,Enderman
,Endermite
,Enemy
,Evoker
,Fish
,Flying
,Fox
,Frog
,Ghast
,Giant
,GlowSquid
,Goat
,Golem
,Guardian
,Hoglin
,Horse
,HumanEntity
,Husk
,Illager
,Illusioner
,IronGolem
,Llama
,MagmaCube
,Mob
,Monster
,Mule
,MushroomCow
,NPC
,Ocelot
,Panda
,Parrot
,Phantom
,Pig
,Piglin
,PiglinAbstract
,PiglinBrute
,PigZombie
,Pillager
,Player
,PolarBear
,PufferFish
,Rabbit
,Raider
,Ravager
,Salmon
,Sheep
,Shulker
,Silverfish
,Skeleton
,SkeletonHorse
,Slime
,Sniffer
,Snowman
,Spellcaster
,Spider
,Squid
,Steerable
,Stray
,Strider
,Tadpole
,Tameable
,TraderLlama
,TropicalFish
,Turtle
,Vex
,Villager
,Vindicator
,WanderingTrader
,Warden
,WaterMob
,Witch
,Wither
,WitherSkeleton
,Wolf
,Zoglin
,Zombie
,ZombieHorse
,ZombieVillager
-
嵌套类概要
从接口继承的嵌套类/接口 org.bukkit.entity.Entity
Entity.Spigot
-
方法概要
修饰符和类型方法说明boolean
addPotionEffect
(@NotNull PotionEffect effect) 向生物实体添加指定的PotionEffect
(药水效果).boolean
addPotionEffect
(@NotNull PotionEffect effect, boolean force) 已过时。由于现已支持多个同种类型的药水效果, 没必要强制添加.boolean
addPotionEffects
(@NotNull Collection<PotionEffect> effects) 尝试向生物实体添加所有指定的PotionEffect
(药水效果).void
让此实体对指定实体进行近战攻击。boolean
如果此实体可以在水下呼吸,并且在空气供应达到零时不会受到窒息伤害,则返回 true。返回当前作用于生物实体的所有PotionEffect
.int
获取箭矢离开实体身体的剩余时间(以 tick 为单位)。int
获取实体身体内的箭矢数量。boolean
获取生物实体是否能捡拾物品.已过时。实体分组现在由标签管理,而不是类别获取可变的 UUID 集合,其中包含被豁免于实体可碰撞规则的实体, 这些实体与此实体的碰撞行为将与之相反。获取此实体在死亡时发出的Sound
。getDrinkingSound
(@NotNull ItemStack itemStack) getEatingSound
(@NotNull ItemStack itemStack) 获取生物实体穿戴的装备背包栏.double
获取生物实体眼睛离脚高度.double
getEyeHeight
(boolean ignorePose) 获取生物实体眼睛离脚高度.获取生物实体眼睛的详细方位的Location对象.getFallDamageSound
(int fallHeight) 获取此实体从给定高度(以方块为单位)坠落时发出的Sound
。获取此实体从大高度坠落时发出的Sound
。获取此实体从小高度坠落时发出的Sound
。获取此实体在受伤时发出的Sound
。获取玩家正在使用的物品(吃食物、拉弓、格挡等)。int
获取当前物品使用的剩余 tick 数。获取击杀指定生物实体的玩家.double
返回生物实体在当前无伤害时间最后受到的伤害.getLastTwoTargetBlocks
(@Nullable Set<Material> transparent, int maxDistance) 获取沿生物实体视线上最后两个方块.获取当前牵引此实体的实体.getLineOfSight
(@Nullable Set<Material> transparent, int maxDistance) 获取沿生物实体视线上的所有方块.int
返回生物实体所能拥有的氧气最大值,单位为tick.int
返回生物实体当前最大无伤害时间,单位为tick.<T> T
返回指定记忆的值。int
获取此实体未执行任何操作的 tick 数。int
返回生物实体当前无伤害时间,单位为tick.返回指定类型的有效PotionEffect
.int
返回生物实体剩余的氧气值,单位为tick.boolean
返回生物实体是否会在远离玩家时消失.getTargetBlock
(@Nullable Set<Material> transparent, int maxDistance) 获取生物实体的目标方块.getTargetBlockExact
(int maxDistance) 获取该生物实体瞄准的方块。getTargetBlockExact
(int maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) 获取该生物实体瞄准的方块。boolean
hasAI()
检查实体是否具有AI.boolean
hasLineOfSight
(@NotNull Entity other) 检查生物实体是否阻挡另一个的视线.boolean
返回生物实体是否已经存在一个指定的PotionEffectType
效果.boolean
获取实体是否正在攀爬.boolean
获取此实体是否会与其他实体发生碰撞。boolean
检查实体是否正在滑翔,如正在使用鞘翅.boolean
获取实体是否不可见。boolean
返回实体当前是否被拴住.boolean
检查实体是否正在使用涡流附魔。boolean
返回实体是否正在睡觉.boolean
检查实体是否正在游泳。void
playHurtAnimation
(float yaw) 使此实体闪烁红色,仿佛它们受到了伤害。rayTraceBlocks
(double maxDistance) 执行一次射线追踪,提供有关目标方块的信息。rayTraceBlocks
(double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) 执行一次射线追踪,提供有关目标方块的信息。void
移除当前所有指定的PotionEffectType
效果.void
setAI
(boolean ai) 设置实体是否具有AI.void
setArrowCooldown
(int ticks) 设置箭矢离开实体身体的剩余时间(以 tick 为单位)。void
setArrowsInBody
(int count) 设置实体身体内的箭矢数量。void
setCanPickupItems
(boolean pickup) 设置生物实体是否能捡拾物品.void
setCollidable
(boolean collidable) 设置此实体是否会与其他实体发生碰撞。void
setGliding
(boolean gliding) 使实体开始或停止滑翔。void
setInvisible
(boolean invisible) 设置实体是否不可见。void
setItemInUseTicks
(int ticks) 设置当前物品使用的剩余 tick 数。void
setLastDamage
(double damage) 设置当前无伤害时间段内处理的伤害.boolean
setLeashHolder
(@Nullable Entity holder) 设置握持拴绳的实体.void
setMaximumAir
(int ticks) 设置生物实体所能拥有的氧气最大值,单位为tick.void
setMaximumNoDamageTicks
(int ticks) 设置生物实体当前当前最大无伤害时间,单位为tick.<T> void
设置指定记忆的值。void
setNoActionTicks
(int ticks) 设置此实体未执行任何操作的 tick 数。void
setNoDamageTicks
(int ticks) 设置生物实体当前无伤害时间,单位为tick.void
setRemainingAir
(int ticks) 设置生物实体剩余的氧气值,单位为tick.void
setRemoveWhenFarAway
(boolean remove) 设置生物实体是否会在远离玩家时消失.void
setSwimming
(boolean swimming) 使实体开始或停止游泳。void
让此实体挥动其主手。void
让此实体挥动其副手。从接口继承的方法 org.bukkit.attribute.Attributable
getAttribute
从接口继承的方法 org.bukkit.command.CommandSender
getName, sendMessage, sendMessage, sendMessage, sendMessage
从接口继承的方法 org.bukkit.entity.Damageable
damage, damage, damage, getAbsorptionAmount, getHealth, getMaxHealth, resetMaxHealth, setAbsorptionAmount, setHealth, setMaxHealth
从接口继承的方法 org.bukkit.entity.Entity
addPassenger, addScoreboardTag, copy, copy, createSnapshot, eject, getAsString, getBoundingBox, getEntityId, getFacing, getFallDistance, getFireTicks, getFreezeTicks, getHeight, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getMaxFreezeTicks, getNearbyEntities, getPassenger, getPassengers, getPistonMoveReaction, getPortalCooldown, getPose, getScoreboardTags, getServer, getSpawnCategory, getSwimHighSpeedSplashSound, getSwimSound, getSwimSplashSound, getTicksLived, getTrackedBy, getType, getUniqueId, getVehicle, getVelocity, getWidth, getWorld, hasGravity, isCustomNameVisible, isDead, isEmpty, isFrozen, isGlowing, isInsideVehicle, isInvulnerable, isInWater, isInWorld, isOnGround, isPersistent, isSilent, isValid, isVisibleByDefault, isVisualFire, leaveVehicle, playEffect, remove, removePassenger, removeScoreboardTag, setCustomNameVisible, setFallDistance, setFireTicks, setFreezeTicks, setGlowing, setGravity, setInvulnerable, setLastDamageCause, setPassenger, setPersistent, setPortalCooldown, setRotation, setSilent, setTicksLived, setVelocity, setVisibleByDefault, setVisualFire, spigot, 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.persistence.PersistentDataHolder
getPersistentDataContainer
从接口继承的方法 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对象.原文: Get a Location detailing the current eye position of the living entity.
- 返回:
- 生物实体眼睛的详细方位的Location对象
-
getLineOfSight
@NotNull @NotNull List<Block> getLineOfSight(@Nullable @Nullable Set<Material> transparent, int maxDistance) 获取沿生物实体视线上的所有方块.这个列表包含生物实体眼睛到目标位置的所有方块. 本方法认为所有方块体积为1x1x1.
原文: 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. This method considers all blocks as 1x1x1 in size.
- 参数:
transparent
- 将包含的所有透明方块的ID的Set(设置为null则只包含空气)maxDistance
- 扫描的最大距离(可能被服务器限制,但至少为100个方块)- 返回:
- 包含沿生物实体视线上的所有方块的列表
-
getTargetBlock
@NotNull @NotNull Block getTargetBlock(@Nullable @Nullable Set<Material> transparent, int maxDistance) 获取生物实体的目标方块.本方法认为所有方块体积为1x1x1. To take exact block collision shapes into account, see
getTargetBlockExact(int, FluidCollisionMode)
.原文: Gets the block that the living entity has targeted.
This method considers all blocks as 1x1x1 in size. To take exact block collision shapes into account, see
getTargetBlockExact(int, FluidCollisionMode)
.- 参数:
transparent
- 将包含的所有透明方块的ID的Set(设置为null则只包含空气)maxDistance
- 扫描的最大距离(可能被服务器限制,但至少为100个方块)- 返回:
- block 生物实体的目标方块
-
getLastTwoTargetBlocks
@NotNull @NotNull List<Block> getLastTwoTargetBlocks(@Nullable @Nullable Set<Material> transparent, int maxDistance) 获取沿生物实体视线上最后两个方块.目标方块将是列表中最后的方块. 本方法认为所有方块体积为1x1x1.
原文: Gets the last two blocks along the living entity's line of sight.
The target block will be the last block in the list. This method considers all blocks as 1x1x1 in size.
- 参数:
transparent
- 将包含的所有透明方块的ID的Set(设置为null则只包含空气)maxDistance
- 扫描的最大距离。可能被服务器限制,但不会低于100个方块- 返回:
- 包含沿生物实体视线上最后两个方块的列表
-
getTargetBlockExact
获取该生物实体瞄准的方块。这会考虑方块的精确碰撞形状。流体将被忽略。
此操作可能会导致区块加载!某些实现可能会对最大距离施加人工限制。
原文: Gets the block that the living entity has targeted.
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
- 扫描的最大距离- 返回:
- 生物实体瞄准的方块
- 另请参阅:
-
getTargetBlockExact
@Nullable @Nullable Block getTargetBlockExact(int maxDistance, @NotNull @NotNull FluidCollisionMode fluidCollisionMode) 获取该生物实体瞄准的方块。这会考虑方块的精确碰撞形状。
此操作可能会导致区块加载!某些实现可能会对最大距离施加人工限制。
原文: Gets the block that the living entity has targeted.
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
- 扫描的最大距离fluidCollisionMode
- 流体碰撞模式- 返回:
- 生物实体瞄准的方块
- 另请参阅:
-
rayTraceBlocks
执行一次射线追踪,提供有关目标方块的信息。这会考虑方块的精确碰撞形状。流体将被忽略。
此操作可能会导致区块加载!某些实现可能会对最大距离施加人工限制。
原文: Performs a ray trace that provides information on the targeted block.
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
- 扫描的最大距离- 返回:
- 目标方块的信息,如果范围内没有目标方块则返回
null
- 另请参阅:
-
rayTraceBlocks
@Nullable @Nullable RayTraceResult rayTraceBlocks(double maxDistance, @NotNull @NotNull FluidCollisionMode fluidCollisionMode) 执行一次射线追踪,提供有关目标方块的信息。这会考虑方块的精确碰撞形状。
此操作可能会导致区块加载!某些实现可能会对最大距离施加人工限制。
原文: Performs a ray trace that provides information on the targeted block.
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
- 扫描的最大距离fluidCollisionMode
- 流体碰撞模式- 返回:
- 目标方块的信息,如果范围内没有目标方块则返回
null
- 另请参阅:
-
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
- 氧气最大值
-
getItemInUse
获取玩家正在使用的物品(吃食物、拉弓、格挡等)。原文: Gets the item that the player is using (eating food, drawing back a bow, blocking, etc.)
- 返回:
- 玩家正在使用的物品,如果未使用物品则返回 null
-
getItemInUseTicks
int getItemInUseTicks()获取当前物品使用的剩余 tick 数。原文: Gets the number of ticks remaining for the current item's usage.
- 返回:
- 剩余的 tick 数
-
setItemInUseTicks
void setItemInUseTicks(int ticks) 设置当前物品使用的剩余 tick 数。 适用于需要时间使用的物品,如吃食物、拉弓或投掷三叉戟。原文: Sets the number of ticks that remain for the current item's usage. Applies to items that take time to use, like eating food, drawing a bow, or throwing a trident.
- 参数:
ticks
- 剩余的 tick 数
-
getArrowCooldown
int getArrowCooldown()获取箭矢离开实体身体的剩余时间(以 tick 为单位)。原文: Gets the time in ticks until the next arrow leaves the entity's body.
- 返回:
- 箭矢离开的 tick 数
-
setArrowCooldown
void setArrowCooldown(int ticks) 设置箭矢离开实体身体的剩余时间(以 tick 为单位)。原文: Sets the time in ticks until the next arrow leaves the entity's body.
- 参数:
ticks
- 箭矢离开的时间
-
getArrowsInBody
int getArrowsInBody()获取实体身体内的箭矢数量。原文: Gets the amount of arrows in an entity's body.
- 返回:
- 身体内的箭矢数量
-
setArrowsInBody
void setArrowsInBody(int count) 设置实体身体内的箭矢数量。原文: Set the amount of arrows in the entity's body.
- 参数:
count
- 实体身体内的箭矢数量
-
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
-
getNoActionTicks
int getNoActionTicks()获取此实体未执行任何操作的 tick 数。"未操作 tick" 的具体含义因实体而异,无法明确定义。 一些示例包括乌贼使用此值来判断何时游泳,袭击者判断何时被驱逐出袭击, 或生物(如凋灵)作为消失的条件。
原文: Get the ticks that this entity has performed no action.
The details of what "no action ticks" entails varies from entity to entity and cannot be specifically defined. Some examples include squid using this value to determine when to swim, raiders for when they are to be expelled from raids, or creatures (such as withers) as a requirement to be despawned.
- 返回:
- 未操作的 tick 数
-
setNoActionTicks
void setNoActionTicks(int ticks) 设置此实体未执行任何操作的 tick 数。"未操作 tick" 的具体含义因实体而异,无法明确定义。 一些示例包括乌贼使用此值来判断何时游泳,袭击者判断何时被驱逐出袭击, 或生物(如凋灵)作为消失的条件。
原文: Set the ticks that this entity has performed no action.
The details of what "no action ticks" entails varies from entity to entity and cannot be specifically defined. Some examples include squid using this value to determine when to swim, raiders for when they are to be expelled from raids, or creatures (such as withers) as a requirement to be despawned.
- 参数:
ticks
- 未操作的 tick 数
-
getKiller
获取击杀指定生物实体的玩家.可能为空.
原文: Gets the player identified as the killer of the living entity.
May be null.
- 返回:
- 击杀指定生物实体的玩家,如果找不到则返回null
-
addPotionEffect
向生物实体添加指定的PotionEffect
(药水效果).原文: Adds the given
PotionEffect
to the living entity.- 参数:
effect
- 添加的药水效果- 返回:
- 效果是否添加
-
addPotionEffect
已过时。由于现已支持多个同种类型的药水效果, 没必要强制添加.译注:在某次版本更新后, Minecraft 自身支持了多个同种药水效果, 效果弱的会被隐藏; 但为兼容性考虑, 如确有覆盖效果需求的, 还是指定force为true
向生物实体添加指定的PotionEffect
(药水效果).一个指定的
PotionEffectType
(药水效果类型)只能有一种药水效果存在.原文: Adds the given
PotionEffect
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 given
PotionEffect
to the living entity.- 参数:
effects
- 添加的效果- 返回:
- 所有效果是否添加
-
hasPotionEffect
返回生物实体是否已经存在一个指定的PotionEffectType
效果.原文: Returns whether the living entity already has an existing effect of the given
PotionEffectType
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 given
PotionEffectType
.- 参数:
type
- 移除的药水类型
-
getActivePotionEffects
返回当前作用于生物实体的所有PotionEffect
.译注:不要向获得的列表中添加条目, 没有任何效果.
原文: Returns all currently active
PotionEffect
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
获取生物实体穿戴的装备背包栏.原文: 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。
-
isSwimming
boolean isSwimming()检查实体是否正在游泳。原文: Checks to see if an entity is swimming.
- 返回:
- 如果该实体正在游泳,则返回 true。
-
setSwimming
void setSwimming(boolean swimming) 使实体开始或停止游泳。 如果实体不在水中,可能会产生意想不到的结果。原文: Makes entity start or stop swimming. This may have unexpected results if the entity is not in water.
- 参数:
swimming
- 如果实体正在游泳,则为 true。
-
isRiptiding
boolean isRiptiding()检查实体是否正在使用涡流附魔。原文: Checks to see if an entity is currently using the Riptide enchantment.
- 返回:
- 如果该实体当前正在使用涡流,则返回 true。
-
isSleeping
boolean isSleeping()返回实体是否正在睡觉.原文:Returns whether this entity is slumbering.
- 返回:
- 实体睡眠状态
-
isClimbing
boolean isClimbing()获取实体是否正在攀爬.原文:Gets if the entity is climbing.
- 返回:
- 实体攀爬状态
-
setAI
void setAI(boolean ai) 设置实体是否具有AI. 实体若无AI将完全无法自主移动.原文: Sets whether an entity will have AI. The entity will be completely unable to move if it has no AI.
- 参数:
ai
- 怪物是否具有AI
-
hasAI
boolean hasAI()检查实体是否具有AI. 实体若无AI将完全无法自主移动.原文: Checks whether an entity has AI. The entity will be completely unable to move if it has no AI.
- 返回:
- 如果实体具有AI则返回true
-
attack
让此实体对指定实体进行近战攻击。 攻击伤害由服务器根据该生物的属性和装备计算, 根据需要对target
施加击退效果。原文: Makes this entity attack the given entity with a melee attack. Attack damage is calculated by the server from the attributes and equipment of this mob, and knockback is applied to
target
as appropriate.- 参数:
target
- 要攻击的实体。
-
swingMainHand
void swingMainHand()让此实体挥动其主手。 如果此实体没有挥动主手的动画,则此方法不会执行任何操作。原文: Makes this entity swing their main hand. This method does nothing if this entity does not have an animation for swinging their main hand.
-
swingOffHand
void swingOffHand()让此实体挥动其副手。 如果此实体没有挥动副手的动画,则此方法不会执行任何操作。原文: Makes this entity swing their off hand. This method does nothing if this entity does not have an animation for swinging their off hand.
-
playHurtAnimation
void playHurtAnimation(float yaw) 使此实体闪烁红色,仿佛它们受到了伤害。原文: Makes this entity flash red as if they were damaged.
- 参数:
yaw
- 伤害来源相对于实体的方向,其中 0 表示玩家面前,90 表示右侧,180 表示后方,270 表示左侧。
-
setCollidable
void setCollidable(boolean collidable) 设置此实体是否会与其他实体发生碰撞。对此规则的豁免可以通过
getCollidableExemptions()
进行管理。请注意,客户端可能会预测其与其他实体之间的碰撞,导致此标志在玩家碰撞时无效。 因此,此方法应仅用于设置非玩家实体的碰撞状态。
要控制玩家碰撞,请使用
Team.Option.COLLISION_RULE
,结合Scoreboard
和Team
。原文: Set if this entity will be subject to collisions with other entities.
Exemptions to this rule can be managed with
getCollidableExemptions()
Note that the client may predict the collision between itself and another entity, resulting in this flag not working for player collisions. This method should therefore only be used to set the collision status of non-player entities.
To control player collisions, use
Team.Option.COLLISION_RULE
in combination with aScoreboard
and aTeam
.- 参数:
collidable
- 碰撞状态
-
isCollidable
boolean isCollidable()获取此实体是否会与其他实体发生碰撞。某些实体可能会被豁免于此实体的可碰撞规则。 使用
getCollidableExemptions()
获取这些实体。请注意,此方法仅返回自定义的可碰撞状态, 而不考虑实体因其他原因(如死亡)而变得不可碰撞的情况。
请注意,客户端可能会预测其与其他实体之间的碰撞, 导致此标志在玩家碰撞时不准确。 因此,此方法应仅用于检查非玩家实体的碰撞状态。
要检查玩家的碰撞行为,请使用
Team.Option.COLLISION_RULE
,结合Scoreboard
和Team
。原文: Gets if this entity is subject to collisions with other entities.
Some entities might be exempted from the collidable rule of this entity. Use
getCollidableExemptions()
to get these.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.
Note that the client may predict the collision between itself and another entity, resulting in this flag not being accurate for player collisions. This method should therefore only be used to check the collision status of non-player entities.
To check the collision behavior for a player, use
Team.Option.COLLISION_RULE
in combination with aScoreboard
and aTeam
.- 返回:
- 碰撞状态
-
getCollidableExemptions
获取可变的 UUID 集合,其中包含被豁免于实体可碰撞规则的实体, 这些实体与此实体的碰撞行为将与之相反。此集合可以修改,以添加或移除豁免。
例如,如果可碰撞为 true,且某个实体在豁免集合中, 则该实体将不会与其发生碰撞。类似地,如果可碰撞为 false, 而某个实体在此集合中,则仍会与其发生碰撞。
请注意,这些豁免当前不是持久的。
请注意,客户端可能会预测其与其他实体之间的碰撞, 导致这些豁免在玩家碰撞时不准确。 因此,此方法应仅用于豁免非玩家实体。
要为玩家豁免碰撞,请使用
Team.Option.COLLISION_RULE
,结合Scoreboard
和Team
。原文: Gets a mutable set of UUIDs of the entities which are exempt from the entity's collidable rule and which's collision with this entity will behave the opposite of it.
This set can be modified to add or remove exemptions.
For example if collidable is true and an entity is in the exemptions set then it will not collide with it. Similarly if collidable is false and an entity is in this set then it will still collide with it.
Note these exemptions are not (currently) persistent.
Note that the client may predict the collision between itself and another entity, resulting in those exemptions not being accurate for player collisions. This method should therefore only be used to exempt non-player entities.
To exempt collisions for a player, use
Team.Option.COLLISION_RULE
in combination with aScoreboard
and aTeam
.- 返回:
- 可碰撞豁免集合
-
getMemory
返回指定记忆的值。请注意,当特定实体默认没有该值时,值为 null。
原文: Returns the value of the memory specified.
Note that the value is null when the specific entity does not have that value by default.
- 类型参数:
T
- 返回值的类型- 参数:
memoryKey
- 要访问的记忆- 返回:
- 记忆部分值的实例,如果不存在则返回 null
-
setMemory
设置指定记忆的值。请注意,当特定实体默认没有该值时,值不会被持久化。
原文: Sets the value of the memory specified.
Note that the value will not be persisted when the specific entity does not have that value by default.
- 类型参数:
T
- 传递值的类型- 参数:
memoryKey
- 要访问的记忆memoryValue
- 一个类型化的记忆值
-
getHurtSound
- 返回:
- 受伤声音,如果实体不发出声音则返回 null
-
getDeathSound
- 返回:
- 死亡声音,如果实体不发出声音则返回 null
-
getFallDamageSound
获取此实体从给定高度(以方块为单位)坠落时发出的Sound
。 如果高度超过 4 个方块,声音通常会在小坠落和大坠落伤害声之间有所不同。原文: Get the
Sound
this entity will make when falling from the given height (in blocks). The sound will often differ between either a small or a big fall damage sound if the height exceeds 4 blocks.- 参数:
fallHeight
- 坠落高度(以方块为单位)- 返回:
- 坠落伤害声音
- 另请参阅:
-
getFallDamageSoundSmall
- 返回:
- 坠落伤害声音
-
getFallDamageSoundBig
- 返回:
- 坠落伤害声音
-
getDrinkingSound
获取此实体饮用给定ItemStack
时发出的Sound
。原文: Get the
Sound
this entity will make when drinking the givenItemStack
.- 参数:
itemStack
- 正在饮用的物品堆- 返回:
- 饮用声音
-
getEatingSound
获取此实体食用给定ItemStack
时发出的Sound
。原文: Get the
Sound
this entity will make when eating the givenItemStack
.- 参数:
itemStack
- 正在食用的物品堆- 返回:
- 食用声音
-
canBreatheUnderwater
boolean canBreatheUnderwater()如果此实体可以在水下呼吸,并且在空气供应达到零时不会受到窒息伤害,则返回 true。原文: Returns true if this entity can breathe underwater and will not take suffocation damage when its air supply reaches zero.
- 返回:
true
如果实体可以在水下呼吸
-
getCategory
已过时。实体分组现在由标签管理,而不是类别获取此实体所属的类别。 类别可能会使此实体受到额外的效果、收益或负面影响。原文: Get the category to which this entity belongs. Categories may subject this entity to additional effects, benefits or debuffs.
- 返回:
- 实体类别
-
setInvisible
void setInvisible(boolean invisible) 设置实体是否不可见。原文: Sets whether the entity is invisible or not.
- 参数:
invisible
- 如果实体不可见,则为 true。
-
isInvisible
boolean isInvisible()获取实体是否不可见。原文: Gets whether the entity is invisible or not.
- 返回:
- 实体是否不可见
-