Class PotionEffectAntidoteSuper
- Direct Known Subclasses:
HARM_ANTIDOTE_LESSER,POISON_ANTIDOTE_LESSER,UNLUCK_ANTIDOTE_LESSER
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.
-
Field Summary
Fields inherited from class net.pottercraft.ollivanders2.effect.O2Effect
affectedPlayerText, duration, effectType, informousText, kill, legilimensText, p, permanent, targetID -
Constructor Summary
ConstructorsConstructorDescriptionPotionEffectAntidoteSuper(@NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull UUID pid) Constructor for creating a potion effect antidote. -
Method Summary
Modifier and TypeMethodDescriptionvoidApply this antidote immediately and expire.doubleGet the strength/potency of this antidote effect.voidsetPermanent(boolean perm) Potion antidote effects cannot ever be permanentMethods inherited from class net.pottercraft.ollivanders2.effect.O2Effect
age, doRemove, getAffectedPlayerText, getInformousText, getLegilimensText, getMaxDuration, getMinDuration, getRemainingDuration, getTargetID, isKilled, isPermanent, kill
-
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 loggingduration- ignored - antidotes apply immediately and are resolvedisPermanent- ignored - antidotes are immediately applied and resolvedpid- 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:
- Checks if the target has an active potion effect matching potionEffectType (target initialized in O2Effect constructor)
- If found: removes the potion effect completely
- If strength is less than 1.0: re-applies the same potion effect with reduced duration (newDuration = originalDuration × strength)
- 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:
checkEffectin classO2Effect
-
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:
setPermanentin classO2Effect- Parameters:
perm- ignored - potion effects are always temporary
-