类 LivingDrownEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event

public class LivingDrownEvent extends LivingEvent
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

  • 字段详细资料

    • isDrowning

      private boolean isDrowning
    • damageAmount

      private float damageAmount
    • bubbleCount

      private int bubbleCount
  • 构造器详细资料

    • LivingDrownEvent

      @Internal 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.
  • 方法详细资料

    • 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 to setDrowning(boolean) with a value of false.
      However, this also incurs the usual side effects of cancellation.
      覆盖:
      setCanceled 在类中 net.minecraftforge.eventbus.api.Event