Skip to content

Commit

Permalink
finally test that it works
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jan 18, 2024
1 parent 51cceb4 commit 1fdc39f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./src/index.js')
module.exports = require('./dist/index.js')
17 changes: 11 additions & 6 deletions src/lib/plugins/world.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"esModuleInterop": true,
"skipLibCheck": true,
"rootDir": "src",
"stripInternal": true
"stripInternal": true,
"noImplicitUseStrict": true,
"ignoreDeprecations": "5.0"
},
"include": [
"src"
Expand Down

0 comments on commit 1fdc39f

Please sign in to comment.