diff --git a/static/map-data/minecraft/fix_xaero_tile_names.py b/static/map-data/minecraft/fix_xaero_tile_names.py
new file mode 100644
index 0000000..31acf64
--- /dev/null
+++ b/static/map-data/minecraft/fix_xaero_tile_names.py
@@ -0,0 +1,58 @@
+import argparse
+import sys
+import logging
+import re
+import json
+from pathlib import Path
+
+logger = logging.getLogger(__name__)
+
+def main() -> int:
+ # Handle program arguments
+ ap = argparse.ArgumentParser(description='Fixes the names of Xaero\'s Minimap tiles to be used in leaflet')
+ ap.add_argument('input', help='The input directory containing the tiles', type=Path)
+ ap.add_argument('-v', '--verbose', help='Enable verbose logging', action='store_true')
+ args = ap.parse_args()
+
+ # Configure logging
+ logging.basicConfig(
+ level=logging.DEBUG if args.verbose else logging.INFO,
+ format='%(levelname)s: %(message)s',
+ )
+
+ # Find all PNGs
+ pngs = list(args.input.glob('*.png'))
+
+ # Look for PNGs with the bad format (0_0_x-1_z-1.png)
+ name_re = re.compile(r"(\d+)_(\d+)_x(-?\d+)_z(-?\d+).png")
+ tiles = []
+ for file in pngs:
+ file_name = file.name
+ match = name_re.match(file_name)
+ if match:
+ # Extract the coordinates
+ chunk_x, chunk_z, world_x, world_z = match.groups()
+
+ # Rename the file
+ new_name = f"xaero_tile_{world_x}_{world_z}.png"
+ new_path = file.with_name(new_name)
+ logger.info(f"Renaming {file_name} to {new_name}")
+ file.rename(new_path)
+
+ tiles.append({
+ "x": int(world_x),
+ "z": int(world_z),
+ "chunk_x": int(chunk_x),
+ "chunk_z": int(chunk_z),
+ "image": new_name
+ })
+
+ # Write a JSON file with the tile data
+ with open(args.input / "tiles.json", "w") as f:
+ json.dump(tiles, f, indent=4)
+
+
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main())
\ No newline at end of file
diff --git a/static/map-data/minecraft/mc-sdf-org/map.js b/static/map-data/minecraft/mc-sdf-org/map.js
index 6212c87..089bd55 100644
--- a/static/map-data/minecraft/mc-sdf-org/map.js
+++ b/static/map-data/minecraft/mc-sdf-org/map.js
@@ -274,6 +274,16 @@ const WAYPOINTS = {
]
}
+// Configure Leaflet to handle Minecraft coordinates
+L.XaeroTileLayer = L.TileLayer.extend({
+ getTileUrl: function (coords) {
+ return `${this._url}/xaero_tile_${(coords.x * 1024) - 512}_${(coords.y * 1024) - 512}.png`;
+ }
+});
+L.xaeroTileLayer = function (url, options) {
+ return new L.XaeroTileLayer(url, options);
+}
+
// Set up the map
var map = L.map('map', {
crs: L.CRS.Simple,
@@ -283,8 +293,10 @@ var map = L.map('map', {
});
// Create the tile layers
-var caves = L.layerGroup();
-var surface = L.layerGroup().addTo(map);
+var caves = L.xaeroTileLayer("/map-data/minecraft/mc-sdf-org/tiles/caves", {
+ tileSize: 1024,
+}).addTo(map);
+var surface = L.layerGroup();
map.attributionControl.addAttribution('With help from: DraconicNEO');
// Add each tile to the map
@@ -293,10 +305,10 @@ TILES.surface.forEach(tile => {
var image = L.imageOverlay(`/map-data/minecraft/mc-sdf-org/tiles/surface/${tile.image}`, bounds).addTo(surface);
});
-TILES.caves.forEach(tile => {
- var bounds = [[tile.z * -1, tile.x], [(tile.z + TILE_SIZE) * -1, tile.x + TILE_SIZE]];
- var image = L.imageOverlay(`/map-data/minecraft/mc-sdf-org/tiles/caves/${tile.image}`, bounds).addTo(caves);
-});
+// TILES.caves.forEach(tile => {
+// var bounds = [[tile.z * -1, tile.x], [(tile.z + TILE_SIZE) * -1, tile.x + TILE_SIZE]];
+// var image = L.imageOverlay(`/map-data/minecraft/mc-sdf-org/tiles/caves/${tile.image}`, bounds).addTo(caves);
+// });
// Add waypoints
diff --git a/templates/map.html b/templates/map.html
index 39cc5a8..43e8b18 100644
--- a/templates/map.html
+++ b/templates/map.html
@@ -22,8 +22,8 @@
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" />
-
-
+ {#
+ #}