From 54365d8430b2aa8e7f3a7b6f8060dab24945dafc Mon Sep 17 00:00:00 2001 From: Vitaly Date: Fri, 29 Sep 2023 08:10:18 +0300 Subject: [PATCH] auto-select version workaround fix version hint --- src/index.ts | 6 ++++++ src/menus/components/button.js | 5 ++++- src/menus/play_screen.js | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index dcf680202..c9d1be138 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,6 +45,7 @@ import { Vec3 } from 'vec3' import blockInteraction from './blockInteraction' import * as THREE from 'three' +import { versionsByMinecraftVersion } from 'minecraft-data' import { initVR } from './vr' import { @@ -401,6 +402,11 @@ async function connect(connectOptions: { closeTimeout: 240 * 1000, respawn: options.autoRespawn, async versionSelectedHook(client) { + // todo keep in sync with esbuild preload, expose cache ideally + if (client.version === '1.20.1') { + // ignore cache hit + versionsByMinecraftVersion.pc['1.20.1']!['dataVersion']++ + } await downloadMcData(client.version) setLoadingScreenStatus('Connecting to server') } diff --git a/src/menus/components/button.js b/src/menus/components/button.js index d1341ef3d..b901b8b4a 100644 --- a/src/menus/components/button.js +++ b/src/menus/components/button.js @@ -31,7 +31,10 @@ export async function playSound (path) { const volume = options.volume / 100 const soundBuffer = sounds[path] - if (!soundBuffer) throw new Error(`Sound ${path} not loaded`) + if (!soundBuffer) { + console.warn(`Sound ${path} not loaded`) + return + } const gainNode = audioContext.createGain() const source = audioContext.createBufferSource() diff --git a/src/menus/play_screen.js b/src/menus/play_screen.js index d1b098b73..9ede1a91e 100644 --- a/src/menus/play_screen.js +++ b/src/menus/play_screen.js @@ -2,6 +2,7 @@ const { LitElement, html, css } = require('lit') const mineflayer = require('mineflayer') const viewerSupportedVersions = require('prismarine-viewer/viewer/supportedVersions.json') +const { versionsByMinecraftVersion } = require('minecraft-data') const { hideCurrentModal } = require('../globalState') const { commonCss } = require('./components/common') @@ -175,7 +176,7 @@ class PlayScreen extends LitElement { pmui-id="botversion" pmui-value="${this.version}" pmui-inputmode="decimal" - state="${this.version && (fullySupporedVersions.includes(/** @type {any} */(this.version)) ? '' : /* TODO improve check: check exact including all */ partiallySupportVersions.some(v => this.version.startsWith(v)) ? 'warning' : 'invalid')}" + state="${this.version && (fullySupporedVersions.includes(/** @type {any} */(this.version)) ? '' : Object.keys(versionsByMinecraftVersion.pc).includes(this.version) ? 'warning' : 'invalid')}" .autocompleteValues=${fullySupporedVersions} @input=${e => { this.version = e.target.value }} >