onAttack method
In your tick function, you can use .onAttack()
to detect the interaction.
This uses the execute on command, and removes the interaction nbt data if present:
Implementation
Execute onAttack({Entity? select, required List<Widget> run}) =>
Execute(as: select ?? this.select(), children: [
Execute.on(Relation.attacker, children: run),
Data.remove(Entity.Self(), path: "attack"),
]).If(Condition.data(Data.get(Entity.Self(), path: "attack")));