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

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<ScaledAttributeReduction>
     

    Fields inherited from interface TemperatureReduction

    DIRECT_CODEC
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    applyReduction(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>
    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.
    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.
    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.
    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 double
    The scale modifies the effectiveness of the resistance attributes.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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 be null, but may be the same as heatResistanceAttribute.
      heatResistanceAttribute - The attribute to use for resistance against positive temperature changes. May not be null, but may be the same as heatResistanceAttribute.
      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 be null, but may be the same as heatResistanceAttribute.
      heatResistanceAttribute - The attribute to use for resistance against positive temperature changes. May not be null, but may be the same as heatResistanceAttribute.
      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:
      applyReduction in interface TemperatureReduction
      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

      public com.mojang.serialization.MapCodec<? extends ScaledAttributeReduction> codec()
      Description copied from interface: TemperatureReduction
      The codec for the reduction type. Implementors should register this codec to ThermooBuiltInRegistries.TEMPERATURE_REDUCTION_TYPE in an entry point.
      Specified by:
      codec in interface TemperatureReduction
      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)