Skip to content

Commit

Permalink
next releae (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy authored Sep 9, 2024
2 parents eb76701 + 2c971f3 commit 9bcdd29
Show file tree
Hide file tree
Showing 20 changed files with 222 additions and 67 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
23 changes: 23 additions & 0 deletions .github/workflows/fix-lint.yml
Original file line number Diff line number Diff line change
@@ -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 }}
27 changes: 27 additions & 0 deletions .github/workflows/merge-next.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 15 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 21 additions & 4 deletions prismarine-viewer/viewer/lib/mesher/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
17 changes: 10 additions & 7 deletions prismarine-viewer/viewer/lib/worldrendererCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export abstract class WorldRendererCommon<WorkerSend = any, WorkerReceive = any>
x: number
z: number
}
neighborChunkUpdates = true

abstract outputFormat: 'threeJs' | 'webgpu'

Expand Down Expand Up @@ -321,7 +322,7 @@ export abstract class WorldRendererCommon<WorkerSend = any, WorkerReceive = any>
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))
Expand Down Expand Up @@ -357,12 +358,14 @@ export abstract class WorldRendererCommon<WorkerSend = any, WorkerReceive = any>
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
Expand Down
1 change: 1 addition & 0 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ declare const bot: Omit<import('mineflayer').Bot, 'world' | '_client'> & {
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<string, any>
Expand Down
6 changes: 5 additions & 1 deletion src/inventoryWindows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 5 additions & 4 deletions src/microsoftAuthflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
52 changes: 51 additions & 1 deletion src/optionsGuiScheme.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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: [
Expand Down Expand Up @@ -228,7 +231,40 @@ export const guiOptionsScheme: {
'never'
],
},
}
},
{
custom () {
return <Category>Experimental</Category>
},
displayBossBars: {
text: 'Boss Bars',
},
},
{
custom () {
return <UiToggleButton name='title' addUiText />
},
},
{
custom () {
return <UiToggleButton name='chat' addUiText />
},
},
{
custom () {
return <UiToggleButton name='scoreboard' addUiText />
},
},
{
custom () {
return <UiToggleButton name='effects-indicators' />
},
},
{
custom () {
return <UiToggleButton name='hotbar' />
},
},
],
controls: [
{
Expand Down Expand Up @@ -391,6 +427,20 @@ const Category = ({ children }) => <div style={{
gridColumn: 'span 2'
}}>{children}</div>

const UiToggleButton = ({ name, addUiText = false, label = noCase(name) }) => {
const { disabledUiParts } = useSnapshot(options)

const currentlyDisabled = disabledUiParts.includes(name)
if (addUiText) label = `${label} UI`
return <Button
inScreen
onClick={() => {
const newDisabledUiParts = currentlyDisabled ? disabledUiParts.filter(x => x !== name) : [...disabledUiParts, name]
options.disabledUiParts = newDisabledUiParts
}}
>{currentlyDisabled ? 'Enable' : 'Disable'} {label}</Button>
}

export const tryFindOptionConfig = (option: keyof AppOptions) => {
for (const group of Object.values(guiOptionsScheme)) {
for (const optionConfig of group) {
Expand Down
3 changes: 3 additions & 0 deletions src/optionsStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
Loading

0 comments on commit 9bcdd29

Please sign in to comment.