|
| 1 | +minecraft-data-generator extracts and generates Minecraft server-side data for multiple Minecraft versions via a Fabric mod that hooks into the vanilla Minecraft server. |
| 2 | +This generated data is then stored inside the https://github.com/PrismarineJS/minecraft-data repo, a cross language repo holding minecraft data on blocks, items and more. |
| 3 | + |
| 4 | +There is a different mod for each Minecraft version this repo supports, under the `mc/<version>` folder. |
| 5 | +Each version has a Gradle project at `:mc:<version>` and generating the data is done by running the Gradle task: |
| 6 | +``` |
| 7 | +./gradlew :mc:<version>:runServer |
| 8 | +``` |
| 9 | +Generated data ends up under `mc/<version>/run/server/minecraft-data` in the repo when run locally. |
| 10 | + |
| 11 | +## Repo Layout |
| 12 | +- mc/ — per-Minecraft-version directories of OUR extractor code (e.g. `mc/1.21.8`) |
| 13 | +- versions.json — canonical JSON array of versions that are supported (i.e. there are folders in mc/ for it) |
| 14 | +- mc-source/<version> — (External) minecraft java edition code for relevant version with Mojang mappings that you can reference for changes. |
| 15 | + * we store the last 2 most recent versions in the folder to save space, but if you need more versions you can do `cd mc-source/1.21.3 && git fetch origin client1.21.3 && git switch client1.21.3` (as these folders are a repo cloned with specific branches) |
| 16 | + * there is a .diff file in mc-source/ like `1.21.7_to_1.21.8.diff` that contains result of `git diff --no-index old new` that you can reference for changes (note it's typically large) |
| 17 | + * Since our generator is using Mojang mappings, the API naming is the same. |
| 18 | +- README.md — info how to set up |
| 19 | + |
| 20 | +## Typical Flow |
| 21 | + |
| 22 | +minecraft-data-generator typically needs updates every time there is a new Minecraft version, particularly if there was code changes |
| 23 | +around one of the areas that our extractors touches (e.g. an API changes, gets renamed, etc.). |
| 24 | + |
| 25 | +As explained in the README.md, there is an auto update workflow that typically creates scaffolding PRs (under the `bump` branch) whenever there is a new minecraft update. |
| 26 | +These PRs are simply copying old version code into new, so there may be changes and other code fixes needed to support the new version. It's your |
| 27 | +job to help plug the gaps by making these changes until the build passes for the given version. |
| 28 | +It's also possible that there maybe missing or broken generated data even if the build is passing: in these cases, listen to the user's request |
| 29 | +and figure out how to replicate, debug and fix the logical issues in data generation. |
| 30 | + |
| 31 | +## Troubleshooting |
| 32 | + |
| 33 | +Simply iterating over errors one by one is a good way to fix most issues. Inside mc-source/ you are provided the latest |
| 34 | +code for the latest minecraft versions you can reference to investigate any code changes that we may need to accomodate in our |
| 35 | +generator code. |
| 36 | + |
| 37 | +Sometimes, some APIs might change inside the mc code and make the data that the current code extracts no longer |
| 38 | +valid. In these cases, do your best to conform the new data to the old structure even if it feels wrong. If you |
| 39 | +can't, for example, let's say something about effects are removed from the game--but our data gen still expects it. |
| 40 | +What to do? You should set the data to null, and inform the user about the issue -- perhaps a schema change is needed. |
| 41 | +You can propose a new schema to the user (so that the relevant changes can be made to minecraft-data) and if the user confirms, you'd update the generator to output in that new schema. |
| 42 | + |
| 43 | +### Steps |
| 44 | +- Reproduce the problem locally inside the container and run the generator task. |
| 45 | + - Example run command: `./gradlew :mc:1.21.6:runServer --stacktrace` |
| 46 | + - See if the problem exists on an older version -- if so inform the user, otherwise compare logs and code |
| 47 | +- Inspect diffs in `mc-source/` to correlate Mojang API changes. |
| 48 | + - See mc-source/ |
| 49 | +- Validate generated output at `mc/<version>/run/server/minecraft-data` to make sure all files are there |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## Examples |
| 54 | + |
| 55 | +Session 1 — Compile error after bump PR |
| 56 | +- User prompt: "The bump PR for mc/1.21.8 fails to compile. Build error: cannot find symbol method RegistryKey.of(...)." |
| 57 | +- Agent actions: |
| 58 | + 1. Reproduce: `./gradlew :mc:1.21.8:runServer --stacktrace` |
| 59 | + 2. Inspect compile error and mc-source/1.21.7_to_1.21.8.diff for API renames. |
| 60 | + 3. Update generator code: edit mc/1.21.8/src/main/java/.../SomeRegistryAdapter.java to use the new Registry API. |
| 61 | + 4. Build again and run generation. |
| 62 | + |
| 63 | +Session 2 — Runtime NPE during generation |
| 64 | +- User prompt: "Generation starts but crashes with NullPointerException in EnchantmentsDataGenerator." |
| 65 | +- Agent actions: |
| 66 | + 1. Reproduce with stacktrace: `./gradlew :mc:1.20.4:runServer --stacktrace` |
| 67 | + 2. Add temporary logging to EnchantmentsDataGenerator to identify the null object, or run in debugger. |
| 68 | + 3. Fix by guarding against null Registries or empty lists and add defensive checks. |
| 69 | + 4. Re-run generation and verify produced files. |
| 70 | +- If problem persists: |
| 71 | + * Add logging to old version too |
| 72 | + * Check relevant code diff to see if anything changed related to this |
| 73 | + |
| 74 | +Session 3 — Semantically incorrect generated data |
| 75 | +- User prompt: "Output JSON is valid but item tags are incorrect after the bump." |
| 76 | +- Agent actions: |
| 77 | + 1. Reproduce generation and open the produced JSON at mc/<version>/run/server/minecraft-data/tags/items.json |
| 78 | + 2. Compare against previous version output (`git diff --no-index`) to identify mismatches. |
| 79 | + 3. Inspect generator assumptions vs. mc-source diffs (names, tag keys, or logic changes). |
| 80 | + 4. Correct mapping logic in generator class and run generation. |
0 commit comments