Skip to content

Map Markers

MehVahdJukaar edited this page Jul 25, 2026 · 1 revision

Map Markers

Custom icons on maps, defined by datapack, plus a way to store your own data inside map items.

Vanilla map decorations are a closed set. This adds a datapack registry of marker types: give one a target block and any map that sees that block gets the icon, which is how "villages and structures show up on my map" mods work. Markers can also be attached to structures, added dynamically per player, or driven entirely from code.

Getting Started

Files go in data/[your namespace]/moonlight/map_marker/[name].json. The icon texture goes in assets/[your namespace]/textures/map/decorations/[name].png.

{
  "target_block": {
    "predicate_type": "minecraft:block_match",
    "block": "minecraft:lodestone"
  },
  "name": "Lodestone",
  "map_color": "#ff0000",
  "rotation": 0
}

An empty {} is valid: it makes a marker type that nothing places automatically, which you then place yourself from code or with /mnl map_marker.

JSON Format

Field Type Default Description
target_block rule test none Blocks that automatically get this marker when a map covers them. Same rule test format worldgen processors use (block_match, blockstate_match, tag_match, random_block_match)
name text component none Label shown on hover
map_color hex string or int 0 Tint for the icon
rotation float 0 Fixed rotation in degrees
target_structures structure id, tag or list none Structures this marker represents. Used when a map is made to point at a structure

In code

// non permanent markers only the holder sees, e.g. a moving icon
MapDataRegistry.addDynamicClientMarkersEvent((mapId, mapData) -> makeMarkers(mapData));

// per player markers, computed server side and synced
MapDataRegistry.addDynamicServerMarkersEvent((player, mapId, mapData) -> makeMarkers(player));

For marker types that need behavior a json can't express, register a factory with registerSpecialMapDecorationTypeFactory(id, supplier) and point a json file at it.

Custom map data

You can also store arbitrary data on a map item, saved and synced with it:

MapDataRegistry.registerCustomMapSavedData(MY_DATA_TYPE);

Useful for anything that belongs to the map rather than to the world. Map Atlases uses this.

Examples: MapMarkersExample, ExtraMapDataExample

Clone this wiki locally