Class LivingDamageEvent.Pre

Enclosing class:
LivingDamageEvent

public static class LivingDamageEvent.Pre extends LivingDamageEvent
LivingDamageEvent.Pre is fired when an Entity is set to be hurt.
At this point armor, and potion modifiers have already been applied to the damage value and the entity. Absorption modifiers are handled after this event.
This event is fired in LivingEntity#actuallyHurt(DamageSource, float
For custom posting of this event, the event expects to be fired after damage reductions have been calculated but before any changes to the entity health has been applied. This event expects a mutable DamageContainer.
This event is fired via the CommonHooks.onLivingDamagePre(LivingEntity, DamageContainer).
See Also:
  • Field Details

  • Constructor Details

    • Pre

      public Pre(net.minecraft.world.entity.LivingEntity entity, DamageContainer container)
  • Method Details

    • getContainer

      public DamageContainer getContainer()
      Returns the DamageContainer instance for this damage sequence.
      Returns:
      the DamageContainer instance for this damage sequence
    • getSource

      public net.minecraft.world.damagesource.DamageSource getSource()
      Returns the damage source for this damage sequence.
      Returns:
      the damage source for this damage sequence
    • getNewDamage

      public float getNewDamage()
      Returns the current value to be applied to the entity's health after this event.
      Returns:
      the current value to be applied to the entity's health after this event
    • getOriginalDamage

      public float getOriginalDamage()
      Returns the original damage amount from the damage source.
      Returns:
      the original damage amount from the damage source
    • setNewDamage

      public void setNewDamage(float newDamage)
      Sets the amount to reduce the entity health by
      Parameters:
      newDamage - the new damage value