@hytopia.com/server-protocol 1.0.14 → 1.0.16
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
package/packets/PacketCore.ts
CHANGED
|
@@ -48,10 +48,10 @@ export interface IPacketDefinition<TId extends PacketId, TSchema> {
|
|
|
48
48
|
validate: ValidateFunction<TSchema>;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
export type IPacket<TId extends PacketId, TSchema> = [
|
|
52
|
+
TId, // packet id
|
|
53
|
+
TSchema // packet data
|
|
54
|
+
];
|
|
55
55
|
|
|
56
56
|
export type AnyPacket = IPacket<PacketId, unknown>;
|
|
57
57
|
|
|
@@ -65,7 +65,7 @@ export function createPacket<TId extends number, TSchema>(
|
|
|
65
65
|
throw new Error(`createPacket(): Invalid payload for packet with id ${packetDef.id}, error: ${Ajv.instance.errorsText(packetDef.validate.errors)}`);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
return
|
|
68
|
+
return [ packetDef.id, data ];
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export function definePacket<TId extends PacketId, TSchema>(
|
package/schemas/Block.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { JSONSchemaType } from 'ajv';
|
|
|
3
3
|
import type { VectorSchema } from './Vector';
|
|
4
4
|
|
|
5
5
|
export type BlockSchema = {
|
|
6
|
-
wi:
|
|
6
|
+
wi: number; // world id
|
|
7
7
|
i: number; // block id
|
|
8
8
|
c: VectorSchema; // coordinate
|
|
9
9
|
};
|
|
@@ -11,7 +11,7 @@ export type BlockSchema = {
|
|
|
11
11
|
export const blockSchema: JSONSchemaType<BlockSchema> = {
|
|
12
12
|
type: 'object',
|
|
13
13
|
properties: {
|
|
14
|
-
wi: { type: '
|
|
14
|
+
wi: { type: 'number' },
|
|
15
15
|
i: { type: 'number' },
|
|
16
16
|
c: vectorSchema,
|
|
17
17
|
},
|
package/schemas/BlockType.ts
CHANGED
|
@@ -3,9 +3,8 @@ import type { JSONSchemaType } from 'ajv';
|
|
|
3
3
|
import type { ColliderDescSchema } from './ColliderDesc';
|
|
4
4
|
|
|
5
5
|
export type BlockTypeSchema = {
|
|
6
|
-
wi:
|
|
6
|
+
wi: number; // world id
|
|
7
7
|
i: number; // block type id
|
|
8
|
-
d: boolean; // delta
|
|
9
8
|
t?: string; // textureUri
|
|
10
9
|
n?: string; // name
|
|
11
10
|
c?: ColliderDescSchema; // collider desc
|
|
@@ -15,14 +14,13 @@ export type BlockTypeSchema = {
|
|
|
15
14
|
export const blockTypeSchema: JSONSchemaType<BlockTypeSchema> = {
|
|
16
15
|
type: 'object',
|
|
17
16
|
properties: {
|
|
18
|
-
wi: { type: '
|
|
17
|
+
wi: { type: 'number' },
|
|
19
18
|
i: { type: 'number' },
|
|
20
|
-
d: { type: 'boolean' },
|
|
21
19
|
t: { type: 'string', nullable: true },
|
|
22
20
|
n: { type: 'string', nullable: true },
|
|
23
21
|
c: { ...colliderDescSchema, nullable: true },
|
|
24
22
|
s: { type: 'boolean', nullable: true },
|
|
25
23
|
},
|
|
26
|
-
required: [ 'wi', 'i'
|
|
24
|
+
required: [ 'wi', 'i' ],
|
|
27
25
|
additionalProperties: false,
|
|
28
26
|
}
|
|
@@ -3,14 +3,14 @@ import type { JSONSchemaType } from 'ajv';
|
|
|
3
3
|
import type { BlockTypeSchema } from './BlockType';
|
|
4
4
|
|
|
5
5
|
export type BlockTypeRegistrySchema = {
|
|
6
|
-
wi:
|
|
6
|
+
wi: number; // world id
|
|
7
7
|
b: BlockTypeSchema[]; // block types
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const blockTypeRegistrySchema: JSONSchemaType<BlockTypeRegistrySchema> = {
|
|
11
11
|
type: 'object',
|
|
12
12
|
properties: {
|
|
13
|
-
wi: { type: '
|
|
13
|
+
wi: { type: 'number' },
|
|
14
14
|
b: {
|
|
15
15
|
type: 'array',
|
|
16
16
|
items: blockTypeSchema,
|
package/schemas/Chunk.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { JSONSchemaType } from 'ajv';
|
|
|
3
3
|
import type { VectorSchema } from './Vector';
|
|
4
4
|
|
|
5
5
|
export type ChunkSchema = {
|
|
6
|
-
wi:
|
|
6
|
+
wi: number; // world id
|
|
7
7
|
c: VectorSchema; // chunk coordinate [ 16n, 16n, 16n ]
|
|
8
8
|
b: Uint8Array | number[]; // block ids in chunk, 16^3 entries, registry block ids 1-255, 0 = none
|
|
9
9
|
};
|
|
@@ -11,7 +11,7 @@ export type ChunkSchema = {
|
|
|
11
11
|
export const chunkSchema: JSONSchemaType<ChunkSchema> = {
|
|
12
12
|
type: 'object',
|
|
13
13
|
properties: {
|
|
14
|
-
wi: { type: '
|
|
14
|
+
wi: { type: 'number' },
|
|
15
15
|
c: vectorSchema,
|
|
16
16
|
b: {
|
|
17
17
|
type: 'array',
|
package/schemas/Entity.ts
CHANGED
|
@@ -3,9 +3,8 @@ import type { JSONSchemaType } from 'ajv';
|
|
|
3
3
|
import type { RigidBodySchema } from './RigidBody';
|
|
4
4
|
|
|
5
5
|
export type EntitySchema = {
|
|
6
|
-
wi:
|
|
6
|
+
wi: number; // world id
|
|
7
7
|
i: number; // entity id
|
|
8
|
-
d: boolean; // delta
|
|
9
8
|
f?: boolean; // focused
|
|
10
9
|
rm?: boolean; // removed
|
|
11
10
|
n?: string; // name
|
|
@@ -17,9 +16,8 @@ export type EntitySchema = {
|
|
|
17
16
|
export const entitySchema: JSONSchemaType<EntitySchema> = {
|
|
18
17
|
type: 'object',
|
|
19
18
|
properties: {
|
|
20
|
-
wi: { type: '
|
|
19
|
+
wi: { type: 'number' },
|
|
21
20
|
i: { type: 'number' },
|
|
22
|
-
d: { type: 'boolean' },
|
|
23
21
|
f: { type: 'boolean', nullable: true },
|
|
24
22
|
rm: { type: 'boolean', nullable: true },
|
|
25
23
|
n: { type: 'string', nullable: true },
|
|
@@ -27,6 +25,6 @@ export const entitySchema: JSONSchemaType<EntitySchema> = {
|
|
|
27
25
|
t: { type: 'string', nullable: true },
|
|
28
26
|
r: { ...rigidBodySchema, nullable: true },
|
|
29
27
|
},
|
|
30
|
-
required: [ 'wi', 'i'
|
|
28
|
+
required: [ 'wi', 'i' ],
|
|
31
29
|
additionalProperties: false,
|
|
32
30
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JSONSchemaType } from 'ajv';
|
|
2
2
|
|
|
3
3
|
export type PhysicsDebugRenderSchema = {
|
|
4
|
-
wi:
|
|
4
|
+
wi: number; // world id
|
|
5
5
|
v: number[]; // rapier debug render vertices
|
|
6
6
|
c: number[]; // rapier debug render colors
|
|
7
7
|
}
|
|
@@ -9,7 +9,7 @@ export type PhysicsDebugRenderSchema = {
|
|
|
9
9
|
export const physicsDebugRenderSchema: JSONSchemaType<PhysicsDebugRenderSchema> = {
|
|
10
10
|
type: 'object',
|
|
11
11
|
properties: {
|
|
12
|
-
wi: { type: '
|
|
12
|
+
wi: { type: 'number' },
|
|
13
13
|
v: { type: 'array', items: { type: 'number' } },
|
|
14
14
|
c: { type: 'array', items: { type: 'number' } },
|
|
15
15
|
},
|