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:
DamageTemperatureEffect, EmptyTemperatureEffect, LegacyDamageTemperatureEffect, ScalingAttributeModifierTemperatureEffect, 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
    Constructor
    Description
     
  • 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
    abstract C
    configFromJson(com.google.gson.JsonElement json, com.google.gson.JsonDeserializationContext context)
    Deserializes a JSON element into a new config instance that is valid for this effect type
    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

      public TemperatureEffect()
  • 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
    • configFromJson

      public abstract C configFromJson(com.google.gson.JsonElement json, com.google.gson.JsonDeserializationContext context) throws com.google.gson.JsonSyntaxException
      Deserializes a JSON element into a new config instance that is valid for this effect type
      Parameters:
      json - The JSON element that represents the config of this effect type
      context - The JSON deserialization context
      Returns:
      Returns a new config instance specified by the JSON element given
      Throws:
      com.google.gson.JsonSyntaxException - Thrown if the given JSON element is not a legal representation of the config for this effect type