Skip to content

EntityDamaged ​

com.jsmacrosce.jsmacros.client.api.event.impl.world.EventEntityDamaged

Not cancellable

Fires before a client-side living entity's health decreases through setHealth; it does not identify a damage source. health is the incoming value and damage is the difference from the previously tracked health.

js
JsMacros.on("EntityDamaged", JavaWrapper.methodToJava(function (event) {
  if (event.entity instanceof EntityHelpers.Creeper) {
    Chat.log(`Creeper took ${event.damage} damage; incoming health: ${event.health}`);  
  }
}))

Constructors ​

new EventEntityDamaged ​

new EventEntityDamaged(Entity e, float health, float amount)#
Wraps an entity and stores the supplied health and damage values without applying damage. A null entity causes Objects.requireNonNull(Object) to throw NullPointerException during helper creation.

Parameters:

  • e: non-null entity to wrap; no living-entity validation is performed
  • health: supplied incoming health value; it is stored unchanged and not applied
  • amount: supplied decrease amount, stored unchanged as damage without calculation or validation

Fields ​

damage ​

damage: floatread-only#
Decrease from the previously tracked health; positive.

entity ​

entity: EntityHelper<?>read-only#
Entity whose health is decreasing.

health ​

health: floatSince1.6.5read-only#
Incoming health value passed to setHealth.

Methods ​

toString ​

toString(): String#
Returns a diagnostic string containing the event name, entity helper string, and stored values. The format is %s:{"entity": %s, "health": %f, "damage": %f}.
Returns: diagnostic text in the stated format