Skip to content

Commit eef1020

Browse files
CodeAsmp2r3
andauthored
automate vanilla registry extraction on linux
* Adding a simple check if someone has read the readme * semi automate the registeries generation. still requires manually downloading server.jar for eula purposes * The mods have spoken: no spelling mistakes allowed. * mention extract_registries script in readme --------- Co-authored-by: p2r3 <41925384+p2r3@users.noreply.github.com>
1 parent 81865cb commit eef1020

3 files changed

Lines changed: 82 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ For PC x86_64 platforms, grab the [latest build binary](https://github.com/p2r3/
1212
For microcontrollers, see the section on **compilation** below.
1313

1414
## Compilation
15-
Before compiling, you'll need to dump registry data from a vanilla Minecraft server. Create a folder called `notchian` here, and put a Minecraft server JAR in it. Then, follow [this guide](https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Data_Generators) to dump all of the registries. Finally, run `build_registries.js` with `node`, `bun`, or `deno`.
15+
Before compiling, you'll need to dump registry data from a vanilla Minecraft server. On Linux, this can be done automatically using the `extract_registries.sh` script. Otherwise, the manual process is as follows: create a folder called `notchian` here, and put a Minecraft server JAR in it. Then, follow [this guide](https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Data_Generators) to dump all of the registries. Finally, run `build_registries.js` with `node`, `bun`, or `deno`.
1616

1717
- To target Linux, install `gcc` and run `build.sh`
1818
- To target Windows, install `gcc` and run `build.bat`

build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
if [ ! -f "include/registries.h" ]; then
4+
echo "Error: 'include/registries.h' is missing."
5+
echo "Please follow the 'Compilation' section of the README to generate it."
6+
exit 1
7+
fi
8+
19
rm bareiron
210
gcc src/*.c -O3 -Iinclude -o bareiron
311
./bareiron

extract_registries.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
REQUIRED_MAJOR=21
5+
SERVER_JAR="${SERVER_JAR:-server.jar}"
6+
NOTCHIAN_DIR="notchian"
7+
JS_RUNTIME=""
8+
9+
get_java_version() {
10+
java -version 2>&1 | awk -F[\".] '/version/ {print $2}'
11+
}
12+
13+
check_java() {
14+
if ! command -v java >/dev/null 2>&1; then
15+
echo "Java not found in PATH."
16+
exit 1
17+
fi
18+
19+
local major
20+
major="$(get_java_version)"
21+
22+
if (( major < REQUIRED_MAJOR )); then
23+
echo "Java $REQUIRED_MAJOR or newer required, but found Java $major."
24+
exit 1
25+
fi
26+
}
27+
28+
prepare_notchian_dir() {
29+
if [[ ! -d "$NOTCHIAN_DIR" ]]; then
30+
echo "Creating $NOTCHIAN_DIR directory..."
31+
mkdir -p "$NOTCHIAN_DIR"
32+
fi
33+
cd "$NOTCHIAN_DIR"
34+
}
35+
36+
dump_registries() {
37+
if [[ ! -f "$SERVER_JAR" ]]; then
38+
echo "No server.jar found (looked for $SERVER_JAR)."
39+
echo "Please download the server.jar from https://www.minecraft.net/en-us/download/server"
40+
echo "and place it in the notchian directory."
41+
exit 1
42+
fi
43+
44+
java -DbundlerMainClass="net.minecraft.data.Main" -jar "$SERVER_JAR" --all
45+
}
46+
47+
detect_js_runtime() {
48+
if command -v node >/dev/null 2>&1; then
49+
JS_RUNTIME="node"
50+
elif command -v bun >/dev/null 2>&1; then
51+
JS_RUNTIME="bun"
52+
elif command -v deno >/dev/null 2>&1; then
53+
JS_RUNTIME="deno run"
54+
else
55+
echo "No JavaScript runtime found (Node.js, Bun, or Deno)."
56+
exit 1
57+
fi
58+
}
59+
60+
run_js_script() {
61+
local script="$1"
62+
if [[ -z "$JS_RUNTIME" ]]; then
63+
detect_js_runtime
64+
fi
65+
echo "Running $script with $JS_RUNTIME..."
66+
$JS_RUNTIME "$script"
67+
}
68+
69+
check_java
70+
prepare_notchian_dir
71+
dump_registries
72+
run_js_script "../build_registries.js"
73+
echo "Registry dump and processing complete."

0 commit comments

Comments
 (0)