Potion effects API

Effect

An Effect represents a potion effect (speed, strength, invisibility, etc.) that can be applied to players. Effects have a type, duration, amplifier, and visual settings.


Constructor

Effect(effect_type=None, duration=0, amplifier=0, ambient=False, particles=True, icon=True)

Create an effect.

speed = Effect("SPEED", duration=600, amplifier=1)         # Speed II for 30 seconds
invis = Effect(EffectType.INVISIBILITY, duration=1200)      # Invisibility for 60 seconds
silent = Effect("REGENERATION", 200, particles=False, icon=False) # Hidden regen

Class Methods

apply

await Effect.apply(player, effect_type=None, duration=0, amplifier=0, ambient=False, particles=True, icon=True)

Create and apply an effect to a player in one call.

await Effect.apply(player, "SPEED", duration=600, amplifier=1)

Attributes

type

The effect type.

duration

Remaining duration in ticks.

amplifier

Effect amplifier (level minus 1).

ambient

Whether particles are translucent (beacon-style).

particles

Whether particles are visible.

icon

Whether the HUD icon is shown.


Methods

with_duration

new_effect = await effect.with_duration(duration)

Create a copy of this effect with a different duration.

base = Effect("SPEED", 100, amplifier=2)
long_speed = await base.with_duration(6000)  # 5 minutes

with_amplifier

new_effect = await effect.with_amplifier(amplifier)

Create a copy of this effect with a different amplifier.


Applying to Players

You can apply effects in two ways:

# 1. Using the class method shortcut
await Effect.apply(player, "SPEED", duration=200, amplifier=1)

# 2. Construct then apply via Player
speed = Effect("SPEED", duration=200, amplifier=1)
await player.add_effect(speed)

To remove an effect:

await player.remove_effect(EffectType.SPEED)

To list active effects:

for effect in player.effects:
    print(f"{effect.type.name}: {effect.duration} ticks remaining")

Duration Reference

Duration Ticks
1 second 20
5 seconds 100
30 seconds 600
1 minute 1200
5 minutes 6000
10 minutes 12000