-
Notifications
You must be signed in to change notification settings - Fork 2
Custom Radar Mode
Creating a Custom Radar Mode is relatively simple, but there are some factors you may want to consider:
- Do I want this to show up in the cycle of radar modes?
- Do I want to render stuff on some or all modes? Use Radar Overlays instead
- Do I have a way to access the data I need?
Custom Radar Modes will show up in the cycle in the order they are registered. There is currently no way to modify the order of radar modes after creation
To create a Radar Mode, you must do so from somewhere that gets called from your Main Mod Class constructor.
It can not be in an FMLCommonSetupEvent, as it will be too late by then.
To create your Radar Mode, use RadarMode#create
RadarMode test = RadarMode.create(...);You must pass in the following parameters:
- A
ResourceLocationspecifying the ID of the mode - A
Function<PixelRenderData, Color>that returns a color for every pixel - An optional
Colorspecifying the color of the dot at the center. Supports transparency
Here is the PMWeather Velocity implementation in this format:
public static final RadarMode VELOCITY = create(PMWeather.getPath("velocity"), prd -> {
Color velCol = prd.velocity() >= 0.0F ? ColorMaps.POSITIVE_VELOCITY.get(prd.velocity() / 1.75F) : ColorMaps.NEGATIVE_VELOCITY.get(-prd.velocity() / 1.75F);
return ColorMap.lerp(Mth.clamp(Math.max(prd.rdbz(), (Mth.abs(prd.velocity() / 1.75F) - 18.0F) / 0.65F) / 12.0F, 0.0F, 1.0F), Color.BLACK, velCol);
});That's all you have to do! You've now created a Custom Radar Mode.
To get the current Radar Mode from a radar's BlockState, you can use the PMWExtras.RADAR_MODE block state property