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

public final class ReinforcingAttributeReduction extends ScaledAttributeReduction
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 Details

  • 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 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 coldResistanceAttribute.
      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 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 coldResistanceAttribute.
      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:
      applyReduction in interface TemperatureReduction
      Overrides:
      applyReduction in class ScaledAttributeReduction
      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

      public com.mojang.serialization.MapCodec<ReinforcingAttributeReduction> 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
      Overrides:
      codec in class ScaledAttributeReduction
      Returns:
      Returns CODEC