Add various generic models

This commit is contained in:
2026-10-12 17:56:47 -03:00
parent e5baeab193
commit d4eff11f3e
34 changed files with 786 additions and 251 deletions
+17 -16
View File
@@ -89,9 +89,9 @@ deno run -A tools/importer.ts model path/to/resources --output DIR # every as
```
A folder can be a mod's whole resources, one `assets/<namespace>/models`, or a folder inside one, and the output keeps
the same folders. `--parents FOLDER` adds other resources to find parent models in (another mod, or vanilla's), and
`--remap FILE` renames locations before they become ids. Every kind reports what it converted, what it skipped and why,
and what's wrong, and exits with an error when anything is.
the same folders. `--parents FOLDER` adds other resources to follow parents through (to tell sprites and OBJ models
apart), and `--remap FILE` renames locations before they become ids. Every kind reports what it converted, what it
skipped and why, and what's wrong, and exits with an error when anything is.
**Ids.** A resource location becomes a bworld id by joining its folders with `_`, the same rule `check-mods` uses for
textures in subfolders: `create:block/cogwheel` is `create:block_cogwheel`, for its model and its texture alike. It's a
@@ -107,7 +107,7 @@ vanilla ids go, and later kinds add sections for items, blocks and fluids.
| Kind | Java | bworld | Status |
| ------------ | -------------------------------------------- | ------------------------------------------------------------------------- | ------ |
| `model` | `assets/*/models/**.json` | `models/`, parents flattened in, faces renamed, Blockbench extras dropped | Built |
| `model` | `assets/*/models/**.json` | `models/`, parents kept, faces renamed, Blockbench extras dropped | Built |
| `texture` | `assets/*/textures/**.png` and `.png.mcmeta` | `textures/`, with animations | Built |
| `blockstate` | `assets/*/blockstates/*.json` | `variants` or `parts` on `blocks/*.json`, string states made numeric | |
| `lang` | `assets/*/lang/en_us.json` | item and block names | |
@@ -122,16 +122,19 @@ Block properties (shape, tool, toughness) aren't in any data file: Java mods set
each blockstate with placeholder properties, and a per-mod table fills them in. For Create that table is
`mods/create/import/blocks.json`.
**What `model` does today.** It flattens `parent` chains into each model (the child's textures win, its elements replace
its parent's), and knows the vanilla parents most mods use without Minecraft's files: `block/block`, `cube`, `cube_all`,
`cube_column`, `cube_column_horizontal`, `cube_bottom_top`, `orientable`, slabs, stairs, walls and glass panes
(`tools/importer/vanilla_models.ts`, written as boxes, not copied). It drops Blockbench's extras, `display`, `particle`
and texture variables no face reaches. It skips item sprites (`item/generated`) and `loader` models (OBJ, composite),
and says why.
**What `model` does today.** It keeps `parent`, since the engine merges parents in when it loads (see
[Parents](docs/modding/resources/models.md#parents)), and remaps it like any id. Minecraft's template parents (`cube`,
`cube_all`, `cube_column`, `orientable`, slabs, stairs, walls, glass panes) become the base game's models of the same
name in `mods/bworld/models/templates/`, and the default remap is read from that folder. A parent that holds nothing
bworld uses, like `block/block` or a mod's own root of display transforms, is left out. It drops Blockbench's extras and
`display`, keeps every texture variable (some models draw faces with `#particle`), skips item sprites (`item/generated`)
and `loader` models (OBJ, composite) anywhere up a model's parents, and says why.
Run over Create 0.5.0.j's 2237 model files it converts 2099, all passing `validate_model`. The rest are 78 item sprites,
50 OBJ or composite models, 9 that are only parents, and 3 name clashes fixed with one remap line. 26 vanilla textures
they use (pistons, redstone torches, rails) aren't in bworld yet.
Run over Create 0.5.0.j's 2237 model files it converts 2105, and with its textures they make a mod `check-mods` accepts.
The rest are 79 item sprites, 50 OBJ or composite models and 5 display-only roots, and 3 name clashes were fixed with
one remap line. Merged the way the game merges them, the 2099 models with boxes come out identical to flattening them,
and the files are 1.5 MB instead of 3.4 MB. 26 vanilla textures they use (pistons, redstone torches, rails) aren't in
bworld yet.
**What `texture` does today.** It copies PNGs keeping their folders, since bworld already names a texture in a subfolder
by joining the folders with `_`, which is the same id the converted models use. A `.png.mcmeta` becomes the `.json` next
@@ -224,9 +227,8 @@ nothing per frame. See `ports/sodium` for how to keep buffer updates cheap.
**R4. Models without blocks** (P1). Any model in `models/` can be loaded by id for visuals, baked once into a GPU
buffer, and turned for whatever axis it's used on.
**R5. The model format** (P0). What Create's models use that bworld's don't support yet:
**R5. The model format** (P0). What Create's models use that bworld's don't support yet (`parent` is built):
- `parent` (or the importer flattens it, which is simpler; decide in P0);
- `x` turns in variants and parts, not just `y`;
- `uvlock`;
- element `rotation` at every 22.5° step on all three axes;
@@ -548,7 +550,6 @@ ratio. Recipes come from the imported data, so tests use Create's recipes instea
fluids, dyes. Add them to bworld, substitute them in Create's remap file, or drop what needs them?
- **Unloaded chunks:** blocks only tick within 6 chunks of a player. Do factories need a way to stay loaded, like chunk
loaders, or is "near a player" fine for bworld?
- **`parent` in models:** support it in the engine (R5), which other mods would use, or flatten it in the importer?
- **Contraption collision:** port `ContraptionCollider`'s approach, or write a simpler one for bworld's physics
(`common/physics.ts`) that handles turning structures differently?
- **Trains before or after contraptions:** trains reuse S6, but they're also the most-loved part of Create. Is P8 worth