@hytopia.com/server-protocol 1.3.39 → 1.3.40

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.3.39",
3
+ "version": "1.3.40",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -32,7 +32,7 @@ export enum PacketId {
32
32
  BLOCK_TYPES = 35,
33
33
  CHAT_MESSAGES = 36,
34
34
  CHUNKS = 37,
35
- ENTITIES = 38,
35
+ MODELS = 38,
36
36
  WORLD = 39,
37
37
  CAMERA = 40,
38
38
  UI = 41,
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { modelsSchema } from '../../schemas/Models';
4
+ import type { ModelsSchema } from '../../schemas/Models';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type ModelsPacket = IPacket<typeof PacketId.MODELS, ModelsSchema> & [WorldTick];
8
+
9
+ export const modelsPacketDefinition = definePacket(
10
+ PacketId.MODELS,
11
+ modelsSchema,
12
+ );
@@ -4,8 +4,8 @@ export * from './BlockTypes';
4
4
  export * from './Camera';
5
5
  export * from './ChatMessages';
6
6
  export * from './Chunks';
7
- export * from './Entities';
8
7
  export * from './Lights';
8
+ export * from './Models';
9
9
  export * from './PhysicsDebugRender';
10
10
  export * from './PhysicsDebugRaycasts';
11
11
  export * from './SceneUIs';
package/schemas/Model.ts CHANGED
@@ -1,27 +1,44 @@
1
+ import { quaternionSchema } from './Quaternion';
1
2
  import { modelNodeSchema } from './ModelNode';
3
+ import { vectorSchema } from './Vector';
2
4
  import type { JSONSchemaType } from 'ajv';
5
+ import type { QuaternionSchema } from './Quaternion';
3
6
  import type { ModelNodeSchema } from './ModelNode';
7
+ import type { VectorSchema } from './Vector';
4
8
 
5
9
  export type ModelSchema = {
10
+ i: number; // model id
6
11
  al?: string[]; // animations looped
7
12
  ao?: string[]; // animations one shot
8
13
  ap?: number; // animations playback rate
9
14
  as?: string[]; // animations stop
10
- n?: ModelNodeSchema[]; // node custom configurations
11
- pn?: string; // parent node name (When model is attached to another model)
12
- u?: string; // uri
15
+ bh?: VectorSchema; // block model half extents
16
+ bt?: string; // block model texture uri
17
+ n?: ModelNodeSchema[]; // model node custom configurations
18
+ p?: VectorSchema; // position
19
+ pm?: number; // parent model id (When model is attached to another model)
20
+ pn?: string; // parent node name (Optional node attached to when model is attached to another model)
21
+ r?: QuaternionSchema; // rotation
22
+ u?: string; // model uri
13
23
  }
14
24
 
15
25
  export const modelSchema: JSONSchemaType<ModelSchema> = {
16
26
  type: 'object',
17
27
  properties: {
28
+ i: { type: 'number' },
18
29
  al: { type: 'array', items: { type: 'string' }, nullable: true },
19
30
  ao: { type: 'array', items: { type: 'string' }, nullable: true },
20
31
  ap: { type: 'number', nullable: true },
21
32
  as: { type: 'array', items: { type: 'string' }, nullable: true },
33
+ bh: { ...vectorSchema, nullable: true },
34
+ bt: { type: 'string', nullable: true },
22
35
  n: { type: 'array', items: { ...modelNodeSchema }, nullable: true },
36
+ p: { ...vectorSchema, nullable: true },
37
+ pm: { type: 'number', nullable: true },
23
38
  pn: { type: 'string', nullable: true },
39
+ r: { ...quaternionSchema, nullable: true },
24
40
  u: { type: 'string', nullable: true },
25
41
  },
42
+ required: [ 'i' ],
26
43
  additionalProperties: false,
27
44
  }
@@ -0,0 +1,10 @@
1
+ import { modelSchema } from './Model';
2
+ import type { JSONSchemaType } from 'ajv';
3
+ import type { ModelSchema } from './Model';
4
+
5
+ export type ModelsSchema = ModelSchema[];
6
+
7
+ export const modelsSchema: JSONSchemaType<ModelsSchema> = {
8
+ type: 'array',
9
+ items: { ...modelSchema },
10
+ }
@@ -1,12 +0,0 @@
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,10 +0,0 @@
1
- import { entitySchema } from './Entity';
2
- import type { JSONSchemaType } from 'ajv';
3
- import type { EntitySchema } from './Entity';
4
-
5
- export type EntitiesSchema = EntitySchema[];
6
-
7
- export const entitiesSchema: JSONSchemaType<EntitiesSchema> = {
8
- type: 'array',
9
- items: { ...entitySchema },
10
- }
package/schemas/Entity.ts DELETED
@@ -1,36 +0,0 @@
1
- import { modelSchema } from './Model';
2
- import { quaternionSchema } from './Quaternion';
3
- import { vectorSchema } from './Vector';
4
- import type { JSONSchemaType } from 'ajv';
5
- import type { ModelSchema } from './Model';
6
- import type { QuaternionSchema } from './Quaternion';
7
- import type { VectorSchema } from './Vector';
8
-
9
- export type EntitySchema = {
10
- i: number; // entity id
11
- am?: ModelSchema[]; // attached models
12
- bh?: VectorSchema; // block half extents
13
- bt?: string; // block texture uri
14
- m?: ModelSchema; // model
15
- n?: string; // name
16
- p?: VectorSchema; // position
17
- r?: QuaternionSchema; // rotation
18
- rm?: boolean; // removed/remove
19
- }
20
-
21
- export const entitySchema: JSONSchemaType<EntitySchema> = {
22
- type: 'object',
23
- properties: {
24
- i: { type: 'number' },
25
- am: { type: 'array', items: { ...modelSchema }, nullable: true },
26
- bh: { ...vectorSchema, nullable: true },
27
- bt: { type: 'string', nullable: true },
28
- m: { ...modelSchema, nullable: true },
29
- n: { type: 'string', nullable: true },
30
- p: { ...vectorSchema, nullable: true },
31
- r: { ...quaternionSchema, nullable: true },
32
- rm: { type: 'boolean', nullable: true },
33
- },
34
- required: [ 'i' ],
35
- additionalProperties: false,
36
- }