Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 0 additions & 138 deletions .github/workflows/capture-baselines.yml

This file was deleted.

18 changes: 9 additions & 9 deletions .github/workflows/generate-spritesheet.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Generate Spritesheet

# Dispatch this on any branch. The regenerated assets are committed back to the branch it ran on,
# or a pull request is opened against that branch, so it works inside an open PR as well as on master.
on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -42,25 +44,23 @@ jobs:
generate:
runs-on: ubuntu-latest

env:
# The render step draws every block and item in the Maven JVM, so give it room for the renderer's context.
MAVEN_OPTS: -Xmx4g

steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Set up JDK 21
- name: Set up JDK 25
uses: actions/setup-java@v6.0.1
with:
java-version: '25'
distribution: 'temurin'
cache: maven

- name: Set up .NET SDK
if: inputs.pipeline == 'full' || inputs.pipeline == 'render-only'
uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'

- name: Build Tooling Module
run: mvn -pl tooling -am compile -DskipTests -q

Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
## Asset Changes

$DIFF_TABLE" \
--base master || echo "PR already exists"
--base "${{ github.ref_name }}" || echo "PR already exists"

- name: Commit Directly
if: steps.changes.outputs.has_changes == 'true' && inputs.create_pr == false
Expand All @@ -196,7 +196,7 @@ jobs:
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add generator/src/main/resources/minecraft/assets/
git commit -m "Update spritesheet assets"
git push origin master
git push origin HEAD:"${{ github.ref_name }}"

- name: Upload Artifacts
if: steps.changes.outputs.has_changes == 'true'
Expand Down
52 changes: 34 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -664,31 +664,47 @@ MinecraftImageGenerator/
The project includes a GitHub Actions workflow for generating and updating Minecraft item spritesheets and overlays. This is triggered manually via `workflow_dispatch` and supports:

- Downloading Minecraft assets for any version
- Rendering items at configurable sizes (requires .NET 10)
- Rendering every block and item icon at a configurable size
- Generating sprite atlases with coordinate metadata
- Generating item overlays for colored variants (armor, potions, etc.)

### Configurable tooling outputs and atlas pages
The render step draws the icons in-process with
[asset-renderer](https://github.com/minecraft-library/asset-renderer), an Apache-2.0 Java library that reads
the client JAR the download step cached. It needs nothing beyond the JDK, and the tooling pins it to a commit
in `tooling/pom.xml` because the library has no tagged releases.

`MinecraftAssetTool` accepts `--work-dir=<path>`, `--output-dir=<path>` and
`--renderer-dir=<path>`. Set these separately for each Minecraft version when
calling the tooling from another build system. The same paths can be set with
`generator.tooling.workDir`, `generator.tooling.outputDir` and
`generator.tooling.rendererDir` JVM system properties. Existing default paths remain unchanged.
### Configurable tooling outputs and atlas pages

`--size` controls the rendered image size and the default item-atlas tile size.
`--tile-size` overrides just the tile size. `--atlas-width`, `--atlas-height`
and `--padding` control page bounds and transparent gutters. Standalone
`SpritesheetGenerator` supports these atlas options and `--input`.
By default the tooling keeps its scratch files under `tooling/build` and writes
spritesheets and JSON into `generator/src/main/resources/minecraft/assets`.
`MinecraftAssetTool`, `SpritesheetGenerator` and `OverlayGenerator` all accept
`--work-dir=<path>` and `--output-dir=<path>` to move those, which is handy when
another build drives the tooling once per Minecraft version. The same two
settings can be given as the JVM system properties `generator.tooling.workDir`
and `generator.tooling.outputDir`, which is the way to pass them through the
Maven profiles. A flag wins over a property.

`--size` sets the render size only. Atlas tiles stay at 256px unless you pass
`--tile-size`. `--atlas-width`, `--atlas-height` and `--padding` bound each page
and add a transparent gutter around every tile. All of these are checked before
any download or render starts, so a bad value fails immediately. The overlay
generator reads its definitions from a file bundled with the tooling; pass
`--overlay-definitions=<file>` to use your own instead.

```text
MinecraftAssetTool --download --render --spritesheet --no-clean --version=26.3
MinecraftAssetTool --download --render --spritesheet --version=26.3
--work-dir=build/26.3/work --output-dir=build/26.3/generated
--size=64 --atlas-width=2048 --atlas-height=2048 --padding=1
--tile-size=64 --atlas-width=2048 --atlas-height=2048 --padding=1
```

The first page keeps its original PNG filename; additional pages use `-1`,
`-2`, etc. Coordinate JSON remains an array with `name`, `x`, `y`, and `size`,
plus `page`, `atlas` (PNG filename), `atlasWidth`, and `atlasHeight` for each entry.
Paging and padding are opt-in. The generator library's bundled single-page
resources retain their existing default layout.
When the tiles do not fit on one page, the first page keeps its file name and
later pages get `-1`, `-2` and so on before the extension. Every coordinates
entry carries `page` and `atlas` (the PNG file name) alongside `name`, `x`, `y`
and `size`. Numbered pages left behind by an earlier, larger run are deleted.
The generator library reads the `atlas` field, so a paged atlas placed in its
resources loads without any other change.

The tool deletes `tooling/build` at the end of a run, as it always has. A work
directory you chose yourself is kept unless you pass `--clean`, and `--no-clean`
keeps the default one too. Cleanup refuses to run when the work directory
contains the current directory or the output directory.
8 changes: 8 additions & 0 deletions generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Mockito's inline mock maker must be attached as an agent on modern JDKs. Only this module mocks. -->
<argLine>-javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar</argLine>
</configuration>
</plugin>
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
Expand Down
Loading
Loading