Class ColorMap

java.lang.Object
net.nullved.pmweatherapi.util.ColorMap

public class ColorMap extends Object
A builder-based representation of ColorTables. Should hopefully be able to produce identical results.

You can create a new ColorMap builder with ColorMap.Builder.of(Color). Use ColorMap.Builder.addPoint(Color, float) to add a new point to lerp between. Use ColorMap.Builder.override(Color, float) to add a new point to override the color at.
Since:
0.14.15.6
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A Builder pattern for creating a ColorMap
    static final record 
    Represents a Lerp Segment
  • Method Summary

    Modifier and Type
    Method
    Description
    get(float val)
    Retrieves the color value using the closest value from the lookup table.
    getAccurate(float val)
    Gets the Color for the specific value.
    getWithBiome(float val, net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biome, net.minecraft.world.phys.Vec3 worldPos)
    Retrieves the color value using a color derived from the biome
    static Color
    lerp(float delta, Color c1, Color c2)
    Lerps between two colors
    float
    Gets the largest value a color is defined for
    float
    Gets the smallest value a color is defined for
    void
    recomputeLookups(float resolution)
    Recomputes the lookup table with the given resolution.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • minValue

      public float minValue()
      Gets the smallest value a color is defined for
      Returns:
      The minimum value
      Since:
      0.14.15.6
    • maxValue

      public float maxValue()
      Gets the largest value a color is defined for
      Returns:
      The maximum value
      Since:
      0.14.15.6
    • recomputeLookups

      public void recomputeLookups(float resolution)
      Recomputes the lookup table with the given resolution.
      Parameters:
      resolution - The new resolution
      Since:
      0.14.16.1
    • get

      public Color get(float val)
      Retrieves the color value using the closest value from the lookup table. If you need the accurate value, use getAccurate(float) instead
      Parameters:
      val - The value to get a color for
      Returns:
      The approximate color for this value
      Since:
      0.14.16.1
      See Also:
    • getWithBiome

      public Color getWithBiome(float val, net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biome, net.minecraft.world.phys.Vec3 worldPos)
      Retrieves the color value using a color derived from the biome
      Parameters:
      val - The value to get a color for
      biome - The biome to derive the starting color from
      worldPos - The world position (for grass color checks)
      Returns:
      The approximate color for this value
      Since:
      0.15.0.0
    • getAccurate

      public Color getAccurate(float val)
      Gets the Color for the specific value.
      This method is SLOWER and oftentimes the same as get(float). Use that instead if you only need the approximate value
      Parameters:
      val - The value to get the Color of
      Returns:
      The Color for the given value
      Since:
      0.14.15.6
      See Also:
    • lerp

      public static Color lerp(float delta, Color c1, Color c2)
      Lerps between two colors
      Parameters:
      delta - The t-value from 0 to 1
      c1 - The first Color
      c2 - The second Color
      Returns:
      A Color lerped between c1 and c2
      Since:
      0.14.15.6