All the stone cutter recipes
This commit is contained in:
+25
-11
@@ -9,7 +9,9 @@
|
||||
import { import_blocks } from "./importer/blocks.ts";
|
||||
import { import_items } from "./importer/items.ts";
|
||||
import { import_models } from "./importer/models.ts";
|
||||
import { import_recipes } from "./importer/recipes.ts";
|
||||
import { DEFAULT_REMAPS, type ImportOptions, type ImportReport } from "./importer/resources.ts";
|
||||
import { import_tags } from "./importer/tags.ts";
|
||||
import { import_textures } from "./importer/textures.ts";
|
||||
|
||||
const KINDS: Record<string, (input: string, options: ImportOptions) => ImportReport> = {
|
||||
@@ -17,6 +19,8 @@ const KINDS: Record<string, (input: string, options: ImportOptions) => ImportRep
|
||||
texture: import_textures,
|
||||
blockstate: import_blocks,
|
||||
item: import_items,
|
||||
tag: import_tags,
|
||||
recipe: import_recipes,
|
||||
};
|
||||
|
||||
const USAGE = `deno run -A tools/importer.ts <kind> <file or folder> [options]
|
||||
@@ -26,6 +30,10 @@ kinds:
|
||||
texture textures, with their .png.mcmeta animations
|
||||
blockstate blockstates to blocks, with their states, models and items, and placeholder mining
|
||||
item item models to items, for the items that aren't a block's
|
||||
tag tags (data/<namespace>/tags) to tags/, entries that don't exist in the mods next to --output
|
||||
made optional
|
||||
recipe recipes to recipes/, for the types bworld has: stonecutting. ones naming items or tags that
|
||||
don't exist in the mods next to --output are left out
|
||||
|
||||
options:
|
||||
--output PATH the file (for one input file) or the folder to write. one model without it is printed
|
||||
@@ -35,8 +43,10 @@ options:
|
||||
--parents FOLDER another folder to follow parent models through, like another mod's resources. can be repeated
|
||||
--remap FILE json that renames locations before they become ids, longest match first, and leaves out
|
||||
locations that match a "skip" pattern:
|
||||
{ "textures": { "minecraft:block/": "bworld:" }, "models": {}, "skip": ["crimson"] }
|
||||
minecraft's block and item textures become bworld's of the same name unless it says otherwise`;
|
||||
{ "textures": { "minecraft:block/": "bworld:" }, "models": {}, "ids": {}, "tags": {},
|
||||
"skip": ["crimson"] }
|
||||
minecraft's block and item textures, blocks, items and tags become bworld's of the same name,
|
||||
and forge's shared tags c's, unless it says otherwise`;
|
||||
|
||||
function parse_args(args: string[]) {
|
||||
const positional: string[] = [];
|
||||
@@ -56,6 +66,8 @@ function parse_args(args: string[]) {
|
||||
options.remaps = {
|
||||
textures: { ...DEFAULT_REMAPS.textures, ...remap.textures },
|
||||
models: { ...DEFAULT_REMAPS.models, ...remap.models },
|
||||
ids: { ...DEFAULT_REMAPS.ids, ...remap.ids },
|
||||
tags: { ...DEFAULT_REMAPS.tags, ...remap.tags },
|
||||
...(remap.skip ? { skip: remap.skip } : {}),
|
||||
};
|
||||
} else if (arg.startsWith("--")) throw new Error(`unknown option ${arg}`);
|
||||
@@ -67,18 +79,20 @@ function parse_args(args: string[]) {
|
||||
function print_report(report: ImportReport) {
|
||||
const [first] = report.written;
|
||||
if (report.written.length === 1 && first.file === undefined) console.log(first.text?.trimEnd());
|
||||
for (const { location, reason } of report.skipped) console.error(`skipped ${location}: ${reason}`);
|
||||
// the same reason for many files is one line
|
||||
const by_reason = (entries: { location: string; reason: string }[]) => {
|
||||
const grouped = new Map<string, string[]>();
|
||||
for (const { location, reason } of entries) grouped.set(reason, [...(grouped.get(reason) ?? []), location]);
|
||||
return [...grouped].map(([reason, locations]) =>
|
||||
`${reason} (${locations.length === 1 ? locations[0] : `${locations.length} files`})`
|
||||
);
|
||||
};
|
||||
for (const line of by_reason(report.skipped)) console.error(`skipped: ${line}`);
|
||||
for (const { location, problems } of report.errors) {
|
||||
for (const problem of problems) console.error(`error in ${location}: ${problem}`);
|
||||
}
|
||||
// the same warning about many files is one line
|
||||
const warnings = new Map<string, string[]>();
|
||||
for (const { location, warning } of report.warnings) {
|
||||
warnings.set(warning, [...(warnings.get(warning) ?? []), location]);
|
||||
}
|
||||
for (const [warning, locations] of warnings) {
|
||||
console.error(`warning: ${warning} (${locations.length === 1 ? locations[0] : `${locations.length} files`})`);
|
||||
}
|
||||
const warnings = report.warnings.map(({ location, warning }) => ({ location, reason: warning }));
|
||||
for (const line of by_reason(warnings)) console.error(`warning: ${line}`);
|
||||
const converted = new Set(report.written.map(({ location }) => location)).size;
|
||||
console.error(
|
||||
`${converted} converted, ${report.skipped.length} skipped, ${report.errors.length} with errors`,
|
||||
|
||||
Reference in New Issue
Block a user