@hytopia.com/server-protocol 1.1.5 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hytopia.com/server-protocol",
3
- "version": "1.1.5",
3
+ "version": "1.2.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -26,16 +26,12 @@ export enum PacketId {
26
26
 
27
27
  // Standard Outbound Packet Types: 32 - 127 range
28
28
  SYNC_RESPONSE = 32,
29
- BLOCK = 33,
30
- BLOCK_BATCH = 34,
31
- BLOCK_TYPE = 35,
32
- BLOCK_TYPE_BATCH = 36,
33
- CHUNK = 37,
34
- CHUNK_BATCH = 38,
35
- ENTITY = 39,
36
- ENTITY_BATCH = 40,
37
- WORLD = 41,
38
- CHAT_MESSAGE = 42,
29
+ BLOCKS = 33,
30
+ BLOCK_TYPES = 34,
31
+ CHAT_MESSAGES = 35,
32
+ CHUNKS = 36,
33
+ ENTITIES = 37,
34
+ WORLD = 38,
39
35
 
40
36
  // Debug Inbound Packet Types: 128 - 191 range
41
37
  DEBUG_CONFIG = 128,
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { blockTypesSchema } from '../../schemas/BlockTypes';
4
+ import type { BlockTypesSchema } from '../../schemas/BlockTypes';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type BlockTypesPacket = IPacket<typeof PacketId.BLOCK_TYPES, BlockTypesSchema> & [WorldTick];
8
+
9
+ export const blockTypesPacketDefinition = definePacket(
10
+ PacketId.BLOCK_TYPES,
11
+ blockTypesSchema,
12
+ );
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { blocksSchema } from '../../schemas/Blocks';
4
+ import type { BlocksSchema } from '../../schemas/Blocks';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type BlocksPacket = IPacket<typeof PacketId.BLOCKS, BlocksSchema> & [WorldTick];
8
+
9
+ export const blocksPacketDefinition = definePacket(
10
+ PacketId.BLOCKS,
11
+ blocksSchema,
12
+ );
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { chatMessagesSchema } from '../../schemas/ChatMessages';
4
+ import type { ChatMessagesSchema } from '../../schemas/ChatMessages';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type ChatMessagesPacket = IPacket<typeof PacketId.CHAT_MESSAGES, ChatMessagesSchema> & [WorldTick];
8
+
9
+ export const chatMessagesPacketDefinition = definePacket(
10
+ PacketId.CHAT_MESSAGES,
11
+ chatMessagesSchema,
12
+ );
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { chunksSchema } from '../../schemas/Chunks';
4
+ import type { ChunksSchema } from '../../schemas/Chunks';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type ChunksPacket = IPacket<typeof PacketId.CHUNKS, ChunksSchema> & [WorldTick];
8
+
9
+ export const chunksPacketDefinition = definePacket(
10
+ PacketId.CHUNKS,
11
+ chunksSchema,
12
+ );
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { entitiesSchema } from '../../schemas/Entities';
4
+ import type { EntitiesSchema } from '../../schemas/Entities';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type EntitiesPacket = IPacket<typeof PacketId.ENTITIES, EntitiesSchema> & [WorldTick];
8
+
9
+ export const entitiesPacketDefinition = definePacket(
10
+ PacketId.ENTITIES,
11
+ entitiesSchema,
12
+ );
@@ -1,12 +1,8 @@
1
- export * from './Block';
2
- export * from './BlockBatch';
3
- export * from './BlockType';
4
- export * from './BlockTypeBatch';
5
- export * from './ChatMessage';
6
- export * from './Chunk';
7
- export * from './ChunkBatch';
8
- export * from './Entity';
9
- export * from './EntityBatch';
1
+ export * from './Blocks';
2
+ export * from './BlockTypes';
3
+ export * from './ChatMessages';
4
+ export * from './Chunks';
5
+ export * from './Entities';
10
6
  export * from './PhysicsDebugRender';
11
7
  export * from './SyncResponse';
12
8
  export * from './World';
package/schemas/Block.ts CHANGED
@@ -4,7 +4,7 @@ import type { VectorSchema } from './Vector';
4
4
 
5
5
  export type BlockSchema = {
6
6
  i: number; // block id
7
- c: VectorSchema; // coordinate
7
+ c: VectorSchema; // block global coordinate
8
8
  };
9
9
 
