@hytopia.com/server-protocol 1.1.4 → 1.2.0

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.4",
3
+ "version": "1.2.0",
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/Entity.ts CHANGED
@@ -4,20 +4,18 @@ import type { JSONSchemaType } from 'ajv';
4
4
  import type { QuaternionSchema } from './Quaternion';
5
5
  import type { VectorSchema } from './Vector';
6
6
 
7
-
8
7
  export type EntitySchema = {
9
8
  i: number; // entity id
10
- al?: string[]; // animations looped
11
- ao?: string[]; // animations one shot
12
- as?: string[]; // animations stop
13
- b?: VectorSchema; // model visual bounding box half extents
9
+ al?: string[]; // model animations looped
10
+ ao?: string[]; // model animations one shot
11
+ as?: string[]; // model animations stop
14
12
  f?: boolean; // focused
15
13
  m?: string; // model uri
16
14
  n?: string; // name
17
15
  p?: VectorSchema; // position
18
16
  r?: QuaternionSchema; // rotation
19
17
  rm?: boolean; // removed/remove
20
- s?: VectorSchema; // model scale relative to visual bounding box
18
+ s?: number; // model scale
21
19
  }
22
20
 
23
21
  export const entitySchema: JSONSchemaType<EntitySchema> = {
@@ -27,14 +25,13 @@ export const entitySchema: JSONSchemaType<EntitySchema> = {
27
25
  al: { type: 'array', items: { type: 'string' }, nullable: true },
28
26
  ao: { type: 'array', items: { type: 'string' }, nullable: true },
29
27
  as: { type: 'array', items: { type: 'string' }, nullable: true },
30
- b: { ...vectorSchema, nullable: true },
31
28
  f: { type: 'boolean', nullable: true },
32
29
  m: { type: 'string', nullable: true },
33
30
  n: { type: 'string', nullable: true },
34
31
  p: { ...vectorSchema, nullable: true },
35
32
  r: { ...quaternionSchema, nullable: true },
36
33
  rm: { type: 'boolean', nullable: true },
37
- s: { ...vectorSchema, nullable: true },
34
+ s: { type: 'number', nullable: true },
38
35
  },
39
36
  required: [ 'i' ],
40
37
  additionalProperties: false,
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
- );