Swimming
This commit is contained in:
@@ -36,6 +36,9 @@ export const CHUNK_AREA = CHUNK_SIZE * CHUNK_SIZE;
|
||||
export const PLAYER_WIDTH = 0.6;
|
||||
export const PLAYER_HEIGHT = 1.79;
|
||||
export const PLAYER_EYE_HEIGHT = 1.69;
|
||||
// while swimming they lie flat in a shorter box, like voxelibre's, so they fit through 1 block gaps
|
||||
export const PLAYER_SWIM_HEIGHT = 0.8;
|
||||
export const PLAYER_SWIM_EYE_HEIGHT = 0.6;
|
||||
|
||||
// where a block placed against each face of another block goes
|
||||
export const FACE_OFFSETS: Record<Faces, { x: number; y: number; z: number }> = {
|
||||
|
||||
@@ -9,7 +9,8 @@ export interface ClientContext {
|
||||
hud: HudRegistry;
|
||||
input: { bind(id: Id, default_key: KeyCode, on_press: () => void): void };
|
||||
net: ClientNet;
|
||||
player: { readonly name: string; readonly position: Readonly<Position> };
|
||||
// is_swimming: lying flat in water in the 0.8 tall box, like minecraft's isSwimming
|
||||
player: { readonly name: string; readonly position: Readonly<Position>; is_swimming(): boolean };
|
||||
// read only, what this client sees
|
||||
world: {
|
||||
get_block(x: number, y: number, z: number): Id | undefined;
|
||||
|
||||
@@ -248,6 +248,8 @@ export interface Player {
|
||||
effect(id: Id): { readonly amplifier: number; readonly duration: number } | undefined;
|
||||
// whether they had it
|
||||
remove_effect(id: Id): boolean;
|
||||
// lying flat in water in the 0.8 tall box, like minecraft's isSwimming. their client says when
|
||||
is_swimming(): boolean;
|
||||
}
|
||||
|
||||
export interface EffectOptions {
|
||||
|
||||
+25
-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 = 17;
|
||||
export const PROTOCOL_VERSION = 18;
|
||||
|
||||
export interface PlayerInfo {
|
||||
id: string;
|
||||
@@ -23,6 +23,8 @@ export interface PlayerInfo {
|
||||
slim?: boolean;
|
||||
// what they're wearing that shows, see player_worn
|
||||
worn?: ItemData[];
|
||||
// lying flat in the short box, see PLAYER_SWIM_HEIGHT
|
||||
swimming?: boolean;
|
||||
}
|
||||
|
||||
// an entity that isn't a player, as the server first sends it. players have their own messages. items on the
|
||||
@@ -87,8 +89,18 @@ export type ClientMessage =
|
||||
| { type: "view_distance"; distance: number }
|
||||
// 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
|
||||
| { type: "move"; x: number; y: number; z: number; yaw: number; pitch: number; teleport?: 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
|
||||
| {
|
||||
type: "move";
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
yaw: number;
|
||||
pitch: number;
|
||||
teleport?: number;
|
||||
swimming?: boolean;
|
||||
}
|
||||
| { type: "break_block"; x: number; y: number; z: number }
|
||||
// the player started hitting a block, for on_click
|
||||
| { type: "hit_block"; x: number; y: number; z: number }
|
||||
@@ -155,7 +167,16 @@ export type ServerMessage =
|
||||
| { type: "chunk_batch_finished"; size: number }
|
||||
| { 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: "player_move";
|
||||
id: string;
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
yaw: number;
|
||||
pitch: number;
|
||||
swimming?: boolean;
|
||||
}
|
||||
// a player changed their skin, including the one receiving it. without skin it's back to the default
|
||||
| { type: "player_skin"; id: string; skin?: string; slim?: boolean }
|
||||
// what a player wears that shows changed, to everyone including them: the items whose json has worn, see
|
||||
|
||||
Reference in New Issue
Block a user