Class RadarMode

java.lang.Object
net.nullved.pmweatherapi.radar.RadarMode
All Implemented Interfaces:
Comparable<RadarMode>, net.minecraft.util.StringRepresentable

public class RadarMode extends Object implements net.minecraft.util.StringRepresentable, Comparable<RadarMode>
A class representing a Radar Mode.

To register your own radar mode, you must call create(net.minecraft.resources.ResourceLocation, java.util.function.Function<net.nullved.pmweatherapi.client.render.PixelRenderData, java.lang.Integer>, int) somewhere from your MAIN MOD CLASS CONSTRUCTOR. This is to ensure the radar mode gets added to PMWExtras.RADAR_MODE so that it will be recognized by Minecraft as a valid property value

For each radar mode, you must define a function taking in a PixelRenderData and returning a Color. This function is run for every pixel on the radar, so try to make it performant.

You can also define a custom dot color with create(ResourceLocation, Function, int) (this supports transparency)

You may also be looking to overlay something on top of the radar instead. If this is what you are looking to do, checkout RadarOverlays instead
Since:
0.14.15.6
See Also:
  • Field Details

    • NULL

      public static final RadarMode NULL
      A "Null" Radar Mode mimicking Minecraft's missing texture. This radar mode is not accessible by normal means, and if you see it that is an error.
      Since:
      0.14.15.6
    • REFLECTIVITY

      public static final RadarMode REFLECTIVITY
      A Radar Mode that is a copy of PMWeather's Reflectivity
      Since:
      0.14.15.6
    • VELOCITY

      public static final RadarMode VELOCITY
      A Radar Mode that is a copy of PMWeather's Velocity
      Since:
      0.14.15.6
    • IR

      public static final RadarMode IR
      A Radar Mode that is a copy of PMWeather's IR
      Since:
      0.15.0.0
  • Method Details

    • disableBaseRendering

      public static void disableBaseRendering(boolean disable)
      Disables all rendering of pixels from any radar mode
      Parameters:
      disable - Whether to disable rendering or not
      Since:
      0.15.3.3
    • isBaseRenderingDisabled

      public static boolean isBaseRenderingDisabled()
      Returns whether base rendering is disabled or not
      Returns:
      Base rendering disable state
      Since:
      0.15.3.3
    • create

      public static RadarMode create(net.minecraft.resources.ResourceLocation id, Function<PixelRenderData,Integer> colorFunction, int renderDotColor)
      Create a new RadarMode
      Parameters:
      id - The ResourceLocation of this radar mode
      colorFunction - The Function mapping a PixelRenderData to a Color. Runs for every pixel
      renderDotColor - The Color of the dot. Supports transparency
      Returns:
      A new RadarMode
      Since:
      0.14.15.6
    • create

      public static RadarMode create(net.minecraft.resources.ResourceLocation id, Function<PixelRenderData,Integer> colorFunction)
      Create a new RadarMode with a red dot at the center. To set a custom dot color, use create(ResourceLocation, Function, int)
      Parameters:
      id - The ResourceLocation of this radar mode
      colorFunction - The Function mapping a PixelRenderData to a Color. Runs for every pixel
      Returns:
      A new RadarMode
      Since:
      0.14.15.6
    • values

      public static Collection<RadarMode> values()
      Returns a Collection of RadarModes
      Returns:
      All Radar Modes
      Since:
      0.14.15.6
    • get

      public static RadarMode get(net.minecraft.resources.ResourceLocation id)
      Gets a specific RadarMode based on ID
      Parameters:
      id - The ResourceLocation of the RadarMode
      Returns:
      The associated RadarMode, or NULL if not found
      Since:
      0.14.15.6
    • get

      public static RadarMode get(String id)
      Gets a specific RadarMode based on ID in string format
      Parameters:
      id - The ID of the RadarMode
      Returns:
      The associated RadarMode, or NULL if not found
      Since:
      0.14.15.6
    • cycle

      public RadarMode cycle()
      Gets the next RadarMode in the cycle
      Returns:
      The next RadarMode
      Since:
      0.14.15.6
    • getId

      public net.minecraft.resources.ResourceLocation getId()
      Gets the ResourceLocation of the radar mode
      Returns:
      The ResourceLocation of this radar mode
    • getDotColor

      public int getDotColor()
      Gets the color of the dot at the center of the radar
      Returns:
      The dot Color
      Since:
      0.14.15.6
    • getColorForPixel

      public int getColorForPixel(PixelRenderData pixelRenderData)
      Parameters:
      pixelRenderData - The PixelRenderData of the pixel
      Returns:
      The Color to draw to the pixel
      Since:
      0.14.15.6
    • getSerializedName

      public String getSerializedName()
      Gets the serialized name of the RadarMode
      Specified by:
      getSerializedName in interface net.minecraft.util.StringRepresentable
      Returns:
      The serialized name
      Since:
      0.14.15.6
    • compareTo

      public int compareTo(@NotNull @NotNull RadarMode o)
      Compares this RadarMode to the given RadarMode. Used to efficiently search for the next RadarMode in the cycle
      Specified by:
      compareTo in interface Comparable<RadarMode>
      Parameters:
      o - The other RadarMode
      Returns:
      0 if same position in the cycle, 1 if later, -1 if earlier
      Since:
      0.14.15.6