Item entities
This commit is contained in:
+20
-1
@@ -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 = 1;
|
||||
export const PROTOCOL_VERSION = 2;
|
||||
|
||||
export interface PlayerInfo {
|
||||
id: string;
|
||||
@@ -19,6 +19,16 @@ export interface PlayerInfo {
|
||||
pitch: number;
|
||||
}
|
||||
|
||||
// an entity that isn't a player, as the server first sends it. players have their own messages
|
||||
export interface EntityInfo {
|
||||
kind: "item";
|
||||
id: string;
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
item: ItemData;
|
||||
}
|
||||
|
||||
// x, y, z, block id, and its state bits when they aren't 0
|
||||
export type BlockChange = [number, number, number, string, number?];
|
||||
|
||||
@@ -84,6 +94,8 @@ export type ServerMessage =
|
||||
// the server may change the name asked for, like alice to alice2
|
||||
name: string;
|
||||
players: PlayerInfo[];
|
||||
// items on the ground
|
||||
entities: EntityInfo[];
|
||||
changes: BlockChange[];
|
||||
spawn: { x: number; y: number; z: number; yaw: number; pitch: number };
|
||||
selected_slot: number;
|
||||
@@ -91,6 +103,13 @@ export type ServerMessage =
|
||||
| { 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: "add_entity"; entity: EntityInfo }
|
||||
| { type: "move_entity"; id: string; x: number; y: number; z: number }
|
||||
// a dropped item's stack changed, like when two stacks merge
|
||||
| { type: "set_entity_item"; id: string; item: ItemData }
|
||||
| { type: "remove_entity"; id: string }
|
||||
// a player picked up an item, it flies to them and goes away
|
||||
| { type: "take_entity"; id: string; player: string }
|
||||
// also sent to the player who caused it, which corrects anything their client predicted wrong
|
||||
| { type: "set_block"; x: number; y: number; z: number; id: string; state?: number }
|
||||
| { type: "chat"; from?: string; text: string }
|
||||
|
||||
Reference in New Issue
Block a user