Class BURNING

java.lang.Object
net.pottercraft.ollivanders2.effect.O2Effect
net.pottercraft.ollivanders2.effect.BURNING
Direct Known Subclasses:
FLAGRANTE_BURNING

public class BURNING extends O2Effect
Effect that applies periodic fire damage to a player with visual burning effects.

The BURNING effect inflicts continuous fire damage to the target player at regular intervals (every 3 seconds). Damage is calculated from the effect's duration parameter (damage = duration / 100) and is clamped to a range of 0.5 to 10 health points per tick. The effect applies smoke particle effects and fire hurt sounds with each damage instance, and prevents the player from being killed by fire (ensures health stays above 1).

Mechanism:

  • Initial damage calculated as: duration / 100 (clamped to 0.5-10 range)
  • Damage applied every 3 seconds (damageFrequencyInSeconds)
  • Cooldown tracked per tick (damageCooldown decrement)
  • Death prevention: damage won't reduce health below 1
  • Visual effects: smoke particles and fire hurt sound each damage tick
  • Detectable by information and mind-reading spells
  • Damage can be adjusted dynamically with addDamage() and removeDamage()
  • Constructor Details

    • BURNING

      public BURNING(@NotNull @NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull @NotNull UUID pid)
      Constructor for creating a burning fire damage effect.

      Creates an effect that applies periodic fire damage to the target player. Initial damage is calculated from the duration parameter using the formula: damage = duration / 100. The calculated damage is not clamped at this point but will be clamped to [0.5, 10] range when adjusted via addDamage(). Detection text is set to "is afflicted with a terrible burning" for both information and mind-reading spells.

      Parameters:
      plugin - a callback to the MC plugin
      duration - the duration of the effect in game ticks (used to calculate initial damage as duration / 100)
      isPermanent - is this effect permanent (does not age)
      pid - the unique ID of the player to burn
  • Method Details

    • checkEffect

      public void checkEffect()
      Age the effect and apply periodic damage based on cooldown countdown.

      Called each game tick. This method:

      1. Ages the effect (decrements duration until expiration)
      2. Checks if the target player still exists; kills effect if not
      3. Checks if damageCooldown has reached 0 or below
      4. If cooldown reached: applies damage via doDamage() and resets damageCooldown
      5. If cooldown not reached: decrements damageCooldown by 1
      Specified by:
      checkEffect in class O2Effect
    • addDamage

      public void addDamage(double d)
      Adjust the damage done by this burning effect with clamping to bounds.

      Increases (or decreases, if d is negative) the current damage value, then clamps it to the valid range [minDamage, maxDamage] (0.5 to 10). The damage value is also stored in the duration field as (damage × 100) to preserve the value during effect serialization and allow recovery after deserialization.

      Parameters:
      d - the amount to adjust damage by (positive increases, negative decreases)
    • removeDamage

      public void removeDamage(double d)
      Reduce the damage done by this burning effect.

      Convenience method that calls addDamage() with the negative of the parameter, effectively reducing the current damage by the specified amount. The damage is clamped to [0.5, 10] range after adjustment.

      Parameters:
      d - the amount to decrease the damage by (will be negated before calling addDamage())
    • getDamage

      public double getDamage()
      Get the current damage per tick inflicted by this burning effect.
      Returns:
      the current damage amount (0.5 to 10 health points)
    • doRemove

      public void doRemove()
      Perform cleanup when the burning effect is removed.

      The burning effect has no persistent state to clean up. The fire damage simply ceases when the effect is removed, and no additional cleanup is required.

      Specified by:
      doRemove in class O2Effect