@serenityjs/protocol 0.5.2-beta-20240923211313 → 0.5.2-beta-20240924154401

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 CHANGED
@@ -2580,6 +2580,18 @@ declare class BlockPosition extends DataType implements IPosition {
2580
2580
  * @returns The converted BlockPosition
2581
2581
  */
2582
2582
  static toVector3f(coordinates: BlockPosition): Vector3f;
2583
+ /**
2584
+ * Convert the block position to a hash.
2585
+ * @param coords The block position.
2586
+ * @returns The hash of the block position.
2587
+ */
2588
+ static hash(position: BlockPosition): bigint;
2589
+ /**
2590
+ * Convert the hash to block position.
2591
+ * @param hash The hash.
2592
+ * @returns The block position.
2593
+ */
2594
+ static unhash(hash: bigint): BlockPosition;
2583
2595
  }
2584
2596
 
2585
2597
  declare class GameRules extends DataType {
package/dist/index.js CHANGED
@@ -3394,6 +3394,29 @@ var BlockPosition = class BlockPosition2 extends import_raknet10.DataType {
3394
3394
  static toVector3f(coordinates) {
3395
3395
  return new Vector3f(coordinates.x, coordinates.y, coordinates.z);
3396
3396
  }
3397
+ /**
3398
+ * Convert the block position to a hash.
3399
+ * @param coords The block position.
3400
+ * @returns The hash of the block position.
3401
+ */
3402
+ static hash(position) {
3403
+ const x = BigInt(position.x);
3404
+ const y = BigInt(position.y);
3405
+ const z = BigInt(position.z);
3406
+ const hash = x << 32n | y << 16n | z & 0xffffn;
3407
+ return hash;
3408
+ }
3409
+ /**
3410
+ * Convert the hash to block position.
3411
+ * @param hash The hash.
3412
+ * @returns The block position.
3413
+ */
3414
+ static unhash(hash) {
3415
+ const x = Number(hash >> 32n);
3416
+ const y = Number(hash >> 16n & 0xffn);
3417
+ const z = Number(hash & 0xffn);
3418
+ return new BlockPosition2(x, y, z);
3419
+ }
3397
3420
  };
3398
3421
 
3399
3422
  // src/proto/types/game-rules.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serenityjs/protocol",
3
- "version": "0.5.2-beta-20240923211313",
3
+ "version": "0.5.2-beta-20240924154401",
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": "0.5.2-beta-20240923211313",
22
- "@serenityjs/jest-presets": "0.5.2-beta-20240923211313",
23
- "@serenityjs/typescript-config": "0.5.2-beta-20240923211313",
21
+ "@serenityjs/eslint-config": "0.5.2-beta-20240924154401",
22
+ "@serenityjs/jest-presets": "0.5.2-beta-20240924154401",
23
+ "@serenityjs/typescript-config": "0.5.2-beta-20240924154401",
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.6.6",
32
- "@serenityjs/nbt": "0.5.2-beta-20240923211313",
33
- "@serenityjs/raknet": "0.5.2-beta-20240923211313"
32
+ "@serenityjs/nbt": "0.5.2-beta-20240924154401",
33
+ "@serenityjs/raknet": "0.5.2-beta-20240924154401"
34
34
  }
35
35
  }