Class LivingAttackEvent

java.lang.Object
net.neoforged.bus.api.Event
All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent

public class LivingAttackEvent extends LivingEvent implements net.neoforged.bus.api.ICancellableEvent
LivingAttackEvent is fired when a living Entity is attacked.
This event is fired whenever an Entity is attacked in LivingEntity.hurt(DamageSource, float) and Player.hurt(DamageSource, float).

This event is fired via the CommonHooks.onLivingAttack(LivingEntity, DamageSource, float).

source contains the DamageSource of the attack.
amount contains the amount of damage dealt to the entity.

This event is ICancellableEvent.
If this event is canceled, the Entity does not take attack damage.

This event does not have a result. Event.HasResult

This event is fired on the NeoForge.EVENT_BUS.
  • Field Details

    • source

      private final DamageSource source
    • amount

      private final float amount
  • Constructor Details

  • Method Details

    • getSource

      public DamageSource getSource()
    • getAmount

      public float getAmount()