@hytopia.com/server-protocol 1.2.3 → 1.2.5

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.2.3",
3
+ "version": "1.2.5",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -26,12 +26,13 @@ export enum PacketId {
26
26
 
27
27
  // Standard Outbound Packet Types: 32 - 127 range
28
28
  SYNC_RESPONSE = 32,
29
- BLOCKS = 33,
30
- BLOCK_TYPES = 34,
31
- CHAT_MESSAGES = 35,
32
- CHUNKS = 36,
33
- ENTITIES = 37,
34
- WORLD = 38,
29
+ AUDIOS = 33,
30
+ BLOCKS = 34,
31
+ BLOCK_TYPES = 35,
32
+ CHAT_MESSAGES = 36,
33
+ CHUNKS = 37,
34
+ ENTITIES = 38,
35
+ WORLD = 39,
35
36
 
36
37
  // Debug Inbound Packet Types: 128 - 191 range
37
38
  DEBUG_CONFIG = 128,
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { audiosSchema } from '../../schemas/Audios';
4
+ import type { AudiosSchema } from '../../schemas/Audios';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type AudiosPacket = IPacket<typeof PacketId.AUDIOS, AudiosSchema> & [WorldTick];
8
+
9
+ export const audiosPacketDefinition = definePacket(
10
+ PacketId.AUDIOS,
11
+ audiosSchema,
12
+ );
@@ -1,3 +1,4 @@
1
+ export * from './Audios';
1
2
  export * from './Blocks';
2
3
  export * from './BlockTypes';
3
4
  export * from './ChatMessages';
@@ -0,0 +1,26 @@
1
+ import { vectorSchema } from './Vector';
2
+ import type { JSONSchemaType } from 'ajv';
3
+ import type { VectorSchema } from './Vector';
4
+
5
+ export type AudioSchema = {
6
+ a: string; // audio uri
7
+ c?: VectorSchema; // coordinate of spatial audio origin
8
+ l?: boolean; // loop
9
+ o?: boolean; // one shot
10
+ s?: boolean; // stop
11
+ v?: number; // volume
12
+ }
13
+
14
+ export const audioSchema: JSONSchemaType<AudioSchema> = {
15
+ type: 'object',
16
+ properties: {
17
+ a: { type: 'string' },
18
+ c: { ...vectorSchema, nullable: true },
19
+ l: { type: 'boolean', nullable: true },
20
+ o: { type: 'boolean', nullable: true },
21
+ s: { type: 'boolean', nullable: true },
22
+ v: { type: 'number', nullable: true },
23
+ },
24
+ required: [ 'a' ],
25
+ additionalProperties: false,
26
+ }
@@ -0,0 +1,10 @@
1
+ import { audioSchema } from './Audio';
2
+ import type { JSONSchemaType } from 'ajv';
3
+ import type { AudioSchema } from './Audio';
4
+
5
+ export type AudiosSchema = AudioSchema[];
6
+
7
+ export const audiosSchema: JSONSchemaType<AudiosSchema> = {
8
+ type: 'array',
9
+ items: { ...audioSchema },
10
+ }
@@ -6,6 +6,7 @@ export type PhysicsDebugRaycastSchema = {
6
6
  o: VectorSchema; // rapier raycast origin
7
7
  d: VectorSchema; // rapier raycast direction
8
8
  l: number; // rapier raycast length
9
+ h: boolean; // rapier raycast hit
9
10
  }
10
11
 
11
12
  export const physicsDebugRaycastSchema: JSONSchemaType<PhysicsDebugRaycastSchema> = {
@@ -14,7 +15,8 @@ export const physicsDebugRaycastSchema: JSONSchemaType<PhysicsDebugRaycastSchema
14
15
  o: { ...vectorSchema },
15
16
  d: { ...vectorSchema },
16
17
  l: { type: 'number' },
18
+ h: { type: 'boolean' },
17
19
  },
18
- required: [ 'o', 'd', 'l' ],
20
+ required: [ 'o', 'd', 'l', 'h' ],
19
21
  additionalProperties: false,
20
22
  }
package/schemas/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from './Audio';
2
+ export * from './Audios';
1
3
  export * from './Block';
2
4
  export * from './Blocks';
3
5
  export * from './BlockType';