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.

  • Method Details Link icon

    • builder Link icon

      static DamageSource.Builder builder()
      Creates a new builder to build a DamageSource.
      Returns:
      A new builder
    • type Link icon

      DamageType type()
      Gets the DamageType of this source.
      Returns:
      The damage type
    • isAbsolute Link icon

      @Deprecated default boolean isAbsolute()
      Deprecated.
      Gets whether this DamageSource's damage is absolute and will ignore potion effects and enchantments.
      Returns:
      If this damage source deals absolute damage
    • isBypassingArmor Link icon

      default boolean isBypassingArmor()
      Gets whether this DamageSource will deal damage that bypasses any armor.
      Returns:
      True if this damage source bypasses armor
    • isScaledByDifficulty Link icon

      default boolean isScaledByDifficulty()
      Gets whether this DamageSource's damage is scaled by Difficulty.
      Returns:
      True if the damage from this source is scaled
    • isExplosive Link icon

      default boolean isExplosive()
      Gets whether this DamageSource is an explosion.
      Returns:
      True if this damage source is an explosion
    • isMagic Link icon

      default boolean isMagic()
      Gets whether this DamageSource is considered to be magical damage, such as potions, or other sources.
      Returns:
      If this damage is magic based
    • doesAffectCreative Link icon

      boolean doesAffectCreative()
      Gets whether this DamageSource is considered to damage creative, or otherwise "normally unharmable" players. Usually associated with DamageTypes.OUT_OF_WORLD.
      Returns:
      If this damage should affect creative players
    • isFire Link icon

      default boolean isFire()
      Gets whether this DamageSource 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 has PotionEffectTypes.FIRE_RESISTANCE active.
      Returns:
      If this damage is considered fire
    • exhaustion Link icon

      default double exhaustion()
      Gets the amount of exhaustion this DamageSource 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 Link icon

      Optional<Entity> source()
      Gets the Entity 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 Link icon

      Optional<Entity> indirectSource()
      Gets the Entity that is indirectly using the source() to cause damage.
      Returns:
      The indirect source
    • position Link icon

      Optional<Vector3d> position()
    • location Link icon

      Gets the location of the BlockSnapshot.
      Returns:
      The location of the block
    • blockSnapshot Link icon

      Optional<BlockSnapshot> blockSnapshot()
      Gets the BlockSnapshot of the source.
      Returns:
      The block snapshot of the source