Interface DamageSource
public interface DamageSource
Represents a
Cause
for damage on the Entity
being
damaged. Usually the DamageSource
will have different properties
based on the DamageType
and its associated tags
Almost always, the DamageSource
will be the first element in
the Cause
of the event. Any additional modifiers that "aid" the
Cause
of the event will be listed subsequently.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
static interface
-
Method Summary
Modifier and TypeMethodDescriptionGets theBlockSnapshot
of the source.static DamageSource.Builder
builder()
Creates a newbuilder
to build aDamageSource
.boolean
Gets whether thisDamageSource
is considered to damage creative, or otherwise "normally unharmable" players.default double
Gets the amount of exhaustion thisDamageSource
will add to the entity, generally only to players.default boolean
Deprecated.default boolean
Gets whether thisDamageSource
will deal damage that bypasses any armor.default boolean
Gets whether thisDamageSource
is an explosion.default 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.default boolean
isMagic()
Gets whether thisDamageSource
is considered to be magical damage, such as potions, or other sources.default boolean
Gets whether thisDamageSource
's damage is scaled byDifficulty
.location()
Gets the location of theBlockSnapshot
.position()
source()
Gets theEntity
that is the source.type()
Gets theDamageType
of this source.
-
Method Details
-
builder
Creates a newbuilder
to build aDamageSource
.- Returns:
- A new builder
-
type
DamageType type()Gets theDamageType
of this source.- Returns:
- The damage type
-
isAbsolute
Deprecated.Gets whether thisDamageSource
's damage is absolute and will ignore potion effects and enchantments.- Returns:
- If this damage source deals absolute damage
-
isBypassingArmor
default boolean isBypassingArmor()Gets whether thisDamageSource
will deal damage that bypasses any armor.- Returns:
- True if this damage source bypasses armor
-
isScaledByDifficulty
default boolean isScaledByDifficulty()Gets whether thisDamageSource
's damage is scaled byDifficulty
.- Returns:
- True if the damage from this source is scaled
-
isExplosive
default boolean isExplosive()Gets whether thisDamageSource
is an explosion.- Returns:
- True if this damage source is an explosion
-
isMagic
default 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.OUT_OF_WORLD
.- Returns:
- If this damage should affect creative players
-
isFire
default 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
default 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
-
source
Gets theEntity
that is the source.Note that a
falling block entity
has some additional information available as data including -Keys.DAMAGE_PER_BLOCK
-Keys.MAX_FALL_DAMAGE
-Keys.CAN_HURT_ENTITIES
-Keys.FALL_TIME
-Keys.CAN_DROP_AS_ITEM
-Keys.CAN_PLACE_AS_BLOCK
- Returns:
- The entity source
-
indirectSource
- Returns:
- The indirect source
-
position
-
location
Optional<ServerLocation> location()Gets the location of theBlockSnapshot
.- Returns:
- The location of the block
-
blockSnapshot
Optional<BlockSnapshot> blockSnapshot()Gets theBlockSnapshot
of the source.- Returns:
- The block snapshot of the source
-