Block Temperature
In Cold Sweat, blocks can be configured to change the world's temperature for players around them, up to 7 blocks away by default.
There are two ways to configure block temperatures:
Using Config Files
This method uses simple JSON parameters in Cold Sweat's world_settings.toml
config file to create basic block temperatures. The syntax is as follows:
Arguments
block-ids
: The ID(s) of the block(s) emitting this temperature. Should be a qualified string ID (i.e."minecraft:lava"
,"cold_sweat:boiler"
).
block-ids can also be a comma-separated list of blocks, allowing this effect to be applied to multiple blocks (i.e. "minecraft:red_wool,minecraft:white_wool"
). Notice there is no space between blocks.
Using a hashtag (#) signifies a tag, allowing this effect to be applied to all blocks under the tag (i.e. "#minecraft:logs"
includes oak logs, birch logs, etc.) See Tags for more information.
temperature
: A decimal representing the temperature of the block, in Minecraft units. (1 MC unit = 42 °F or 23.3 °C)range
: A decimal or integer from 0-16 representing the range of the block's effect, in blocks.max effect
(Optional) : A decimal or integer that applies a hard cap to how much this block can affect a player's temperature, no matter how many of the block are near the player. (i.e. If the block'stemperature
is 0.15, and themax effect
is 0.3, the cap would be reached after two blocks, and a third block would not change the total).predicates
(Optional) : A list of BlockState predicates that must be true for the block to emit temperature. For example, a campfire must havelit=true
to emit heat.nbt
(Optional): The NBT data that the block must have for the temperature to be applied. If the targeted block is not a Block Entity, this parameter does nothing.temp limit
(Optional): The maximum world temperature at which this block temp will be effective. If the world's temperature exceeds this value, the block will not emit anything. If the temperature for this block temp is negative, this represents the minimum world temperature.
The following section assumes the reader has a solid grasp on Java programming and modding with Forge.
Using BlockTemps
These must be added via 3rd party Forge mods. Because they are programmed in Java, which is more flexible than JSON, BlockTemps provide more precise control in how they work.
Creating a BlockTemp
A BlockTemp extends the base class BlockTemp
, which has several methods that control how the block(s) temperature works. The getTemperature()
method must be overridden for implementations:
Parameters:
entity
: The entity that this BlockTemp is trying to affect.state
: The BlockState of the block associated with this BlockTemp. This can be used to make the effect conditional, such as when a furnace is lit. One might want to usehasBlock()
to determine if the given block is valid for this BlockTemp to ensure this temperature isn't applied to the wrong block.pos
: The BlockPos, or x/y/z position, of the block associated with this BlockTemp.distance
: The distance of the entity from the center of the block. This can be used to make the effect of the block weaken as distance increases, since this does not happen by default. A common way to calculate this is:
Returns a double representing the temperature of this block relative to the given player. Note that this value is in Minecraft units.
Registering a BlockTemp
A BlockTemp must be registered in order to be associated with any blocks. This can be easily done by subscribing to BlockTempRegisterEvent
(Forge event bus) and calling the event's register()
method, passing in an instance of the BlockTemp there.
Constructor
BlockTemps have a constructor, provided by the BlockTemp
class, that allows for passing in a comma-separated list (or Array
) of blocks that will be associated with the BlockTemp.
This can be done either in the class declaration by calling super()
in a default constructor, or when a new instance of the BlockEffect is being created to pass into the register()
method.
Examples
Last updated