10
10
  export const blockSchema: JSONSchemaType<BlockSchema> = {
@@ -2,9 +2,9 @@ import { blockTypeSchema } from './BlockType';
2
2
  import type { JSONSchemaType } from 'ajv';
3
3
  import type { BlockTypeSchema } from './BlockType';
4
4
 
5
- export type BlockTypeBatchSchema = BlockTypeSchema[];
5
+ export type BlockTypesSchema = BlockTypeSchema[];
6
6
 
7
- export const blockTypeBatchSchema: JSONSchemaType<BlockTypeBatchSchema> = {
7
+ export const blockTypesSchema: JSONSchemaType<BlockTypesSchema> = {
8
8
  type: 'array',
9
9
  items: { ...blockTypeSchema },
10
10
  }
@@ -2,9 +2,9 @@ import { blockSchema } from './Block';
2
2
  import type { JSONSchemaType } from 'ajv';
3
3
  import type { BlockSchema } from './Block';
4
4
 
5
- export type BlockBatchSchema = BlockSchema[];
5
+ export type BlocksSchema = BlockSchema[];
6
6
 
7
- export const blockBatchSchema: JSONSchemaType<BlockBatchSchema> = {
7
+ export const blocksSchema: JSONSchemaType<BlocksSchema> = {
8
8
  type: 'array',
9
9
  items: { ...blockSchema },
10
10
  }
@@ -0,0 +1,10 @@
1
+ import { chatMessageSchema } from './ChatMessage';
2
+ import type { JSONSchemaType } from 'ajv';
3
+ import type { ChatMessageSchema } from './ChatMessage';
4
+
5
+ export type ChatMessagesSchema = ChatMessageSchema[];
6
+
7
+ export const chatMessagesSchema: JSONSchemaType<ChatMessagesSchema> = {
8
+ type: 'array',
9
+ items: { ...chatMessageSchema },
10
+ }
package/schemas/Chunk.ts CHANGED
@@ -3,8 +3,9 @@ import type { JSONSchemaType } from 'ajv';
3
3
  import type { VectorSchema } from './Vector';
4
4
 
5
5
  export type ChunkSchema = {
6
- c: VectorSchema; // chunk coordinate [ 16n, 16n, 16n ]
7
- b: Uint8Array | number[]; // block ids in chunk, 16^3 entries, registry block ids 1-255, 0 = none
6
+ c: VectorSchema; // chunk origin coordinate [ 16n, 16n, 16n ]
7
+ b?: Uint8Array | number[]; // block ids in chunk, 16^3 entries, registry block ids 1-255, 0 = none
8
+ rm?: boolean; // removed/remove
8
9
  };
9
10
 
10
11
  export const chunkSchema: JSONSchemaType<ChunkSchema> = {
@@ -19,9 +20,11 @@ export const chunkSchema: JSONSchemaType<ChunkSchema> = {
19
20
  maximum: 255
20
21
  },
21
22
  minItems: 4096,
22
- maxItems: 4096
23
- }
23
+ maxItems: 4096,
24
+ nullable: true,
25
+ },
26
+ rm: { type: 'boolean', nullable: true },
24
27
  },
25
- required: [ 'c', 'b' ],
28
+ required: [ 'c' ],
26
29
  additionalProperties: false,
27
30
  }
@@ -2,9 +2,9 @@ import { chunkSchema } from './Chunk';
2
2
  import type { JSONSchemaType } from 'ajv';
3
3
  import type { ChunkSchema } from './Chunk';
4
4
 
5
- export type ChunkBatchSchema = ChunkSchema[];
5
+ export type ChunksSchema = ChunkSchema[];
6
6
 
