@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 +1 -1
- package/packets/PacketCore.ts +6 -10
- package/packets/outbound/BlockTypes.ts +12 -0
- package/packets/outbound/Blocks.ts +12 -0
- package/packets/outbound/ChatMessages.ts +12 -0
- package/packets/outbound/Chunks.ts +12 -0
- package/packets/outbound/Entities.ts +12 -0
- package/packets/outbound/index.ts +5 -9
- package/schemas/Block.ts +1 -1
- package/schemas/{BlockTypeBatch.ts → BlockTypes.ts} +2 -2
- package/schemas/{BlockBatch.ts → Blocks.ts} +2 -2
- package/schemas/ChatMessages.ts +10 -0
- package/schemas/Chunk.ts +8 -5
- package/schemas/{ChunkBatch.ts → Chunks.ts} +2 -2
- package/schemas/{EntityBatch.ts → Entities.ts} +2 -2
- package/schemas/Entity.ts +5 -8
- package/schemas/index.ts +5 -4
- package/packets/outbound/Block.ts +0 -12
- package/packets/outbound/BlockBatch.ts +0 -12
- package/packets/outbound/BlockType.ts +0 -12
- package/packets/outbound/BlockTypeBatch.ts +0 -12
- package/packets/outbound/ChatMessage.ts +0 -12
- package/packets/outbound/Chunk.ts +0 -12
- package/packets/outbound/ChunkBatch.ts +0 -12
- package/packets/outbound/Entity.ts +0 -12
- package/packets/outbound/EntityBatch.ts +0 -12
package/package.json
CHANGED
package/packets/PacketCore.ts
CHANGED
|
@@ -26,16 +26,12 @@ export enum PacketId {
|
|
|
26
26
|
|
|
27
27
|
// Standard Outbound Packet Types: 32 - 127 range
|
|
28
28
|
SYNC_RESPONSE = 32,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
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
|
@@ -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
|
|
5
|
+
export type BlockTypesSchema = BlockTypeSchema[];
|
|
6
6
|
|
|
7
|
-
export const
|
|
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
|
|
5
|
+
export type BlocksSchema = BlockSchema[];
|
|
6
6
|
|
|
7
|
-
export const
|
|
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;
|
|
7
|
-
b
|
|
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'
|
|
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
|
|
5
|
+
export type ChunksSchema = ChunkSchema[];
|
|
6
6
|
|
|
7
|
-
export const
|
|
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
|
|
5
|
+
export type EntitiesSchema = EntitySchema[];
|
|
6
6
|
|
|
7
|
-
export const
|
|
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?:
|
|
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: {
|
|
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 './
|
|
2
|
+
export * from './Blocks';
|
|
3
3
|
export * from './BlockType';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './BlockTypes';
|
|
5
5
|
export * from './ChatMessage';
|
|
6
|
+
export * from './ChatMessages';
|
|
6
7
|
export * from './Chunk';
|
|
7
|
-
export * from './
|
|
8
|
+
export * from './Chunks';
|
|
8
9
|
export * from './DebugConfig';
|
|
9
10
|
export * from './Entity';
|
|
10
|
-
export * from './
|
|
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
|
-
);
|