Class DamageEffect

java.lang.Object
com.github.thedeathlycow.thermoo.api.temperature.status.v2.effect.DamageEffect
All Implemented Interfaces:
TemperatureEffect

public final class DamageEffect extends Object implements TemperatureEffect
Applies damage to LivingEntitys.

The type and amount of damage can be configured, as well as the damage type. However, the DamageSource applied only stores the type - the direct source entity, attacker, and position are all null.

  • Field Details

    • CODEC

      public static final com.mojang.serialization.MapCodec<DamageEffect> CODEC
  • Method Details

    • create

      public static DamageEffect create(float amount, net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType)
      Creates a new damage effect for data generation.
      Parameters:
      amount - A non-negative finite float.
      damageType - The damage type key.
      Throws:
      IllegalArgumentException - if the amount is negative, infinite, or NaN.
      NullPointerException - if the damageType is null.
    • apply

      public boolean apply(net.minecraft.world.entity.LivingEntity target, TemperatureEffectContext context)
      Hurts the target.
      Specified by:
      apply in interface TemperatureEffect
      Parameters:
      target - The entity receiving the effect.
      context - Additional context for the effect.
      Returns:
      Returns true if executed on the logical server AND the target was successfully hurt.
    • codec

      public com.mojang.serialization.MapCodec<DamageEffect> codec()
      Specified by:
      codec in interface TemperatureEffect
      Returns:
      Returns CODEC
    • amount

      public float amount()
      The amount of damage inflicted by the effect.
      Returns:
      Returns a float that is finite and non-negative.
    • damageType

      public net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> damageType()
      The damage type of the effect.