Send block data to clients
This commit is contained in:
@@ -29,6 +29,9 @@ export interface ClientContext {
|
||||
// read only, what this client sees
|
||||
world: {
|
||||
get_block(x: number, y: number, z: number): Id | undefined;
|
||||
// a field of the block's client data, what server scripts set with BlockRef.set_client_data, a copy.
|
||||
// undefined when it isn't set or the chunk isn't loaded
|
||||
get_client_data<T>(x: number, y: number, z: number, field: string): T | undefined;
|
||||
// the column's biome and its season, undefined when the chunk isn't loaded
|
||||
biome_at(x: number, z: number): Id | undefined;
|
||||
season_at(x: number, z: number): Season | undefined;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user