Class LivingIncomingDamageEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.LivingEvent
net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
public class LivingIncomingDamageEvent
extends LivingEvent
implements net.neoforged.bus.api.ICancellableEvent
LivingIncomingDamageEvent is fired when a LivingEntity is about to receive damage.
This event is fired in
For custom posting of this event, the event expects to be fired before any damage reductions have been calculated. This event expects a mutable
This event is fired via the
This event is fired in
LivingEntity.hurt(DamageSource, float)
after invulnerability checks but before any damage processing/mitigation.
For custom posting of this event, the event expects to be fired before any damage reductions have been calculated. This event expects a mutable
DamageContainer
.
This event is fired via the
CommonHooks.onEntityIncomingDamage(LivingEntity, DamageContainer)
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEvent
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addReductionModifier
(DamageContainer.Reduction type, IReductionFunction reductionFunc) Reduction modifiers alter the vanilla damage reduction before it modifies the damage value.float
Returns the current damage to be applied to the entity.Returns the container for this damage sequence.float
Returns the damage value passed into the damage sequence before modifications.Returns theDamageSource
for this damage sequence.void
setAmount
(float newDamage) void
setInvulnerabilityTicks
(int ticks) When an entity's invulnerable time is fully cooled down, 20 ticks of invulnerability is added on the next attack.Methods inherited from class net.neoforged.neoforge.event.entity.living.LivingEvent
getEntity
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
Field Details
-
container
-
-
Constructor Details
-
LivingIncomingDamageEvent
-
-
Method Details
-
getContainer
Returns the container for this damage sequence.- Returns:
- the container for this damage sequence
-
getSource
Returns theDamageSource
for this damage sequence.- Returns:
- the
DamageSource
for this damage sequence
-
getAmount
public float getAmount()Returns the current damage to be applied to the entity.- Returns:
- the current damage to be applied to the entity
-
getOriginalAmount
public float getOriginalAmount()Returns the damage value passed into the damage sequence before modifications.- Returns:
- the damage value passed into the damage sequence before modifications
-
setAmount
public void setAmount(float newDamage) - Parameters:
newDamage
- the damage value to be used in the rest of the damage sequence.
-
addReductionModifier
Reduction modifiers alter the vanilla damage reduction before it modifies the damage value. Modifiers are executed in sequence.- Parameters:
type
- the reduction type to be modifiedreductionFunc
- the function to apply to the reduction value.
-
setInvulnerabilityTicks
public void setInvulnerabilityTicks(int ticks) When an entity's invulnerable time is fully cooled down, 20 ticks of invulnerability is added on the next attack. This method allows for setting a new invulnerability tick count when those conditions are met.
Note: this value will be ignored if the damage is taken while invulnerability ticks are greater than 10 and the damage source does not bypass invulnerability- Parameters:
ticks
- the number of ticks for the entity to remain invulnerable to incoming damage
-