Temperature Basics (Mods) - TheDeathlyCow/thermoo GitHub Wiki

[!WARNING] This page has been moved to https://thermoo.thedeathlycow.com/api_overview/

How temperature works

Thermoo uses interface injection to allow all entities that extend LivingEntity to be "Temperature Aware". Things that are Temperature Aware will track a piece of (synced) data called temperature on each entity individually. Through the TemperatureAware interface, you can control the value of this data piece. Temperature is a bounded variable, it has both a minimum and maximum value that it may take. Temperature can never be set to a value outside of these bounds. Internally, temperature is stored using Cardinal Components, however accessing it through CCA is not a stable temperature interface.

Note: Displaying temperature

Thermoo provides one very specific way of displaying temperature to the player: the Status Bar Overlay. Currently, other methods are left up to you and your design needs. If you want an example of how to use the overlay, see Frostiful.

Examples

Example: Setting the temperature of an entity

To set the temperature of a Living Entity, you simply must call thermoo$setTemperature on that entity. Note that you do not need to cast the entity to TemperatureAware first!

LivingEntity entity; // source this from somewhere

entity.thermoo$setTemperature(1000); // works without needing to cast to TemperatureAware

Example: Getting the temperature of an entity

LivingEntity entity; // source this from somewhere

int currentTemperature = entity.thermoo$getTemperature();

Example: Getting the temperature bounds of an entity

LivingEntity entity; // source this from somewhere

int minTemperature = entity.thermoo$getMinTemperature(); // Gets the minimum temperature - this value will be either zero or negative
int maxTemperature = entity.thermoo$getMaxTemperature(); // Gets the maximum temperature - this value will be either zero or positive

➡️ Next: Temperature Attributes