Interface DamageSource
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Utility class to make building aDamageSource
easier. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull DamageSource.Builder
builder
(@NotNull DamageType damageType) Create a newDamageSource.Builder
.@Nullable Entity
Get theEntity
that caused the damage to occur.@Nullable Location
Get theLocation
from where the damage originated.@NotNull DamageType
Get theDamageType
.@Nullable Entity
Get theEntity
that directly caused the damage.폭발 래퍼를 가져옵니다.@Nullable Integer
이 인스턴스에 설정된 무적 시간을 가져옵니다.float
Get the amount of hunger exhaustion caused by this damage.사용자 지정 메타데이터를 가져옵니다.@NotNull Object
NMS DamageSource를 가져옵니다.@Nullable Location
Get theLocation
from where the damage originated.boolean
크리티컬 대미지 여부를 가져옵니다.boolean
Get if this damage is indirect.@Nullable Boolean
대미지 처리 이후 엔티티가 받게 될 넉백의 비활성화 여부를 가져옵니다.boolean
Gets if this source of damage scales with difficulty.void
setFixedNoDamageTick
(@Nullable Integer ticks) 이 인스턴스에 설정될 무적 시간을 설정합니다.void
setKnockbackDisabled
(@Nullable Boolean disabled) 대미지 처리 이후 엔티티가 받게 될 넉백의 비활성화 여부를 설정합니다.
-
Method Details
-
getNmsDamageSource
NMS DamageSource를 가져옵니다.- Returns:
- NMS DamageSource
-
getMetadata
사용자 지정 메타데이터를 가져옵니다.DamageSource 인스턴스는 재사용이 가능하므로 메타데이터 공유에 주의하세요.
- Returns:
- 사용자 지정 메타데이터
-
getFixedNoDamageTick
이 인스턴스에 설정된 무적 시간을 가져옵니다.- Returns:
- 무적 시간
-
setFixedNoDamageTick
이 인스턴스에 설정될 무적 시간을 설정합니다.이 설정은 이벤트에서 지정된 무적 시간보다 우선순위가 낮습니다.
- Parameters:
ticks
- 무적 시간
-
isKnockbackDisabled
대미지 처리 이후 엔티티가 받게 될 넉백의 비활성화 여부를 가져옵니다.- Returns:
- 넉백 비활성화 여부
-
setKnockbackDisabled
대미지 처리 이후 엔티티가 받게 될 넉백의 비활성화 여부를 설정합니다.- Parameters:
disabled
- 넉백 비활성화 여부,null
인 경우DamageTypeTags.NO_KNOCKBACK
의 영향을 받습니다.
-
isCritical
boolean isCritical()크리티컬 대미지 여부를 가져옵니다.- Returns:
- 크리티컬 대미지 여부
-
getExplosion
폭발 래퍼를 가져옵니다.- Returns:
- 폭발 래퍼
-
getDamageType
Get theDamageType
.- Returns:
- the damage type
-
getCausingEntity
Get theEntity
that 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.- Returns:
- an Entity or null
-
getDirectEntity
Get theEntity
that 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.- Returns:
- an Entity or null
-
getDamageLocation
Get theLocation
from where the damage originated. This will only be present if an entity did not cause the damage.- Returns:
- the location, or null if none
- API Note:
- the world of the location might be null for positioned-only damage source not caused by any entity
-
getSourceLocation
Get theLocation
from 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 location
will be returned. Finally if there is no damage location nor a causing entity, null will be returned.- Returns:
- the source of the location or null.
- API Note:
- the world of the location might be null for positioned-only damage source not caused by any entity
-
isIndirect
boolean isIndirect()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.- Returns:
true
if is indirect,false
otherwise.
-
getFoodExhaustion
float getFoodExhaustion()Get the amount of hunger exhaustion caused by this damage.- Returns:
- the amount of hunger exhaustion caused.
-
scalesWithDifficulty
boolean scalesWithDifficulty()Gets if this source of damage scales with difficulty.- Returns:
True
if scales.
-
builder
Create a newDamageSource.Builder
.- Parameters:
damageType
- theDamageType
to use- Returns:
- a
DamageSource.Builder
-