DEV Community

Cover image for How Minecraft Java 26.2 Computes Locator Bar Colors from Player UUIDs (JS & Python)
yksalun
yksalun

Posted on

How Minecraft Java 26.2 Computes Locator Bar Colors from Player UUIDs (JS & Python)

When Minecraft added the multiplayer Locator Bar to the HUD, players quickly noticed something interesting: every player gets a consistent default dot color across worlds and servers, without picking one manually.

If you are building a Minecraft server plugin, web dashboard, Discord bot, or SMP companion utility, you might assume the color is just the first 6 hex characters of a player's UUID—or an MD5 hash. Neither is right.

Here is the exact deterministic algorithm audited against Minecraft Java Edition 26.2 (WaypointColor / FastColor), along with zero-dependency JavaScript and Python implementations and verified test vectors.


How the Java Edition Algorithm Works

Minecraft derives a player's default Locator Bar dot color in three steps:

  1. Compute Java's 32-bit UUID.hashCode() Split the 128-bit UUID into two 64-bit halves—msb (most significant bits) and lsb (least significant bits)—then XOR all four 32-bit chunks:
   hash32 = (msb >>> 32) ^ msb ^ (lsb >>> 32) ^ lsb
Enter fullscreen mode Exit fullscreen mode
  1. Extract the lower 24 bits as raw RGB rawRgb = hash32 & 0xFFFFFF gives the source RGB color before normalization.
  2. Normalize HSB brightness to 0.9 in IEEE-754 float32 To prevent near-black dots from disappearing on the HUD, Minecraft converts the raw RGB into HSB (hue, saturation, brightness), locks brightness to 0.9f, and converts back to RGB using single-precision (float32) math.

Why float32 matters: Using 64-bit IEEE-754 floats (number in JS or float in Python) without Math.fround() / struct.pack('>f', ...) produces 1-channel rounding drift (±1 on R, G, or B) on edge-case UUIDs.

For the full version-by-version breakdown—including /waypoint modify override precedence, scoreboard team colors, and why Bedrock Edition does not share a publicly verified UUID color formula—see the Java 26.2 Locator Bar UUID Color Reference.


Zero-Dependency JavaScript Implementation

const f32 = Math.fround;

export function uuidHashCode32(uuid) {
  const hex = uuid.replace(/-/g, "").toLowerCase();
  if (!/^[0-9a-f]{32}$/.test(hex)) {
    throw new Error(`Invalid UUID: ${uuid}`);
  }
  const msb = BigInt(`0x${hex.slice(0, 16)}`);
  const lsb = BigInt(`0x${hex.slice(16)}`);
  const hilo = msb ^ lsb;
  return Number(((hilo >> 32n) ^ hilo) & 0xffffffffn) >>> 0;
}

export function normalizeBrightness09Float32(rgb24) {
  const r = (rgb24 >> 16) & 0xff;
  const g = (rgb24 >> 8) & 0xff;
  const b = rgb24 & 0xff;

  const cmax = Math.max(r, g, b);
  const cmin = Math.min(r, g, b);
  const sat = cmax !== 0 ? f32((cmax - cmin) / cmax) : f32(0);

  let hue = f32(0);
  if (sat !== 0) {
    const delta = f32(cmax - cmin);
    const rc = f32((cmax - r) / delta);
    const gc = f32((cmax - g) / delta);
    const bc = f32((cmax - b) / delta);
    if (r === cmax) hue = f32(bc - gc);
    else if (g === cmax) hue = f32(f32(2) + f32(rc - bc));
    else hue = f32(f32(4) + f32(gc - rc));
    hue = f32(hue / f32(6));
    if (hue < 0) hue = f32(hue + f32(1));
  }

  const v = f32(0.9);
  if (sat === 0) {
    const gray = Math.trunc(f32(v * f32(255) + f32(0.5)));
    return (gray << 16) | (gray << 8) | gray;
  }

  const h = f32(f32(hue - Math.floor(hue)) * f32(6));
  const f = f32(h - Math.floor(h));
  const p = f32(v * f32(f32(1) - sat));
  const q = f32(v * f32(f32(1) - f32(sat * f)));
  const t = f32(v * f32(f32(1) - f32(sat * f32(f32(1) - f))));

  let rf, gf, bf;
  switch (Math.trunc(h)) {
    case 0: rf = v; gf = t; bf = p; break;
    case 1: rf = q; gf = v; bf = p; break;
    case 2: rf = p; gf = v; bf = t; break;
    case 3: rf = p; gf = q; bf = v; break;
    case 4: rf = t; gf = p; bf = v; break;
    default: rf = v; gf = p; bf = q; break;
  }

  const ro = Math.trunc(f32(rf * f32(255) + f32(0.5)));
  const go = Math.trunc(f32(gf * f32(255) + f32(0.5)));
  const bo = Math.trunc(f32(bf * f32(255) + f32(0.5)));
  return (ro << 16) | (go << 8) | bo;
}

export function uuidToLocatorColor(uuid) {
  const raw = uuidHashCode32(uuid) & 0xffffff;
  const display = normalizeBrightness09Float32(raw);
  const toHex = (n) => `#${n.toString(16).toUpperCase().padStart(6, "0")}`;
  return { rawHex: toHex(raw), displayHex: toHex(display) };
}
Enter fullscreen mode Exit fullscreen mode

Verified Test Vectors (Java 26.2)

Both the JS and Python 3 implementations in our MIT repository match all 5 public test vectors identically:

Player UUID Raw RGB In-Game Display Hex
Notch 069a79f4-44e9-4726-a5be-fca90e38aaf5 #F5688E #E66185
jeb_ 853c80ef-3c37-49fd-aa49-938b674adae6 #08807F #0EE6E4
Dinnerbone 61699b2e-d327-4a01-9f1e-0ea8c3f06bc6 #A0B441 #CCE653
MHF_Steve c06f8906-4c8a-4911-9c29-ea1dbd1aab82 #92585D #E68A92
MHF_Alex 6ab43178-89fd-4905-97f6-0f67d9d76fd9 #4C1190 #7A1CE6

Source Code & Interactive Web Tools

If you want the Python 3 port (uuid_color.py), automated tests, or ready-to-use browser tools for SMP admins and players:

Have you built custom waypoint overlays or team color rules for an SMP? Drop your setup or edge cases in the comments!

Top comments (0)