Class TemperatureEffect<C>

java.lang.Object
com.github.thedeathlycow.thermoo.api.temperature.effects.TemperatureEffect<C>
Type Parameters:
C - The config type of the effect
Direct Known Subclasses:
AttributeModifierTemperatureEffect, DamageTemperatureEffect, EmptyTemperatureEffect, FunctionTemperatureEffect, ScalingAttributeModifierTemperatureEffect, SequenceTemperatureEffect, StatusEffectTemperatureEffect

public abstract class TemperatureEffect<C> extends Object
A temperature effect is some effect that is applied to a LivingEntity based on their current temperature, as determined by TemperatureAware. This class represents the parent class for all temperature effect 'types', which implement the specific behaviour of an effect. Effects may apply potion effects, modify attributes, apply damage, and more.

Effect types can be configured to only apply effects of different strengths or only under certain conditions. The config is provided by the C generic type.

The config is specified via a datapack in the folder data/{namespace}/thermoo/temperature_effects/.

See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    TemperatureEffect(com.mojang.serialization.Codec<C> configCodec)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    apply(net.minecraft.entity.LivingEntity victim, net.minecraft.server.world.ServerWorld serverWorld, C config)
    Applies the effect to a living entity
    final com.mojang.serialization.MapCodec<ConfiguredTemperatureEffect<C>>
     
    void
    remove(net.minecraft.entity.LivingEntity victim, net.minecraft.server.world.ServerWorld serverWorld, C config)
    Called the first tick that a temperature effect could not be applied
    abstract boolean
    shouldApply(net.minecraft.entity.LivingEntity victim, C config)
    Tests if the effect should be applied to a living entity.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TemperatureEffect

      protected TemperatureEffect(com.mojang.serialization.Codec<C> configCodec)
      Parameters:
      configCodec - Codec for the config type
  • Method Details

    • apply

      public abstract void apply(net.minecraft.entity.LivingEntity victim, net.minecraft.server.world.ServerWorld serverWorld, C config)
      Applies the effect to a living entity
      Parameters:
      victim - The living entity to apply the effect to
      serverWorld - The server world of the victim
      config - The effect config
    • shouldApply

      public abstract boolean shouldApply(net.minecraft.entity.LivingEntity victim, C config)
      Tests if the effect should be applied to a living entity. Note that even if this returns true, the effect is not guaranteed to be applied. This is because all entity must pass the predicate specified by ConfiguredTemperatureEffect.predicate().
      Parameters:
      victim - The victim to test if the effect should be applied to
      config - The effect config
      Returns:
      Returns if the effect should be applied to the victim
    • remove

      public void remove(net.minecraft.entity.LivingEntity victim, net.minecraft.server.world.ServerWorld serverWorld, C config)
      Called the first tick that a temperature effect could not be applied
      Parameters:
      victim - The entity the effect was applied to
      serverWorld - The server world of the entity
      config - The effect config
    • getCodec

      public final com.mojang.serialization.MapCodec<ConfiguredTemperatureEffect<C>> getCodec()
      Returns:
      Returns the codec