Chunk Base map to CSV
I recently wanted to copy-paste all of the Chunk Base coordinates for every single POI on the map for a ±5000 block square around (0, 0). There is no (current) official way to download a Chunk Base map as a CSV file.
Here's how you can do it anyway:
- Navigate to https://www.chunkbase.com/apps/seed-map
- Enter your seed, version, etc.
- Make sure the map shows everything you want to export
- Open DevTools using
F12
orCtrl
+Shift
+I
- Type
allow pasting
if pasting is disabled - Copy & paste the script into your DevTools panel
- Right-click &
Copy string contents
to get the CSV export and use it however you want to! 🎉
const CSV = await import("https://esm.run/csv-string@4.1.1");
const table = [["Type", "X", "Y", "Z", "Details"]];
const oldOnPoiDrawn = CB3TooltipManager.onPoiDrawn;
CB3TooltipManager.onPoiDrawn = function (type, repr, coords, details) {
const [x, y, z] = coords;
table.push([type, x, y, z, JSON.stringify(details)]);
};
CB3FinderApp.trigger("redrawmap");
CB3TooltipManager.onPoiDrawn = oldOnPoiDrawn;
CSV.stringify(table);
How it works
The real trick is intercepting the onPoiDrawn
event and using the provided structured data to construct our own CSV table instead of drawing images to the map canvas. We really lucked out that CB3FinderApp
and friends are all global variables!
So we:
- Create our table. It has
Type
,X
,Y
,Z
, andDetails
columns. - Stash the old
onPoiDrawn
function that probably does some important things. - Overwrite the
onPoiDrawn
function with our own that.push()
-es a new row for each POI that needs to be drawn. You canconsole.log(arguments)
to see the complete arguments list. This was the most complicated part; you need to inspect thearguments
in the console and then pluck the right attributes off the right objects to get the data you want. - Trigger a redraw. This was another case of trial and error. You can
console.log(CB3FinderApp)
in the console and look for any event-related properties to find more events.redrawmap
seemed like a good thing to try and it worked! There may be other events that do different things. Who knows! - Reset the
onPoiDrawn
callback back to the original. - Return the table stringified as CSV. Since this is the last evaluated expression it will be shown to the user in the DevTools console. Chrome (no idea about other browsers) has a handy
Copy string contents
option in the right-click menu which can be used to easily copy the CSV string to your clipboard.
You can very easily edit the code and export the POI data in JSON or some other format if you like.