类 LivingDrownEvent
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.LivingDrownEvent
- 所有已实现的接口:
net.neoforged.bus.api.ICancellableEvent
public class LivingDrownEvent
extends LivingEvent
implements net.neoforged.bus.api.ICancellableEvent
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 CommonHooks.onLivingBreathe(LivingEntity, int, int)
.
This event is ICancellableEvent
. Effects of cancellation are noted in setCanceled(boolean)
.
This event does not
.
This event is fired on 引用无效
have a result
NeoForge.EVENT_BUS
-
嵌套类概要
从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEvent
从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
字段概要
字段 -
构造器概要
构造器构造器说明LivingDrownEvent
(LivingEntity entity) Constructor which auto-populates with all vanilla values.LivingDrownEvent
(LivingEntity entity, boolean isDrowning, float damageAmount, int bubbleCount) Constructs a new LivingDrownEvent. -
方法概要
修饰符和类型方法说明int
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.从类继承的方法 net.neoforged.neoforge.event.entity.living.LivingEvent
getEntity
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 net.neoforged.bus.api.ICancellableEvent
isCanceled
-
字段详细资料
-
isDrowning
private boolean isDrowning -
damageAmount
private float damageAmount -
bubbleCount
private int bubbleCount
-
-
构造器详细资料
-
LivingDrownEvent
public LivingDrownEvent(LivingEntity entity, boolean isDrowning, float damageAmount, int bubbleCount) Constructs a new LivingDrownEvent.- 参数:
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
Constructor which auto-populates with all vanilla values.- 另请参阅:
-
-
方法详细资料
-
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.- 返回:
- If the entity is actively drowning.
-
setDrowning
public void setDrowning(boolean isDrowning) Sets if the entity is actively drowning.- 参数:
isDrowning
- The new value.- 另请参阅:
-
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.- 返回:
- 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.- 参数:
damageAmount
- The new value.- 另请参阅:
-
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.- 返回:
- 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.- 参数:
bubbleCount
- The new value.- 另请参阅:
-
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.- 指定者:
setCanceled
在接口中net.neoforged.bus.api.ICancellableEvent
-