@serenityjs/protocol 0.2.4-beta-20240601202508 → 0.2.4
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/dist/index.d.ts +12 -0
- package/dist/index.js +22 -0
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -2275,6 +2275,18 @@ declare class ChunkCoords extends DataType {
|
|
|
2275
2275
|
constructor(x: number, z: number);
|
|
2276
2276
|
static read(stream: BinaryStream): Array<ChunkCoords>;
|
|
2277
2277
|
static write(stream: BinaryStream, value: Array<ChunkCoords>): void;
|
|
2278
|
+
/**
|
|
2279
|
+
* Convert the chunk coordinates to a hash.
|
|
2280
|
+
* @param coords The chunk coordinates.
|
|
2281
|
+
* @returns The hash of the chunk coordinates.
|
|
2282
|
+
*/
|
|
2283
|
+
static hash(coords: ChunkCoords): bigint;
|
|
2284
|
+
/**
|
|
2285
|
+
* Convert the hash to chunk coordinates.
|
|
2286
|
+
* @param hash The hash.
|
|
2287
|
+
* @returns The chunk coordinates.
|
|
2288
|
+
*/
|
|
2289
|
+
static unhash(hash: bigint): ChunkCoords;
|
|
2278
2290
|
}
|
|
2279
2291
|
|
|
2280
2292
|
declare class MetadataDictionary extends DataType {
|
package/dist/index.js
CHANGED
|
@@ -3478,6 +3478,28 @@ var ChunkCoords = class _ChunkCoords extends import_raknet26.DataType {
|
|
|
3478
3478
|
stream.writeZigZag(chunk.z);
|
|
3479
3479
|
}
|
|
3480
3480
|
}
|
|
3481
|
+
/**
|
|
3482
|
+
* Convert the chunk coordinates to a hash.
|
|
3483
|
+
* @param coords The chunk coordinates.
|
|
3484
|
+
* @returns The hash of the chunk coordinates.
|
|
3485
|
+
*/
|
|
3486
|
+
static hash(coords) {
|
|
3487
|
+
const x = BigInt(coords.x);
|
|
3488
|
+
const z = BigInt(coords.z);
|
|
3489
|
+
const hash = x << 32n | z & 0xffffffffn;
|
|
3490
|
+
return hash;
|
|
3491
|
+
}
|
|
3492
|
+
/**
|
|
3493
|
+
* Convert the hash to chunk coordinates.
|
|
3494
|
+
* @param hash The hash.
|
|
3495
|
+
* @returns The chunk coordinates.
|
|
3496
|
+
*/
|
|
3497
|
+
static unhash(hash) {
|
|
3498
|
+
const x = Number(hash >> 32n);
|
|
3499
|
+
const bigZ = hash & 0xffffffffn;
|
|
3500
|
+
const z = Number(bigZ >= 0x80000000n ? bigZ - 0x100000000n : bigZ);
|
|
3501
|
+
return new _ChunkCoords(x, z);
|
|
3502
|
+
}
|
|
3481
3503
|
};
|
|
3482
3504
|
|
|
3483
3505
|
// src/proto/types/metadata-dictionary.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenityjs/protocol",
|
|
3
|
-
"version": "0.2.4
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/SerenityJS/serenity",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"preset": "@serenityjs/jest-presets/jest/node"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@serenityjs/eslint-config": "
|
|
22
|
-
"@serenityjs/jest-presets": "
|
|
23
|
-
"@serenityjs/typescript-config": "
|
|
21
|
+
"@serenityjs/eslint-config": "*",
|
|
22
|
+
"@serenityjs/jest-presets": "*",
|
|
23
|
+
"@serenityjs/typescript-config": "*",
|
|
24
24
|
"@types/jest": "^29.5.12",
|
|
25
25
|
"@types/node": "^20.11.24",
|
|
26
26
|
"jest": "^29.7.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@serenityjs/binarystream": "^2.5.2",
|
|
32
|
-
"@serenityjs/nbt": "
|
|
33
|
-
"@serenityjs/raknet": "
|
|
32
|
+
"@serenityjs/nbt": "*",
|
|
33
|
+
"@serenityjs/raknet": "*"
|
|
34
34
|
}
|
|
35
35
|
}
|