Predict interactions with blocks
This commit is contained in:
+8
-4
@@ -7,7 +7,7 @@ export const AIR_ID = "bworld:air";
|
||||
|
||||
// bump when a client and server of different versions can't play together.
|
||||
// the server rejects a different version before the client downloads anything
|
||||
export const PROTOCOL_VERSION = 19;
|
||||
export const PROTOCOL_VERSION = 20;
|
||||
|
||||
export interface PlayerInfo {
|
||||
id: string;
|
||||
@@ -101,7 +101,8 @@ export type ClientMessage =
|
||||
teleport?: number;
|
||||
swimming?: boolean;
|
||||
}
|
||||
| { type: "break_block"; x: number; y: number; z: number }
|
||||
// seq numbers what this client guessed for it, the server answers with block_ack. see client/level/block_predictions.ts
|
||||
| { type: "break_block"; x: number; y: number; z: number; seq?: number }
|
||||
// the player started hitting a block, for on_click
|
||||
| { type: "hit_block"; x: number; y: number; z: number }
|
||||
// left click on an entity, by id
|
||||
@@ -111,8 +112,8 @@ export type ClientMessage =
|
||||
// right click without looking at a block, for items' on_use
|
||||
| { type: "use_item" }
|
||||
// right click on a block: interact with it, or place the held block against `face`. hit is where on the block it
|
||||
// clicked, 0 to 1 on each axis, like minecraft's click location
|
||||
| { type: "use_block"; x: number; y: number; z: number; face: Faces; hit?: [number, number, number] }
|
||||
// clicked, 0 to 1 on each axis, like minecraft's click location. seq is like break_block's
|
||||
| { type: "use_block"; x: number; y: number; z: number; face: Faces; hit?: [number, number, number]; seq?: number }
|
||||
| { type: "select_slot"; slot: number }
|
||||
// a slot of the open menu, or of menu 0 when none is. shift moves the stack to the other part of the menu instead,
|
||||
// like minecraft's quick move. clicks for a menu that isn't open any more are ignored
|
||||
@@ -208,6 +209,9 @@ export type ServerMessage =
|
||||
// to the players who have the chunk, including the one who caused it, which corrects anything their client
|
||||
// predicted wrong
|
||||
| { type: "set_block"; x: number; y: number; z: number; id: string; state?: number }
|
||||
// the break_block or use_block with this seq is handled, and so is every one before it. the set_blocks it caused
|
||||
// came first, and what they said about blocks this client guessed shows now
|
||||
| { type: "block_ack"; seq: number }
|
||||
// the item a block shows, see BlockRegistry.item_display. to the players who have the chunk, after it and whenever
|
||||
// it changes. null when it shows nothing any more
|
||||
| { type: "set_block_item"; x: number; y: number; z: number; item: ItemData | null }
|
||||
|
||||
Reference in New Issue
Block a user