Record Class Potion

java.lang.Object
java.lang.Record
net.minestom.server.potion.Potion
Record Components:
effect - the potion effect
amplifier - the amplifier starting at 0 (level 1)
duration - the duration (in ticks) that the potion will last
flags - the flags of the potion, see flags()
All Implemented Interfaces:
NetworkBuffer.Writer

public record Potion(@NotNull PotionEffect effect, byte amplifier, int duration, byte flags) extends Record implements NetworkBuffer.Writer
Represents a potion effect that can be added to an Entity.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte
    A flag indicating that this Potion is ambient (it came from a beacon).
    static final byte
    A flag instructing the client to use its builtin blending effect, only used with the darkness effect currently.
    static final byte
    A flag indicating that this Potion has an icon.
    static final int
    A duration constant which sets a Potion duration to infinite.
    static final byte
    A flag indicating that this Potion has particles.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Potion(@NotNull NetworkBuffer reader)
     
    Potion(@NotNull PotionEffect effect, byte amplifier, int duration)
    Creates a new Potion with no flags.
    Potion(@NotNull PotionEffect effect, byte amplifier, int duration, byte flags)
    Creates an instance of a Potion record class.
    Potion(@NotNull PotionEffect effect, byte amplifier, int duration, int flags)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte
    Returns the value of the amplifier record component.
    int
    Returns the value of the duration record component.
    @NotNull PotionEffect
    Returns the value of the effect record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    byte
    Returns the flags that this Potion has.
    boolean
     
    final int
    Returns a hash code value for this object.
    boolean
    Returns whether this Potion has an icon or not.
    boolean
    Returns whether this Potion has particles or not.
    boolean
    Returns whether this Potion is ambient (it came from a beacon) or not.
    void
    sendAddPacket(@NotNull Entity entity)
    Sends a packet that a potion effect has been applied to the entity.
    void
    sendRemovePacket(@NotNull Entity entity)
    Sends a packet that a potion effect has been removed from the entity.
    final String
    Returns a string representation of this record class.
    void
    write(@NotNull NetworkBuffer writer)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Potion

      public Potion(@NotNull @NotNull PotionEffect effect, byte amplifier, int duration, int flags)
      See Also:
    • Potion

      public Potion(@NotNull @NotNull PotionEffect effect, byte amplifier, int duration)
      Creates a new Potion with no flags.
      See Also:
    • Potion

      public Potion(@NotNull @NotNull NetworkBuffer reader)
    • Potion

      public Potion(@NotNull @NotNull PotionEffect effect, byte amplifier, int duration, byte flags)
      Creates an instance of a Potion record class.
      Parameters:
      effect - the value for the effect record component
      amplifier - the value for the amplifier record component
      duration - the value for the duration record component
      flags - the value for the flags record component
  • Method Details

    • flags

      public byte flags()
      Returns the flags that this Potion has.
      See Also:
    • isAmbient

      public boolean isAmbient()
      Returns whether this Potion is ambient (it came from a beacon) or not.
      Returns:
      true if the Potion is ambient
    • hasParticles

      public boolean hasParticles()
      Returns whether this Potion has particles or not.
      Returns:
      true if the Potion has particles
    • hasIcon

      public boolean hasIcon()
      Returns whether this Potion has an icon or not.
      Returns:
      true if the Potion has an icon
    • hasBlend

      public boolean hasBlend()
    • sendAddPacket

      public void sendAddPacket(@NotNull @NotNull Entity entity)
      Sends a packet that a potion effect has been applied to the entity.

      Used internally by Entity.addEffect(Potion)

      Parameters:
      entity - the entity to add the effect to
    • sendRemovePacket

      public void sendRemovePacket(@NotNull @NotNull Entity entity)
      Sends a packet that a potion effect has been removed from the entity.

      Used internally by Entity.removeEffect(PotionEffect)

      Parameters:
      entity - the entity to remove the effect from
    • write

      public void write(@NotNull @NotNull NetworkBuffer writer)
      Specified by:
      write in interface NetworkBuffer.Writer
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • effect

      @NotNull public @NotNull PotionEffect effect()
      Returns the value of the effect record component.
      Returns:
      the value of the effect record component
    • amplifier

      public byte amplifier()
      Returns the value of the amplifier record component.
      Returns:
      the value of the amplifier record component
    • duration

      public int duration()
      Returns the value of the duration record component.
      Returns:
      the value of the duration record component