3D biomes
This commit is contained in:
@@ -145,14 +145,16 @@ export function register_fishing(ctx: ServerContext) {
|
||||
ctx.loot.register_condition("bworld:season", (params, context) => {
|
||||
const seasons = params.seasons as string[];
|
||||
if (!context.position) return true;
|
||||
return seasons.includes(ctx.world.season_at(context.position.x, context.position.z));
|
||||
const { x, y, z } = context.position;
|
||||
return seasons.includes(ctx.world.season_at(x, y, z));
|
||||
});
|
||||
|
||||
// "biomes": ["bworld:swamp", "#bworld:is_ocean"], holds in any of the biomes or biome tags at the loot's
|
||||
// position. without a position it holds, like bworld:season
|
||||
ctx.loot.register_condition("bworld:biome", (params, context) => {
|
||||
if (!context.position) return true;
|
||||
const biome = ctx.world.biome_at(context.position.x, context.position.z);
|
||||
const { x, y, z } = context.position;
|
||||
const biome = ctx.world.biome_at(x, y, z);
|
||||
return (params.biomes as string[]).some((entry) =>
|
||||
entry.startsWith("#") ? ctx.tags.has("biomes", entry, biome) : entry === biome
|
||||
);
|
||||
|
||||
@@ -235,11 +235,12 @@ export function register_trees(gen: WorldgenContext) {
|
||||
};
|
||||
|
||||
for (const site of tree_sites(chunk)) {
|
||||
const here = trees.get(chunk.biome_at(site.x, site.z));
|
||||
// the biome of the ground it grows from
|
||||
const ground_y = chunk.height_at(site.x, site.z);
|
||||
const here = trees.get(chunk.biome_at(site.x, ground_y, site.z));
|
||||
if (!here || site.rng.next() >= here.chance) continue;
|
||||
|
||||
// on soil with air above it, so never under water or on bare rock
|
||||
const ground_y = chunk.height_at(site.x, site.z);
|
||||
const ground = chunk.get_block(site.x, ground_y, site.z);
|
||||
const above = chunk.get_block(site.x, ground_y + 1, site.z);
|
||||
if (!SOIL.has(ground!) || above !== "cubi:air") continue;
|
||||
|
||||
@@ -27,10 +27,10 @@ function cactus(chunk: FeatureChunk) {
|
||||
const x = chunk.x * 16 + Math.floor(chunk.rng.next() * 16);
|
||||
const z = chunk.z * 16 + Math.floor(chunk.rng.next() * 16);
|
||||
const height = pick_height(chunk.rng.next());
|
||||
if (chunk.biome_at(x, z) !== "bworld:desert") {
|
||||
const ground = chunk.height_at(x, z);
|
||||
if (chunk.biome_at(x, ground, z) !== "bworld:desert") {
|
||||
continue;
|
||||
}
|
||||
const ground = chunk.height_at(x, z);
|
||||
if (chunk.get_block(x, ground, z) !== "bworld:sand") {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user