@zardoy/flying-squid 0.0.100 → 0.0.101

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.
@@ -7,6 +7,7 @@ export type BreakTimeConfig = {
7
7
  [stateId: number]: number;
8
8
  '*'?: number;
9
9
  };
10
+ rawConfig?: any;
10
11
  };
11
12
  declare global {
12
13
  interface Server {
@@ -32,7 +32,8 @@ function sendBreakTimeConfig(player, serv) {
32
32
  const config = serv.customPlayersBreakTime[player.uuid];
33
33
  const data = {
34
34
  customBreakTime: config?.blocks ?? {},
35
- customBreakTimeToolAllowance: config?.toolNames ?? []
35
+ customBreakTimeToolAllowance: config?.toolNames ?? [],
36
+ ...config?.rawConfig
36
37
  };
37
38
  player._client.writeChannel(CHANNEL_NAME, {
38
39
  newConfiguration: JSON.stringify(data)
@@ -7,7 +7,14 @@ exports.player = exports.server = void 0;
7
7
  const once_1 = __importDefault(require("@tootallnate/once"));
8
8
  const server = function (serv) {
9
9
  serv.quit = async (reason = 'Server closed') => {
10
- serv.cleanupFunctions.forEach(fn => fn());
10
+ serv.cleanupFunctions.forEach(fn => {
11
+ try {
12
+ fn?.();
13
+ }
14
+ catch (err) {
15
+ serv.err('[quit] Error in cleanup function: ' + err);
16
+ }
17
+ });
11
18
  await Promise.all(serv.players.map((player) => {
12
19
  player.kick(reason);
13
20
  return (0, once_1.default)(player, 'disconnected');
@@ -1,6 +1,7 @@
1
1
  import { Vec3 } from 'vec3';
2
2
  export declare const server: (serv: Server) => void;
3
3
  export declare const player: (player: Player, serv: Server, { basePositionAntiCheat, positionAntiCheatNotifyPlayer }: Options) => void;
4
+ export declare function isInsideStrict(pos: Vec3, box: AABB): boolean;
4
5
  export type AABB = {
5
6
  min: Vec3;
6
7
  max: Vec3;
@@ -14,5 +15,6 @@ declare global {
14
15
  safeZones: AABB[];
15
16
  resetSafeZones: () => void;
16
17
  addSafeZones: (x1: number, y1: number, z1: number, x2: number, y2: number, z2: number) => void;
18
+ onSafeZoneViolation?: (player: Player) => Vec3 | void;
17
19
  }
18
20
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.player = exports.server = void 0;
4
+ exports.isInsideStrict = isInsideStrict;
4
5
  const vec3_1 = require("vec3");
5
6
  // Module to make positions safe to move to.
6
7
  // If a client sends a position outside by more than threshold, ignore and teleport back inside.
@@ -123,10 +124,11 @@ const player = (player, serv, { basePositionAntiCheat = false, positionAntiCheat
123
124
  if (isInsideExpanded(position, zone, THRESHOLD))
124
125
  return;
125
126
  // Otherwise, clamp back inside from direction of attempted position
126
- const corrected = clampToAABBFromDirection(position, zone);
127
+ let corrected = clampToAABBFromDirection(position, zone);
128
+ corrected = serv.onSafeZoneViolation?.(player) ?? corrected;
127
129
  // Prevent default cancel handling and perform corrective teleport ourselves
128
130
  if (positionAntiCheatNotifyPlayer) {
129
- player.chat(`[safeZones] Out of bounds. Teleporting to safe position.`);
131
+ player.chat(`[safeZones] Out of bounds ${zone.min.toString()} <-> ${zone.max.toString()}: ${position.toString()} -> ${corrected.toString()}. Teleporting to safe position.`);
130
132
  }
131
133
  cancel(false);
132
134
  player.teleport(corrected);
@@ -14,6 +14,7 @@ declare global {
14
14
  position: Vec3;
15
15
  /** Used to calculate collisions for server-side entities */
16
16
  size: Vec3;
17
+ knownPosition: Vec3;
17
18
  /** Yaw of entity (rotation looking up and down) */
18
19
  yaw: number;
19
20
  /** Pitch of entity (rotation sideways) */
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.100",
4
+ "version": "0.0.101",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "bin": "dist/app.js",
@@ -38,6 +38,7 @@
38
38
  "prismarine-chunk": "^1.39.0",
39
39
  "prismarine-entity": "^2.5.0",
40
40
  "prismarine-item": "^1.17.0",
41
+ "prismarine-block": "^1.22.0",
41
42
  "prismarine-nbt": "^2.7.0",
42
43
  "prismarine-provider-anvil": "github:zardoy/prismarine-provider-anvil#everything",
43
44
  "prismarine-windows": "^2.8.0",