@zardoy/flying-squid 0.0.86 → 0.0.88

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.
@@ -10,9 +10,12 @@ export declare const server: (serv: Server, options: Options) => {
10
10
  data: string;
11
11
  }) => void;
12
12
  };
13
- export declare const player: (player: Player, serv: Server) => void;
13
+ export declare const player: (player: Player, serv: Server, options: Options) => void;
14
14
  declare global {
15
15
  interface Server {
16
16
  customSync: ReturnType<typeof server>;
17
17
  }
18
+ interface Options {
19
+ clientCheckSync?: boolean;
20
+ }
18
21
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.player = exports.server = void 0;
4
4
  const SYNC_REQUEST_CHANNEL = 'minecraft-web-client:sync-request';
5
5
  const SYNC_RESPONSE_CHANNEL = 'minecraft-web-client:sync-response';
6
+ // TODO add chunks sync
6
7
  const CHECK_INTERVAL = 1000; // 1 second
7
8
  const server = (serv, options) => {
8
9
  const module = {
@@ -94,7 +95,7 @@ const server = (serv, options) => {
94
95
  return module;
95
96
  };
96
97
  exports.server = server;
97
- const player = (player, serv) => {
98
+ const player = (player, serv, options) => {
98
99
  // Register sync channels with simplified string format
99
100
  player._client.registerChannel(SYNC_REQUEST_CHANNEL, ['container', [
100
101
  {
@@ -115,7 +116,9 @@ const player = (player, serv) => {
115
116
  // Start periodic sync checks
116
117
  player.on('spawned', () => {
117
118
  player.setInterval(() => {
118
- serv.customSync.requestSync(player);
119
+ if (options.clientCheckSync) {
120
+ serv.customSync.requestSync(player);
121
+ }
119
122
  }, CHECK_INTERVAL);
120
123
  });
121
124
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.entity = exports.server = void 0;
4
+ const isPlayer = (arg) => arg.type === 'player';
4
5
  const server = function (serv) {
5
6
  let ticking = false;
6
7
  serv.on('tick', function (delta) {
@@ -26,10 +27,17 @@ const server = function (serv) {
26
27
  players[0].collect(entity);
27
28
  }
28
29
  }
30
+ // if (isPlayer(entity) && entity.isFake && !entity.size) {
31
+ // entity.size = new Vec3(0.6, 1.8, 0.6)
32
+ // entity.gravity = new Vec3(0, -20, 0)
33
+ // entity.friction = new Vec3(0.6, 0.6, 0.6)
34
+ // entity.terminalvelocity = new Vec3(27, 27, 27)
35
+ // }
29
36
  if (!entity.velocity || !entity.size)
30
37
  return;
31
38
  const { position, onGround } = await entity.calculatePhysics(delta);
32
39
  if (entity.type === 'mob' ||
40
+ entity.type === 'player' ||
33
41
  (entity.type === 'object' &&
34
42
  (entity.velocity.x !== 0 ||
35
43
  entity.velocity.y !== 0 ||
@@ -1,10 +1,11 @@
1
+ import { Vec3 } from 'vec3';
1
2
  export declare const entity: (entity: Entity, serv: Server, { version }: Options) => void;
2
3
  export declare const server: (serv: Server) => void;
3
4
  declare global {
4
5
  interface Entity {
5
6
  /** Gravity of entity (non-players) to calculate physics. */
6
- gravity: any;
7
+ gravity: Vec3;
7
8
  /** Decreases velocity when touching blocks */
8
- friction: any;
9
+ friction: Vec3;
9
10
  }
10
11
  }
@@ -50,7 +50,7 @@ const player = function (player, serv) {
50
50
  player.gameMode = serv.gameMode;
51
51
  player.prevGameMode = player.gameMode;
52
52
  player.findSpawnPoint = async () => {
53
- player.spawnPoint = await serv.getSpawnPoint(player.world);
53
+ player.spawnPoint ??= await serv.getSpawnPoint(player.world);
54
54
  };
55
55
  player._client.on('settings', ({ viewDistance }) => {
56
56
  player.view = viewDistance;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zardoy/flying-squid",
3
3
  "description": "A minecraft server written in TS",
4
- "version": "0.0.86",
4
+ "version": "0.0.88",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "bin": "dist/app.js",