Skip to content

AttackEntity ​

com.jsmacrosce.jsmacros.client.api.event.impl.player.EventAttackEntity

Not cancellable

Fires after the local player's entity-attack action.

js
JsMacros.on("AttackEntity", JavaWrapper.methodToJava(function (event) {
  if (event.entity instanceof EntityHelpers.Player) {
    Chat.log(`Attacked player ${event.entity.getName().getString()}`);  
  }
}))

Constructors ​

new EventAttackEntity ​

new EventAttackEntity(Entity entity)#
Initializes the event with the client core and wraps the supplied entity. The helper refers to the supplied entity; it is not a copy or snapshot. A null entity causes NullPointerException during wrapping.

Parameters:

  • entity: the Minecraft entity to wrap

Fields ​

entity ​

entity: EntityHelper<?>read-only#
The attacked entity, wrapped in the most specific EntityHelper subclass for its type. Use instanceof EntityHelpers.Player and the other namespace types to narrow the wrapper; the as...() helpers are casts. Its type and name are available from getType() and getName().

Methods ​

toString ​

toString(): String#
Returns a diagnostic string containing the event name and stored entity helper. The helper's representation is determined by its runtime implementation; the result uses the literal format %s:{"entity": %s} and is not JSON as a whole.
Returns: the formatted event name and entity-helper representation