@hytopia.com/server-protocol 1.0.31 → 1.0.33

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.0.31",
3
+ "version": "1.0.33",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -19,19 +19,20 @@ import type { JSONSchemaType, ValidateFunction } from 'ajv';
19
19
 
20
20
  export enum PacketId {
21
21
  // Standard Inbound Packet Types: 0 - 31 range
22
- HEARTBEAT = 0,
22
+ SYNC_REQUEST = 0,
23
23
  DEBUG_CONFIG = 1,
24
24
  INPUT = 2,
25
25
  STATE_REQUEST = 3,
26
26
 
27
27
  // Standard Outbound Packet Types: 32 - 127 range
28
- BLOCK = 32,
29
- BLOCK_TYPE_REGISTRY = 33,
30
- BLOCK_TYPE = 34,
31
- CHUNK = 35,
32
- ENTITY = 36,
33
- SIMULATION = 37,
34
- WORLD = 38,
28
+ SYNC_RESPONSE = 32,
29
+ BLOCK = 33,
30
+ BLOCK_TYPE_REGISTRY = 34,
31
+ BLOCK_TYPE = 35,
32
+ CHUNK = 36,
33
+ ENTITY = 37,
34
+ SIMULATION = 38,
35
+ WORLD = 39,
35
36
 
36
37
  // Debug Inbound Packet Types: 128 - 191 range
37
38
  // NONE atm, start at 128
@@ -0,0 +1,11 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { syncRequestSchema } from '../../schemas/SyncRequest';
4
+ import type { SyncRequestSchema } from '../../schemas/SyncRequest';
5
+
6
+ export type SyncRequestPacket = IPacket<typeof PacketId.SYNC_REQUEST, SyncRequestSchema>;
7
+
8
+ export const syncRequestPacketDefinition = definePacket(
9
+ PacketId.SYNC_REQUEST,
10
+ syncRequestSchema
11
+ );
@@ -1,3 +1,5 @@
1
1
  export * from './DebugConfig';
2
- export * from './Heartbeat';
3
- export * from './Input';
2
+ export * from './SyncRequest';
3
+ export * from './Input';
4
+ export * from './StateRequest';
5
+ export * from './SyncRequest';
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { syncResponseSchema } from '../../schemas/SyncResponse';
4
+ import type { SyncResponseSchema } from '../../schemas/SyncResponse';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type SyncResponsePacket = IPacket<typeof PacketId.SYNC_RESPONSE, SyncResponseSchema> & [WorldTick];
8
+
9
+ export const syncResponsePacketDefinition = definePacket(
10
+ PacketId.SYNC_RESPONSE,
11
+ syncResponseSchema,
12
+ );
@@ -5,4 +5,5 @@ export * from './Chunk';
5
5
  export * from './Entity';
6
6
  export * from './PhysicsDebugRender';
7
7
  export * from './Simulation';
8
+ export * from './SyncResponse';
8
9
  export * from './World';
@@ -0,0 +1,16 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+
3
+ export type SyncResponseSchema = {
4
+ s: number; // server time
5
+ nt: number; // time until next server tick, relative to server time
6
+ };
7
+
8
+ export const syncResponseSchema: JSONSchemaType<SyncResponseSchema> = {
9
+ type: 'object',
10
+ properties: {
11
+ s: { type: 'number' },
12
+ nt: { type: 'number' },
13
+ },
14
+ required: [ 's', 'nt' ],
15
+ additionalProperties: false,
16
+ }
package/schemas/index.ts CHANGED
@@ -5,12 +5,13 @@ export * from './Chunk';
5
5
  export * from './Collider';
6
6
  export * from './ColliderDesc';
7
7
  export * from './Entity';
8
- export * from './Heartbeat';
8
+ export * from './SyncRequest';
9
9
  export * from './Input';
10
10
  export * from './PhysicsDebugRender';
11
11
  export * from './Quaternion';
12
12
  export * from './RigidBody';
13
13
  export * from './Shape';
14
+ export * from './Simulation';
14
15
  export * from './Vector';
15
16
  export * from './VectorBoolean';
16
17
  export * from './World';
@@ -1,11 +0,0 @@
1
- import { definePacket, PacketId } from '../PacketCore';
2
- import type { IPacket } from '../PacketCore';
3
- import { heartbeatSchema } from '../../schemas/Heartbeat';
4
- import type { HeartbeatSchema } from '../../schemas/Heartbeat';
5
-
6
- export type HeartbeatPacket = IPacket<typeof PacketId.HEARTBEAT, HeartbeatSchema>;
7
-
8
- export const heartbeatPacketDefinition = definePacket(
9
- PacketId.HEARTBEAT,
10
- heartbeatSchema
11
- );
File without changes