Class RandomlyDodgeReduction

java.lang.Object
com.github.thedeathlycow.thermoo.api.core.v2.source.RandomlyDodgeReduction
All Implemented Interfaces:
TemperatureReduction

public final class RandomlyDodgeReduction extends Object implements 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

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

    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)
    Applies the reduction by using the relevant resistance attribute as a dodge probability.
    com.mojang.serialization.MapCodec<RandomlyDodgeReduction>
    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.
    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.
    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.

    Methods inherited from class Object

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

  • 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 be null, but may be the same as heatResistanceAttribute.
      heatResistanceAttribute - The attribute to use as the dodge probability 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)
      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 to 0.
      • 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:
      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 0, temperatureChange, or 2 * temperatureChange depending on the result of the random roll.
    • codec

      public com.mojang.serialization.MapCodec<RandomlyDodgeReduction> 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 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.