接口 DamageSource
-
嵌套类概要
嵌套类 -
方法概要
修饰符和类型方法说明static @NotNull DamageSource.Builderbuilder(@NotNull DamageType damageType) 创建一个新的DamageSource.Builder.获取造成伤害的Entity.获取伤害来源的Location.获取DamageType.获取直接造成伤害的Entity.float获取此伤害造成的饥饿消耗量.获取伤害来源的Location.boolean获取此伤害是否为间接伤害.boolean获取此伤害来源是否随难度缩放.
-
方法详细资料
-
getDamageType
获取DamageType.原文: Get the
DamageType.- 返回:
- 伤害类型
-
getCausingEntity
获取造成伤害的Entity.不要与
getDirectEntity()混淆, 造成伤害的实体是当受伤害者死亡时最终归因的实体. 例如, 如果受伤害者被弹射物击中, 将返回射击者/投掷者.原文: Get the
Entitythat caused the damage to occur.Not to be confused with
getDirectEntity(), the causing entity is the entity to which the damage is ultimately attributed if the receiver is killed. If, for example, the receiver was damaged by a projectile, the shooter/thrower would be returned.- 返回:
- 一个Entity或null
-
getDirectEntity
获取直接造成伤害的Entity.不要与
getCausingEntity()混淆, 直接实体是实际造成伤害的实体. 例如, 如果受伤害者被弹射物击中, 将返回弹射物.原文: Get the
Entitythat directly caused the damage.Not to be confused with
getCausingEntity(), the direct entity is the entity that actually inflicted the damage. If, for example, the receiver was damaged by a projectile, the projectile would be returned.- 返回:
- 一个Entity或null
-
getDamageLocation
获取伤害来源的Location. 仅在伤害不是由实体造成时存在.原文: Get the
Locationfrom where the damage originated. This will only be present if an entity did not cause the damage.- 返回:
- 位置, 如果没有则返回null
-
getSourceLocation
获取伤害来源的Location.这是一个便捷方法来获取伤害的最终位置. 此方法将尝试返回
伤害位置. 如果为null, 将返回造成伤害实体的位置. 最后如果既没有伤害位置也没有造成伤害的实体, 将返回null.原文: Get the
Locationfrom where the damage originated.This is a convenience method to get the final location of the damage. This method will attempt to return
the damage location. If this is null, thecausing entity locationwill be returned. Finally if there is no damage location nor a causing entity, null will be returned.- 返回:
- 位置来源或null.
-
isIndirect
boolean isIndirect()获取此伤害是否为间接伤害.如果
getCausingEntity()不等于getDirectEntity(), 则伤害被视为间接的. 例如, 如果骷髅射箭或玩家投掷药水, 就是这种情况.原文: Get if this damage is indirect.
Damage is considered indirect if
getCausingEntity()is not equal togetDirectEntity(). This will be the case, for example, if a skeleton shot an arrow or a player threw a potion.- 返回:
true如果是间接伤害,false否则.
-
getFoodExhaustion
float getFoodExhaustion()获取此伤害造成的饥饿消耗量.原文: Get the amount of hunger exhaustion caused by this damage.
- 返回:
- 造成的饥饿消耗量.
-
scalesWithDifficulty
boolean scalesWithDifficulty()获取此伤害来源是否随难度缩放.原文: Gets if this source of damage scales with difficulty.
- 返回:
True如果缩放.
-
builder
创建一个新的DamageSource.Builder.原文: Create a new
DamageSource.Builder.- 参数:
damageType- 要使用的DamageType- 返回:
- 一个
DamageSource.Builder
-