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
+15 -2
View File
@@ -1,10 +1,10 @@
// what server scripts get, see docs/modding/
import type { EventSignal, Face, Id, ItemStack, ModInfo, Position, TagApi } from "./shared.ts";
import type { EventSignal, Face, Id, ItemStack, ModInfo, Position, Season, TagApi } from "./shared.ts";
import type { ArgumentType, CommandNode } from "../commands.ts";
export type { ArgumentType, CommandContext, CommandNode, Suggestion } from "../commands.ts";
export type { EventSignal, Face, Id, ItemStack, ModInfo, Position, TagApi, TagRegistry } from "./shared.ts";
export type { EventSignal, Face, Id, ItemStack, ModInfo, Position, Season, TagApi, TagRegistry } from "./shared.ts";
export interface ServerContext {
mod: ModInfo;
@@ -34,6 +34,9 @@ export interface BlockRef {
readonly x: number;
readonly y: number;
readonly z: number;
// the biome of its column and that biome's season, see ServerWorld.biome_at
readonly biome: Id;
readonly season: Season;
// tile data, any json value. saved with the world, never sent to clients
// deno-lint-ignore no-explicit-any
data: any;
@@ -221,6 +224,10 @@ export interface ServerWorld {
// into, so it goes through plants and other blocks without collision. undefined when nothing is in the way
raycast(from: Position, to: Position, options?: RaycastOptions): RaycastHit | undefined;
is_loaded(x: number, z: number): boolean;
// the column's biome, like "bworld:plains", and that biome's season. in chunks that aren't loaded it's what
// generation makes there, which takes a while the first time
biome_at(x: number, z: number): Id;
season_at(x: number, z: number): Season;
readonly seed: string;
// ticks since 06:00 of day 1. a day is 36000 ticks (06:00 to 18:00), a night 12000
readonly time: number;
@@ -252,6 +259,9 @@ export interface EntityRef {
readonly id: string;
readonly type: Id;
readonly position: Readonly<Position>;
// the biome where its feet are and that biome's season
readonly biome: Id;
readonly season: Season;
readonly removed: boolean;
teleport(x: number, y: number, z: number): void;
remove(): void;
@@ -265,6 +275,9 @@ export interface Player {
// ctx.world.raycast(player.eye_position, ...)
readonly eye_position: Readonly<Position>;
readonly look_direction: Readonly<Position>;
// the biome where their feet are and that biome's season
readonly biome: Id;
readonly season: Season;
readonly inventory: Container; // 36 slots, hotbar is 0-8
readonly selected_slot: number;
readonly held_item: ItemStack | undefined;