Use local Python renderer for previews

This commit is contained in:
2026-08-11 00:32:11 +01:00
parent da89bb60f1
commit 01a6a99777
3 changed files with 18 additions and 51 deletions
+2 -39
View File
@@ -18,50 +18,13 @@ jobs:
with: with:
python-version: "3.11" python-version: "3.11"
- name: Resolve latest Minecraft release - name: Install Python renderer dependencies
run: | run: python -m pip install pillow
mkdir -p build
python build/scripts/resolve_latest_minecraft_release.py > build/minecraft-version.txt
- name: Read latest Minecraft release
id: minecraft_version
shell: bash
run: |
release=$(head -n 1 build/minecraft-version.txt)
snapshot=$(sed -n '2s/^snapshot=//p' build/minecraft-version.txt)
java_version=$(sed -n '3s/^java_version=//p' build/minecraft-version.txt)
echo "release=$release" >> "$GITHUB_OUTPUT"
echo "snapshot=$snapshot" >> "$GITHUB_OUTPUT"
echo "java_version=$java_version" >> "$GITHUB_OUTPUT"
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ steps.minecraft_version.outputs.java_version }}
- name: Set up Gradle
run: |
GRADLE_VERSION=9.7.0
curl -fsSL -o /tmp/gradle.zip "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip"
sudo unzip -q /tmp/gradle.zip -d /opt
echo "/opt/gradle-${GRADLE_VERSION}/bin" >> "$GITHUB_PATH"
- name: Install Vulkan runtime
run: |
sudo apt-get update
sudo apt-get install -y libvulkan1 xvfb libflite1
- name: Build readme - name: Build readme
run: python build/scripts/build_readme.py --pack-root resourcepack --output-dir build run: python build/scripts/build_readme.py --pack-root resourcepack --output-dir build
- name: Render model previews - name: Render model previews
env:
MINECRAFT_VERSION: ${{ steps.minecraft_version.outputs.release }}
RENDER_MANIFEST: ${{ github.workspace }}/build/renameable-items.json
RENDER_OUTPUT_DIR: ${{ github.workspace }}/build
RENDER_PACK_ROOT: ${{ github.workspace }}/resourcepack
ALSOFT_DRIVERS: "null"
run: python build/scripts/render_client_items.py --manifest build/renameable-items.json --pack-root resourcepack --output-dir build run: python build/scripts/render_client_items.py --manifest build/renameable-items.json --pack-root resourcepack --output-dir build
- name: Publish generated catalog artifacts - name: Publish generated catalog artifacts
+2 -2
View File
@@ -151,7 +151,7 @@ def build_markdown(records: list[dict[str, Any]]) -> str:
lines.append("") lines.append("")
lines.append(f"- Base items: {len(records)}") lines.append(f"- Base items: {len(records)}")
lines.append(f"- Rename variants: {total_cases}") lines.append(f"- Rename variants: {total_cases}")
lines.append("- Render mode: pluggable") lines.append("- Render mode: local Python renderer")
lines.append("") lines.append("")
lines.append("Sections are sorted by the item they are generated from.") lines.append("Sections are sorted by the item they are generated from.")
@@ -389,7 +389,7 @@ def build_html(records: list[dict[str, Any]]) -> str:
<div class="stats"> <div class="stats">
<div class="stat"><span>Base items</span><strong>{len(records)}</strong></div> <div class="stat"><span>Base items</span><strong>{len(records)}</strong></div>
<div class="stat"><span>Rename variants</span><strong>{total_cases}</strong></div> <div class="stat"><span>Rename variants</span><strong>{total_cases}</strong></div>
<div class="stat"><span>Render mode</span><strong>pluggable</strong></div> <div class="stat"><span>Render mode</span><strong>local Python renderer</strong></div>
</div> </div>
</section> </section>
<section class="grid"> <section class="grid">
+14 -10
View File
@@ -2,29 +2,33 @@
from __future__ import annotations from __future__ import annotations
import argparse import argparse
import os
import subprocess import subprocess
import sys
from pathlib import Path from pathlib import Path
def main() -> int: def main() -> int:
parser = argparse.ArgumentParser(description="Render renameable item previews with the Minecraft client.") parser = argparse.ArgumentParser(description="Render renameable item previews from resource pack model JSON.")
parser.add_argument("--manifest", default="build/renameable-items.json", help="Path to the generated manifest") parser.add_argument("--manifest", default="build/renameable-items.json", help="Path to the generated manifest")
parser.add_argument("--pack-root", default="resourcepack", help="Path to the resource pack root") parser.add_argument("--pack-root", default="resourcepack", help="Path to the resource pack root")
parser.add_argument("--output-dir", default="build", help="Directory where renders should be written") parser.add_argument("--output-dir", default="build", help="Directory where renders should be written")
args = parser.parse_args() args = parser.parse_args()
repo_root = Path(__file__).resolve().parents[2] repo_root = Path(__file__).resolve().parents[2]
client_renderer = repo_root / "build" / "client-renderer" renderer_script = repo_root / "build" / "scripts" / "render_models.py"
env = os.environ.copy() command = [
env["RENDER_MANIFEST"] = str((repo_root / args.manifest).resolve()) sys.executable,
env["RENDER_OUTPUT_DIR"] = str((repo_root / args.output_dir).resolve()) str(renderer_script),
env["RENDER_PACK_ROOT"] = str((repo_root / args.pack_root).resolve()) "--manifest",
str((repo_root / args.manifest).resolve()),
"--pack-root",
str((repo_root / args.pack_root).resolve()),
"--output-dir",
str((repo_root / args.output_dir).resolve()),
]
command = ["gradle", "-p", str(client_renderer), "runClient", "--no-daemon"] completed = subprocess.run(command, cwd=repo_root)
completed = subprocess.run(command, cwd=repo_root, env=env)
return completed.returncode return completed.returncode