Class PotionEffectAntidoteSuper

java.lang.Object
net.pottercraft.ollivanders2.effect.O2Effect
net.pottercraft.ollivanders2.effect.PotionEffectAntidoteSuper
Direct Known Subclasses:
HARM_ANTIDOTE_LESSER, POISON_ANTIDOTE_LESSER, UNLUCK_ANTIDOTE_LESSER

public abstract class PotionEffectAntidoteSuper extends O2Effect
Parent class for antidotes that neutralize standard Minecraft potion effects.

PotionEffectAntidoteSuper provides a strength-based antidote mechanism that reduces the duration of active potion effects rather than completely removing them. Antidotes are implemented as instant effects: they apply immediately in checkEffect() and then kill themselves in the same tick.

Antidote Mechanism: When an antidote activates, it locates any active potion effect of the target type on the player. If found:

  • The potion effect is removed entirely
  • If strength is less than 1.0, a new potion effect of the same type is re-applied with reduced duration
  • The reduced duration is calculated as: newDuration = originalDuration × strength
  • If strength is 1.0 or higher, the effect is completely removed (no re-application)

Examples:

  • strength = 1.0: Removes poison effect entirely (full antidote)
  • strength = 0.5: Re-applies poison with half the original duration (partial antidote)
  • strength = 0.25: Re-applies poison with 1/4 the original duration (weak antidote)

Effect Lifecycle: Antidote effects are designed to be "instant" - they perform their action immediately when created and expire in the same game tick. Subclasses set potionEffectType to specify which Minecraft potion effect to target.

  • Constructor Details

    • PotionEffectAntidoteSuper

      public PotionEffectAntidoteSuper(@NotNull @NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull @NotNull UUID pid)
      Constructor for creating a potion effect antidote.

      Creates an antidote effect that will apply immediately and expire in a single game tick. Subclasses should initialize potionEffectType and strength fields before the effect is added to a player's effect list.

      Parameters:
      plugin - a reference to the plugin for logging
      duration - ignored - antidotes apply immediately and are resolved
      isPermanent - ignored - antidotes are immediately applied and resolved
      pid - the unique ID of the target player to receive this antidote
  • Method Details

    • checkEffect

      public void checkEffect()
      Apply this antidote immediately and expire.

      This method executes in a single game tick and performs the following steps:

      1. Checks if the target has an active potion effect matching potionEffectType (target initialized in O2Effect constructor)
      2. If found: removes the potion effect completely
      3. If strength is less than 1.0: re-applies the same potion effect with reduced duration (newDuration = originalDuration × strength)
      4. Kills the antidote effect so it doesn't persist

      Example: An antidote with strength 0.5 applied to a player with a 10-second poison effect will remove the poison and immediately re-apply it with a 5-second duration.

      Specified by:
      checkEffect in class O2Effect
    • getStrength

      public double getStrength()
      Get the strength/potency of this antidote effect.

      Returns a value between 0.0 and 1.0+ that determines how effectively this antidote reduces the target potion effect's duration:

      • strength ≥ 1.0: Full-strength antidote - completely removes the target effect
      • 0.5 ≤ strength < 1.0: Medium-strength antidote - reduces target effect duration by 50-99%
      • 0.0 < strength < 0.5: Weak antidote - reduces target effect duration by less than 50%
      Returns:
      the antidote strength as a decimal value (0.0 to 1.0+)
    • setPermanent

      public void setPermanent(boolean perm)
      Potion antidote effects cannot ever be permanent
      Overrides:
      setPermanent in class O2Effect
      Parameters:
      perm - ignored - potion effects are always temporary