1
0
mirror of https://github.com/p2r3/bareiron.git synced 2025-10-01 23:25:09 +02:00

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>
This commit is contained in:
CodeAsm
2025-09-12 18:31:03 +02:00
committed by GitHub
parent 81865cb7ac
commit eef1020ad8
3 changed files with 82 additions and 1 deletions

View File

@@ -12,7 +12,7 @@ For PC x86_64 platforms, grab the [latest build binary](https://github.com/p2r3/
For microcontrollers, see the section on **compilation** below. For microcontrollers, see the section on **compilation** below.
## Compilation ## Compilation
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`. 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`.
- To target Linux, install `gcc` and run `build.sh` - To target Linux, install `gcc` and run `build.sh`
- To target Windows, install `gcc` and run `build.bat` - To target Windows, install `gcc` and run `build.bat`

View File

@@ -1,3 +1,11 @@
#!/usr/bin/env bash
if [ ! -f "include/registries.h" ]; then
echo "Error: 'include/registries.h' is missing."
echo "Please follow the 'Compilation' section of the README to generate it."
exit 1
fi
rm bareiron rm bareiron
gcc src/*.c -O3 -Iinclude -o bareiron gcc src/*.c -O3 -Iinclude -o bareiron
./bareiron ./bareiron

73
extract_registries.sh Executable file
View File

@@ -0,0 +1,73 @@
#!/usr/bin/env bash
set -euo pipefail
REQUIRED_MAJOR=21
SERVER_JAR="${SERVER_JAR:-server.jar}"
NOTCHIAN_DIR="notchian"
JS_RUNTIME=""
get_java_version() {
java -version 2>&1 | awk -F[\".] '/version/ {print $2}'
}
check_java() {
if ! command -v java >/dev/null 2>&1; then
echo "Java not found in PATH."
exit 1
fi
local major
major="$(get_java_version)"
if (( major < REQUIRED_MAJOR )); then
echo "Java $REQUIRED_MAJOR or newer required, but found Java $major."
exit 1
fi
}
prepare_notchian_dir() {
if [[ ! -d "$NOTCHIAN_DIR" ]]; then
echo "Creating $NOTCHIAN_DIR directory..."
mkdir -p "$NOTCHIAN_DIR"
fi
cd "$NOTCHIAN_DIR"
}
dump_registries() {
if [[ ! -f "$SERVER_JAR" ]]; then
echo "No server.jar found (looked for $SERVER_JAR)."
echo "Please download the server.jar from https://www.minecraft.net/en-us/download/server"
echo "and place it in the notchian directory."
exit 1
fi
java -DbundlerMainClass="net.minecraft.data.Main" -jar "$SERVER_JAR" --all
}
detect_js_runtime() {
if command -v node >/dev/null 2>&1; then
JS_RUNTIME="node"
elif command -v bun >/dev/null 2>&1; then
JS_RUNTIME="bun"
elif command -v deno >/dev/null 2>&1; then
JS_RUNTIME="deno run"
else
echo "No JavaScript runtime found (Node.js, Bun, or Deno)."
exit 1
fi
}
run_js_script() {
local script="$1"
if [[ -z "$JS_RUNTIME" ]]; then
detect_js_runtime
fi
echo "Running $script with $JS_RUNTIME..."
$JS_RUNTIME "$script"
}
check_java
prepare_notchian_dir
dump_registries
run_js_script "../build_registries.js"
echo "Registry dump and processing complete."