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(int). Use ColorMap.Builder.addPoint(int, float) to add a new point to lerp between. Use ColorMap.Builder.override(int, 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
    int
    get(float val)
    Retrieves the color value using the closest value from the lookup table.
    int
    getAccurate(float val)
    Gets the Color for the specific value.
    int
    getWithBiome(float val, net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biome, double wx, double wz)
    Retrieves the color value using a color derived from the biome
    int
    getWithTerrainMap(float val, dev.protomanly.pmweather.block.entity.RadarBlockEntity rbe, double x, double z)
     
    static int
    lerp(float delta, int c1, int c2)
    Lerps between two colors
    static int
    lerpBlackTransparent(float delta, int c1, int c2)
     
    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 int 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 int getWithBiome(float val, net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biome, double wx, double wz)
      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
      wx - The world x position (for grass color checks)
      wz - The world z position (for grass color checks)
      Returns:
      The approximate color for this value
      Since:
      0.15.0.0
    • getWithTerrainMap

      public int getWithTerrainMap(float val, dev.protomanly.pmweather.block.entity.RadarBlockEntity rbe, double x, double z)
    • getAccurate

      public int 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:
    • lerpBlackTransparent

      public static int lerpBlackTransparent(float delta, int c1, int c2)
    • lerp

      public static int lerp(float delta, int c1, int 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