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
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 -
Method Summary
Modifier and TypeMethodDescriptionabstract voidapply(net.minecraft.entity.LivingEntity victim, net.minecraft.server.world.ServerWorld serverWorld, C config) Applies the effect to a living entityabstract CconfigFromJson(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 typeabstract booleanshouldApply(net.minecraft.entity.LivingEntity victim, C config) Tests if the effect should be applied to a living entity.
-
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 toserverWorld- The server world of the victimconfig- The effect config
-
shouldApply
Tests if the effect should be applied to a living entity. Note that even if this returnstrue, the effect is not guaranteed to be applied. This is because all entity must pass the predicate specified byConfiguredTemperatureEffect.predicate.- Parameters:
victim- The victim to test if the effect should be applied toconfig- 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 typecontext- 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
-