Interface DamageSource
-
- All Known Subinterfaces:
BlockDamageSource
,EntityDamageSource
,FallingBlockDamageSource
,IndirectEntityDamageSource
- All Known Implementing Classes:
AbstractDamageSource
,AbstractEntityDamageSource
,AbstractIndirectEntityDamageSource
public interface DamageSource
Represents aCause
for damage on theEntity
being damaged. Usually theDamageSource
will have different properties based on the source of damage, such asEntityDamageSource
s,BlockDamageSource
s, andFallingBlockDamageSource
s.Almost always, the
DamageSource
will be the first element in theCause
of the event. Any additional modifiers that "aid" theCause
of the event will be listed subsequently.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
DamageSource.Builder
static interface
DamageSource.DamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
static interface
DamageSource.Factory
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static DamageSource.Builder
builder()
Creates a newbuilder
to build aDamageSource
.boolean
doesAffectCreative()
Gets whether thisDamageSource
is considered to damage creative, or otherwise "normally unharmable" players.double
exhaustion()
Gets the amount of exhaustion thisDamageSource
will add to the entity, generally only to players.boolean
isAbsolute()
Gets whether thisDamageSource
's damage is absolute and will ignore potion effects and enchantments.boolean
isBypassingArmor()
Gets whether thisDamageSource
will deal damage that bypasses any armor.boolean
isExplosive()
Gets whether thisDamageSource
is an explosion.boolean
isFire()
Gets whether thisDamageSource
is considered to be "fire" based, can be from flames or blocks that are flaming, or the entity being on fire.boolean
isMagic()
Gets whether thisDamageSource
is considered to be magical damage, such as potions, or other sources.boolean
isScaledByDifficulty()
Gets whether thisDamageSource
's damage is scaled byDifficulty
.DamageType
type()
Gets theDamageType
of this source.
-
-
-
Method Detail
-
builder
static DamageSource.Builder builder()
Creates a newbuilder
to build aDamageSource
.- Returns:
- A new builder
-
type
DamageType type()
Gets theDamageType
of this source.- Returns:
- The damage type
-
isAbsolute
boolean isAbsolute()
Gets whether thisDamageSource
's damage is absolute and will ignore potion effects and enchantments.- Returns:
- If this damage source deals absolute damage
-
isBypassingArmor
boolean isBypassingArmor()
Gets whether thisDamageSource
will deal damage that bypasses any armor.- Returns:
- True if this damage source bypasses armor
-
isScaledByDifficulty
boolean isScaledByDifficulty()
Gets whether thisDamageSource
's damage is scaled byDifficulty
.- Returns:
- True if the damage from this source is scaled
-
isExplosive
boolean isExplosive()
Gets whether thisDamageSource
is an explosion.- Returns:
- True if this damage source is an explosion
-
isMagic
boolean isMagic()
Gets whether thisDamageSource
is considered to be magical damage, such as potions, or other sources.- Returns:
- If this damage is magic based
-
doesAffectCreative
boolean doesAffectCreative()
Gets whether thisDamageSource
is considered to damage creative, or otherwise "normally unharmable" players. Usually associated withDamageTypes.VOID
.- Returns:
- If this damage should affect creative players
-
isFire
boolean isFire()
Gets whether thisDamageSource
is considered to be "fire" based, can be from flames or blocks that are flaming, or the entity being on fire. Usually is possible to bypass or ignore this damage if the owning entity hasPotionEffectTypes.FIRE_RESISTANCE
active.- Returns:
- If this damage is considered fire
-
exhaustion
double exhaustion()
Gets the amount of exhaustion thisDamageSource
will add to the entity, generally only to players.In vanilla gameplay this is set to 0.1 by default and overridden to 0 if the source is set to be absolute or as overriding armor.
- Returns:
- The increase in exhaustion
-
-