Skip to content

Commit

Permalink
Fix version check. (#413)
Browse files Browse the repository at this point in the history
* Fix version check.

* Update supported versions.

* Check file size of screenshot.

* Fix.
  • Loading branch information
rom1504 authored Dec 17, 2023
1 parent 6526159 commit 635d252
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

strategy:
matrix:
mcVersion: ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.1', '1.16.4', '1.17.1', '1.18.1', '1.19.1', '1.20.1']
mcVersion: ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.1', '1.16.4', '1.17.1', '1.18.1', '1.19', '1.20.1']
fail-fast: false

steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ examples/standalone/public/worker.js
examples/standalone/public/textures/
examples/standalone/public/blocksStates/
*.DS_Store
test/server_*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Web based viewer for servers and bots

[<img src="https://prismarinejs.github.io/prismarine-viewer/test_1.18.1.png" alt="viewer" width="300">](https://prismarinejs.github.io/prismarine-viewer/)

Supports versions 1.8.8, 1.9.4, 1.10.2, 1.11.2, 1.12.2, 1.13.2, 1.14.4, 1.15.2, 1.16.1, 1.16.4, 1.17.1, 1.18.1, 1.19.1, 1.20.1.
Supports versions 1.8.8, 1.9.4, 1.10.2, 1.11.2, 1.12.2, 1.13.2, 1.14.4, 1.15.2, 1.16.1, 1.16.4, 1.17.1, 1.18.1, 1.19, 1.20.1.

## Install

Expand Down
2 changes: 1 addition & 1 deletion examples/exporter/3dmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const main = async () => {

await schem.paste(world, new Vec3(0, 60, 0))

if (viewer.setVersion(version)) {
if (!viewer.setVersion(version)) {
return false
}

Expand Down
2 changes: 1 addition & 1 deletion examples/exporter/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const main = async () => {

await schem.paste(world, new Vec3(0, 60, 0))

if (viewer.setVersion(version)) {
if (!viewer.setVersion(version)) {
return false
}

Expand Down
2 changes: 1 addition & 1 deletion examples/standalone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function main () {

// Create viewer
const viewer = new Viewer(renderer)
if (viewer.setVersion(version)) {
if (!viewer.setVersion(version)) {
return false
}
// Attach controls to viewer
Expand Down
2 changes: 1 addition & 1 deletion examples/web_client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function main () {

// Create viewer
const viewer = new Viewer(renderer)
if (viewer.setVersion(version)) {
if (!viewer.setVersion(version)) {
return false
}

Expand Down
2 changes: 1 addition & 1 deletion lib/headless.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = (bot, { viewDistance = 6, output = 'output.mp4', frames = -1, w
const renderer = new THREE.WebGLRenderer({ canvas })
const viewer = new Viewer(renderer)

if (viewer.setVersion(bot.version)) {
if (!viewer.setVersion(bot.version)) {
return false
}
viewer.setFirstPersonCamera(bot.entity.position, bot.entity.yaw, bot.entity.pitch)
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ window.addEventListener('resize', () => {
})

socket.on('version', (version) => {
if (viewer.setVersion(version)) {
if (!viewer.setVersion(version)) {
return false
}

Expand Down
11 changes: 10 additions & 1 deletion test/viewer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* global page */

const supportedVersions = require('../').supportedVersions
const fs = require('fs')

const path = require('path')
const MC_SERVER_PATH = path.join(__dirname, 'server')
Expand Down Expand Up @@ -117,7 +118,15 @@ supportedVersions.forEach(function (supportedVersion) {
exit(pageerr)
})
setTimeout(() => {
page.screenshot({ path: path.join(__dirname, `test_${supportedVersion}.png`) }).then(() => exit()).catch(err => exit(err))
const fileName = path.join(__dirname, `test_${supportedVersion}.png`)
page.screenshot({ path: fileName }).then(() => {
const fileSize = fs.statSync(fileName).size
if (fileSize < 100000) {
exit(new Error(`The file size of ${fileName} is ${fileSize}. This is less than 100KB, and is likely an empty render.`))
} else {
exit()
}
}).catch(err => exit(err))
}, TIMEOUT_SCREENSHOT)
}).catch(err => exit(err))
})
Expand Down
2 changes: 1 addition & 1 deletion viewer/lib/version.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const supportedVersions = ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.1', '1.16.4', '1.17.1', '1.18.1', '1.19.1', '1.20.2']
const supportedVersions = ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.1', '1.16.4', '1.17.1', '1.18.1', '1.19', '1.20.1']

const lastOfMajor = {}
for (const version of supportedVersions) {
Expand Down

0 comments on commit 635d252

Please sign in to comment.