diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1882914d..29b2f2d55 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,9 @@ jobs: with: name: cypress-images path: cypress/integration/__image_snapshots__/ + - name: print current ref + run: echo ${{ github.event.pull_request.base.ref }} - run: node scripts/outdatedGitPackages.mjs - if: github.ref == 'refs/heads/next' + if: ${{ github.event.pull_request.base.ref == 'next' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/fix-lint.yml b/.github/workflows/fix-lint.yml new file mode 100644 index 000000000..990de3faf --- /dev/null +++ b/.github/workflows/fix-lint.yml @@ -0,0 +1,23 @@ +name: Fix Lint Command +on: + issue_comment: + types: [created] +jobs: + deploy: + runs-on: ubuntu-latest + if: >- + github.event.issue.pull_request != '' && + ( + contains(github.event.comment.body, '/fix') + ) + permissions: + pull-requests: write + steps: + - uses: actions/checkout@v2 + with: + ref: refs/pull/${{ github.event.issue.number }}/head + - run: pnpm lint --fix + - name: Push Changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/merge-next.yml b/.github/workflows/merge-next.yml new file mode 100644 index 000000000..9bed1b3d7 --- /dev/null +++ b/.github/workflows/merge-next.yml @@ -0,0 +1,27 @@ +name: Update Base Branch Command +on: + issue_comment: + types: [created] +jobs: + deploy: + runs-on: ubuntu-latest + if: >- + github.event.issue.pull_request != '' && + ( + contains(github.event.comment.body, '/update') + ) + permissions: + pull-requests: write + contents: write + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Fetch all history so we can merge branches + - name: Fetch All Branches + run: git fetch --all + - name: Checkout PR + run: git checkout ${{ github.event.issue.pull_request.head.ref }} + - name: Merge From Next + run: git merge origin/next --strategy-option=theirs + - name: Push Changes + run: git push diff --git a/package.json b/package.json index 80c6fdac2..c0ac0cc1a 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ "@dimaka/interface": "0.0.3-alpha.0", "@floating-ui/react": "^0.26.1", "@mui/base": "5.0.0-beta.40", - "@nxg-org/mineflayer-auto-jump": "^0.7.7", - "@nxg-org/mineflayer-tracker": "^1.2.1", + "@nxg-org/mineflayer-auto-jump": "^0.7.12", + "@nxg-org/mineflayer-tracker": "^1.2.3", "@react-oauth/google": "^0.12.1", "@stylistic/eslint-plugin": "^2.6.1", "@types/gapi": "^0.0.47", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 84ea8fa16..05b83f3cf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,11 +45,11 @@ importers: specifier: 5.0.0-beta.40 version: 5.0.0-beta.40(@types/react@18.2.20)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@nxg-org/mineflayer-auto-jump': - specifier: ^0.7.7 - version: 0.7.7 + specifier: ^0.7.12 + version: 0.7.12 '@nxg-org/mineflayer-tracker': - specifier: ^1.2.1 - version: 1.2.1 + specifier: ^1.2.3 + version: 1.2.3 '@react-oauth/google': specifier: ^0.12.1 version: 0.12.1(react-dom@18.2.0(react@18.2.0))(react@18.2.0) @@ -160,7 +160,7 @@ importers: version: 6.1.1 prismarine-provider-anvil: specifier: github:zardoy/prismarine-provider-anvil#everything - version: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/0228b5252f48a0d6ad7f36d7189851c427fbe8c4(minecraft-data@3.65.0) + version: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/a3f462dc81ded5b46e88e3442f99aadf35f7f699(minecraft-data@3.65.0) prosemirror-example-setup: specifier: ^1.2.2 version: 1.2.2 @@ -2110,14 +2110,14 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} deprecated: This functionality has been moved to @npmcli/fs - '@nxg-org/mineflayer-auto-jump@0.7.7': - resolution: {integrity: sha512-50FYsz5rxBuLzOh7wqmg9iN9zdVGD+QjuaPcw/mD7q8Bq6Bq+o1/DfXfpoNGIHaDag80q6FJSpc73MI3Scid8g==} + '@nxg-org/mineflayer-auto-jump@0.7.12': + resolution: {integrity: sha512-F5vX/lerlWx/5HVlkDNbvrtQ19PL6iG8i4ItPTIRtjGiFzusDefP7DI226zSFR8Wlaw45qHv0jn814p/4/qVdQ==} '@nxg-org/mineflayer-physics-util@1.5.8': resolution: {integrity: sha512-KmCkAqpUo8BbuRdIBs6+V2hWHehz++PRz3lRwIsb47CuG0u4sgLYh37RY3ifAznC6uWvmPK+q3B4ZXwJzPy1MQ==} - '@nxg-org/mineflayer-tracker@1.2.1': - resolution: {integrity: sha512-SI1ffF8zvg3/ZNE021Ja2W0FZPN+WbQDZf8yFqOcXtPRXAtM9W6HvoACdzXep8BZid7WYgYLIgjKpB+9RqvCNQ==} + '@nxg-org/mineflayer-tracker@1.2.3': + resolution: {integrity: sha512-E7Ik/scU117Rr6kQUHHMBk8qOGh63YlTCGN33jMfeP7L8xmLeSHN3JtV/fbog8Y+R+HgO99yfZiRAaV7z1T6gQ==} '@nxg-org/mineflayer-trajectories@1.1.1': resolution: {integrity: sha512-X103KXlX8+L3uMeK4jQxMUdTizv01sQRSfBizAF/iOAdfQZehRLXr3CYKeJzfwPYGLN0X0JCl++cMEcZVn4vbg==} @@ -7514,8 +7514,8 @@ packages: prismarine-physics@1.8.0: resolution: {integrity: sha512-gbM+S+bmVtOKVv+Z0WGaHMeEeBHISIDsRDRlv8sr0dex3ZJRhuq8djA02CBreguXtI18ZKh6q3TSj2qDr45NHA==} - prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/0228b5252f48a0d6ad7f36d7189851c427fbe8c4: - resolution: {tarball: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/0228b5252f48a0d6ad7f36d7189851c427fbe8c4} + prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/a3f462dc81ded5b46e88e3442f99aadf35f7f699: + resolution: {tarball: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/a3f462dc81ded5b46e88e3442f99aadf35f7f699} version: 2.8.0 prismarine-realms@1.3.2: @@ -11514,7 +11514,7 @@ snapshots: rimraf: 3.0.2 optional: true - '@nxg-org/mineflayer-auto-jump@0.7.7': + '@nxg-org/mineflayer-auto-jump@0.7.12': dependencies: '@nxg-org/mineflayer-physics-util': 1.5.8 strict-event-emitter-types: 2.0.0 @@ -11523,7 +11523,7 @@ snapshots: dependencies: '@nxg-org/mineflayer-util-plugin': 1.8.3 - '@nxg-org/mineflayer-tracker@1.2.1': + '@nxg-org/mineflayer-tracker@1.2.3': dependencies: '@nxg-org/mineflayer-trajectories': 1.1.1 '@nxg-org/mineflayer-util-plugin': 1.8.3 @@ -13385,7 +13385,7 @@ snapshots: prismarine-entity: 2.3.1 prismarine-item: 1.14.0 prismarine-nbt: 2.5.0 - prismarine-provider-anvil: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/0228b5252f48a0d6ad7f36d7189851c427fbe8c4(minecraft-data@3.65.0) + prismarine-provider-anvil: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/a3f462dc81ded5b46e88e3442f99aadf35f7f699(minecraft-data@3.65.0) prismarine-windows: 2.9.0 prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/187a87f6d71cba12881a7bbaa510ed9085bf6da7 rambda: 9.2.0 @@ -18623,7 +18623,7 @@ snapshots: prismarine-nbt: 2.5.0 vec3: 0.1.8 - prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/0228b5252f48a0d6ad7f36d7189851c427fbe8c4(minecraft-data@3.65.0): + prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/a3f462dc81ded5b46e88e3442f99aadf35f7f699(minecraft-data@3.65.0): dependencies: prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/a69b66ab1e4be6b67f25a5a6db15e0ad39e11819 prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/cea0b6c792d7dcbb69dfd20fa48be5fd60ce83ef(minecraft-data@3.65.0) diff --git a/prismarine-viewer/viewer/lib/mesher/models.ts b/prismarine-viewer/viewer/lib/mesher/models.ts index 8b9115e79..e63a92ea4 100644 --- a/prismarine-viewer/viewer/lib/mesher/models.ts +++ b/prismarine-viewer/viewer/lib/mesher/models.ts @@ -479,15 +479,32 @@ export function getSectionGeometry (sx, sy, sz, world: World) { // cache let { models } = block if (block.models === undefined) { + const props = block.getProperties() try { + // fixme + if (world.preflat) { + if (block.name === 'cobblestone_wall') { + props.up = 'true' + for (const key of ['north', 'south', 'east', 'west']) { + const val = props[key] + if (val === 'false' || val === 'true') { + props[key] = val === 'true' ? 'low' : 'none' + } + } + } + } + models = blockProvider.getAllResolvedModels0_1({ name: block.name, - properties: block.getProperties(), - })! - if (!models.length) models = null + properties: props, + }, world.preflat)! // fixme! this is a hack (also need a setting for all versions) + if (!models.length) { + console.debug('[mesher] block to render not found', block.name, props) + models = null + } } catch (err) { models ??= erroredBlockModel - console.error(`Critical assets error. Unable to get block model for ${block.name}[${JSON.stringify(block.getProperties())}]: ` + err.message, err.stack) + console.error(`Critical assets error. Unable to get block model for ${block.name}[${JSON.stringify(props)}]: ` + err.message, err.stack) attr.hadErrors = true } } diff --git a/prismarine-viewer/viewer/lib/worldrendererCommon.ts b/prismarine-viewer/viewer/lib/worldrendererCommon.ts index 49de2ca01..92fc96819 100644 --- a/prismarine-viewer/viewer/lib/worldrendererCommon.ts +++ b/prismarine-viewer/viewer/lib/worldrendererCommon.ts @@ -100,6 +100,7 @@ export abstract class WorldRendererCommon x: number z: number } + neighborChunkUpdates = true abstract outputFormat: 'threeJs' | 'webgpu' @@ -321,7 +322,7 @@ export abstract class WorldRendererCommon for (let y = this.worldConfig.minY; y < this.worldConfig.worldHeight; y += 16) { const loc = new Vec3(x, y, z) this.setSectionDirty(loc) - if (!isLightUpdate || this.mesherConfig.smoothLighting) { + if (this.neighborChunkUpdates && (!isLightUpdate || this.mesherConfig.smoothLighting)) { this.setSectionDirty(loc.offset(-16, 0, 0)) this.setSectionDirty(loc.offset(16, 0, 0)) this.setSectionDirty(loc.offset(0, 0, -16)) @@ -357,12 +358,14 @@ export abstract class WorldRendererCommon worker.postMessage({ type: 'blockUpdate', pos, stateId }) } this.setSectionDirty(pos) - if ((pos.x & 15) === 0) this.setSectionDirty(pos.offset(-16, 0, 0)) - if ((pos.x & 15) === 15) this.setSectionDirty(pos.offset(16, 0, 0)) - if ((pos.y & 15) === 0) this.setSectionDirty(pos.offset(0, -16, 0)) - if ((pos.y & 15) === 15) this.setSectionDirty(pos.offset(0, 16, 0)) - if ((pos.z & 15) === 0) this.setSectionDirty(pos.offset(0, 0, -16)) - if ((pos.z & 15) === 15) this.setSectionDirty(pos.offset(0, 0, 16)) + if (this.neighborChunkUpdates) { + if ((pos.x & 15) === 0) this.setSectionDirty(pos.offset(-16, 0, 0)) + if ((pos.x & 15) === 15) this.setSectionDirty(pos.offset(16, 0, 0)) + if ((pos.y & 15) === 0) this.setSectionDirty(pos.offset(0, -16, 0)) + if ((pos.y & 15) === 15) this.setSectionDirty(pos.offset(0, 16, 0)) + if ((pos.z & 15) === 0) this.setSectionDirty(pos.offset(0, 0, -16)) + if ((pos.z & 15) === 15) this.setSectionDirty(pos.offset(0, 0, 16)) + } } queueAwaited = false diff --git a/src/globals.d.ts b/src/globals.d.ts index 0f9a36f07..7fc9baecc 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -13,6 +13,7 @@ declare const bot: Omit & { declare const __type_bot: typeof bot declare const viewer: import('prismarine-viewer/viewer/lib/viewer').Viewer declare const worldView: import('prismarine-viewer/viewer/lib/worldDataEmitter').WorldDataEmitter | undefined +declare const addStatPerSec: (name: string) => void declare const localServer: import('flying-squid/dist/index').FullServer & { options } | undefined /** all currently loaded mc data */ declare const mcData: Record diff --git a/src/inventoryWindows.ts b/src/inventoryWindows.ts index b23c88faf..23e898a5a 100644 --- a/src/inventoryWindows.ts +++ b/src/inventoryWindows.ts @@ -54,7 +54,6 @@ export const onGameLoad = (onLoad) => { bot.on('windowOpen', (win) => { if (implementedContainersGuiMap[win.type]) { - // todo also render title! openWindow(implementedContainersGuiMap[win.type]) } else if (options.unimplementedContainers) { openWindow('ChestWin') @@ -385,6 +384,11 @@ const openWindow = (type: string | undefined) => { lastWindow = inv const upWindowItems = () => { + if (!lastWindow && bot.currentWindow) { + // edge case: might happen due to high ping, inventory should be closed soon! + // openWindow(implementedContainersGuiMap[bot.currentWindow.type]) + return + } void Promise.resolve().then(() => upInventoryItems(type === undefined)) } upWindowItems() diff --git a/src/microsoftAuthflow.ts b/src/microsoftAuthflow.ts index 18b3eb0b6..2e7c3a00d 100644 --- a/src/microsoftAuthflow.ts +++ b/src/microsoftAuthflow.ts @@ -93,8 +93,8 @@ export default async ({ tokenCaches, proxyBaseUrl, setProgressText = (text) => { } } -function isPageSecure () { - return window.location.protocol === 'https:' +function isPageSecure (url = window.location.href) { + return !url.startsWith('http:') } // restore dates from strings @@ -161,9 +161,10 @@ function pemToArrayBuffer (pem) { } const urlWithBase = (url: string, base: string) => { - if (!base.startsWith('http')) base = `https://${base}` + const defaultBase = isPageSecure() ? 'https' : 'http' + if (!base.startsWith('http')) base = `${defaultBase}://${base}` const urlObj = new URL(url, base) base = base.replace(/^https?:\/\//, '') - urlObj.host = base.includes(':') ? base : `${base}:${isPageSecure() ? '443' : '80'}` + urlObj.host = base.includes(':') ? base : `${base}:${isPageSecure(base) ? '443' : '80'}` return urlObj } diff --git a/src/optionsGuiScheme.tsx b/src/optionsGuiScheme.tsx index 2082acdb0..015013d15 100644 --- a/src/optionsGuiScheme.tsx +++ b/src/optionsGuiScheme.tsx @@ -1,6 +1,8 @@ import { useState } from 'react' import { useSnapshot } from 'valtio' import { openURL } from 'prismarine-viewer/viewer/lib/simpleUtils' +import { noCase } from 'change-case' +import { titleCase } from 'title-case' import { loadedGameState, miscUiState, openOptionsMenu, showModal } from './globalState' import { AppOptions, options } from './optionsStorage' import Button from './react/Button' @@ -89,6 +91,7 @@ export const guiOptionsScheme: { tooltip: 'Additional distance to keep the chunks loading before unloading them by marking them as too far', }, handDisplay: {}, + neighborChunkUpdates: {}, }, ], main: [ @@ -228,7 +231,40 @@ export const guiOptionsScheme: { 'never' ], }, - } + }, + { + custom () { + return Experimental + }, + displayBossBars: { + text: 'Boss Bars', + }, + }, + { + custom () { + return + }, + }, + { + custom () { + return + }, + }, + { + custom () { + return + }, + }, + { + custom () { + return + }, + }, + { + custom () { + return + }, + }, ], controls: [ { @@ -391,6 +427,20 @@ const Category = ({ children }) =>
{children}
+const UiToggleButton = ({ name, addUiText = false, label = noCase(name) }) => { + const { disabledUiParts } = useSnapshot(options) + + const currentlyDisabled = disabledUiParts.includes(name) + if (addUiText) label = `${label} UI` + return +} + export const tryFindOptionConfig = (option: keyof AppOptions) => { for (const group of Object.values(guiOptionsScheme)) { for (const optionConfig of group) { diff --git a/src/optionsStorage.ts b/src/optionsStorage.ts index b7bf4abed..d5a9e5aa8 100644 --- a/src/optionsStorage.ts +++ b/src/optionsStorage.ts @@ -82,6 +82,9 @@ const defaultOptions = { /** Wether to popup sign editor on server action */ autoSignEditor: true, wysiwygSignEditor: 'auto' as 'auto' | 'always' | 'never', + displayBossBars: false, // boss bar overlay was removed for some reason, enable safely + disabledUiParts: [] as string[], + neighborChunkUpdates: true } function getDefaultTouchControlsPositions () { diff --git a/src/preflatMap.json b/src/preflatMap.json index fdf2640ff..81c2a20a4 100644 --- a/src/preflatMap.json +++ b/src/preflatMap.json @@ -925,18 +925,18 @@ "143:11": "oak_button[face=wall,facing=south,powered=true]", "143:12": "oak_button[face=wall,facing=north,powered=true]", "143:13": "oak_button[face=floor,facing=north,powered=true]", - "144:0": "undefined[facing=down,nodrop=false]", - "144:1": "undefined[facing=up,nodrop=false]", - "144:2": "undefined[facing=north,nodrop=false]", - "144:3": "undefined[facing=south,nodrop=false]", - "144:4": "undefined[facing=west,nodrop=false]", - "144:5": "undefined[facing=east,nodrop=false]", - "144:8": "undefined[facing=down,nodrop=true]", - "144:9": "undefined[facing=up,nodrop=true]", - "144:10": "undefined[facing=north,nodrop=true]", - "144:11": "undefined[facing=south,nodrop=true]", - "144:12": "undefined[facing=west,nodrop=true]", - "144:13": "undefined[facing=east,nodrop=true]", + "144:0": "player_head[facing=down]", + "144:1": "player_head[facing=up]", + "144:2": "player_head[facing=north]", + "144:3": "player_head[facing=south]", + "144:4": "player_head[facing=west]", + "144:5": "player_head[facing=east]", + "144:8": "player_head[facing=down]", + "144:9": "player_head[facing=up]", + "144:10": "player_head[facing=north]", + "144:11": "player_head[facing=south]", + "144:12": "player_head[facing=west]", + "144:13": "player_head[facing=east]", "145:0": "anvil[facing=south]", "145:1": "anvil[facing=west]", "145:2": "anvil[facing=north]", diff --git a/src/react/BossBarOverlayProvider.tsx b/src/react/BossBarOverlayProvider.tsx index 9bb7d9480..5cac3c8ac 100644 --- a/src/react/BossBarOverlayProvider.tsx +++ b/src/react/BossBarOverlayProvider.tsx @@ -1,5 +1,4 @@ import { useState, useEffect } from 'react' -import { BotEvents } from 'mineflayer' import BossBar, { BossBarType } from './BossBarOverlay' import './BossBarOverlay.css' @@ -8,9 +7,8 @@ export default () => { const [bossBars, setBossBars] = useState(new Map()) useEffect(() => { - // typescript error: no bossBarCreated in BotEvents. Why?? - bot.on('bossBarCreated' as keyof BotEvents, (bossBar) => { - setBossBars(prevBossBars => new Map(prevBossBars.set(bossBar.entityUUID, bossBar))) + bot.on('bossBarCreated', (bossBar) => { + setBossBars(prevBossBars => new Map(prevBossBars.set(bossBar.entityUUID, bossBar as any))) }) bot.on('bossBarUpdated', (bossBar) => { setBossBars(prevBossBars => new Map(prevBossBars.set(bossBar.entityUUID, bossBar as BossBarType))) diff --git a/src/react/DebugOverlay.tsx b/src/react/DebugOverlay.tsx index 9315d8a49..23f0d7db1 100644 --- a/src/react/DebugOverlay.tsx +++ b/src/react/DebugOverlay.tsx @@ -14,10 +14,17 @@ export default () => { received: {} as { [key: string]: number }, sent: {} as { [key: string]: number } }) + window.packetsCountByNamePerSec = packetsCountByNamePerSec + const packetsCountByNamePer10Sec = useRef({ + received: {} as { [key: string]: number }, + sent: {} as { [key: string]: number } + }) + window.packetsCountByNamePer10Sec = packetsCountByNamePer10Sec const packetsCountByName = useRef({ received: {} as { [key: string]: number }, sent: {} as { [key: string]: number } }) + window.packetsCountByName = packetsCountByName const ignoredPackets = useRef(new Set([] as any[])) const [packetsString, setPacketsString] = useState('') const [showDebug, setShowDebug] = useState(false) @@ -62,9 +69,11 @@ export default () => { const managePackets = (type, name, data) => { packetsCountByName.current[type][name] ??= 0 packetsCountByName.current[type][name]++ + packetsCountByNamePerSec.current[type][name] ??= 0 + packetsCountByNamePerSec.current[type][name]++ + packetsCountByNamePer10Sec.current[type][name] ??= 0 + packetsCountByNamePer10Sec.current[type][name]++ if (options.debugLogNotFrequentPackets && !ignoredPackets.current.has(name) && !hardcodedListOfDebugPacketsToIgnore[type].includes(name)) { - packetsCountByNamePerSec.current[type][name] ??= 0 - packetsCountByNamePerSec.current[type][name]++ if (packetsCountByNamePerSec.current[type][name] > 5 || packetsCountByName.current[type][name] > 100) { // todo think of tracking the count within 10s console.info(`[packet ${name} was ${type} too frequent] Ignoring...`) ignoredPackets.current.add(name) @@ -76,12 +85,17 @@ export default () => { useEffect(() => { document.addEventListener('keydown', handleF3) + let update = 0 const packetsUpdateInterval = setInterval(() => { setPacketsString(`↓ ${received.current.count} (${(received.current.size / 1024).toFixed(2)} KB/s, ${getFixedFilesize(receivedTotal.current)}) ↑ ${sent.current.count}`) received.current = { ...defaultPacketsCount } sent.current = { ...defaultPacketsCount } packetsCountByNamePerSec.current.received = {} packetsCountByNamePerSec.current.sent = {} + if (update++ % 10 === 0) { + packetsCountByNamePer10Sec.current.received = {} + packetsCountByNamePer10Sec.current.sent = {} + } }, 1000) const freqUpdateInterval = setInterval(() => { diff --git a/src/react/IndicatorEffectsProvider.tsx b/src/react/IndicatorEffectsProvider.tsx index 00b78d8a1..b82782e66 100644 --- a/src/react/IndicatorEffectsProvider.tsx +++ b/src/react/IndicatorEffectsProvider.tsx @@ -3,6 +3,7 @@ import { useEffect, useMemo } from 'react' import { inGameError } from '../utils' import { fsState } from '../loadSave' import { miscUiState } from '../globalState' +import { options } from '../optionsStorage' import IndicatorEffects, { EffectType, defaultIndicatorsState } from './IndicatorEffects' import { images } from './effectsImages' @@ -52,6 +53,7 @@ const getEffectIndex = (newEffect: EffectType) => { export default () => { const stateIndicators = useSnapshot(state.indicators) const { hasErrors } = useSnapshot(miscUiState) + const { disabledUiParts } = useSnapshot(options) const { isReadonly, openReadOperations, openWriteOperations } = useSnapshot(fsState) const allIndicators: typeof defaultIndicatorsState = { readonlyFiles: isReadonly, diff --git a/src/react/ScoreboardProvider.tsx b/src/react/ScoreboardProvider.tsx index bcae99079..cb67b9416 100644 --- a/src/react/ScoreboardProvider.tsx +++ b/src/react/ScoreboardProvider.tsx @@ -10,6 +10,7 @@ export default function ScoreboardProvider () { useMemo(() => { // useMemo instead of useEffect to register them asap and not after the initial dom render const updateSidebarScoreboard = () => { + addStatPerSec('scoreboard') if (bot.scoreboard.sidebar) { setTitle(bot.scoreboard.sidebar.title) setItems([...bot.scoreboard.sidebar.items]) diff --git a/src/reactUi.tsx b/src/reactUi.tsx index 029b24934..2fb63c197 100644 --- a/src/reactUi.tsx +++ b/src/reactUi.tsx @@ -42,6 +42,8 @@ import BedTime from './react/BedTime' import NoModalFoundProvider from './react/NoModalFoundProvider' import SignInMessageProvider from './react/SignInMessageProvider' import BookProvider from './react/BookProvider' +import { options } from './optionsStorage' +import BossBarOverlayProvider from './react/BossBarOverlayProvider' const RobustPortal = ({ children, to }) => { return createPortal({children}, to) @@ -99,34 +101,36 @@ const InGameComponent = ({ children }) => { const InGameUi = () => { const { gameLoaded, showUI: showUIRaw } = useSnapshot(miscUiState) + const { disabledUiParts, displayBossBars } = useSnapshot(options) const hasModals = useSnapshot(activeModalStack).length > 0 const showUI = showUIRaw || hasModals - if (!gameLoaded || !bot) return + if (!gameLoaded || !bot || disabledUiParts.includes('*')) return return <> {/* apply scaling */}
- - - - - + {!disabledUiParts.includes('death-screen') && } + {!disabledUiParts.includes('debug-overlay') && } + {!disabledUiParts.includes('mobile-top-buttons') && } + {!disabledUiParts.includes('players-list') && } + {!disabledUiParts.includes('chat') && } - - - - - + {!disabledUiParts.includes('title') && } + {!disabledUiParts.includes('scoreboard') && } + {!disabledUiParts.includes('effects-indicators') && } + {!disabledUiParts.includes('crosshair') && } + {!disabledUiParts.includes('books') && } + {!disabledUiParts.includes('bossbars') && displayBossBars && }
- - + {!disabledUiParts.includes('xp-bar') && } + {!disabledUiParts.includes('hud-bars') && }
- {showUI && } + {showUI && !disabledUiParts.includes('hotbar') && }
diff --git a/src/shims/dns.js b/src/shims/dns.js index 0bbe5320d..22160ff33 100644 --- a/src/shims/dns.js +++ b/src/shims/dns.js @@ -26,6 +26,7 @@ module.exports.resolveSrv = function (hostname, callback) { const willreturn = [] for (const object of response.Answer) { const data = object.data.split(' ') + if (data[3] === undefined || data[2] === undefined) continue willreturn.push({ priority: data[0], weight: data[1], diff --git a/src/watchOptions.ts b/src/watchOptions.ts index d26d2b90d..926c6be1d 100644 --- a/src/watchOptions.ts +++ b/src/watchOptions.ts @@ -62,6 +62,10 @@ export const watchOptionsAfterViewerInit = () => { if (!(viewer.world instanceof WorldRendererThree)) return viewer.world.starField.enabled = o.starfieldRendering }) + + watchValue(options, o => { + viewer.world.neighborChunkUpdates = o.neighborChunkUpdates + }) } let viewWatched = false