Class RandomlyDodgeReduction
java.lang.Object
com.github.thedeathlycow.thermoo.api.core.v2.source.RandomlyDodgeReduction
- All Implemented Interfaces:
TemperatureReduction
A temperature reduction that uses resistance attributes as a probability to either fully dodge or double an incoming
temperature change. Positive resistance values give a chance to dodge the change entirely, while negative resistance
values give a chance to double it. Resistance values are clamped to the range [-1, 1], where the absolute value is
used as the probability.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<RandomlyDodgeReduction> Fields inherited from interface TemperatureReduction
DIRECT_CODEC -
Method Summary
Modifier and TypeMethodDescriptionintapplyReduction(net.minecraft.world.entity.LivingEntity target, TemperatureChange context, int temperatureChange) Applies the reduction by using the relevant resistance attribute as a dodge probability.com.mojang.serialization.MapCodec<RandomlyDodgeReduction> codec()The codec for the reduction type.net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> The resistance attribute to be used as the dodge probability for negative temperature changes.static RandomlyDodgeReductioncreate(net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> coldResistanceAttribute, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> heatResistanceAttribute) Creates a new randomly dodge reduction.net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> The resistance attribute to be used as the dodge probability for positive temperature changes.
-
Field Details
-
CODEC
-
-
Method Details
-
create
public static RandomlyDodgeReduction create(net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> coldResistanceAttribute, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> heatResistanceAttribute) Creates a new randomly dodge reduction. This method is primarily intended for use with data generation.- Parameters:
coldResistanceAttribute- The attribute to use as the dodge probability against negative temperature changes. May not benull, but may be the same asheatResistanceAttribute.heatResistanceAttribute- The attribute to use as the dodge probability against positive temperature changes. May not benull, but may be the same ascoldResistanceAttribute.- Returns:
- Returns a new reduction.
-
applyReduction
public int applyReduction(net.minecraft.world.entity.LivingEntity target, TemperatureChange context, int temperatureChange) Applies the reduction by using the relevant resistance attribute as a dodge probability. The resistance value is clamped to [-1, 1] before use.- If resistance is positive, there is a
resistance * 100%chance the change is reduced to0. - If resistance is negative, there is a
-resistance * 100%chance the change is doubled. - If resistance is
0, the change is returned unmodified.
- Specified by:
applyReductionin interfaceTemperatureReduction- Parameters:
target- The target being affected by the temperature change.context- The context of the temperature change.temperatureChange- The amount of the temperature change.- Returns:
- Returns
0,temperatureChange, or2 * temperatureChangedepending on the result of the random roll.
- If resistance is positive, there is a
-
codec
Description copied from interface:TemperatureReductionThe codec for the reduction type. Implementors should register this codec toThermooBuiltInRegistries.TEMPERATURE_REDUCTION_TYPEin an entry point.- Specified by:
codecin interfaceTemperatureReduction- Returns:
- Returns
CODEC
-
coldResistanceAttribute
public net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> coldResistanceAttribute()The resistance attribute to be used as the dodge probability for negative temperature changes. -
heatResistanceAttribute
public net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> heatResistanceAttribute()The resistance attribute to be used as the dodge probability for positive temperature changes.
-