Package net.minestom.server.potion
Record Class Potion
java.lang.Object
java.lang.Record
net.minestom.server.potion.Potion
- Record Components:
effect
- the potion effectamplifier
- the amplifier starting at 0 (level 1)duration
- the duration (in ticks) that the potion will lastflags
- the flags of the potion, seeflags()
- 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
Modifier and TypeFieldDescriptionstatic 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
ConstructorDescriptionPotion
(@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 aPotion
record class.Potion
(@NotNull PotionEffect effect, byte amplifier, int duration, int flags) -
Method Summary
Modifier and TypeMethodDescriptionbyte
Returns the value of theamplifier
record component.int
duration()
Returns the value of theduration
record component.@NotNull PotionEffect
effect()
Returns the value of theeffect
record component.final boolean
Indicates whether some other object is "equal to" this one.byte
flags()
Returns the flags that this Potion has.boolean
hasBlend()
final int
hashCode()
Returns a hash code value for this object.boolean
hasIcon()
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
toString()
Returns a string representation of this record class.void
write
(@NotNull NetworkBuffer writer)
-
Field Details
-
AMBIENT_FLAG
public static final byte AMBIENT_FLAGA flag indicating that this Potion is ambient (it came from a beacon).- See Also:
-
PARTICLES_FLAG
public static final byte PARTICLES_FLAGA flag indicating that this Potion has particles.- See Also:
-
ICON_FLAG
public static final byte ICON_FLAGA flag indicating that this Potion has an icon.- See Also:
-
BLEND_FLAG
public static final byte BLEND_FLAGA flag instructing the client to use its builtin blending effect, only used with the darkness effect currently.- See Also:
-
INFINITE_DURATION
public static final int INFINITE_DURATIONA duration constant which sets a Potion duration to infinite.- See Also:
-
-
Constructor Details
-
Potion
- See Also:
-
Potion
Creates a new Potion with no flags.- See Also:
-
Potion
-
Potion
Creates an instance of aPotion
record class.
-
-
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
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
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
- Specified by:
write
in interfaceNetworkBuffer.Writer
-
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. -
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. -
equals
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 withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
effect
Returns the value of theeffect
record component.- Returns:
- the value of the
effect
record component
-
amplifier
public byte amplifier()Returns the value of theamplifier
record component.- Returns:
- the value of the
amplifier
record component
-
duration
public int duration()Returns the value of theduration
record component.- Returns:
- the value of the
duration
record component
-