Compare commits
11 Commits
rewrite-in
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
6fae27b165
|
|||
|
d3bb5c7e8c
|
|||
|
7c86d342e6
|
|||
|
1af4bbc330
|
|||
|
be638b2ade
|
|||
|
1b3a7d0e90
|
|||
|
89e9d8827c
|
|||
|
08507b8d53
|
|||
|
30e1aabde9
|
|||
|
1168d37d7e
|
|||
|
c20520b400
|
82
.gitea/workflows/build.yml
Normal file
82
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
name: "Build maps"
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
jobs:
|
||||||
|
build-mapcrafter:
|
||||||
|
runs-on: debian-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v7
|
||||||
|
|
||||||
|
- name: Build map
|
||||||
|
run: uv run mckart export-mapcrafter
|
||||||
|
|
||||||
|
# - name: Setup Biome
|
||||||
|
# uses: biomejs/setup-biome@v2
|
||||||
|
|
||||||
|
# - name: Format map
|
||||||
|
# run: biome format ./mapcrafter/* --write
|
||||||
|
|
||||||
|
- name: Transfer results
|
||||||
|
uses: https://git.pvv.ntnu.no/Projects/rsync-action@v1
|
||||||
|
with:
|
||||||
|
source: ./mapcrafter/
|
||||||
|
target: ${{ gitea.ref_name }}/mapcrafter/
|
||||||
|
username: gitea-web
|
||||||
|
ssh-key: ${{ secrets.WEB_SYNC_SSH_KEY }}
|
||||||
|
host: pages.pvv.ntnu.no
|
||||||
|
known-hosts: "pages.pvv.ntnu.no ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH2QjfFB+city1SYqltkVqWACfo1j37k+oQQfj13mtgg"
|
||||||
|
|
||||||
|
- name: Upload deb package artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: minecraft-kartverket-mapcrafter-export-${{ gitea.sha }}.zip
|
||||||
|
path: ./mapcrafter/
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 30
|
||||||
|
compression: 7
|
||||||
|
|
||||||
|
build-bluemap:
|
||||||
|
runs-on: debian-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v7
|
||||||
|
|
||||||
|
- name: Build map
|
||||||
|
run: uv run mckart export-bluemap
|
||||||
|
|
||||||
|
- name: Transfer results
|
||||||
|
uses: https://git.pvv.ntnu.no/Projects/rsync-action@v1
|
||||||
|
with:
|
||||||
|
source: ./bluemap/
|
||||||
|
target: ${{ gitea.ref_name }}/bluemap/
|
||||||
|
username: gitea-web
|
||||||
|
ssh-key: ${{ secrets.WEB_SYNC_SSH_KEY }}
|
||||||
|
host: pages.pvv.ntnu.no
|
||||||
|
known-hosts: "pages.pvv.ntnu.no ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH2QjfFB+city1SYqltkVqWACfo1j37k+oQQfj13mtgg"
|
||||||
|
|
||||||
|
- name: Upload deb package artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: minecraft-kartverket-bluemap-export-${{ gitea.sha }}.zip
|
||||||
|
path: ./bluemap/
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 30
|
||||||
|
compression: 7
|
||||||
|
|
||||||
|
# build-nix:
|
||||||
|
# runs-on: debian-latest
|
||||||
|
# steps:
|
||||||
|
# - name: Install sudo
|
||||||
|
# run: apt-get update && apt-get -y install sudo
|
||||||
|
|
||||||
|
# - name: Install nix
|
||||||
|
# uses: https://github.com/cachix/install-nix-action@v31
|
||||||
|
|
||||||
|
# - name: Configure nix
|
||||||
|
# run: echo -e "show-trace = true\nmax-jobs = auto\ntrusted-users = root\nexperimental-features = nix-command flakes\nbuild-users-group =" > /etc/nix/nix.conf
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@ result-*
|
|||||||
# Ignore generated files by default
|
# Ignore generated files by default
|
||||||
/mapcrafter
|
/mapcrafter
|
||||||
/bluemap
|
/bluemap
|
||||||
|
/out
|
||||||
|
|||||||
20
Makefile
Normal file
20
Makefile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
.PHONY: all clean validate
|
||||||
|
|
||||||
|
all: bluemap mapcrafter
|
||||||
|
|
||||||
|
export PYTHONPATH := $(CURDIR)/src/
|
||||||
|
|
||||||
|
OUT := $(CURDIR)/out
|
||||||
|
|
||||||
|
validate:
|
||||||
|
python -m cli.main validate
|
||||||
|
|
||||||
|
bluemap: validate
|
||||||
|
python -m cli.main export-bluemap --output-dir "$(OUT)/bluemap"
|
||||||
|
|
||||||
|
mapcrafter: validate
|
||||||
|
python -m cli.main export-mapcrafter --output-dir "$(OUT)/mapcrafter"
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf ./bluemap
|
||||||
|
rm -rf ./mapcrafter
|
||||||
54
README.md
54
README.md
@@ -7,7 +7,16 @@ Map markers for PVV's minecraft server
|
|||||||
This project is meant to let PVV members contribute map data for PVV's minecraft server, like coordinates for bases, cities, and other points of interest.
|
This project is meant to let PVV members contribute map data for PVV's minecraft server, like coordinates for bases, cities, and other points of interest.
|
||||||
These markers are written in python so that we can do things like generating points in a loop, calculating distances, and other types of automation.
|
These markers are written in python so that we can do things like generating points in a loop, calculating distances, and other types of automation.
|
||||||
|
|
||||||
There is also a cli tool that we use to export these points into the formats of several minecraft map implementations.
|
The codebase includes a CLI tool that we use to export this data into the formats of several minecraft map implementations.
|
||||||
|
|
||||||
|
Grab the latest exports here:
|
||||||
|
|
||||||
|
- Bluemap:
|
||||||
|
- https://pages.pvv.ntnu.no/Projects/minecraft-kartverket/main/bluemap/overworld.hocon
|
||||||
|
- https://pages.pvv.ntnu.no/Projects/minecraft-kartverket/main/bluemap/nether.hocon
|
||||||
|
- https://pages.pvv.ntnu.no/Projects/minecraft-kartverket/main/bluemap/the-end.hocon
|
||||||
|
- Mapcrafter:
|
||||||
|
- https://pages.pvv.ntnu.no/Projects/minecraft-kartverket/main/mapcrafter/markers.js
|
||||||
|
|
||||||
## Marker sets
|
## Marker sets
|
||||||
|
|
||||||
@@ -37,6 +46,47 @@ Here is an overview of the different marker sets, and what they are meant for.
|
|||||||
- Other: anything that doesn't fit into the other categories
|
- Other: anything that doesn't fit into the other categories
|
||||||
- Portals: end portals that send you back to the center of the map
|
- Portals: end portals that send you back to the center of the map
|
||||||
|
|
||||||
|
## How to run the python code
|
||||||
|
|
||||||
|
You can either use `uv`, `nix` or the bundled `Makefile` with a bare python installation to run the project.
|
||||||
|
|
||||||
|
There should be no external dependencies to run the code.
|
||||||
|
|
||||||
|
In the following sections of the readme, we will assume that you are using `uv`, but the other methods can also be adapted to the instructions.
|
||||||
|
|
||||||
|
### Using uv
|
||||||
|
|
||||||
|
If you have [uv](https://docs.astral.sh/uv/) installed, running the code is as easy as executing
|
||||||
|
|
||||||
|
```bash
|
||||||
|
uv run mckart <args>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using the Makefile
|
||||||
|
|
||||||
|
The makefile will validate the map data, and generate both types of map exports in a directory named `out`
|
||||||
|
|
||||||
|
You can invoke it with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make
|
||||||
|
ls out
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using nix
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run the cli tool
|
||||||
|
nix run .# <args>
|
||||||
|
|
||||||
|
# Build the exports
|
||||||
|
nix build .#bluemap-export
|
||||||
|
nix build .#mapcrafter-export
|
||||||
|
|
||||||
|
# Get a python environment with development tooling
|
||||||
|
nix develop
|
||||||
|
```
|
||||||
|
|
||||||
## How to add a point marker
|
## How to add a point marker
|
||||||
|
|
||||||
1. Find the correct marker set file in `src/marker_sets/<world>`.
|
1. Find the correct marker set file in `src/marker_sets/<world>`.
|
||||||
@@ -48,7 +98,7 @@ uv run mckart verify
|
|||||||
uv run mckart print
|
uv run mckart print
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Open a PR
|
4. Open a pull request at https://git.pvv.ntnu.no/Projects/minecraft-kartverket/pulls
|
||||||
|
|
||||||
## How to add a railway / road
|
## How to add a railway / road
|
||||||
|
|
||||||
|
|||||||
6
flake.lock
generated
6
flake.lock
generated
@@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1762482733,
|
"lastModified": 1764947035,
|
||||||
"narHash": "sha256-g/da4FzvckvbiZT075Sb1/YDNDr+tGQgh4N8i5ceYMg=",
|
"narHash": "sha256-EYHSjVM4Ox4lvCXUMiKKs2vETUSL5mx+J2FfutM7T9w=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "e1ebeec86b771e9d387dd02d82ffdc77ac753abc",
|
"rev": "a672be65651c80d3f592a89b3945466584a22069",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from textwrap import indent
|
from textwrap import indent
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
from lib_marker import Point, Track
|
||||||
from marker_sets import WORLDS
|
from marker_sets import WORLDS
|
||||||
from lib_marker import Point
|
|
||||||
|
|
||||||
|
|
||||||
def generate_bluemap_output(output_dir: Path):
|
def generate_bluemap_output(output_dir: Path):
|
||||||
@@ -42,8 +42,11 @@ def convert_data_to_bluemap_structure() -> dict:
|
|||||||
}
|
}
|
||||||
|
|
||||||
for marker in marker_set.markers:
|
for marker in marker_set.markers:
|
||||||
|
poi_markers = result[world_name][slug(marker_set.name)]["markers"]
|
||||||
|
track_markers = result[world_name][slug(marker_set.name)]["markers"]
|
||||||
if isinstance(marker, Point):
|
if isinstance(marker, Point):
|
||||||
result[world_name][slug(marker_set.name)][slug(marker.name)] = {
|
# https://bluemap.bluecolored.de/wiki/customization/Markers.html#poi-markers
|
||||||
|
poi_markers[slug(marker.name)] = {
|
||||||
"type": "poi",
|
"type": "poi",
|
||||||
"label": marker.name,
|
"label": marker.name,
|
||||||
"position": {
|
"position": {
|
||||||
@@ -52,6 +55,21 @@ def convert_data_to_bluemap_structure() -> dict:
|
|||||||
"z": marker.z,
|
"z": marker.z,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
elif isinstance(marker, Track):
|
||||||
|
# https://bluemap.bluecolored.de/wiki/customization/Markers.html#line-markers
|
||||||
|
track_markers[slug(marker.name)] = {
|
||||||
|
"type": "line",
|
||||||
|
# TODO: Calculate the median point of the track for the label position
|
||||||
|
"position": {
|
||||||
|
"x": marker.points[0][0],
|
||||||
|
"y": marker.points[0][1],
|
||||||
|
"z": marker.points[0][2],
|
||||||
|
},
|
||||||
|
"label": marker.name,
|
||||||
|
"line": [
|
||||||
|
{"x": p[0], "y": p[1], "z": p[2]} for p in marker.points
|
||||||
|
],
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(f"Unknown marker type: {marker}")
|
raise NotImplementedError(f"Unknown marker type: {marker}")
|
||||||
|
|
||||||
@@ -72,7 +90,7 @@ def to_hocon(x: Any) -> str:
|
|||||||
return f"[\n{'\n'.join(items)}\n]"
|
return f"[\n{'\n'.join(items)}\n]"
|
||||||
elif isinstance(x, dict):
|
elif isinstance(x, dict):
|
||||||
items = [
|
items = [
|
||||||
f' "{k}": {indent(to_hocon(v), ' ').removeprefix(' ')}'
|
f' "{k}": {indent(to_hocon(v), " ").removeprefix(" ")}'
|
||||||
for k, v in x.items()
|
for k, v in x.items()
|
||||||
]
|
]
|
||||||
return f"{{\n{'\n'.join(items)}\n}}"
|
return f"{{\n{'\n'.join(items)}\n}}"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from lib_marker import Area, Point, Track
|
||||||
from marker_sets import WORLDS
|
from marker_sets import WORLDS
|
||||||
from lib_marker import Point, Track, Area
|
|
||||||
|
|
||||||
|
|
||||||
def generate_mapcrafter_output(output_dir: Path):
|
def generate_mapcrafter_output(output_dir: Path):
|
||||||
@@ -30,6 +30,7 @@ def convert_data_to_mapcrafter_structure() -> dict:
|
|||||||
|
|
||||||
for world_name, world_marker_sets in WORLDS.items():
|
for world_name, world_marker_sets in WORLDS.items():
|
||||||
for marker_set in world_marker_sets:
|
for marker_set in world_marker_sets:
|
||||||
|
# https://mapcrafter.readthedocs.io/en/latest/markers.html#manually-specifying-markers
|
||||||
if marker_set.name not in result:
|
if marker_set.name not in result:
|
||||||
result[marker_set.name] = {
|
result[marker_set.name] = {
|
||||||
"id": marker_set.name.lower().replace(" ", "-"),
|
"id": marker_set.name.lower().replace(" ", "-"),
|
||||||
@@ -46,10 +47,14 @@ def convert_data_to_mapcrafter_structure() -> dict:
|
|||||||
)
|
)
|
||||||
|
|
||||||
elif isinstance(marker, Track):
|
elif isinstance(marker, Track):
|
||||||
raise NotImplementedError("Track markers are not supported")
|
print(
|
||||||
|
f"Track markers are not natively supported in Mapcrafter, skipping '{marker.name}'..."
|
||||||
|
)
|
||||||
|
|
||||||
elif isinstance(marker, Area):
|
elif isinstance(marker, Area):
|
||||||
raise NotImplementedError("Area markers are not supported")
|
print(
|
||||||
|
f"Area markers are not natively supported in Mapcrafter, skipping '{marker.name}'..."
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unknown marker type: {marker}")
|
raise ValueError(f"Unknown marker type: {marker}")
|
||||||
|
|||||||
@@ -38,5 +38,12 @@ MARKER_SET = MarkerSet(
|
|||||||
y=64,
|
y=64,
|
||||||
z=0,
|
z=0,
|
||||||
),
|
),
|
||||||
|
Point(
|
||||||
|
name="Nordørkenen",
|
||||||
|
icon=None,
|
||||||
|
x=0,
|
||||||
|
y=67,
|
||||||
|
z=-485,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -38,5 +38,19 @@ MARKER_SET = MarkerSet(
|
|||||||
y=64,
|
y=64,
|
||||||
z=-460,
|
z=-460,
|
||||||
),
|
),
|
||||||
|
Point(
|
||||||
|
name="Shiro",
|
||||||
|
icon=None,
|
||||||
|
x=-790,
|
||||||
|
y=64,
|
||||||
|
z=-837,
|
||||||
|
),
|
||||||
|
Point(
|
||||||
|
name="Singapore",
|
||||||
|
icon=None,
|
||||||
|
x=-600,
|
||||||
|
y=64,
|
||||||
|
z=-1130,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -38,6 +38,13 @@ MARKER_SET = MarkerSet(
|
|||||||
y=78,
|
y=78,
|
||||||
z=-3043,
|
z=-3043,
|
||||||
),
|
),
|
||||||
|
Point(
|
||||||
|
name="Blomenholm",
|
||||||
|
icon=None,
|
||||||
|
x=-295,
|
||||||
|
y=64,
|
||||||
|
z=2372,
|
||||||
|
),
|
||||||
Point(
|
Point(
|
||||||
name="Huløyeid",
|
name="Huløyeid",
|
||||||
icon=None,
|
icon=None,
|
||||||
@@ -45,6 +52,13 @@ MARKER_SET = MarkerSet(
|
|||||||
y=64,
|
y=64,
|
||||||
z=234,
|
z=234,
|
||||||
),
|
),
|
||||||
|
Point(
|
||||||
|
name="Linder",
|
||||||
|
icon=None,
|
||||||
|
x=4321,
|
||||||
|
y=64,
|
||||||
|
z=-8778,
|
||||||
|
),
|
||||||
Point(
|
Point(
|
||||||
name="Singapore",
|
name="Singapore",
|
||||||
icon=None,
|
icon=None,
|
||||||
@@ -80,5 +94,12 @@ MARKER_SET = MarkerSet(
|
|||||||
y=64,
|
y=64,
|
||||||
z=447,
|
z=447,
|
||||||
),
|
),
|
||||||
|
Point(
|
||||||
|
name="Østsumpøyene",
|
||||||
|
icon=None,
|
||||||
|
x=4070,
|
||||||
|
y=64,
|
||||||
|
z=2900,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,59 @@
|
|||||||
from lib_marker import MarkerSet
|
from lib_marker import MarkerSet, Track
|
||||||
|
|
||||||
|
|
||||||
MARKER_SET = MarkerSet(
|
MARKER_SET = MarkerSet(
|
||||||
name="Railways",
|
name="Railways",
|
||||||
markers=[],
|
markers=[
|
||||||
|
Track(
|
||||||
|
name="Sentralbane vest",
|
||||||
|
points=[
|
||||||
|
(143, 71, 127),
|
||||||
|
(44, 71, 127),
|
||||||
|
(41, 71, 123),
|
||||||
|
(-32, 71, 123),
|
||||||
|
(-32, 71, 126),
|
||||||
|
(-34, 71, 128),
|
||||||
|
(-53, 71, 128),
|
||||||
|
(-68, 71, 128),
|
||||||
|
(-77, 71, 128),
|
||||||
|
(-106, 71, 173),
|
||||||
|
(-106, 71, 180),
|
||||||
|
(-129, 71, 203),
|
||||||
|
(-271, 71, 203),
|
||||||
|
(-308, 71, 165),
|
||||||
|
(-358, 71, 165),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Track(
|
||||||
|
name="Shiro Monorail",
|
||||||
|
points=[
|
||||||
|
(-689, 73, -770),
|
||||||
|
(-685, 73, -770),
|
||||||
|
(-685, 73, -765),
|
||||||
|
(-685, 74, -764),
|
||||||
|
(-685, 74, -760),
|
||||||
|
(-720, 74, -760),
|
||||||
|
(-737, 76, -760),
|
||||||
|
(-737, 76, -646),
|
||||||
|
(-739, 77, -646),
|
||||||
|
(-742, 77, -646),
|
||||||
|
(-744, 78, -646),
|
||||||
|
(-759, 92, -646),
|
||||||
|
(-815, 92, -646),
|
||||||
|
(-815, 92, -643),
|
||||||
|
(-815, 101, -633),
|
||||||
|
(-815, 101, -385),
|
||||||
|
(-815, 97, -380),
|
||||||
|
(-815, 97, -377),
|
||||||
|
(-815, 90, -370),
|
||||||
|
(-813, 90, -370),
|
||||||
|
(-813, 73, -352),
|
||||||
|
(-813, 73, -306),
|
||||||
|
(-813, 68, -300),
|
||||||
|
(-813, 68, -298),
|
||||||
|
(-817, 68, -298),
|
||||||
|
(-819, 67, -298),
|
||||||
|
(-822, 67, -298),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user