Class ScaledAttributeReduction
java.lang.Object
com.github.thedeathlycow.thermoo.api.core.v2.source.ScaledAttributeReduction
- All Implemented Interfaces:
TemperatureReduction
- Direct Known Subclasses:
ReinforcingAttributeReduction
public sealed class ScaledAttributeReduction
extends Object
implements TemperatureReduction
permits ReinforcingAttributeReduction
A temperature reduction that reduces an incoming temperature linearly based on a scale factor and resistance attribute.
Allows for different attributes to be used based on whether the change is freezing (cold resistance) or warming
(heat resistance).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<ScaledAttributeReduction> 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.com.mojang.serialization.MapCodec<? extends ScaledAttributeReduction> codec()The codec for the reduction type.final net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> The resistance attribute to be used for negative temperature changes.static ScaledAttributeReductioncreate(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 scaled attribute reduction with a scale of 1.static ScaledAttributeReductioncreate(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 scaled attribute reduction.protected static <T extends ScaledAttributeReduction>
com.mojang.serialization.MapCodec<T> createCodec(com.mojang.datafixers.util.Function3<net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>, Double, T> constructor) final net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> The resistance attribute to be used for positive temperature changes.final doublescale()The scale modifies the effectiveness of the resistance attributes.
-
Field Details
-
CODEC
-
-
Method Details
-
create
public static ScaledAttributeReduction 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 scaled 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 asheatResistanceAttribute.scale- The scale to modify the effectiveness of the resistance. Must be finite.- Returns:
- Returns a new reduction.
-
create
public static ScaledAttributeReduction 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 scaled 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 asheatResistanceAttribute.- 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.- 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 a reduced temperature change. 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- Returns:
- Returns
CODEC.
-
coldResistanceAttribute
public final net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> coldResistanceAttribute()The resistance attribute to be used for negative temperature changes. -
heatResistanceAttribute
public final net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> heatResistanceAttribute()The resistance attribute to be used for positive temperature changes. -
scale
public final double scale()The scale modifies the effectiveness of the resistance attributes.- Returns:
- Returns a finite double.
-
createCodec
protected static <T extends ScaledAttributeReduction> com.mojang.serialization.MapCodec<T> createCodec(com.mojang.datafixers.util.Function3<net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>, net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>, Double, T> constructor)
-