Remove duplicate code

This commit is contained in:
2026-10-13 11:57:43 -03:00
parent dfc6a6d77b
commit 5165698fe3
50 changed files with 307 additions and 812 deletions
+24
View File
@@ -36,6 +36,7 @@ import {
type WorldgenRefs,
} from "./worldgen/data.ts";
import { feature_refs, type FeatureJson } from "./worldgen/features.ts";
import type { ModData } from "./mod_loader.ts";
export interface ModReport {
id: string;
@@ -73,6 +74,29 @@ export interface LoadedMod {
texture_json: Map<string, TextureJson>;
}
// what a mod's data files hold, as packed into its .bmod
export function mod_data(mod: LoadedMod): ModData {
return {
blocks: mod.blocks.map((b) => b.json),
models: mod.models.map((m) => m.json),
items: mod.items.map((i) => i.json),
recipes: mod.recipes.map((r) => r.json),
ores: mod.ores.map((o) => o.json),
spawns: mod.spawns.map((s) => s.json),
entities: mod.entities.map((e) => e.json),
entity_models: mod.entity_models.map((m) => m.json),
effects: mod.effects.map((e) => e.json),
tags: mod.tags.map((t) => t.json),
loot_tables: mod.loot_tables.map((t) => t.json),
biomes: mod.biomes.map((b) => b.json),
noises: mod.noises.map((n) => n.json),
density_functions: mod.density_functions.map((d) => d.json),
noise_settings: mod.noise_settings.map((n) => n.json),
biome_sources: mod.biome_sources.map((b) => b.json),
features: mod.features.map((f) => f.json),
};
}
// dependencies before the mods that need them, otherwise alphabetical
export function load_order(mods: LoadedMod[]): LoadedMod[] {
const by_id = new Map(mods.map((mod) => [mod.id, mod]));