Send block data to clients

This commit is contained in:
2026-10-13 23:26:10 -03:00
parent a10b15a3fd
commit 55ad08266e
18 changed files with 283 additions and 90 deletions
+8 -2
View File
@@ -44,6 +44,12 @@ export interface BlockRef {
// tile data, any json value. saved with the world, never sent to clients
// deno-lint-ignore no-explicit-any
data: any;
// the part of its data clients see too, like how fast a shaft turns, by field. each is any json value, saved with
// the world, sent to players with the block's chunk and again when it's set to something else, so a field that
// changes often doesn't resend the rest. undefined removes a field, and they all go with the block. "item" is the
// item a block with item_display shows, see set_block_item. get returns a copy
get_client_data<T>(field: string): T | undefined;
set_client_data(field: string, value: unknown): void;
// turns on_tick and on_second off for this block, or back on, like a machine with nothing to do. it stays off until
// it's turned on again, saved with the world, and goes with the block
set_ticking(ticking: boolean): void;
@@ -234,8 +240,8 @@ export interface ServerWorld {
get_block_data<T>(x: number, y: number, z: number): T | undefined;
// BlockRef.set_ticking for a block, for waking one from somewhere else, like a machine getting something to work on
set_block_ticking(x: number, y: number, z: number, ticking: boolean): void;
// the item a block with item_display shows on top of it, like a block entity renderer: saved with the block's data
// and synced to players. undefined shows nothing. it goes away with the block, without dropping
// the item a block with item_display shows on top of it, like a block entity renderer: its "item" client data, see
// BlockRef.set_client_data. undefined shows nothing. it goes away with the block, without dropping
set_block_item(x: number, y: number, z: number, item: ItemStack | undefined): void;
// a copy
get_block_item(x: number, y: number, z: number): ItemStack | undefined;