public class PotionEffect extends Object implements ConfigurationSerializable
LivingEntity
. A
potion effect has a duration that it will last for, an amplifier that will
enhance its effects, and a PotionEffectType
, that represents its
effect on an entity.Constructor and Description |
---|
PotionEffect(@NotNull Map<String,Object> map)
Constructor for deserialization.
|
PotionEffect(@NotNull PotionEffectType type,
int duration,
int amplifier)
Creates a potion effect.
|
PotionEffect(@NotNull PotionEffectType type,
int duration,
int amplifier,
boolean ambient)
Creates a potion effect.
|
PotionEffect(@NotNull PotionEffectType type,
int duration,
int amplifier,
boolean ambient,
boolean particles)
Creates a potion effect with no defined color.
|
PotionEffect(@NotNull PotionEffectType type,
int duration,
int amplifier,
boolean ambient,
boolean particles,
boolean icon)
Creates a potion effect.
|
Modifier and Type | Method and Description |
---|---|
boolean |
apply(@NotNull LivingEntity entity)
Attempts to add the effect represented by this object to the given
LivingEntity . |
boolean |
equals(Object obj) |
int |
getAmplifier()
Returns the amplifier of this effect.
|
@Nullable Color |
getColor()
Deprecated.
color is not part of potion effects
|
int |
getDuration()
Returns the duration (in ticks) that this effect will run for when
applied to a
LivingEntity . |
@NotNull PotionEffectType |
getType()
Returns the
PotionEffectType of this effect. |
int |
hashCode() |
boolean |
hasIcon() |
boolean |
hasParticles() |
boolean |
isAmbient()
Makes potion effect produce more, translucent, particles.
|
@NotNull Map<String,Object> |
serialize()
Creates a Map representation of this class.
|
String |
toString() |
@NotNull PotionEffect |
withAmbient(boolean ambient) |
@NotNull PotionEffect |
withAmplifier(int amplifier) |
@NotNull PotionEffect |
withDuration(int duration) |
@NotNull PotionEffect |
withIcon(boolean icon) |
@NotNull PotionEffect |
withParticles(boolean particles) |
@NotNull PotionEffect |
withType(@NotNull PotionEffectType type) |
public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles, boolean icon)
type
- effect typeduration
- measured in ticks, see getDuration()
amplifier
- the amplifier, see getAmplifier()
ambient
- the ambient status, see isAmbient()
particles
- the particle status, see hasParticles()
icon
- the icon status, see hasIcon()
public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles)
type
- effect typeduration
- measured in ticks, see getDuration()
amplifier
- the amplifier, see getAmplifier()
ambient
- the ambient status, see isAmbient()
particles
- the particle status, see hasParticles()
public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier, boolean ambient)
type
- effect typeduration
- measured in ticks, see getDuration()
amplifier
- the amplifier, see getAmplifier()
ambient
- the ambient status, see isAmbient()
public PotionEffect(@NotNull @NotNull PotionEffectType type, int duration, int amplifier)
type
- Effect typeduration
- measured in ticksamplifier
- the amplifier for the effectPotionEffect(PotionEffectType, int, int, boolean)
@NotNull public @NotNull PotionEffect withType(@NotNull @NotNull PotionEffectType type)
@NotNull public @NotNull PotionEffect withDuration(int duration)
@NotNull public @NotNull PotionEffect withAmplifier(int amplifier)
@NotNull public @NotNull PotionEffect withAmbient(boolean ambient)
@NotNull public @NotNull PotionEffect withParticles(boolean particles)
@NotNull public @NotNull PotionEffect withIcon(boolean icon)
@NotNull public @NotNull Map<String,Object> serialize()
ConfigurationSerializable
This class must provide a method to restore this class, as defined in
the ConfigurationSerializable
interface javadocs.
serialize
in interface ConfigurationSerializable
public boolean apply(@NotNull @NotNull LivingEntity entity)
LivingEntity
.entity
- The entity to add this effect toLivingEntity.addPotionEffect(PotionEffect)
public int getAmplifier()
public int getDuration()
LivingEntity
.@NotNull public @NotNull PotionEffectType getType()
PotionEffectType
of this effect.public boolean isAmbient()
public boolean hasParticles()
@Deprecated @Nullable @Contract(value="-> null") public @Nullable Color getColor()
public boolean hasIcon()
Copyright © 2021. All rights reserved.