7
- export const chunkBatchSchema: JSONSchemaType<ChunkBatchSchema> = {
7
+ export const chunksSchema: JSONSchemaType<ChunksSchema> = {
8
8
  type: 'array',
9
9
  items: { ...chunkSchema },
10
10
  }
@@ -2,9 +2,9 @@ import { entitySchema } from './Entity';
2
2
  import type { JSONSchemaType } from 'ajv';
3
3
  import type { EntitySchema } from './Entity';
4
4
 
5
- export type EntityBatchSchema = EntitySchema[];
5
+ export type EntitiesSchema = EntitySchema[];
6
6
 
7
- export const entityBatchSchema: JSONSchemaType<EntityBatchSchema> = {
7
+ export const entitiesSchema: JSONSchemaType<EntitiesSchema> = {
8
8
  type: 'array',
9
9
  items: { ...entitySchema },
10
10
  }
package/schemas/Input.ts CHANGED
@@ -5,9 +5,26 @@ export type InputSchema = {
5
5
  a?: boolean; // a key pressed
6
6
  s?: boolean; // s key pressed
7
7
  d?: boolean; // d key pressed
8
+ q?: boolean; // q key pressed
9
+ e?: boolean; // e key pressed
10
+ r?: boolean; // r key pressed
11
+ f?: boolean; // f key pressed
12
+ z?: boolean; // z key pressed
13
+ x?: boolean; // x key pressed
14
+ c?: boolean; // c key pressed
15
+ v?: boolean; // v key pressed
16
+ 1?: boolean; // 1 key pressed
17
+ 2?: boolean; // 2 key pressed
18
+ 3?: boolean; // 3 key pressed
19
+ 4?: boolean; // 4 key pressed
20
+ 5?: boolean; // 5 key pressed
21
+ 6?: boolean; // 6 key pressed
22
+ 7?: boolean; // 7 key pressed
23
+ 8?: boolean; // 8 key pressed
24
+ 9?: boolean; // 9 key pressed
25
+ 0?: boolean; // 0 key pressed
8
26
  sp?: boolean; // space key pressed
9
27
  sh?: boolean; // shift key pressed
10
- ct?: boolean; // ctrl key pressed
11
28
  tb?: boolean; // tab key pressed
12
29
  ml?: boolean; // mouse left pressed
13
30
  mr?: boolean; // mouse right pressed
@@ -22,9 +39,26 @@ export const inputSchema: JSONSchemaType<InputSchema> = {
22
39
  a: { type: 'boolean', nullable: true },
23
40
  s: { type: 'boolean', nullable: true },
24
41
  d: { type: 'boolean', nullable: true },
42
+ q: { type: 'boolean', nullable: true },
43
+ e: { type: 'boolean', nullable: true },
44
+ r: { type: 'boolean', nullable: true },
45
+ f: { type: 'boolean', nullable: true },
46
+ z: { type: 'boolean', nullable: true },
47
+ x: { type: 'boolean', nullable: true },
48
+ c: { type: 'boolean', nullable: true },
49
+ v: { type: 'boolean', nullable: true },
50
+ 1: { type: 'boolean', nullable: true },
51
+ 2: { type: 'boolean', nullable: true },
52
+ 3: { type: 'boolean', nullable: true },
53
+ 4: { type: 'boolean', nullable: true },
54
+ 5: { type: 'boolean', nullable: true },
55
+ 6: { type: 'boolean', nullable: true },
56
+ 7: { type: 'boolean', nullable: true },
57
+ 8: { type: 'boolean', nullable: true },
58
+ 9: { type: 'boolean', nullable: true },
59
+ 0: { type: 'boolean', nullable: true },
25
60
  sp: { type: 'boolean', nullable: true },
26
61
  sh: { type: 'boolean', nullable: true },
27
- ct: { type: 'boolean', nullable: true },
28
62
  tb: { type: 'boolean', nullable: true },
29
63
  ml: { type: 'boolean', nullable: true },
30
64
  mr: { type: 'boolean', nullable: true },
package/schemas/index.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  export * from './Block';
2
- export * from './BlockBatch';
2
+ export * from './Blocks';
3
3
  export * from './BlockType';
4
- export * from './BlockTypeBatch';
4
+ export * from './BlockTypes';
5
5
  export * from './ChatMessage';
6
+ export * from './ChatMessages';
6
7
  export * from './Chunk';
7
- export * from './ChunkBatch';
8
+ export * from './Chunks';
8
9
  export * from './DebugConfig';
9
10
  export * from './Entity';
10
- export * from './EntityBatch';
11
+ export * from './Entities';
11
12
  export * from './HexColor';
12
13
  export * from './Input';
13
14
  export * from './PhysicsDebugRender';
@@ -1,12 +0,0 @@
1
- import { definePacket, PacketId } from '../PacketCore';
2
- import type { IPacket } from '../PacketCore';
3
- import { blockSchema } from '../../schemas/Block';
4
- import type { BlockSchema } from '../../schemas/Block';
5
- import type { WorldTick } from '../PacketCore';
6
-
7
- export type BlockPacket = IPacket<typeof PacketId.BLOCK, BlockSchema> & [WorldTick];
8
-
9
- export const blockPacketDefinition = definePacket(
10
- PacketId.BLOCK,
11
- blockSchema,
12
- );
@@ -1,12 +0,0 @@
1
- import { definePacket, PacketId } from '../PacketCore';
2
- import type { IPacket } from '../PacketCore';
3
- import { blockBatchSchema } from '../../schemas/BlockBatch';
4
- import type { BlockBatchSchema } from '../../schemas/BlockBatch';
5
- import type { WorldTick } from '../PacketCore';
6
-
7
- export type BlockBatchPacket = IPacket<typeof PacketId.BLOCK_BATCH, BlockBatchSchema> & [WorldTick];
8
-
9
- export const blockBatchPacketDefinition = definePacket(
10
- PacketId.BLOCK_BATCH,
11
- blockBatchSchema,
12
- );
@@ -1,12 +0,0 @@
1
- import { definePacket, PacketId } from '../PacketCore';
2
- import type { IPacket } from '../PacketCore';
3
- import { blockTypeSchema } from '../../schemas/BlockType';
4
- import type { BlockTypeSchema } from '../../schemas/BlockType';
5
- import type { WorldTick } from '../PacketCore';
6
-
7
- export type BlockTypePacket = IPacket<typeof PacketId.BLOCK_TYPE, BlockTypeSchema> & [WorldTick];
8
-
9
- export const blockTypePacketDefinition = definePacket(
10
- PacketId.BLOCK_TYPE,
11
- blockTypeSchema,
12
- );
@@ -1,12 +0,0 @@
1
- import { definePacket, PacketId } from '../PacketCore';
2
- import type { IPacket } from '../PacketCore';
3
- import { blockTypeBatchSchema } from '../../schemas/BlockTypeBatch';
4
- import type { BlockTypeBatchSchema } from '../../schemas/BlockTypeBatch';
5
- import type { WorldTick } from '../PacketCore';
6
-
7
- export type BlockTypeBatchPacket = IPacket<typeof PacketId.BLOCK_TYPE_BATCH, BlockTypeBatchSchema> & [WorldTick];
8
-
9
- export const blockTypeBatchPacketDefinition = definePacket(
10
- PacketId.BLOCK_TYPE_BATCH,
11
- blockTypeBatchSchema,
12
- );
@@ -1,12 +0,0 @@
1
- import { definePacket, PacketId } from '../PacketCore';
2
- import type { IPacket } from '../PacketCore';
3
- import { chatMessageSchema } from '../../schemas/ChatMessage';
4
- import type { ChatMessageSchema } from '../../schemas/ChatMessage';
5
- import type { WorldTick } from '../PacketCore';
6
-
7
- export type ChatMessagePacket = IPacket<typeof PacketId.CHAT_MESSAGE, ChatMessageSchema> & [WorldTick];
8
-
9
- export const chatMessagePacketDefinition = definePacket(
10
- PacketId.CHAT_MESSAGE,
11
- chatMessageSchema,
12
- );
@@ -1,12 +0,0 @@
1
- import { definePacket, PacketId } from '../PacketCore';
2
- import type { IPacket } from '../PacketCore';
3
- import { chunkSchema } from '../../schemas/Chunk';
4
- import type { ChunkSchema } from '../../schemas/Chunk';
5
- import type { WorldTick } from '../PacketCore';
6
-
7
- export type ChunkPacket = IPacket<typeof PacketId.CHUNK, ChunkSchema> & [WorldTick];
8
-
9
- export const chunkPacketDefinition = definePacket(
10
- PacketId.CHUNK,
11
- chunkSchema,
12
- );
@@ -1,12 +0,0 @@
1
- import { definePacket, PacketId } from '../PacketCore';
2
- import type { IPacket } from '../PacketCore';
3
- import { chunkBatchSchema } from '../../schemas/ChunkBatch';
4
- import type { ChunkBatchSchema } from '../../schemas/ChunkBatch';
5
- import type { WorldTick } from '../PacketCore';
6
-
7
- export type ChunkBatchPacket = IPacket<typeof PacketId.CHUNK_BATCH, ChunkBatchSchema> & [WorldTick];
8
-
9
- export const chunkBatchPacketDefinition = definePacket(
10
- PacketId.CHUNK_BATCH,
11
- chunkBatchSchema,
12
- );
@@ -1,12 +0,0 @@
1
- import { definePacket, PacketId } from '../PacketCore';
2
- import type { IPacket } from '../PacketCore';
3
- import { entitySchema } from '../../schemas/Entity';
4
- import type { EntitySchema } from '../../schemas/Entity';
5
- import type { WorldTick } from '../PacketCore';
6
-
7
- export type EntityPacket = IPacket<typeof PacketId.ENTITY, EntitySchema> & [WorldTick];
8
-
9
- export const entityPacketDefinition = definePacket(
10
- PacketId.ENTITY,
11
- entitySchema,
12
- );
@@ -1,12 +0,0 @@
1
- import { definePacket, PacketId } from '../PacketCore';
2
- import type { IPacket } from '../PacketCore';
3
- import { entityBatchSchema } from '../../schemas/EntityBatch';
4
- import type { EntityBatchSchema } from '../../schemas/EntityBatch';
5
- import type { WorldTick } from '../PacketCore';
6
-
7
- export type EntityBatchPacket = IPacket<typeof PacketId.ENTITY_BATCH, EntityBatchSchema> & [WorldTick];
8
-
9
- export const entityBatchPacketDefinition = definePacket(
10
- PacketId.ENTITY_BATCH,
11
- entityBatchSchema,
12
- );