Skip to content

Commit

Permalink
auto-select version workaround
Browse files Browse the repository at this point in the history
fix version hint
  • Loading branch information
zardoy committed Sep 29, 2023
1 parent fc104cd commit 54365d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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')
}
Expand Down
5 changes: 4 additions & 1 deletion src/menus/components/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/menus/play_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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 }}
></pmui-editbox>
Expand Down

0 comments on commit 54365d8

Please sign in to comment.