Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfixes #44

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

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

28 changes: 15 additions & 13 deletions prismarine-viewer/viewer/lib/worldrenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class WorldRenderer {
lastCamUpdate = 0
droppedFpsPercentage = 0
initialChunksLoad = true
enableChunksLoadDelay = false

texturesVersion?: string

Expand Down Expand Up @@ -66,19 +67,19 @@ export class WorldRenderer {
const chunkCoords = data.key.split(',')
if (!this.loadedChunks[chunkCoords[0] + ',' + chunkCoords[2]] || !data.geometry.positions.length || !this.active) return

if (!this.initialChunksLoad) {
const newPromise = new Promise(resolve => {
if (this.droppedFpsPercentage > 0.5) {
setTimeout(resolve, 1000 / 50 * this.droppedFpsPercentage)
} else {
setTimeout(resolve)
}
})
this.promisesQueue.push(newPromise)
for (const promise of this.promisesQueue) {
await promise
}
}
// if (!this.initialChunksLoad && this.enableChunksLoadDelay) {
// const newPromise = new Promise(resolve => {
// if (this.droppedFpsPercentage > 0.5) {
// setTimeout(resolve, 1000 / 50 * this.droppedFpsPercentage)
// } else {
// setTimeout(resolve)
// }
// })
// this.promisesQueue.push(newPromise)
// for (const promise of this.promisesQueue) {
// await promise
// }
// }

const geometry = new THREE.BufferGeometry()
geometry.setAttribute('position', new THREE.BufferAttribute(data.geometry.positions, 3))
Expand All @@ -95,6 +96,7 @@ export class WorldRenderer {
const boxHelper = new THREE.BoxHelper(mesh, 0xffff00)
boxHelper.name = 'helper'
object.add(boxHelper)
object.name = 'chunk'
if (!this.showChunkBorders) {
boxHelper.visible = false
}
Expand Down
18 changes: 17 additions & 1 deletion src/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,17 @@ contro.on('trigger', ({ command }) => {
openPlayerInventory()
break
case 'general.drop':
if (bot.heldItem) bot.tossStack(bot.heldItem)
// if (bot.heldItem/* && ctrl */) bot.tossStack(bot.heldItem)
bot._client.write('block_dig', {
'status': 4,
'location': {
'x': 0,
'z': 0,
'y': 0
},
'face': 0,
sequence: 0
})
break
case 'general.chat':
document.getElementById('hud').shadowRoot.getElementById('chat').enableChat()
Expand Down Expand Up @@ -235,6 +245,12 @@ export const f3Keybinds = [
for (const [x, z] of loadedChunks) {
worldView!.unloadChunk({ x, z })
}
for (const child of viewer.scene.children) {
if (child.name === 'chunk') { // should not happen
viewer.scene.remove(child)
console.warn('forcefully removed chunk from scene')
}
}
if (localServer) {
//@ts-expect-error not sure why it is private... maybe revisit api?
localServer.players[0].world.columns = {}
Expand Down
2 changes: 1 addition & 1 deletion src/react/Singleplayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default ({ worldData, onGeneralAction, onWorldAction }: Props) => {
</div>
<div style={{ display: 'flex', flexDirection: 'column', minWidth: 400 }}>
<div>
<Button ref={firstButton} disabled={!focusedWorld} onClick={() => onWorldAction('load', focusedWorld)}>LOAD WORLD</Button>
<Button rootRef={firstButton} disabled={!focusedWorld} onClick={() => onWorldAction('load', focusedWorld)}>LOAD WORLD</Button>
<Button onClick={() => onGeneralAction('create')}>Create New World</Button>
</div>
<div>
Expand Down