Skip to content

Color Maps

Maximilian Dorn edited this page Aug 31, 2022 · 5 revisions

Color Maps

A ColorMap is a container that contains Minecraft map color <-> RGB color mappings.

The data for the color maps is sourced from cerus/minecraft-map-colors.

Usage

boolean latest = false;
final ColorMap cm = latest
        ? ColorMaps.latest()    // Get a color map for the latest Minecraft version
        : ColorMaps.current();  // Get a color map for the currently running Minecraft version
byte mapCol1 = cm.rgbToMapColor(0, 255, 0);         // 0, 255, 0  ->  30
byte mapCol2 = cm.rgbToMapColor(0x00, 0xAF, 0xFE);  // 0x00AFFE   ->  125
Color rgbCol1 = cm.mapColorToRgb((byte) 118);       // 118        ->  25, 25, 25
Color rgbCol2 = cm.mapColorToRgb((byte) 16);        // 16         ->  180, 0, 0

// Please keep in mind:
// ColorMap#rgbToMapColor() does not cache the result, it will always calculate 
// the best matching color again (which is very expensive)
// Use the ColorCache for rgbToMapColor operations