Interface PotionEffect

All Superinterfaces:
DataSerializable

public interface PotionEffect extends DataSerializable
Represents an effect of a PotionEffectType for a specified duration(), amplifier(), showsParticles() and showsIcon(). The PotionEffect itself is immutable once created and can be offered to Entity instances through the Keys.POTION_EFFECTS.
  • Method Details

    • builder

      static PotionEffect.Builder builder()
      Creates a new PotionEffect.Builder to build a PotionEffect.
      Returns:
      The new builder
    • of

      static PotionEffect of(PotionEffectType type, int amplifier, Ticks duration) throws IllegalArgumentException
      Creates a new PotionEffect with the provided PotionEffectType, the provided amplifier, and the provided duration in ticks.
      Parameters:
      type - The potion type
      amplifier - The zero-indexed amplifier
      duration - The duration in ticks
      Returns:
      The potion effect
      Throws:
      IllegalArgumentException - If the duration is not positive
    • of

      static PotionEffect of(Supplier<? extends PotionEffectType> type, int amplifier, Ticks duration) throws IllegalArgumentException
      Creates a new PotionEffect with the provided PotionEffectType, the provided amplifier, and the provided duration in ticks.
      Parameters:
      type - The potion type
      amplifier - The amplifier
      duration - The duration in ticks
      Returns:
      The potion effect
      Throws:
      IllegalArgumentException - If the duration is not positive
    • type

      Gets the PotionEffectType of this potion.
      Returns:
      The type.
    • duration

      Ticks duration()
      Gets the duration in ticks for which this potion effect will apply for.
      Returns:
      The duration in ticks.
    • amplifier

      int amplifier()
      Gets the amplifier at which this potion effect will apply effects.

      A potion amplifier dictates the potion level as a zero based index. An amplifier of zero will produce a potion effect of level 1 (e.g. Strength I), while an amplifier of four will produce a potion effect corresponding to a potion of level 4 (e.g. Strength V).

      Returns:
      The amplifier as a zero-indexed integer.
    • isAmbient

      boolean isAmbient()
      Gets whether or not this potion effect is an ambient effect. Ambient potions emit more translucent particles.
      Returns:
      If the effect should be ambient.
    • showsParticles

      boolean showsParticles()
      Gets whether or not this potion effect is showing particles.
      Returns:
      If particles should be shown.
    • showsIcon

      boolean showsIcon()
      Gets whether or not this potion effect is showing its icon.
      Returns:
      If the icon should be shown.