Skip to content

Temperature Attributes (Mods)

TheDeathlyCow edited this page Nov 12, 2024 · 11 revisions

Thermoo provides four attributes related to temperature, two for each 'form' of temperature (cooling/heating). They are Minimum Temperature (thermoo:min_temperature), Maximum Temperature (thermoo:max_temperature), Frost Resistance (thermoo:frost_resistance), and Heat Resistance (thermoo:heat_resistance).

Note

In Thermoo 4.x and below (for Minecraft 1.21.1 and below) all Thermoo attributes had a generic prefix in their name. For example, thermoo:generic.frost_resistance. In Thermoo 5.0 and above (for Minecraft 1.21.2+), this was removed. Please use the appropriate ID for your version!

Minimum and Maximum

The minimum and maximum temperature attributes set the temperature bounds for a TemperatureAware entity, and control the result of LivingEntity#thermoo$getMinTemperature and Living#thermoo$getMaxTemperature respectively. More specifically, the value of the bound is 140 times the sum total value of the attribute (base + all modifiers). The reason why 140 was chosen specifically, was because 140 is the vanilla maximum value of the TicksFrozen data piece that is associated with powder snow, so you can think of these bounds as being some multiple of the maximum freezing of powder snow.

Resistances

The attributes of Frost- and Heat Resistance both control how temperature changes (applied with TemperatureAware#thermoo$addTemperature) are, as the name implies, resisted. Frost Resistance deals with negative changes in temperature, while Heat Resistance deals with positive changes in temperature. Frost and Heat Resistance control the return value of TemperautreAware#thermoo$getColdResistance and TemperatureAware#thermoo$getHeatResistance, respectively. More about how resistance works can be found in the next section.

Setting the base values for these attributes

By default, all attributes have a base value of 0. If you wish to set a different value for this, you will need to set a value with the method EnvironmentController#getBaseValueForAttribute(EntityAttribute, LivingEntity). We will see more about the environment controller later, though you can read about it right now here. Note that the EntityAttribute argument will only ever be one of Thermoo's (generic) attributes, and does not apply generally to all entity attributes.

Examples

Example: Setting a base Minimum Temperature for all living entities

// This is explained more on the controller page, but left here for your convenient reference
public class AttributeController extends EnvironmentControllerDecorator {
    private static final double BASE_MIN_TEMPERATURE = 40;

    public AttributeController(EnvironmentController controller) {
        super(controller);
    }

    @Override
    public double getBaseValueForAttribute(EntityAttribute attribute, LivingEntity entity) {
        double base = controller.getBaseValueForAttribute(attribute, entity);

        if (attribute == ThermooAttributes.MIN_TEMPERATURE) {
            base = BASE_MIN_TEMPERATURE;
        }

        return base;
    }
}

Example: Get the Resistances of an Entity

LivingEntity entity;

double coldResistance = entity.thermoo$getColdResistance(); // get cold (or frost) resistance
double heatResistance = entity.thermoo$getHeatResistance(); // get heat resistance

➡️ Next: Temperature Changes