Player api
This commit is contained in:
+11
-4
@@ -10,7 +10,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 = 20;
|
||||
export const PROTOCOL_VERSION = 21;
|
||||
|
||||
export interface PlayerInfo {
|
||||
id: string;
|
||||
@@ -95,7 +95,8 @@ export type ClientMessage =
|
||||
// answers chunk_batch_finished once the batch is loaded, with how many chunks a tick the client can take
|
||||
| { type: "chunk_batch_received"; chunks_per_tick: number }
|
||||
// teleport is the id of the last teleport the client heard of. moves from before the latest one are ignored.
|
||||
// swimming is whether they're swimming, sent right away when it changes
|
||||
// swimming is whether they're swimming and sneaking whether they hold the sneak key, both sent right away when they
|
||||
// change
|
||||
| {
|
||||
type: "move";
|
||||
x: number;
|
||||
@@ -105,6 +106,7 @@ export type ClientMessage =
|
||||
pitch: number;
|
||||
teleport?: number;
|
||||
swimming?: boolean;
|
||||
sneaking?: boolean;
|
||||
}
|
||||
// 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 }
|
||||
@@ -116,6 +118,8 @@ export type ClientMessage =
|
||||
| { type: "swing" }
|
||||
// right click without looking at a block, for items' on_use
|
||||
| { type: "use_item" }
|
||||
// the use button let go of after a use_item or use_block, which stops using an item over time, like shooting a bow
|
||||
| { type: "release_use" }
|
||||
// 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. seq is like break_block's
|
||||
| { type: "use_block"; x: number; y: number; z: number; face: Faces; hit?: [number, number, number]; seq?: number }
|
||||
@@ -249,8 +253,11 @@ export type ServerMessage =
|
||||
| { type: "suggestions"; id: number; start: number; suggestions: { text: string; tooltip?: string }[] }
|
||||
// the player's own health, max health, hunger, saturation and air (out of 20, 2 a bubble), when they change
|
||||
| { type: "vitals"; health: number; max_health: number; food: number; saturation: number; air: number }
|
||||
// the player's own attack speed attribute, when it changes, for the attack indicator under the crosshair
|
||||
| { type: "attack_speed"; value: number }
|
||||
// the player's own attributes their client needs, when they change: attack speed for the attack indicator under the
|
||||
// crosshair, and how far they reach blocks and entities
|
||||
| { type: "attributes"; attack_speed: number; block_interaction_range: number; entity_interaction_range: number }
|
||||
// whether they're using their held item over time, like drawing a bow, see ctx's player.start_using
|
||||
| { type: "using_item"; using: boolean }
|
||||
// whether the player flies, see /fly, when it changes
|
||||
| { type: "flying"; flying: boolean }
|
||||
// the player's own effects that show an icon, when they change. duration is in ticks, -1 for forever, and the
|
||||
|
||||
Reference in New Issue
Block a user