Class ReinforcingAttributeReduction
java.lang.Object
com.github.thedeathlycow.thermoo.api.core.v2.source.ScaledAttributeReduction
com.github.thedeathlycow.thermoo.api.core.v2.source.ReinforcingAttributeReduction
- All Implemented Interfaces:
TemperatureReduction
A temperature reduction that only applies when the temperature change reinforces the target's current temperature
state. That is, cold resistance is only applied when the target is already cold and the change is negative, and
heat resistance is only applied when the target is already warm and the change is positive. When the change does
not reinforce the current state, the temperature change is passed through unmodified.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<ReinforcingAttributeReduction> Fields inherited from interface TemperatureReduction
DIRECT_CODEC -
Method Summary
Modifier and TypeMethodDescriptionintapplyReduction(net.minecraft.world.entity.LivingEntity target, TemperatureChange context, int temperatureChange) Linearly reduces the temperature change based on the relevant resistance type, but only when the change reinforces the target's current temperature state.com.mojang.serialization.MapCodec<ReinforcingAttributeReduction> codec()The codec for the reduction type.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 reinforcing attribute reduction with a scale of 1.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, double scale) Creates a new reinforcing attribute reduction.Methods inherited from class ScaledAttributeReduction
coldResistanceAttribute, createCodec, heatResistanceAttribute, scale
-
Field Details
-
CODEC
-
-
Method Details
-
create
public static ReinforcingAttributeReduction 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, double scale) Creates a new reinforcing attribute reduction. This method is primarily intended for use with data generation.- Parameters:
coldResistanceAttribute- The attribute to use for resistance against negative temperature changes. May not benull, but may be the same asheatResistanceAttribute.heatResistanceAttribute- The attribute to use for resistance against positive temperature changes. May not benull, but may be the same ascoldResistanceAttribute.scale- The scale to modify the effectiveness of the resistance. Must be finite.- Returns:
- Returns a new reduction.
-
create
public static ReinforcingAttributeReduction 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 reinforcing attribute reduction with a scale of 1. This method is primarily intended for use with data generation.- Parameters:
coldResistanceAttribute- The attribute to use for resistance against negative temperature changes. May not benull, but may be the same asheatResistanceAttribute.heatResistanceAttribute- The attribute to use for resistance 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) Linearly reduces the temperature change based on the relevant resistance type, but only when the change reinforces the target's current temperature state. If the change does not reinforce the current state, the temperature change is returned unmodified.- Specified by:
applyReductionin interfaceTemperatureReduction- Overrides:
applyReductionin classScaledAttributeReduction- 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 the reduced temperature change if reinforcing, or the original temperature change otherwise.
If the reduced temperature value is not an integer, returns the
Math.ceil(double)of the value.
-
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- Overrides:
codecin classScaledAttributeReduction- Returns:
- Returns
CODEC
-