Move trees out of cubi
This commit is contained in:
@@ -18,8 +18,6 @@ export interface WorldgenContext {
|
||||
id: Id,
|
||||
modify: (chunk: FeatureChunk, config: C, positions: Position[]) => Position[],
|
||||
): void;
|
||||
// every biome mods added, for what features read from them, like which trees grow
|
||||
biomes(): FeatureBiome[];
|
||||
}
|
||||
|
||||
// the order features run in, minecraft's decoration steps. features without one run in the last
|
||||
@@ -42,13 +40,6 @@ export interface FeatureOptions {
|
||||
biomes?: Id | Id[];
|
||||
}
|
||||
|
||||
// a biome, as features see it
|
||||
export interface FeatureBiome {
|
||||
id: Id;
|
||||
// its json's trees, see docs/modding/worldgen/biomes.md
|
||||
trees?: { chance: number; kinds: string[]; wood: Record<string, string> };
|
||||
}
|
||||
|
||||
export interface FeatureChunk {
|
||||
// chunk coordinates
|
||||
readonly x: number;
|
||||
|
||||
@@ -34,15 +34,6 @@ const biome_schema = z.object({
|
||||
surface: surface_schema,
|
||||
// minecraft's grass, foliage and water colors, which blocks pick with "tint". plains' when not set
|
||||
colors: z.strictObject({ grass: color.optional(), foliage: color.optional(), water: color.optional() }).optional(),
|
||||
// how likely each tree cell is to have a tree, and which kinds grow, picked evenly (list one twice to make it
|
||||
// twice as likely). wood is the logs and leaves a kind grows here when it isn't its own, like big oaks being dark
|
||||
// oak in the dark forest. the trees feature reads it (bworld's, in its worldgen script), which says what kinds
|
||||
// and woods there are, and checks them when it loads
|
||||
trees: z.object({
|
||||
chance: z.number().min(0).max(1),
|
||||
kinds: z.array(z.string()).min(1),
|
||||
wood: z.record(z.string(), z.string()).optional(),
|
||||
}).optional(),
|
||||
});
|
||||
|
||||
export type BiomeJson = z.infer<typeof biome_schema>;
|
||||
@@ -54,11 +45,10 @@ export interface Biome {
|
||||
surface: Required<SurfaceJson>;
|
||||
// 0xRRGGBB
|
||||
colors: { grass?: number; foliage?: number; water?: number };
|
||||
trees?: { chance: number; kinds: string[]; wood: Record<string, string> };
|
||||
}
|
||||
|
||||
export function biome_from_json(json: BiomeJson): Biome {
|
||||
const { surface, colors = {}, trees } = json;
|
||||
const { surface, colors = {} } = json;
|
||||
const color = (value: string | undefined) => value === undefined ? undefined : parseInt(value.slice(1), 16);
|
||||
return {
|
||||
id: json.id,
|
||||
@@ -72,7 +62,6 @@ export function biome_from_json(json: BiomeJson): Biome {
|
||||
bare_cliffs: surface.bare_cliffs ?? false,
|
||||
},
|
||||
colors: { grass: color(colors.grass), foliage: color(colors.foliage), water: color(colors.water) },
|
||||
trees: trees && { chance: trees.chance, kinds: trees.kinds, wood: trees.wood ?? {} },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
// imports mods' worldgen scripts and collects what they and mods' data add to generation: the generator, ores, and
|
||||
// features, code and data, in the order they run. used by the game server
|
||||
import type { FeatureBiome, FeatureChunk, FeatureStep, WorldgenContext } from "@/common/mod_api/worldgen.ts";
|
||||
import type { FeatureChunk, FeatureStep, WorldgenContext } from "@/common/mod_api/worldgen.ts";
|
||||
import type { OreJson } from "@/common/mod_data.ts";
|
||||
import type { SetupFeature, WorldgenSetup } from "./generation.ts";
|
||||
import { EverythingRegistry } from "./everything_registry.ts";
|
||||
@@ -11,7 +11,6 @@ import { ModLoadError } from "./mod_loader.ts";
|
||||
import { loading_mod } from "./hooks.ts";
|
||||
import { compile_generator } from "./worldgen/generator.ts";
|
||||
import type { WorldShape } from "./world_shape.ts";
|
||||
import type { Biome } from "./worldgen/biomes.ts";
|
||||
import {
|
||||
compile_feature,
|
||||
DEFAULT_STEP,
|
||||
@@ -54,14 +53,6 @@ export async function load_worldgen(sources: WorldgenSources): Promise<WorldgenS
|
||||
const types = new Map<string, FeatureType>();
|
||||
const modifiers = new Map<string, PlacementModifier>();
|
||||
const data_features = (EverythingRegistry.get_registry<FeatureJson>("features") ?? []).filter((f) => f);
|
||||
const biomes = (EverythingRegistry.get_registry<Biome>("biomes") ?? []).filter((b) => b).map((
|
||||
biome,
|
||||
): FeatureBiome => ({
|
||||
id: biome.id,
|
||||
...(biome.trees
|
||||
? { trees: { ...biome.trees, kinds: [...biome.trees.kinds], wood: { ...biome.trees.wood } } }
|
||||
: {}),
|
||||
}));
|
||||
|
||||
for (const { mod, url, engine_access } of sources.scripts) {
|
||||
const own = (id: string, what: string) => {
|
||||
@@ -98,7 +89,6 @@ export async function load_worldgen(sources: WorldgenSources): Promise<WorldgenS
|
||||
if (modifiers.has(id)) throw new ModLoadError(mod, `placement modifier ${id} is registered twice`);
|
||||
modifiers.set(id, modify as PlacementModifier);
|
||||
},
|
||||
biomes: () => biomes,
|
||||
register_terrain(id) {
|
||||
throw new ModLoadError(
|
||||
mod,
|
||||
|
||||
Reference in New Issue
Block a user