Temperature Basics
The essentials of how temperature works
Traits
There are several types of temperature that affect entities in differing ways. Every entity has a separate instance of all eight of these temperature traits. These traits are defined in detail on the Attributes page.
Functions
The Temperature
utility class has several functions to manipulate and read an entity's temperature. The following are some of the basic functions that pertain to entity temperature:
get()
Returns the chosen temperature trait on this entity.
trait
specifies which temperature should be fetched from the entity (world, body, etc).
set()
Sets the entity's temperature to the given value. trait
is used to denote what aspect of the entity's temperature is being affected.
This method also has an overload method with an extra boolean parameter that controls whether or not the new temperature will by synced to the client automatically via a packet (if the entity is a player). In the default implementation, the new temperature is always synced.
add()
Shorthand for adding to the entity's temperature. Negative values are also accepted.
Using Real-World Values
Cold Sweat uses Minecraft's biome temperature scale when dealing with world Temperatures. This is good because it standardizes all operations to use Minecraft's built-in temperature system.
However, this new temperature scale isn't easy to work with, as typical biome temperature values range from 0 to 2, with 0 being a snowy tundra and a 2 being the nether (there are some rare examples outside these values; see the Minecraft Wiki page on biomes for more information).
Cold Sweat has a function for converting real units of temperature (Celsius, Fahrenheit) to Minecraft's units. The CSMath
utility class has a method that does just that:
convertUnits()
This returns a double value representing the temperature specified, converted to the desired unit of measurement.
from
- The unit of measurement you are converting fromto
- The unit of measurement you are converting toabsolute
- Whether the specified temperature is absolute or relative. For example, the temperature of a room would be in absolute units, but adding 10 degrees to the room's temperature is a relative measurement, so it would not be absolute.
Units
is an enum inside the Temperature class that lists the three units of measurement:
F
- FahrenheitC
- CelsiusMC
- Minecraft units
Note: Body temperature uses its own set of "units" separate from normal temperature values. It ranges from -150 to 150, with -100 being freezing, 100 being burning, and 0 being neutral.
Last updated