From 5348cd3d0667e125565bc74fafb9cb4027316247 Mon Sep 17 00:00:00 2001 From: paulaboks Date: Fri, 13 Mar 2026 16:34:09 -0300 Subject: [PATCH] Terrain generation --- assets/sprites/textures/snow.png | Bin 0 -> 262 bytes client/client_world.ts | 4 +- client/components/dimension.ts | 69 +++++-- client/components/player_controls.ts | 2 +- client/game.ts | 2 - client/generation.ts | 231 ++++++++++++++++++---- client/player.ts | 1 + client/systems/clickable_system.ts | 14 -- client/systems/rendering/dimension.ts | 11 +- client/systems/world_generation_system.ts | 43 ++++ client/tiles/mod.ts | 2 + client/tiles/sand.ts | 6 + client/tiles/snow.ts | 6 + client/tiles/water.ts | 14 +- common/everything_registry.ts | 13 +- 15 files changed, 320 insertions(+), 98 deletions(-) create mode 100644 assets/sprites/textures/snow.png delete mode 100644 client/systems/clickable_system.ts create mode 100644 client/systems/world_generation_system.ts create mode 100644 client/tiles/sand.ts create mode 100644 client/tiles/snow.ts diff --git a/assets/sprites/textures/snow.png b/assets/sprites/textures/snow.png new file mode 100644 index 0000000000000000000000000000000000000000..ac655a2e3de0a48dc9b9894210ee89357b3637d6 GIT binary patch literal 262 zcmV+h0r~!kP)RFFV=po^y~dJ#X*s0ARy*05zqgxE;i3$nH3(5g1moF~ zgMNn3yiabcFl>Q>lF5#IlpsZv#F(r`7^9e}$vo12YW6Y#w3}}Yehh>}7#N5&P5=M^ M07*qoM6N<$g5RrcF#rGn literal 0 HcmV?d00001 diff --git a/client/client_world.ts b/client/client_world.ts index 7ca042e..ad8a889 100644 --- a/client/client_world.ts +++ b/client/client_world.ts @@ -6,12 +6,12 @@ import { DebugSystem } from "$/client/systems/debug_system.ts"; import { UIInteractionSystem } from "$/client/systems/ui_interaction_system.ts"; import { UIRenderSystem } from "$/client/systems/ui_render_system.ts"; import { create_main_menu } from "./main_menu.ts"; -import { ClickableSystem } from "./systems/clickable_system.ts"; import { start_game } from "./game.ts"; import { canvas, resize_canvas } from "./renderer/mod.ts"; import { DimensionLogicSystem } from "./systems/dimension_logic.ts"; import { Dimension } from "./components/dimension.ts"; import { GuiRenderSystem, GuiTickSystem } from "./gui/gui_systems.ts"; +import { WorldGenerationSystem } from "./systems/world_generation_system.ts"; export class ClientWorld extends World { paused = false; @@ -39,9 +39,9 @@ export class ClientWorld extends World { this.add_system(new UIInteractionSystem(), "main_menu"); this.add_system(new UIInteractionSystem(), "paused"); this.add_system(new GuiTickSystem(), "game"); - this.add_system(new ClickableSystem(), "game"); this.add_system(new PlayerControlsSystem(), "game"); this.add_system(new MovementSystem(), "game"); + this.add_system(new WorldGenerationSystem(), "game"); this.add_system(new DimensionLogicSystem(), "game"); // render systems diff --git a/client/components/dimension.ts b/client/components/dimension.ts index 9eb49a3..2e4eb34 100644 --- a/client/components/dimension.ts +++ b/client/components/dimension.ts @@ -2,7 +2,8 @@ import { Component } from "$/common/ecs/mod.ts"; import { EverythingRegistry, TileRegistry } from "$/common/everything_registry.ts"; import { AssetManager } from "../assets.ts"; import { ClientWorld } from "../client_world.ts"; -import { Texture } from "../renderer/mod.ts"; +import { generate_chunk } from "../generation.ts"; +import { gl, Texture } from "../renderer/mod.ts"; export interface Block { x: number; @@ -13,17 +14,18 @@ export interface Block { tickable?: boolean; } -export const CHUNK_SIDE_SIZE = 16; +export const CHUNK_SIZE = 16; export const CHUNK_HEIGHT = 128; -export const CHUNK_AREA = CHUNK_SIDE_SIZE * CHUNK_SIDE_SIZE; +export const CHUNK_AREA = CHUNK_SIZE * CHUNK_SIZE; export interface Chunk { x: number; z: number; blocks: Int32Array; + generated: boolean; + dirty: boolean; vertexBuffer?: WebGLBuffer; vertexCount?: number; - dirty: boolean; vertexTransparentBuffer?: WebGLBuffer; vertexTransparentCount?: number; } @@ -35,14 +37,14 @@ export class Dimension extends Component { tick_timer = 0; add_chunk(x: number, z: number) { - const chunk = { x, z, blocks: new Int32Array(CHUNK_AREA * CHUNK_HEIGHT), dirty: true }; + const chunk = { x, z, blocks: new Int32Array(CHUNK_AREA * CHUNK_HEIGHT), dirty: true, generated: false }; this.chunks.push(chunk); return chunk; } - add_block(world: ClientWorld, block: Block) { - const block_chunk_x = Math.floor(block.x / CHUNK_SIDE_SIZE); - const block_chunk_z = Math.floor(block.z / CHUNK_SIDE_SIZE); + add_block(block: Block) { + const block_chunk_x = Math.floor(block.x / CHUNK_SIZE); + const block_chunk_z = Math.floor(block.z / CHUNK_SIZE); let chunk = this.chunks.find((chunk) => chunk.x === block_chunk_x && chunk.z === block_chunk_z); if (!chunk) { chunk = this.add_chunk(block_chunk_x, block_chunk_z); @@ -50,21 +52,21 @@ export class Dimension extends Component { const [nid, block_info] = EverythingRegistry.get_full("blocks", block.id)!; - const lx = block.x - block_chunk_x * CHUNK_SIDE_SIZE; - const lz = block.z - block_chunk_z * CHUNK_SIDE_SIZE; + const lx = block.x - block_chunk_x * CHUNK_SIZE; + const lz = block.z - block_chunk_z * CHUNK_SIZE; const ly = block.y; - const index = ly * CHUNK_SIDE_SIZE * CHUNK_SIDE_SIZE + lz * CHUNK_SIDE_SIZE + lx; + const index = ly * CHUNK_SIZE * CHUNK_SIZE + lz * CHUNK_SIZE + lx; chunk.blocks[index] = nid; if (block_info?.on_create) { - block_info?.on_create(world, block); + block_info?.on_create(this, block); } } get_block(x: number, y: number, z: number) { - const chunk_x = Math.floor(x / CHUNK_SIDE_SIZE); - const chunk_z = Math.floor(z / CHUNK_SIDE_SIZE); + const chunk_x = Math.floor(x / CHUNK_SIZE); + const chunk_z = Math.floor(z / CHUNK_SIZE); const chunk = this.chunks.find( (c) => c.x === chunk_x && c.z === chunk_z, @@ -74,11 +76,11 @@ export class Dimension extends Component { return 0; } - const lx = x - chunk_x * CHUNK_SIDE_SIZE; - const lz = z - chunk_z * CHUNK_SIDE_SIZE; + const lx = x - chunk_x * CHUNK_SIZE; + const lz = z - chunk_z * CHUNK_SIZE; const ly = y; - const index = ly * CHUNK_SIDE_SIZE * CHUNK_SIDE_SIZE + lz * CHUNK_SIDE_SIZE + lx; + const index = ly * CHUNK_SIZE * CHUNK_SIZE + lz * CHUNK_SIZE + lx; return chunk.blocks[index]; } @@ -99,9 +101,38 @@ export class Dimension extends Component { const y = Math.floor(index / CHUNK_AREA); const rem = index % CHUNK_AREA; - const z = Math.floor(rem / CHUNK_SIDE_SIZE); - const x = rem % CHUNK_SIDE_SIZE; + const z = Math.floor(rem / CHUNK_SIZE); + const x = rem % CHUNK_SIZE; return [x, y, z]; } + + load_chunk(cx: number, cz: number) { + generate_chunk(this, cx, cz); + const chunk = this.chunks.find((c) => c.x === cx && c.z === cz); + if (chunk) { + chunk.generated = true; + chunk.dirty = true; + } + } + + unload_chunk(cx: number, cz: number) { + const chunk_i = this.chunks.findIndex((c) => c.x === cx && c.z === cz); + if (chunk_i === -1) { + console.warn("Tried unloading a chunk that doesn't exist dumbass"); + return; + } + + this.delete_chunk_mesh(this.chunks[chunk_i]); + this.chunks.splice(chunk_i, 1); + } + + delete_chunk_mesh(chunk: Chunk) { + if (chunk.vertexBuffer) { + gl.deleteBuffer(chunk.vertexBuffer); + } + if (chunk.vertexTransparentBuffer) { + gl.deleteBuffer(chunk.vertexTransparentBuffer); + } + } } diff --git a/client/components/player_controls.ts b/client/components/player_controls.ts index eb3629b..57ddf17 100644 --- a/client/components/player_controls.ts +++ b/client/components/player_controls.ts @@ -2,7 +2,7 @@ import { Component } from "$/common/ecs/mod.ts"; import { KeyCode } from "$/client/input_manager.ts"; export class PlayerControls extends Component { - move_speed: number = 5; + move_speed: number = 50; // Keys move_forward: KeyCode = "KeyW"; diff --git a/client/game.ts b/client/game.ts index 16b4e05..9948ce1 100644 --- a/client/game.ts +++ b/client/game.ts @@ -5,7 +5,6 @@ import { Dimension } from "./components/dimension.ts"; import { create_player } from "./player.ts"; import { UIButton } from "./components/ui_components.ts"; import { open_about } from "./about.ts"; -import { generate } from "./generation.ts"; import { canvas } from "./renderer/mod.ts"; export function start_game(world: ClientWorld) { @@ -16,7 +15,6 @@ export function start_game(world: ClientWorld) { world.dimension = new Dimension(); dimension.add(world.dimension); world.add_entity(dimension); - generate(world, dimension.get(Dimension)!, 16 * 8, 16 * 8); create_player(world); diff --git a/client/generation.ts b/client/generation.ts index 970c886..4ce33a0 100644 --- a/client/generation.ts +++ b/client/generation.ts @@ -1,46 +1,211 @@ -import { Alea, create_noise_2d } from "@paulaboks/rng"; +import { Alea, create_noise_2d, NoiseFunction2D } from "@paulaboks/rng"; +import { CHUNK_SIZE, Dimension } from "./components/dimension.ts"; -import { Dimension } from "./components/dimension.ts"; -import { ClientWorld } from "./client_world.ts"; +type Biome = + | "desert" + | "plains" + | "forest" + | "jungle" + | "tundra" + | "taiga" + | "snow" + | "savanna" + | "swamp"; -export function generate( - world: ClientWorld, - dimension: Dimension, - width: number, - depth: number, - max_height = 64, - seed = "seed", -) { - const height_noise = create_noise_2d(new Alea(seed + "_height")); +function get_biome(temp: number, moisture: number): Biome { + if (temp > 0.6) { + if (moisture < -0.2) { + return "desert"; + } + if (moisture > 0.4) { + return "jungle"; + } + return "savanna"; + } + if (temp > 0) { + if (moisture > 0.5) { + return "swamp"; + } + if (moisture > 0) { + return "forest"; + } + return "plains"; + } + if (temp > -0.5) { + return "taiga"; + } + return "tundra"; +} - const scale = 0.05; +function get_surface_block(biome: Biome) { + if (biome === "desert") { + return "bworld:sand"; + } else if (biome === "tundra") { + return "bworld:snow"; + } + return "bworld:grass"; +} - for (let z = 0; z < depth; z++) { - for (let x = 0; x < width; x++) { - const nx = x * scale; - const nz = z * scale; +function biome_height_modifier(biome: Biome) { + if (biome === "desert") { + return 0.2; + } + if (biome === "plains") { + return 0.4; + } + if (biome === "forest") { + return 0.5; + } + if (biome === "jungle") { + return 0.45; + } + if (biome === "taiga") { + return 0.55; + } + if (biome === "tundra") { + return 0.35; + } + if (biome === "savanna") { + return 0.4; + } + if (biome === "swamp") { + return 0.35; + } - // multi-octave terrain - let h = height_noise(nx, nz) * 1 + - height_noise(nx * 2, nz * 2) * 0.5 + - height_noise(nx * 4, nz * 4) * 0.25; + return 0.4; +} - h /= 1.75; +function fractal_noise(noise: NoiseFunction2D, x: number, y: number, octaves = 2) { + let value = 0; + let amp = 1; + let freq = 1; + let max = 0; + for (let i = 0; i < octaves; i++) { + value += noise(x * freq, y * freq) * amp; + max += amp; + amp *= 0.5; + freq *= 2; + } + return value / max; +} - // convert noise to terrain height - const terrain_height = Math.floor((h * 0.5 + 0.5) * max_height); +function get_terrain_height(base: number, biome: Biome, x: number, z: number, noise: NoiseFunction2D) { + const biomeMod = biome_height_modifier(biome); - for (let y = 0; y <= terrain_height; y++) { - let id = "bworld:stone"; + const main = fractal_noise(noise, x * 0.003, z * 0.003) * 15; - // simple terrain layers - if (y === terrain_height) { - id = "bworld:leaves"; - } else if (y > terrain_height - 4) { - id = "bworld:dirt"; + const detail = fractal_noise(noise, x * 0.01, z * 0.01) * 3; + + return Math.floor(base + biomeMod * 20 + main + detail); +} + +function can_place_tree(tree_map: boolean[][], local_x: number, local_z: number) { + const TREE_SPACING = 4; + for (let dx = -TREE_SPACING; dx <= TREE_SPACING; dx++) { + for (let dz = -TREE_SPACING; dz <= TREE_SPACING; dz++) { + const nx = local_x + dx; + const nz = local_z + dz; + if (nx >= 0 && nx < CHUNK_SIZE && nz >= 0 && nz < CHUNK_SIZE && tree_map[nx][nz]) { + return false; + } + } + } + return true; +} + +function place_tree(dimension: Dimension, x: number, y: number, z: number, biome: Biome) { + const height = Math.floor(Math.random() * 3) + (biome === "jungle" ? 8 : 4); + const trunk_block = "bworld:log"; + const leaves_block = "bworld:leaves"; + + // if (biome === "jungle") { + // trunkBlock = "bworld:jungle_log"; + // leavesBlock = "bworld:jungle_leaves"; + // } else if (biome === "taiga") { + // leavesBlock = "bworld:spruce_leaves"; + // } + + for (let i = 0; i < height; i++) { + dimension.add_block({ x, y: y + i, z, id: trunk_block }); + } + + for (let dx = -2; dx <= 2; dx++) { + for (let dz = -2; dz <= 2; dz++) { + for (let dy = -1; dy <= 1; dy++) { + if (Math.abs(dx) + Math.abs(dz) + Math.abs(dy) <= 3) { + dimension.add_block({ + x: x + dx, + y: y + height + dy, + z: z + dz, + id: leaves_block, + }); } - - dimension.add_block(world, { x, y, z, id }); + } + } + } +} + +const TREE_THRESHOLD: Record = { + forest: 0.5, + jungle: 0.3, + taiga: 0.6, + plains: 0.95, + desert: 1, + tundra: 1, + savanna: 0.65, + swamp: 0.5, + snow: 0.8, +}; + +function should_place_tree(feature_noise: NoiseFunction2D, biome: Biome, x: number, z: number) { + const n = feature_noise(x * 0.1, z * 0.1); + return n > (TREE_THRESHOLD[biome] ?? 0.8); +} + +export function generate_chunk(dimension: Dimension, cx: number, cz: number, seed = "seed") { + const height_noise = create_noise_2d(new Alea(seed + "_height")); + const temp_noise = create_noise_2d(new Alea(seed + "_temp")); + const moisture_noise = create_noise_2d(new Alea(seed + "_moisture")); + const feature_noise = create_noise_2d(new Alea(seed + "_feature")); + + const biome_scale = 0.003; + const terrain_scale = 0.01; + + const tree_map: boolean[][] = Array.from({ length: CHUNK_SIZE }, () => Array(CHUNK_SIZE).fill(false)); + + for (let x = 0; x < CHUNK_SIZE; x++) { + for (let z = 0; z < CHUNK_SIZE; z++) { + const wx = cx * CHUNK_SIZE + x; + const wz = cz * CHUNK_SIZE + z; + + const temp = temp_noise(wx * biome_scale, wz * biome_scale); + const moisture = moisture_noise(wx * biome_scale, wz * biome_scale); + const biome = get_biome(temp, moisture); + + const height_noise_value = fractal_noise(height_noise, wx * terrain_scale, wz * terrain_scale); + const base_height = (height_noise_value + 1) * 15 + 50; + const height = get_terrain_height(base_height, biome, wx, wz, height_noise); + + const surface_block = get_surface_block(biome); + + for (let y = 0; y <= height; y++) { + let block = "bworld:stone"; + if (y === height) { + block = surface_block; + } else if (y > height - 4) { + block = "bworld:dirt"; + } + + if (biome === "swamp" && y === height && Math.random() < 0.2) { + block = "bworld:water"; + } + + dimension.add_block({ x: wx, y, z: wz, id: block }); + } + + if (should_place_tree(feature_noise, biome, wx, wz) && can_place_tree(tree_map, x, z)) { + place_tree(dimension, wx, height + 1, wz, biome); + tree_map[x][z] = true; } } } diff --git a/client/player.ts b/client/player.ts index 4a0cdd6..88174fc 100644 --- a/client/player.ts +++ b/client/player.ts @@ -10,6 +10,7 @@ import { GuiScreen } from "./gui/gui_screen.ts"; export class PlayerComponent extends Component { player_inventory = new PlayerInventory(""); screens: GuiScreen[] = []; + render_distance = 6; pop_screen() { const screen = this.screens.pop(); diff --git a/client/systems/clickable_system.ts b/client/systems/clickable_system.ts deleted file mode 100644 index 9c5cc9a..0000000 --- a/client/systems/clickable_system.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { System } from "$/common/ecs/mod.ts"; -import { Position } from "$/common/components/position.ts"; -import { Sprite } from "../components/sprite.ts"; -import { ClientWorld } from "../client_world.ts"; -import { ClickableSprite } from "../components/clickable.ts"; -import { point_inside_rec } from "$/common/utils.ts"; -import { InputManager } from "../input_manager.ts"; -import { Camera } from "../components/camera.ts"; -import { canvas } from "../renderer/mod.ts"; - -export class ClickableSystem extends System { - update(world: ClientWorld, _delta: number): void { - } -} diff --git a/client/systems/rendering/dimension.ts b/client/systems/rendering/dimension.ts index 165038c..c11b7a6 100644 --- a/client/systems/rendering/dimension.ts +++ b/client/systems/rendering/dimension.ts @@ -1,5 +1,5 @@ import { distance_point_point, get_sprite_region } from "$/common/utils.ts"; -import { Chunk, CHUNK_SIDE_SIZE, Dimension } from "$/client/components/dimension.ts"; +import { Chunk, CHUNK_SIZE, Dimension } from "$/client/components/dimension.ts"; import { TEXTURE_SIZE } from "$/common/constants.ts"; import { EverythingRegistry, TileRegistry } from "$/common/everything_registry.ts"; import { flush_buffer, gl, push_cube_to_mesh, set_current_texture } from "$/client/renderer/mod.ts"; @@ -9,10 +9,7 @@ export function render_dimension(dimension: Dimension, camera: Camera) { set_current_texture(dimension.image.tex); for (const chunk of dimension.chunks) { if (chunk.dirty) { - if (chunk.vertexBuffer && chunk.vertexTransparentBuffer) { - gl.deleteBuffer(chunk.vertexBuffer); - gl.deleteBuffer(chunk.vertexTransparentBuffer); - } + dimension.delete_chunk_mesh(chunk); chunk.dirty = false; make_chunk_mesh(chunk, dimension, camera); } @@ -80,8 +77,8 @@ function make_chunk_mesh(chunk: Chunk, dimension: Dimension, camera: Camera) { const [x, y, z] = dimension.index_to_xyz(i); - const wx = chunk.x * CHUNK_SIDE_SIZE + x; - const wz = chunk.z * CHUNK_SIDE_SIZE + z; + const wx = chunk.x * CHUNK_SIZE + x; + const wz = chunk.z * CHUNK_SIZE + z; const show_face = (x: number, y: number, z: number) => { const block = dimension.get_block(x, y, z); diff --git a/client/systems/world_generation_system.ts b/client/systems/world_generation_system.ts new file mode 100644 index 0000000..3c5ee65 --- /dev/null +++ b/client/systems/world_generation_system.ts @@ -0,0 +1,43 @@ +import { System } from "$/common/ecs/mod.ts"; +import { ClientWorld } from "../client_world.ts"; +import { Position } from "../../common/components/position.ts"; +import { CHUNK_SIZE } from "../components/dimension.ts"; +import { PlayerComponent } from "$/client/player.ts"; + +export class WorldGenerationSystem extends System { + constructor() { + super(); + } + + update(world: ClientWorld, _delta: number): void { + const [player] = world.get_tag("player")!; + const position = player.get(Position)!; + const player_component = player.get(PlayerComponent)!; + const dimension = world.dimension; + + const player_chunk_x = Math.floor(position.x / CHUNK_SIZE); + const player_chunk_z = Math.floor(position.z / CHUNK_SIZE); + + const render_distance = player_component.render_distance; + + for (const chunk of dimension.chunks) { + if (Math.abs(chunk.x - player_chunk_x) > render_distance) { + dimension.unload_chunk(chunk.x, chunk.z); + } + if (Math.abs(chunk.z - player_chunk_z) > render_distance) { + dimension.unload_chunk(chunk.x, chunk.z); + } + } + + for (let i = player_chunk_x - render_distance; i <= player_chunk_x + render_distance; i += 1) { + for (let j = player_chunk_z - render_distance; j <= player_chunk_z + render_distance; j += 1) { + const maybe_chunk = dimension.chunks.find((chunk) => chunk.x === i && chunk.z === j); + if (!maybe_chunk || !maybe_chunk.generated) { + console.log("loading chunk", i, j); + dimension.load_chunk(i, j); + return; + } + } + } + } +} diff --git a/client/tiles/mod.ts b/client/tiles/mod.ts index 8d71187..17b9628 100644 --- a/client/tiles/mod.ts +++ b/client/tiles/mod.ts @@ -7,3 +7,5 @@ import "./chest.ts"; import "./furnace.ts"; import "./stone.ts"; import "./log.ts"; +import "./sand.ts"; +import "./snow.ts"; diff --git a/client/tiles/sand.ts b/client/tiles/sand.ts new file mode 100644 index 0000000..76bfa83 --- /dev/null +++ b/client/tiles/sand.ts @@ -0,0 +1,6 @@ +import { EverythingRegistry, TileRegistry } from "$/common/everything_registry.ts"; + +EverythingRegistry.register("blocks", "bworld:sand", { + texture_id: "bworld:sand", + has_collision: true, +}); diff --git a/client/tiles/snow.ts b/client/tiles/snow.ts new file mode 100644 index 0000000..ec32051 --- /dev/null +++ b/client/tiles/snow.ts @@ -0,0 +1,6 @@ +import { EverythingRegistry, TileRegistry } from "$/common/everything_registry.ts"; + +EverythingRegistry.register("blocks", "bworld:snow", { + texture_id: "bworld:snow", + has_collision: true, +}); diff --git a/client/tiles/water.ts b/client/tiles/water.ts index 234d30e..02dd39c 100644 --- a/client/tiles/water.ts +++ b/client/tiles/water.ts @@ -1,18 +1,6 @@ import { EverythingRegistry, TileRegistry } from "$/common/everything_registry.ts"; -import { WateringCanData } from "../items/watering_can.ts"; -import { PlayerComponent } from "../player.ts"; EverythingRegistry.register("blocks", "bworld:water", { texture_id: "bworld:water", - has_collision: true, - - on_interact(world, _tile) { - const [player] = world.get_tag("player")!; - const player_inventory = player.get(PlayerComponent)!.player_inventory; - const maybe_item = player_inventory.container.get_item(player_inventory.hotbar_selected); - if (maybe_item && maybe_item.type_id === "bworld:watering_can") { - const data = maybe_item.data as WateringCanData; - data.water = data.max_water; - } - }, + has_collision: false, }); diff --git a/common/everything_registry.ts b/common/everything_registry.ts index 67498c8..f2dbd91 100644 --- a/common/everything_registry.ts +++ b/common/everything_registry.ts @@ -1,5 +1,4 @@ -import { ClientWorld } from "$/client/client_world.ts"; -import { Block } from "$/client/components/dimension.ts"; +import { Block, Dimension } from "$/client/components/dimension.ts"; import { ItemStack } from "$/client/inventory.ts"; export class EverythingRegistry { @@ -55,11 +54,11 @@ export interface TileRegistry { has_collision: boolean; transparent?: boolean; - on_create?(world: ClientWorld, tile: Block): void; - on_click?(world: ClientWorld, tile: Block): void; - on_interact?(world: ClientWorld, tile: Block): void; - on_tick?(world: ClientWorld, tile: Block, tick_delta: number): void; - on_second?(world: ClientWorld, tile: Block, second_delta: number): void; + on_create?(dimension: Dimension, tile: Block): void; + on_click?(dimension: Dimension, tile: Block): void; + on_interact?(dimension: Dimension, tile: Block): void; + on_tick?(dimension: Dimension, tile: Block, tick_delta: number): void; + on_second?(dimension: Dimension, tile: Block, second_delta: number): void; } export interface ItemRegistry {