Damage constructor

Damage(
  1. Entity target, {
  2. required double amount,
  3. String? damageType,
  4. Location? location,
  5. Entity? by,
  6. Entity? cause,
})

Wrapper for the damage command which simulates the situation of causing damage to the entity.

constructor
Entity target entity
amount floating point number (must >= 0)
damageType String type of damage(optional)
location Location where to deal the damage(optional)
by Entity which deals damage(optional, not together with location)
cause specifies the cause Entity of the damage(optional, only together with by)
Damage(
  Entity.Self(),
  amount: 4.5,
  damageType: "minecraft:falling_block"
)
⇒ damage @s 4.5 minecraft:falling_block

Implementation

Damage(
  this.target, {
  required this.amount,
  this.damageType,
  this.location,
  this.by,
  this.cause,
})  : assert(amount >= 0),
      assert(location == null || cause == null);