Interface PotionEffect
-
- All Superinterfaces:
DataSerializable
public interface PotionEffect extends DataSerializable
Represents an effect of aPotionEffectType
for a specifiedduration()
,amplifier()
,showsParticles()
andshowsIcon()
. ThePotionEffect
itself is immutable once created and can be offered toEntity
instances through theKeys.POTION_EFFECTS
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
PotionEffect.Builder
Represents a builder interface to create aPotionEffect
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description int
amplifier()
Gets the amplifier at which this potion effect will apply effects.static PotionEffect.Builder
builder()
Creates a newPotionEffect.Builder
to build aPotionEffect
.Ticks
duration()
Gets the duration in ticks for which this potion effect will apply for.boolean
isAmbient()
Gets whether or not this potion effect is an ambient effect.static PotionEffect
of(java.util.function.Supplier<? extends PotionEffectType> type, int amplifier, Ticks duration)
Creates a newPotionEffect
with the providedPotionEffectType
, the provided amplifier, and the provided duration in ticks.static PotionEffect
of(PotionEffectType type, int amplifier, Ticks duration)
Creates a newPotionEffect
with the providedPotionEffectType
, the provided amplifier, and the provided duration in ticks.boolean
showsIcon()
Gets whether or not this potion effect is showing its icon.boolean
showsParticles()
Gets whether or not this potion effect is showing particles.PotionEffectType
type()
Gets thePotionEffectType
of this potion.-
Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
-
-
-
-
Method Detail
-
builder
static PotionEffect.Builder builder()
Creates a newPotionEffect.Builder
to build aPotionEffect
.- Returns:
- The new builder
-
of
static PotionEffect of(PotionEffectType type, int amplifier, Ticks duration) throws java.lang.IllegalArgumentException
Creates a newPotionEffect
with the providedPotionEffectType
, the provided amplifier, and the provided duration in ticks.- Parameters:
type
- The potion typeamplifier
- The zero-indexed amplifierduration
- The duration in ticks- Returns:
- The potion effect
- Throws:
java.lang.IllegalArgumentException
- If the amplifier is negative or the duration is not positive
-
of
static PotionEffect of(java.util.function.Supplier<? extends PotionEffectType> type, int amplifier, Ticks duration) throws java.lang.IllegalArgumentException
Creates a newPotionEffect
with the providedPotionEffectType
, the provided amplifier, and the provided duration in ticks.- Parameters:
type
- The potion typeamplifier
- The amplifierduration
- The duration in ticks- Returns:
- The potion effect
- Throws:
java.lang.IllegalArgumentException
- If the amplifier is negative or the duration is not positive
-
type
PotionEffectType type()
Gets thePotionEffectType
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.
-
-