Server
This commit is contained in:
@@ -18,3 +18,7 @@ export const VOID = 0xFFFFFFFF;
|
||||
|
||||
export const ID_MASK = 0xFFFF;
|
||||
export const STATE_SHIFT = 16;
|
||||
|
||||
export const CHUNK_SIZE = 16;
|
||||
export const CHUNK_HEIGHT = 128;
|
||||
export const CHUNK_AREA = CHUNK_SIZE * CHUNK_SIZE;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// messages sent between the client and the server, as json over a websocket
|
||||
|
||||
export const AIR_ID = "bworld:air";
|
||||
|
||||
export interface PlayerInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
yaw: number;
|
||||
pitch: number;
|
||||
}
|
||||
|
||||
// x, y, z, block id
|
||||
export type BlockChange = [number, number, number, string];
|
||||
|
||||
export type ClientMessage =
|
||||
| { type: "hello"; name: string }
|
||||
| { type: "move"; x: number; y: number; z: number; yaw: number; pitch: number }
|
||||
| { type: "set_block"; x: number; y: number; z: number; id: string }
|
||||
| { type: "chat"; text: string };
|
||||
|
||||
export type ServerMessage =
|
||||
| { type: "welcome"; id: string; seed: string; players: PlayerInfo[]; changes: BlockChange[] }
|
||||
| { type: "player_join"; player: PlayerInfo }
|
||||
| { type: "player_leave"; id: string }
|
||||
| { type: "player_move"; id: string; x: number; y: number; z: number; yaw: number; pitch: number }
|
||||
| { type: "set_block"; x: number; y: number; z: number; id: string }
|
||||
| { type: "chat"; from?: string; text: string };
|
||||
|
||||
export const MAX_NAME_LENGTH = 16;
|
||||
export const MAX_CHAT_LENGTH = 256;
|
||||
Reference in New Issue
Block a user