Remove reimporting logic from importer

This commit is contained in:
2026-10-28 21:47:52 -03:00
parent 872db88066
commit fa0748a9c5
7 changed files with 16 additions and 81 deletions
+1 -9
View File
@@ -4,7 +4,7 @@
// java blockstates (assets/<namespace>/blockstates/*.json) to bworld's blocks/, so a mod's blocks can be placed and look
// right: their states, and the model each state is drawn with, turned. how a block behaves isn't in any data file (java
// mods set mining, sounds and what blocks do in code), so every block gets the same placeholders: a second to break with
// anything, dropping itself. --blocks gives some of them more, see ImportOptions.blocks
// anything, dropping itself, and what they really have is written by hand after
import { dirname, join } from "@std/path";
import { FORMAT_VERSION } from "$/common/mod_data.ts";
import { is_empty, made_by, model_source, type ModelSource } from "./models.ts";
@@ -95,19 +95,11 @@ export function import_blocks(input: string, options: ImportOptions = {}): Impor
const result = convert_blockstate(location, json, read, remaps);
if (result.kind === "error") report.errors.push({ location, problems: result.problems });
else if (claim(result.id, location)) {
Object.assign(result.json.block, options.blocks?.[result.id]);
for (const warning of result.warnings) report.warnings.push({ location, warning });
const text = format_json(result.json) + "\n";
report.written.push({ location, id: result.id, file: join(options.output, `${where.path}.json`), text });
}
}
// a typo in the table would otherwise quietly give a block nothing
const written = new Set(report.written.map(({ id }) => id));
for (const id of Object.keys(options.blocks ?? {})) {
if (!written.has(id)) {
report.errors.push({ location: id, problems: ["--blocks has it, but no block was made for it"] });
}
}
write_report(report);
return report;
}
-3
View File
@@ -254,9 +254,6 @@ export interface ImportOptions {
// more folders to look things up in, like parent models from another mod
parents?: string[];
remaps?: Remaps;
// fields blocks get by id, over the placeholders, like their components or how long they take to mine. java sets
// those in code, so a mod's import keeps them in a table, like mods/create/import/blocks.json
blocks?: Record<string, Record<string, unknown>>;
}
// one file an import makes: text to write, or a file to copy