Class LivingKnockBackEvent

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

public class LivingKnockBackEvent extends LivingEvent implements net.neoforged.bus.api.ICancellableEvent
LivingKnockBackEvent is fired when a living entity is about to be knocked back.
This event is fired whenever an Entity is knocked back in LivingEntity.hurt(DamageSource, float), LivingEntity#blockUsingShield(LivingEntity), Mob.doHurtTarget(Entity) and Player.attack(Entity)

This event is fired via CommonHooks.onLivingKnockBack(LivingEntity, float, double, double) .

strength contains the strength of the knock back.
ratioX contains the x ratio of the knock back.
ratioZ contains the z ratio of the knock back.

This event is ICancellableEvent.
If this event is canceled, the entity is not knocked back.

This event does not have a result.
invalid reference
HasResult


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

    • strength

      protected float strength
    • ratioX

      protected double ratioX
    • ratioZ

      protected double ratioZ
    • originalStrength

      protected final float originalStrength
    • originalRatioX

      protected final double originalRatioX
    • originalRatioZ

      protected final double originalRatioZ
  • Constructor Details

    • LivingKnockBackEvent

      public LivingKnockBackEvent(LivingEntity target, float strength, double ratioX, double ratioZ)
  • Method Details

    • getStrength

      public float getStrength()
    • getRatioX

      public double getRatioX()
    • getRatioZ

      public double getRatioZ()
    • getOriginalStrength

      public float getOriginalStrength()
    • getOriginalRatioX

      public double getOriginalRatioX()
    • getOriginalRatioZ

      public double getOriginalRatioZ()
    • setStrength

      public void setStrength(float strength)
    • setRatioX

      public void setRatioX(double ratioX)
    • setRatioZ

      public void setRatioZ(double ratioZ)