Class LivingDrownEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.entity.EntityEvent
net.minecraftforge.event.entity.living.LivingEvent
net.minecraftforge.event.entity.living.LivingDrownEvent
LivingDrownEvent is fired whenever a living entity can't breathe and its air supply is less than or equal to zero.
This event is fired via ForgeHooks.onLivingBreathe(LivingEntity, int, int)
.
This event is Cancelable
. Effects of cancellation are noted in setCanceled(boolean)
.
This event does not have a result.
This event is fired on MinecraftForge.EVENT_BUS
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingTickEvent, LivingEvent.LivingVisibilityEvent
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.EyeHeight, EntityEvent.Size
Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
-
Field Summary
Modifier and TypeFieldDescriptionprivate int
private float
private boolean
-
Constructor Summary
ConstructorDescriptionLivingDrownEvent
(LivingEntity entity, boolean isDrowning) Deprecated, for removal: This API element is subject to removal in a future version.LivingDrownEvent
(LivingEntity entity, boolean isDrowning, float damageAmount, int bubbleCount) Constructs a new LivingDrownEvent. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the number of ParticleTypes.BUBBLE particles that would be spawned.
Bubbles are only spawned if the entity is actively drowning.
For vanilla entities, the default value is 8 particles.float
Gets the amount of drowning damage the entity would take.
Drowning damage is only inflicted if the entity is actively drowning.
For vanilla entities, the default amount of damage is 2 (1 heart).boolean
This method returns true if the entity is "actively" drowning.
For most entities, this happens when their air supply reaches -20.
When this is true, the entity will take damage, spawn particles, and reset their air supply to 0.void
setBubbleCount
(int bubbleCount) Sets the amount of bubbles that may be spawned.void
setCanceled
(boolean cancel) Cancels the drowning event.
Cancellation is mostly equivalent tosetDrowning(boolean)
with a value of false.
However, this also incurs the usual side effects of cancellation.void
setDamageAmount
(float damageAmount) Sets the amount of drowning damage that may be inflicted.void
setDrowning
(boolean isDrowning) Sets if the entity is actively drowning.Methods inherited from class net.minecraftforge.event.entity.living.LivingEvent
getEntity
Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setPhase, setResult
-
Field Details
-
isDrowning
private boolean isDrowning -
damageAmount
private float damageAmount -
bubbleCount
private int bubbleCount
-
-
Constructor Details
-
LivingDrownEvent
@Internal public LivingDrownEvent(LivingEntity entity, boolean isDrowning, float damageAmount, int bubbleCount) Constructs a new LivingDrownEvent.- Parameters:
entity
- The entity that is drowning.isDrowning
- If the entity is "actively" drowning, and would take damage.damageAmount
- The amount of drowning damage the entity would take.bubbleCount
- The number of ParticleTypes.BUBBLE particles that will be spawned when actively drowning.
-
LivingDrownEvent
@Internal @Deprecated(forRemoval=true, since="1.20.1") public LivingDrownEvent(LivingEntity entity, boolean isDrowning) Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Details
-
isDrowning
public boolean isDrowning()This method returns true if the entity is "actively" drowning.
For most entities, this happens when their air supply reaches -20.
When this is true, the entity will take damage, spawn particles, and reset their air supply to 0.- Returns:
- If the entity is actively drowning.
-
setDrowning
public void setDrowning(boolean isDrowning) Sets if the entity is actively drowning.- Parameters:
isDrowning
- The new value.- See Also:
-
getDamageAmount
public float getDamageAmount()Gets the amount of drowning damage the entity would take.
Drowning damage is only inflicted if the entity is actively drowning.
For vanilla entities, the default amount of damage is 2 (1 heart).If the damage amount is less than or equal to zero,
Entity.hurt(net.minecraft.world.damagesource.DamageSource, float)
will not be called.- Returns:
- The amount of damage that will be dealt to the entity when actively drowning.
-
setDamageAmount
public void setDamageAmount(float damageAmount) Sets the amount of drowning damage that may be inflicted.- Parameters:
damageAmount
- The new value.- See Also:
-
getBubbleCount
public int getBubbleCount()Gets the number of ParticleTypes.BUBBLE particles that would be spawned.
Bubbles are only spawned if the entity is actively drowning.
For vanilla entities, the default value is 8 particles.- Returns:
- The number of bubble particles that will spawn when actively drowning.
-
setBubbleCount
public void setBubbleCount(int bubbleCount) Sets the amount of bubbles that may be spawned.- Parameters:
bubbleCount
- The new value.- See Also:
-
setCanceled
public void setCanceled(boolean cancel) Cancels the drowning event.
Cancellation is mostly equivalent tosetDrowning(boolean)
with a value of false.
However, this also incurs the usual side effects of cancellation.- Overrides:
setCanceled
in classnet.minecraftforge.eventbus.api.Event
-