Seasons api

This commit is contained in:
2026-10-08 13:42:18 -03:00
parent 7e7ac8f6f4
commit dd66d6caa7
16 changed files with 231 additions and 10 deletions
+16
View File
@@ -17,6 +17,7 @@ import { GuiModScreen } from "./gui/gui_mod_screens.ts";
import { clear_hooks, expose_engine, loading_mod } from "$/common/hooks.ts";
import { common_engine } from "$/common/engine_modules.ts";
import { client_engine } from "./engine_modules.ts";
import { biome_season } from "$/common/worldgen/biomes.ts";
// each loaded mod's credits file, for the credits screen
export const mod_credits: { name: string; version: string; text: string }[] = [];
@@ -89,6 +90,11 @@ const rules_world: SharedWorld = {
const shape = client?.level.collision_shape(x, y, z) ?? false;
return covers_face(shape === true ? FULL_SHAPE : shape === false ? EMPTY_SHAPE : shape, face);
},
biome_at: (x, z) => client?.level.biome_at(Math.floor(x), Math.floor(z)),
season_at(x, z) {
const biome = this.biome_at(x, z);
return biome === undefined ? undefined : biome_season(biome);
},
};
// this client changed the block at x y z ahead of the server, the blocks beside it change with it the way they will
@@ -267,6 +273,14 @@ function client_context(listing: ModListing): ClientContext {
const { x, y, z } = need_client().player;
return { x, y, z };
},
get biome() {
const { x, z } = need_client().player;
return rules_world.biome_at(x, z);
},
get season() {
const { x, z } = need_client().player;
return rules_world.season_at(x, z);
},
is_swimming: () => need_client().player.swimming,
},
world: {
@@ -275,6 +289,8 @@ function client_context(listing: ModListing): ClientContext {
if (nid === AIR) return AIR_ID;
return EverythingRegistry.get_by_id<BlockRegistry>("blocks", nid)?.id;
},
biome_at: (x, z) => rules_world.biome_at(x, z),
season_at: (x, z) => rules_world.season_at(x, z),
get time() {
return need_client().level.time;
},