From 1fdc39f7806f963ac31ad8944900b791b655446f Mon Sep 17 00:00:00 2001 From: Vitaly Date: Thu, 18 Jan 2024 21:53:10 +0530 Subject: [PATCH] finally test that it works --- index.js | 2 +- src/lib/plugins/world.ts | 17 +++++++++++------ tsconfig.json | 4 +++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index d12c5e73..fb7d6493 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports = require('./src/index.js') +module.exports = require('./dist/index.js') diff --git a/src/lib/plugins/world.ts b/src/lib/plugins/world.ts index f9551661..4ed7e4c0 100644 --- a/src/lib/plugins/world.ts +++ b/src/lib/plugins/world.ts @@ -1,6 +1,3 @@ -import { gzip } from 'node-gzip' -import nbt from 'prismarine-nbt' - import { promisify } from 'util' import fs from 'fs' import { level, Anvil as AnvilLoader } from 'prismarine-provider-anvil' @@ -21,7 +18,7 @@ export const server = async function (serv: Server, options: Options) { const { version, worldFolder, generation = { name: 'diamond_square', options: { worldHeight: 80 } } } = options const World = WorldLoader(version) const registry = RegistryLoader(version) - const Anvil = AnvilLoader.Anvil(version) + const Anvil = AnvilLoader(version) const newSeed = generation.options.seed || Math.floor(Math.random() * Math.pow(2, 31)) let seed @@ -160,7 +157,7 @@ export const server = async function (serv: Server, options: Options) { }) } -const player = function (player: Player, serv: Server, settings: Options) { +export const player = function (player: Player, serv: Server, settings: Options) { const registry = RegistryLoader(settings.version) player.flying = 0 @@ -231,6 +228,14 @@ const player = function (player: Player, serv: Server, settings: Options) { }) } + function spiral (arr) { + const t = [] as any[] + spiralloop(arr, (x, z) => { + t.push([x, z]) + }) + return t + } + player.sendNearbyChunks = (view, group) => { player.lastPositionChunkUpdated = player.position const playerChunkX = Math.floor(player.position.x / 16) @@ -241,7 +246,7 @@ const player = function (player: Player, serv: Server, settings: Options) { .filter(([x, z]) => Math.abs(x - playerChunkX) > view || Math.abs(z - playerChunkZ) > view) .forEach(([x, z]) => player._unloadChunk(x, z)) - return spiralloop([view * 2, view * 2]) + return spiral([view * 2, view * 2]) .map(t => ({ chunkX: playerChunkX + t[0] - view, chunkZ: playerChunkZ + t[1] - view diff --git a/tsconfig.json b/tsconfig.json index f6aa474b..f08e60d8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,9 @@ "esModuleInterop": true, "skipLibCheck": true, "rootDir": "src", - "stripInternal": true + "stripInternal": true, + "noImplicitUseStrict": true, + "ignoreDeprecations": "5.0" }, "include": [ "src"