-
Notifications
You must be signed in to change notification settings - Fork 56
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.
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.
| 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 |
// 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.
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
Basics Platform Helpers Registration Networking Events Configs Config Screen
Resources Runtime Resource Packs Texture Manipulation Resource Helpers Block Set API
Client Custom Models Item Rendering Rendered Textures Post Shaders GUI Toolkit Colors
World Block and Item Interfaces Additional Item Placements Improved Entities Fake Levels World Data Dispenser Behaviors
Utilities Codec Utilities Misc Helpers Commands
Datapacks Villagers Soft Fluids Map Markers Spawn Boxes Global Datapack Folder