Seasons based on a calendar
This commit is contained in:
@@ -8,6 +8,7 @@ import { TICKS_PER_SECOND } from "$/common/constants.ts";
|
||||
import type { BlockRegistry } from "$/common/everything_registry.ts";
|
||||
import type { ItemStack } from "$/common/inventory.ts";
|
||||
import type { Shape } from "$/common/block_shapes.ts";
|
||||
import type { Season } from "$/common/worldgen/biomes.ts";
|
||||
import { type Collisions, type LiquidInCell, physics } from "$/common/physics.ts";
|
||||
import type { EntityData, EntityEvent, EntityInfo } from "$/common/protocol.ts";
|
||||
import type { ServerPlayer } from "../player.ts";
|
||||
@@ -72,6 +73,8 @@ export interface EntityLevel {
|
||||
get_block_info(x: number, y: number, z: number): BlockRegistry | undefined;
|
||||
// the column's biome, like "bworld:plains"
|
||||
biome_at(x: number, z: number): string;
|
||||
// that biome's season now, see biome_season in common/worldgen/biomes.ts
|
||||
season_at(x: number, z: number): Season;
|
||||
add_entity(entity: Entity): void;
|
||||
get_entity(id: string): Entity | undefined;
|
||||
// entities whose feet are within the box around x, y, z
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { CHUNK_SIZE } from "$/common/constants.ts";
|
||||
import { is_within_view } from "$/common/chunk_streaming.ts";
|
||||
import { liquid_block, liquid_in_cell } from "$/common/utils.ts";
|
||||
import { biome_season } from "$/common/worldgen/biomes.ts";
|
||||
import type { ItemStack } from "$/common/inventory.ts";
|
||||
import type { EntityEvent, EntityInfo, ServerMessage } from "$/common/protocol.ts";
|
||||
import type { ServerPlayer } from "../player.ts";
|
||||
@@ -108,6 +109,10 @@ export class EntityManager implements EntityLevel {
|
||||
return this.#host.world.biome_at(x, z);
|
||||
}
|
||||
|
||||
season_at(x: number, z: number) {
|
||||
return biome_season(this.biome_at(x, z), this.#host.world.time);
|
||||
}
|
||||
|
||||
liquid_at(x: number, y: number, z: number) {
|
||||
const world = this.#host.world;
|
||||
return liquid_in_cell(world.get_block_value(x, y, z), world.get_block_info(x, y, z));
|
||||
|
||||
Reference in New Issue
Block a user