diff --git a/package.json b/package.json index f243c6ddb..97ffbaa63 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "test-mc-server": "tsx cypress/minecraft-server.mjs", "lint": "eslint \"{src,cypress}/**/*.{ts,js,jsx,tsx}\"", "storybook": "storybook dev -p 6006", - "build-storybook": "storybook build" + "build-storybook": "storybook build", + "watch-worker": "node prismarine-viewer/buildWorker.mjs -w" }, "keywords": [ "prismarine", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 176ec8554..e4d83f19c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -63,7 +63,7 @@ importers: version: 4.18.2 flying-squid: specifier: github:zardoy/space-squid#everything - version: github.com/zardoy/space-squid/bdf1e0859ad435bf722e5b7794b84a50b84c5c7f + version: github.com/zardoy/space-squid/85dd6ed6eb645a6536dc34465e9e10c1979d9eee fs-extra: specifier: ^11.1.1 version: 11.1.1 @@ -14467,8 +14467,8 @@ packages: - utf-8-validate dev: false - github.com/zardoy/space-squid/bdf1e0859ad435bf722e5b7794b84a50b84c5c7f: - resolution: {tarball: https://codeload.github.com/zardoy/space-squid/tar.gz/bdf1e0859ad435bf722e5b7794b84a50b84c5c7f} + github.com/zardoy/space-squid/85dd6ed6eb645a6536dc34465e9e10c1979d9eee: + resolution: {tarball: https://codeload.github.com/zardoy/space-squid/tar.gz/85dd6ed6eb645a6536dc34465e9e10c1979d9eee} name: flying-squid version: 1.5.0 engines: {node: '>=8'} diff --git a/prismarine-viewer/viewer/lib/models.ts b/prismarine-viewer/viewer/lib/models.ts index f931ebd33..468de0e33 100644 --- a/prismarine-viewer/viewer/lib/models.ts +++ b/prismarine-viewer/viewer/lib/models.ts @@ -245,6 +245,8 @@ function renderElement (world, cursor, element, doAO, attr, globalMatrix, global if (neighbor) { if (cullIfIdentical && neighbor.type === block.type) continue if (!neighbor.transparent && neighbor.isCube) continue + } else { + continue } } diff --git a/prismarine-viewer/viewer/lib/worldDataEmitter.ts b/prismarine-viewer/viewer/lib/worldDataEmitter.ts index d770e2064..8693db953 100644 --- a/prismarine-viewer/viewer/lib/worldDataEmitter.ts +++ b/prismarine-viewer/viewer/lib/worldDataEmitter.ts @@ -110,7 +110,7 @@ export class WorldDataEmitter extends EventEmitter { const [botX, botZ] = chunkPos(this.lastPos) const dx = Math.abs(botX - Math.floor(pos.x / 16)) const dz = Math.abs(botZ - Math.floor(pos.z / 16)) - if (dx < this.viewDistance && dz < this.viewDistance) { + if (dx <= this.viewDistance && dz <= this.viewDistance) { const column = await this.world.getColumnAt(pos['y'] ? pos as Vec3 : new Vec3(pos.x, 0, pos.z)) if (column) { // todo optimize toJson data, make it clear why it is used @@ -124,6 +124,9 @@ export class WorldDataEmitter extends EventEmitter { this.emitter.emit('loadChunk', { x: pos.x, z: pos.z, chunk, blockEntities: column.blockEntities, worldConfig }) this.loadedChunks[`${pos.x},${pos.z}`] = true } + } else { + // todo should not happend in singleplayer + console.log('skipped loading chunk', dx, dz, '>', this.viewDistance) } } diff --git a/src/texturePack.ts b/src/texturePack.ts index c7adac82d..1e975522b 100644 --- a/src/texturePack.ts +++ b/src/texturePack.ts @@ -206,6 +206,11 @@ export const genTexturePackTextures = async (version: string) => { const imgSize = texSize * tileSize + const MAX_CANVAS_SIZE = 16_384 + if (imgSize > MAX_CANVAS_SIZE) { + throw new Error(`Texture pack texture resolution is too big, max size is ${MAX_CANVAS_SIZE}x${MAX_CANVAS_SIZE}`) + // texSize = nextPowerOfTwo(Math.ceil(Math.sqrt(textureFiles.length / 2))) + } const canvas = document.createElement('canvas') canvas.width = imgSize canvas.height = imgSize