Item rendering

This commit is contained in:
2026-10-13 22:29:38 -03:00
parent a18b099206
commit b34e97e487
269 changed files with 12566 additions and 3220 deletions
+11 -5
View File
@@ -3,12 +3,12 @@
// java item models (assets/<namespace>/models/item/*.json) to bworld's items/, for the items that aren't a block's: a
// block's item comes with the block (see blocks.ts). java says an item is a flat sprite with item/generated and its
// layer0 texture, which is what a bworld item is. one java draws in 3D (a wrench, goggles) is drawn flat here, with a
// texture of its model, until bworld items can have models
// layer0 texture, which is what a bworld item is. one java draws in 3D (a wrench) is drawn with its model, which the
// model kind writes, and gets its model's particle texture as its texture
import { join } from "@std/path";
import { FORMAT_VERSION } from "$/common/mod_data.ts";
import { made_by, model_source } from "./models.ts";
import { merged_textures, models_near } from "./blocks.ts";
import { merged_textures, model_missing, models_near } from "./blocks.ts";
import {
DEFAULT_REMAPS,
empty_report,
@@ -60,6 +60,7 @@ export function import_items(input: string, options: ImportOptions = {}): Import
return reference?.startsWith("#") ? undefined : reference;
};
let texture: string | undefined;
let model: string | undefined;
if (made_by(location, read)?.startsWith("an item sprite")) {
texture = resolve(textures.layer0);
if (textures.layer1 !== undefined) {
@@ -67,7 +68,12 @@ export function import_items(input: string, options: ImportOptions = {}): Import
}
} else {
texture = resolve(textures.particle) ?? Object.values(textures).map(resolve).find((t) => t !== undefined);
report.warnings.push({ location, warning: "drawn in 3D in java, it's a flat texture of its model here" });
model = to_id(location, remaps.models);
const missing = model_missing(location, model, read, remaps);
if (missing) {
report.warnings.push({ location, warning: `its model ${missing}, so it's a flat texture of it here` });
model = undefined;
}
}
if (texture === undefined) {
// like item/pane, a template other item models use as their parent
@@ -80,7 +86,7 @@ export function import_items(input: string, options: ImportOptions = {}): Import
continue;
}
if (!claim(id, location)) continue;
const json = { format_version: FORMAT_VERSION, item: { id, texture: texture_id } };
const json = { format_version: FORMAT_VERSION, item: { id, texture: texture_id, ...(model ? { model } : {}) } };
report.written.push({
location,
id,