Class EnvironmentControllerDecorator

java.lang.Object
com.github.thedeathlycow.thermoo.api.temperature.EnvironmentControllerDecorator
All Implemented Interfaces:
EnvironmentController

public abstract non-sealed class EnvironmentControllerDecorator extends Object implements EnvironmentController
Decorator for the EnvironmentController, to be extended by other mods for the purpose of adding or replacing functionality from the default environment controller.

Every method by default delegates to the base controller

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final @NotNull EnvironmentController
    The base controller to decorate with new functionality.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructs a decorator out of a base controller
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    getBaseValueForAttribute(net.minecraft.entity.attribute.EntityAttribute attribute, net.minecraft.entity.LivingEntity entity)
    Gets the base value for one of the ThermooAttributes.
    final @NotNull EnvironmentController
    Getter for the base controller
    int
    getEnvironmentTemperatureForPlayer(net.minecraft.entity.player.PlayerEntity player, int localTemperature)
    Computes the environmental temperature change for a player, based on a local temperature computed from EnvironmentController.getLocalTemperatureChange(World, BlockPos)
    int
    getFloorTemperature(net.minecraft.entity.LivingEntity entity, net.minecraft.world.World world, net.minecraft.block.BlockState state, net.minecraft.util.math.BlockPos pos)
    Gets the amount of warmth generated by a floor block state for a given entity.
    int
    getHeatAtLocation(net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos)
    Calculates the passive warmth nearby heat sources at a location in a world.
    int
    getHeatFromBlockState(net.minecraft.block.BlockState state)
    Calculates the heat produced by a block state.
    int
    getLocalTemperatureChange(net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos)
    Computes the local temperature change from the environment at a given position in a world.
    int
    Gets the default maximum wet ticks for the soakable.
    int
    Gets the wetness increase for a Soakable this tick
    int
    getTemperatureEffectsChange(net.minecraft.entity.LivingEntity entity)
    Computes temperature changes for LivingEntitys from heat effects.
    boolean
    isAreaHeated(net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos)
    Check if a position in a world is heated
    boolean
    isColdSource(net.minecraft.block.BlockState state)
    Checks if a block state is a cold source, as defined by this controller.
    boolean
    isHeatSource(net.minecraft.block.BlockState state)
    Checks if a block state is a heat source, as defined by this controller.
    final String
    Wraps the class name around the string representation of the controller so that it is easy to see which mods are decorating the Thermoo environment controller

    Methods inherited from class java.lang.Object

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

    • controller

      @NotNull protected final @NotNull EnvironmentController controller
      The base controller to decorate with new functionality. This field may never be null
  • Constructor Details

    • EnvironmentControllerDecorator

      protected EnvironmentControllerDecorator(EnvironmentController controller)
      Constructs a decorator out of a base controller
      Parameters:
      controller - The base controller
  • Method Details

    • getDecorated

      @NotNull public final @NotNull EnvironmentController getDecorated()
      Getter for the base controller
      Specified by:
      getDecorated in interface EnvironmentController
      Returns:
      Returns the decorated base controller
    • getBaseValueForAttribute

      public double getBaseValueForAttribute(net.minecraft.entity.attribute.EntityAttribute attribute, net.minecraft.entity.LivingEntity entity)
      Description copied from interface: EnvironmentController
      Gets the base value for one of the ThermooAttributes. If the return of this method is non-zero, then this value will be applied as an attribute modifier to the entity when the entity is created, with the addition operation. This method is called for each of the Thermoo attributes.
      Specified by:
      getBaseValueForAttribute in interface EnvironmentController
      Parameters:
      attribute - The attribute to get the base value for. Strictly the attributes in ThermooAttributes.
      entity - The entity to apply the attribute to.
      Returns:
      Returns the base value for the attribute to apply to the entity.
    • getLocalTemperatureChange

      public int getLocalTemperatureChange(net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos)
      Description copied from interface: EnvironmentController
      Computes the local temperature change from the environment at a given position in a world.
      Specified by:
      getLocalTemperatureChange in interface EnvironmentController
      Parameters:
      world - The world
      pos - The position in that world
      Returns:
      The passive temperature change at pos in world.
    • getEnvironmentTemperatureForPlayer

      public int getEnvironmentTemperatureForPlayer(net.minecraft.entity.player.PlayerEntity player, int localTemperature)
      Description copied from interface: EnvironmentController
      Computes the environmental temperature change for a player, based on a local temperature computed from EnvironmentController.getLocalTemperatureChange(World, BlockPos)
      Specified by:
      getEnvironmentTemperatureForPlayer in interface EnvironmentController
      Parameters:
      player - The player to compute the temperature change for
      localTemperature - The base local temperature
      Returns:
      Returns the passive environmental temperature change for the player this tick
    • getTemperatureEffectsChange

      public int getTemperatureEffectsChange(net.minecraft.entity.LivingEntity entity)
      Description copied from interface: EnvironmentController
      Computes temperature changes for LivingEntitys from heat effects. For example, being on fire or freezing in powder snow
      Specified by:
      getTemperatureEffectsChange in interface EnvironmentController
      Parameters:
      entity - The entity to tick warmth effects for
      Returns:
      Returns the temperature change that should be applied
    • getFloorTemperature

      public int getFloorTemperature(net.minecraft.entity.LivingEntity entity, net.minecraft.world.World world, net.minecraft.block.BlockState state, net.minecraft.util.math.BlockPos pos)
      Description copied from interface: EnvironmentController
      Gets the amount of warmth generated by a floor block state for a given entity.

      Hot floor is different from EnvironmentController.getHeatFromBlockState(BlockState), as it ONLY applies to entities stepping on the block - it does not affect the area around the block. An example implementation would be to provide warmth from Blocks.MAGMA_BLOCK, but not provide area heat.

      You can also use this for blocks that are cold to step on.

      Specified by:
      getFloorTemperature in interface EnvironmentController
      Parameters:
      entity - The entity that is stepping on the given state
      world - The world/level where the floor is located
      state - The state of the floor. This is exactly the state at the pos in the world
      pos - The position of the world in the world
      Returns:
      Returns the heat to apply each tick to entities standing on the block state
    • getMaxWetTicks

      public int getMaxWetTicks(Soakable soakable)
      Description copied from interface: EnvironmentController
      Gets the default maximum wet ticks for the soakable. Important note - so that behaviour will remain consistent with previous versions, this will return 600 by default, instead of the normal 0 for this type.
      Specified by:
      getMaxWetTicks in interface EnvironmentController
      Parameters:
      soakable - The soakable to get the max wet ticks for.
      Returns:
      Returns the default maximum wet ticks for the soakable
    • getSoakChange

      public int getSoakChange(Soakable soakable)
      Description copied from interface: EnvironmentController
      Gets the wetness increase for a Soakable this tick
      Specified by:
      getSoakChange in interface EnvironmentController
      Parameters:
      soakable - The soakable to compute increase for
      Returns:
      Returns the soaking change for the player.
    • getHeatAtLocation

      public int getHeatAtLocation(net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos)
      Description copied from interface: EnvironmentController
      Calculates the passive warmth nearby heat sources at a location in a world. 'Heat sources' being things that exist in the world that produce heat around them. For example, this could include artificial light producing sources, such as torches, campfires, lit furnaces, glowstone, and more.

      This can also be negative, to indicate a cold position.

      Specified by:
      getHeatAtLocation in interface EnvironmentController
      Parameters:
      world - The world the temperature aware is in
      pos - The position to check
      Returns:
      Returns the temperature change that should be applied from nearby temperature sources.
    • getHeatFromBlockState

      public int getHeatFromBlockState(net.minecraft.block.BlockState state)
      Description copied from interface: EnvironmentController
      Calculates the heat produced by a block state. May be negative, indicating a cold source.
      Specified by:
      getHeatFromBlockState in interface EnvironmentController
      Parameters:
      state - The block state heat source
      Returns:
      The warmth that the state produces around it
    • isHeatSource

      public boolean isHeatSource(net.minecraft.block.BlockState state)
      Description copied from interface: EnvironmentController
      Checks if a block state is a heat source, as defined by this controller.
      Specified by:
      isHeatSource in interface EnvironmentController
      Parameters:
      state - The block state to check
      Returns:
      Returns if a block state is a heat source
      See Also:
    • isColdSource

      public boolean isColdSource(net.minecraft.block.BlockState state)
      Description copied from interface: EnvironmentController
      Checks if a block state is a cold source, as defined by this controller.
      Specified by:
      isColdSource in interface EnvironmentController
      Parameters:
      state - The block state to check
      Returns:
      Returns true if a block state is a cold source
      See Also:
    • isAreaHeated

      public boolean isAreaHeated(net.minecraft.world.World world, net.minecraft.util.math.BlockPos pos)
      Description copied from interface: EnvironmentController
      Check if a position in a world is heated
      Specified by:
      isAreaHeated in interface EnvironmentController
      Parameters:
      world - The world of the position
      pos - The position to check
      Returns:
      Returns if the location in the world is heated
      See Also:
    • toString

      public final String toString()
      Wraps the class name around the string representation of the controller so that it is easy to see which mods are decorating the Thermoo environment controller

      Subclasses may not override this method any further.

      Overrides:
      toString in class Object
      Returns:
      Returns the class name of this class, and the string representation of the controller