From e129184ff1d14388a0d4d7b2d5a57e5a7f031422 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Mon, 27 May 2024 10:14:42 +0300 Subject: [PATCH 001/985] fix tsc --- src/workerWorkaround.ts | 2 ++ tsconfig.json | 1 + 2 files changed, 3 insertions(+) diff --git a/src/workerWorkaround.ts b/src/workerWorkaround.ts index 00419b8c..7fad22cf 100644 --- a/src/workerWorkaround.ts +++ b/src/workerWorkaround.ts @@ -1,2 +1,4 @@ +//@ts-nocheck +// eslint-disable-next-line no-global-assign global = globalThis globalThis.window = globalThis diff --git a/tsconfig.json b/tsconfig.json index dbbb9ced..454e60cb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,7 @@ "forceConsistentCasingInFileNames": true, "useUnknownInCatchVariables": false, "skipLibCheck": true, + "experimentalDecorators": true, "strictBindCallApply": true, // this the only options that allows smooth transition from js to ts (by not dropping types from js files) // however might need to consider includeing *only needed libraries* instead of using this From 68269ee975f7c1f0d620dc6aac02b3efe2d5b533 Mon Sep 17 00:00:00 2001 From: gguio <109200692+gguio@users.noreply.github.com> Date: Mon, 27 May 2024 12:24:28 +0400 Subject: [PATCH 002/985] feat: Screenshot on F2 and hide/show UI on F1 (#136) Co-authored-by: gguio --- src/controls.ts | 18 ++++++++++++++++++ src/globalState.ts | 1 + src/index.ts | 2 ++ src/reactUi.tsx | 4 +++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/controls.ts b/src/controls.ts index f940d59d..a3a22029 100644 --- a/src/controls.ts +++ b/src/controls.ts @@ -651,6 +651,24 @@ window.addEventListener('keydown', (e) => { } }) +window.addEventListener('keydown', (e) => { + if (e.code !== 'F2' || e.repeat || !isGameActive(true)) return + e.preventDefault() + const canvas = document.getElementById('viewer-canvas') as HTMLCanvasElement + if (!canvas) return + const link = document.createElement('a') + link.href = canvas.toDataURL('image/png') + const date = new Date() + link.download = `screenshot ${date.toLocaleString().replaceAll('.', '-').replace(',', '')}.png` + link.click() +}) + +window.addEventListener('keydown', (e) => { + if (e.code !== 'F1' || e.repeat || !isGameActive(true)) return + e.preventDefault() + miscUiState.showUI = !miscUiState.showUI +}) + // #region experimental debug things window.addEventListener('keydown', (e) => { if (e.code === 'F11') { diff --git a/src/globalState.ts b/src/globalState.ts index 4b62f8d6..b7dc1602 100644 --- a/src/globalState.ts +++ b/src/globalState.ts @@ -138,6 +138,7 @@ export const miscUiState = proxy({ wanOpened: false, /** wether game hud is shown (in playing state) */ gameLoaded: false, + showUI: true, loadedServerIndex: '', /** currently trying to load or loaded mc version, after all data is loaded */ loadedDataVersion: null as string | null, diff --git a/src/index.ts b/src/index.ts index 89baaa10..d02f7b92 100644 --- a/src/index.ts +++ b/src/index.ts @@ -108,6 +108,8 @@ let renderer: THREE.WebGLRenderer try { renderer = new THREE.WebGLRenderer({ powerPreference: options.gpuPreference, + preserveDrawingBuffer: true, + logarithmicDepthBuffer: true, }) } catch (err) { console.error(err) diff --git a/src/reactUi.tsx b/src/reactUi.tsx index d86cf202..497f091f 100644 --- a/src/reactUi.tsx +++ b/src/reactUi.tsx @@ -143,6 +143,8 @@ const WidgetDisplay = ({ name, Component }) => { } const App = () => { + const { showUI } = useSnapshot(miscUiState) + return
@@ -154,7 +156,7 @@ const App = () => {
- + {showUI && } From cbaeb8c9186be140634f577d9396f129e39b81e0 Mon Sep 17 00:00:00 2001 From: gguio <109200692+gguio@users.noreply.github.com> Date: Tue, 28 May 2024 13:34:22 +0400 Subject: [PATCH 003/985] fix hide ui was resetting state (#138) --- src/reactUi.tsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/reactUi.tsx b/src/reactUi.tsx index 497f091f..ab1e4ae5 100644 --- a/src/reactUi.tsx +++ b/src/reactUi.tsx @@ -95,7 +95,7 @@ const InGameComponent = ({ children }) => { } const InGameUi = () => { - const { gameLoaded } = useSnapshot(miscUiState) + const { gameLoaded, showUI } = useSnapshot(miscUiState) if (!gameLoaded) return return <> @@ -107,17 +107,21 @@ const InGameUi = () => { - - - +
+ + + + +
- - - - - +
+ + + +
+ {showUI && }
From def2baba8fd728a16f38feb9649b3a4b95d6a12e Mon Sep 17 00:00:00 2001 From: Vitaly Date: Tue, 28 May 2024 18:52:15 +0300 Subject: [PATCH 004/985] rm unused pmui-playscreen --- index.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/index.html b/index.html index 3e921855..6d3b326b 100644 --- a/index.html +++ b/index.html @@ -94,9 +94,7 @@
-
- -
+
From 295967cc4d6ff4b5b9f83b6fe4f6b2c7f4600158 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Wed, 29 May 2024 10:56:57 +0300 Subject: [PATCH 005/985] fix inspectPacket function --- src/devtools.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/devtools.ts b/src/devtools.ts index 4dbeb51d..e836af02 100644 --- a/src/devtools.ts +++ b/src/devtools.ts @@ -29,7 +29,7 @@ window.len = (obj) => Object.keys(obj).length window.inspectPacket = (packetName, full = false) => { const listener = (...args) => console.log('packet', packetName, full ? args : args[0]) const attach = () => { - bot?.on(packetName, listener) + bot?._client.on(packetName, listener) } attach() customEvents.on('mineflayerBotCreated', attach) From d96ff9ef3a23fc130a0133cc5c2b67dfa41da538 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Wed, 29 May 2024 11:16:42 +0300 Subject: [PATCH 006/985] fix: was unable to go edit server screen after hitting cancel --- src/react/ServersListProvider.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/react/ServersListProvider.tsx b/src/react/ServersListProvider.tsx index bd39bc10..bb23004f 100644 --- a/src/react/ServersListProvider.tsx +++ b/src/react/ServersListProvider.tsx @@ -186,6 +186,12 @@ const Inner = () => { } }, [serverEditScreen]) + useDidUpdateEffect(() => { + if (!isEditScreenModal) { + setServerEditScreen(null) + } + }, [isEditScreenModal]) + if (isEditScreenModal) { return Date: Sat, 1 Jun 2024 10:36:04 +0300 Subject: [PATCH 007/985] fix: page was reloading infinitely in some edge cases, give some time service workers to unregister in these cases --- src/react/MainMenu.tsx | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/react/MainMenu.tsx b/src/react/MainMenu.tsx index f99b6b98..3e3170f4 100644 --- a/src/react/MainMenu.tsx +++ b/src/react/MainMenu.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from 'react' import { openURL } from 'prismarine-viewer/viewer/lib/simpleUtils' import { haveDirectoryPicker } from '../utils' +import { activeModalStack } from '../globalState' import styles from './mainMenu.module.css' import Button from './Button' import ButtonWithTooltip from './ButtonWithTooltip' @@ -17,12 +18,24 @@ interface Props { mapsProvider?: string } -const refreshApp = async () => { +const refreshApp = async (failedUpdate = false) => { const registration = await navigator.serviceWorker.getRegistration() await registration?.unregister() - window.justReloaded = true - sessionStorage.justReloaded = true - window.location.reload() + if (failedUpdate) { + await new Promise(resolve => { + setTimeout(resolve, 2000) + }) + } + if (activeModalStack.length !== 0) return + if (failedUpdate) { + sessionStorage.justReloaded = false + // try to force bypass cache + location.search = '?update=true' + } else { + window.justReloaded = true + sessionStorage.justReloaded = true + window.location.reload() + } } const httpsRegex = /^https?:\/\// @@ -40,10 +53,10 @@ export default ({ connectToServerAction, mapsProvider, singleplayerAction, optio const contents = await f.text() const isLatest = contents === process.env.BUILD_VERSION if (!isLatest && sessionStorage.justReloaded) { - // try to force bypass cache - location.search = '?update=true' + setVersionStatus('(force reloading, wait)') + void refreshApp(true) + return } - sessionStorage.justReloaded = false setVersionStatus(`(${isLatest ? 'latest' : 'new version available'})`) setVersionTitle(`Loaded: ${process.env.BUILD_VERSION}. Remote: ${contents}`) }, () => { }) From c5e636f2416312cf58c8a84cb0937f5cad007c23 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 2 Jun 2024 00:59:23 +0300 Subject: [PATCH 008/985] fix (and now check) hide ui --- src/reactUi.tsx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/reactUi.tsx b/src/reactUi.tsx index ab1e4ae5..2f57e6f0 100644 --- a/src/reactUi.tsx +++ b/src/reactUi.tsx @@ -101,19 +101,19 @@ const InGameUi = () => { return <> {/* apply scaling */} - - - - - -
+ + + + + + +
-
@@ -129,7 +129,7 @@ const InGameUi = () => { {/* because of z-index */} - + {showUI && } @@ -147,8 +147,6 @@ const WidgetDisplay = ({ name, Component }) => { } const App = () => { - const { showUI } = useSnapshot(miscUiState) - return
@@ -160,7 +158,7 @@ const App = () => {
- {showUI && } + From 0b2e92c8606a66782243fc632985b569178112f2 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 2 Jun 2024 10:29:29 +0300 Subject: [PATCH 009/985] fix sentry 5431874132 --- src/react/HotbarRenderApp.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/react/HotbarRenderApp.tsx b/src/react/HotbarRenderApp.tsx index 02689485..9c6dbe40 100644 --- a/src/react/HotbarRenderApp.tsx +++ b/src/react/HotbarRenderApp.tsx @@ -88,7 +88,7 @@ export default () => { return } const hotbarSlot = slot - bot.inventory.hotbarStart - if (hotbarSlot < 0 || hotbarSlot > 9) return + if (hotbarSlot < 0 || hotbarSlot > 8) return bot.setQuickBarSlot(hotbarSlot) }, } as any) From b317d8ad354e375b4a00c146eafeebf4d86a4170 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 2 Jun 2024 14:20:21 +0300 Subject: [PATCH 010/985] fix: reduce fps drops on chunks load a bit by batching operations with a few other minor optimizations --- prismarine-viewer/viewer/lib/entities.js | 39 +++++++++-------- prismarine-viewer/viewer/lib/mesher/mesher.ts | 36 +++++++++++++++- prismarine-viewer/viewer/lib/threeJsUtils.ts | 8 ++-- .../viewer/lib/worldDataEmitter.ts | 11 ++++- .../viewer/lib/worldrendererCommon.ts | 34 +++++++++++++-- .../viewer/lib/worldrendererThree.ts | 43 ++++++++++++++++--- src/optionsGuiScheme.tsx | 3 +- src/react/DebugOverlay.tsx | 26 ++++++----- src/watchOptions.ts | 2 +- src/worldInteractions.ts | 1 + 10 files changed, 153 insertions(+), 50 deletions(-) diff --git a/prismarine-viewer/viewer/lib/entities.js b/prismarine-viewer/viewer/lib/entities.js index 930f62c9..28fc6d89 100644 --- a/prismarine-viewer/viewer/lib/entities.js +++ b/prismarine-viewer/viewer/lib/entities.js @@ -17,7 +17,7 @@ import { disposeObject } from './threeJsUtils' export const TWEEN_DURATION = 50 // todo should be 100 -function getUsernameTexture (username, { fontFamily = 'sans-serif' }) { +function getUsernameTexture(username, { fontFamily = 'sans-serif' }) { const canvas = document.createElement('canvas') const ctx = canvas.getContext('2d') if (!ctx) throw new Error('Could not get 2d context') @@ -61,7 +61,7 @@ const addNametag = (entity, options, mesh) => { // todo cleanup const nametags = {} -function getEntityMesh (entity, scene, options, overrides) { +function getEntityMesh(entity, scene, options, overrides) { if (entity.name) { try { // https://github.com/PrismarineJS/prismarine-viewer/pull/410 @@ -94,18 +94,19 @@ function getEntityMesh (entity, scene, options, overrides) { export class Entities extends EventEmitter { constructor(scene) { super() + /** @type {THREE.Scene} */ this.scene = scene this.entities = {} this.entitiesOptions = {} this.debugMode = 'none' this.onSkinUpdate = () => { } this.clock = new THREE.Clock() - this.visible = true + this.rendering = true this.itemsTexture = null this.getItemUv = undefined } - clear () { + clear() { for (const mesh of Object.values(this.entities)) { this.scene.remove(mesh) disposeObject(mesh) @@ -113,7 +114,7 @@ export class Entities extends EventEmitter { this.entities = {} } - setDebugMode (mode, /** @type {THREE.Object3D?} */entity = null) { + setDebugMode(mode, /** @type {THREE.Object3D?} */entity = null) { this.debugMode = mode for (const mesh of entity ? [entity] : Object.values(this.entities)) { const boxHelper = mesh.children.find(c => c.name === 'debug') @@ -125,14 +126,18 @@ export class Entities extends EventEmitter { } } - setVisible (visible, /** @type {THREE.Object3D?} */entity = null) { - this.visible = visible - for (const mesh of entity ? [entity] : Object.values(this.entities)) { - mesh.visible = visible + setRendering(rendering, /** @type {THREE.Object3D?} */entity = null) { + this.rendering = rendering + for (const ent of entity ? [entity] : Object.values(this.entities)) { + if (rendering) { + if (!this.scene.children.includes(ent)) this.scene.add(ent) + } else { + this.scene.remove(ent) + } } } - render () { + render() { const dt = this.clock.getDelta() for (const entityId of Object.keys(this.entities)) { const playerObject = this.getPlayerObject(entityId) @@ -142,7 +147,7 @@ export class Entities extends EventEmitter { } } - getPlayerObject (entityId) { + getPlayerObject(entityId) { /** @type {(PlayerObject & { animation?: PlayerAnimation }) | undefined} */ const playerObject = this.entities[entityId]?.playerObject return playerObject @@ -152,7 +157,7 @@ export class Entities extends EventEmitter { defaultSteveTexture // true means use default skin url - updatePlayerSkin (entityId, username, /** @type {string | true} */skinUrl, /** @type {string | true | undefined} */capeUrl = undefined) { + updatePlayerSkin(entityId, username, /** @type {string | true} */skinUrl, /** @type {string | true | undefined} */capeUrl = undefined) { let playerObject = this.getPlayerObject(entityId) if (!playerObject) return // const username = this.entities[entityId].username @@ -235,14 +240,14 @@ export class Entities extends EventEmitter { playerObject.cape.map = null } - function isCanvasBlank (canvas) { + function isCanvasBlank(canvas) { return !canvas.getContext('2d') .getImageData(0, 0, canvas.width, canvas.height).data .some(channel => channel !== 0) } } - playAnimation (entityPlayerId, /** @type {'walking' | 'running' | 'oneSwing' | 'idle'} */animation) { + playAnimation(entityPlayerId, /** @type {'walking' | 'running' | 'oneSwing' | 'idle'} */animation) { const playerObject = this.getPlayerObject(entityPlayerId) if (!playerObject) return @@ -262,14 +267,14 @@ export class Entities extends EventEmitter { } - displaySimpleText (jsonLike) { + displaySimpleText(jsonLike) { if (!jsonLike) return const parsed = typeof jsonLike === 'string' ? mojangson.simplify(mojangson.parse(jsonLike)) : nbt.simplify(jsonLike) const text = flat(parsed).map(x => x.text) return text.join('') } - update (/** @type {import('prismarine-entity').Entity & {delete?, pos}} */entity, overrides) { + update(/** @type {import('prismarine-entity').Entity & {delete?, pos}} */entity, overrides) { let isPlayerModel = entity.name === 'player' if (entity.name === 'zombie' || entity.name === 'zombie_villager' || entity.name === 'husk') { isPlayerModel = true @@ -392,7 +397,7 @@ export class Entities extends EventEmitter { this.updatePlayerSkin(entity.id, '', overrides?.texture || stevePng) } this.setDebugMode(this.debugMode, group) - this.setVisible(this.visible, group) + this.setRendering(this.rendering, group) } //@ts-ignore diff --git a/prismarine-viewer/viewer/lib/mesher/mesher.ts b/prismarine-viewer/viewer/lib/mesher/mesher.ts index bc1d3bbb..d0c82280 100644 --- a/prismarine-viewer/viewer/lib/mesher/mesher.ts +++ b/prismarine-viewer/viewer/lib/mesher/mesher.ts @@ -19,6 +19,29 @@ function sectionKey (x, y, z) { return `${x},${y},${z}` } +const batchMessagesLimit = 100 + +let queuedMessages = [] as any[] +let queueWaiting = false +const postMessage = (data, transferList = []) => { + queuedMessages.push({ data, transferList }) + if (queuedMessages.length > batchMessagesLimit) { + drainQueue(0, batchMessagesLimit) + } + if (queueWaiting) return + queueWaiting = true + setTimeout(() => { + queueWaiting = false + drainQueue(0, queuedMessages.length) + }) +} + +function drainQueue (from, to) { + const messages = queuedMessages.slice(from, to) + global.postMessage(messages.map(m => m.data), messages.flatMap(m => m.transferList) as unknown as string) + queuedMessages = queuedMessages.slice(to) +} + function setSectionDirty (pos, value = true) { const x = Math.floor(pos.x / 16) * 16 const y = Math.floor(pos.y / 16) * 16 @@ -43,7 +66,7 @@ const softCleanup = () => { world = new World(world.config.version) } -self.onmessage = ({ data }) => { +const handleMessage = data => { const globalVar: any = globalThis if (data.type === 'mcData') { @@ -52,7 +75,7 @@ self.onmessage = ({ data }) => { if (data.config) { world ??= new World(data.config.version) - world.config = {...world.config, ...data.config} + world.config = { ...world.config, ...data.config } globalThis.world = world } @@ -80,6 +103,15 @@ self.onmessage = ({ data }) => { } } +self.onmessage = ({ data }) => { + if (Array.isArray(data)) { + data.forEach(handleMessage) + return + } + + handleMessage(data) +} + setInterval(() => { if (world === null || !blockStatesReady) return diff --git a/prismarine-viewer/viewer/lib/threeJsUtils.ts b/prismarine-viewer/viewer/lib/threeJsUtils.ts index e4f9404b..ee22c477 100644 --- a/prismarine-viewer/viewer/lib/threeJsUtils.ts +++ b/prismarine-viewer/viewer/lib/threeJsUtils.ts @@ -1,12 +1,12 @@ -import * as THREE from 'three'; +import * as THREE from 'three' export const disposeObject = (obj: THREE.Object3D) => { // not cleaning texture there as it might be used by other objects, but would be good to also do that if (obj instanceof THREE.Mesh) { - obj.geometry?.dispose?.(); - obj.material?.dispose?.(); + obj.geometry?.dispose?.() + obj.material?.dispose?.() } if (obj.children) { - obj.children.forEach(disposeObject); + obj.children.forEach(disposeObject) } } diff --git a/prismarine-viewer/viewer/lib/worldDataEmitter.ts b/prismarine-viewer/viewer/lib/worldDataEmitter.ts index 40cc3413..3a8fbd40 100644 --- a/prismarine-viewer/viewer/lib/worldDataEmitter.ts +++ b/prismarine-viewer/viewer/lib/worldDataEmitter.ts @@ -129,6 +129,15 @@ export class WorldDataEmitter extends EventEmitter { } } + readdDebug () { + const clonedLoadedChunks = { ...this.loadedChunks } + this.unloadAllChunks() + for (const loadedChunk in clonedLoadedChunks) { + const [x, z] = loadedChunk.split(',').map(Number) + this.loadChunk(new Vec3(x, 0, z)) + } + } + async loadChunk (pos: ChunkPos, isLightUpdate = false) { const [botX, botZ] = chunkPos(this.lastPos) const dx = Math.abs(botX - Math.floor(pos.x / 16)) @@ -187,7 +196,7 @@ export class WorldDataEmitter extends EventEmitter { const positions = generateSpiralMatrix(this.viewDistance).map(([x, z]) => { const pos = new Vec3((botX + x) * 16, 0, (botZ + z) * 16) if (!this.loadedChunks[`${pos.x},${pos.z}`]) return pos - return undefined + return undefined! }).filter(a => !!a) this.lastPos.update(pos) await this._loadChunks(positions) diff --git a/prismarine-viewer/viewer/lib/worldrendererCommon.ts b/prismarine-viewer/viewer/lib/worldrendererCommon.ts index d1786650..1a87fa5d 100644 --- a/prismarine-viewer/viewer/lib/worldrendererCommon.ts +++ b/prismarine-viewer/viewer/lib/worldrendererCommon.ts @@ -73,10 +73,10 @@ export abstract class WorldRendererCommon const src = typeof window === 'undefined' ? `${__dirname}/${workerName}` : workerName const worker: any = new Worker(src) - worker.onmessage = async ({ data }) => { + const handleMessage = (data) => { if (!this.active) return this.handleWorkerMessage(data) - await new Promise(resolve => { + new Promise(resolve => { setTimeout(resolve, 0) }) if (data.type === 'sectionFinished') { @@ -105,6 +105,13 @@ export abstract class WorldRendererCommon this.renderUpdateEmitter.emit('update') } } + worker.onmessage = ({ data }) => { + if (Array.isArray(data)) { + data.forEach(handleMessage) + return + } + handleMessage(data) + } if (worker.on) worker.on('message', (data) => { worker.onmessage({ data }) }) this.workers.push(worker) } @@ -215,6 +222,7 @@ export abstract class WorldRendererCommon } addColumn (x: number, z: number, chunk: any, isLightUpdate: boolean) { + if (!this.active) return if (this.workers.length === 0) throw new Error('workers not initialized yet') this.initialChunksLoad = false this.loadedChunks[`${x},${z}`] = true @@ -256,6 +264,9 @@ export abstract class WorldRendererCommon if ((pos.z & 15) === 15) this.setSectionDirty(pos.offset(0, 0, 16)) } + queueAwaited = false + messagesQueue = {} as { [workerIndex: string]: any[] } + setSectionDirty (pos: Vec3, value = true) { if (this.viewDistance === -1) throw new Error('viewDistance not set') this.allChunksFinished = false @@ -269,7 +280,9 @@ export abstract class WorldRendererCommon // is always dispatched to the same worker const hash = mod(Math.floor(pos.x / 16) + Math.floor(pos.y / 16) + Math.floor(pos.z / 16), this.workers.length) this.sectionsOutstanding.set(key, (this.sectionsOutstanding.get(key) ?? 0) + 1) - this.workers[hash].postMessage({ + this.messagesQueue[hash] ??= [] + this.messagesQueue[hash].push({ + // this.workers[hash].postMessage({ type: 'dirty', x: pos.x, y: pos.y, @@ -277,6 +290,21 @@ export abstract class WorldRendererCommon value, config: this.mesherConfig, }) + this.dispatchMessages() + } + + dispatchMessages () { + if (this.queueAwaited) return + this.queueAwaited = true + setTimeout(() => { + // group messages and send as one + for (const workerIndex in this.messagesQueue) { + const worker = this.workers[Number(workerIndex)] + worker.postMessage(this.messagesQueue[workerIndex]) + } + this.messagesQueue = {} + this.queueAwaited = false + }) } // Listen for chunk rendering updates emitted if a worker finished a render and resolve if the number diff --git a/prismarine-viewer/viewer/lib/worldrendererThree.ts b/prismarine-viewer/viewer/lib/worldrendererThree.ts index 60156a50..4d28519a 100644 --- a/prismarine-viewer/viewer/lib/worldrendererThree.ts +++ b/prismarine-viewer/viewer/lib/worldrendererThree.ts @@ -16,6 +16,7 @@ export class WorldRendererThree extends WorldRendererCommon { chunkTextures = new Map() signsCache = new Map() starField: StarField + cameraSectionPos: Vec3 = new Vec3(0, 0, 0) get tilesRendered () { return Object.values(this.sectionObjects).reduce((acc, obj) => acc + (obj as any).tilesCount, 0) @@ -42,16 +43,18 @@ export class WorldRendererThree extends WorldRendererCommon { */ updatePosDataChunk (key: string) { const [x, y, z] = key.split(',').map(x => Math.floor(+x / 16)) - const [xPlayer, yPlayer, zPlayer] = this.camera.position.toArray().map(x => Math.floor(x / 16)) // sum of distances: x + y + z - const chunkDistance = Math.abs(x - xPlayer) + Math.abs(y - yPlayer) + Math.abs(z - zPlayer) + const chunkDistance = Math.abs(x - this.cameraSectionPos.x) + Math.abs(y - this.cameraSectionPos.y) + Math.abs(z - this.cameraSectionPos.z) const section = this.sectionObjects[key].children.find(child => child.name === 'mesh')! section.renderOrder = 500 - chunkDistance } updateViewerPosition (pos: Vec3): void { this.viewerPosition = pos - for (const [key, value] of Object.entries(this.sectionObjects)) { + const cameraPos = this.camera.position.toArray().map(x => Math.floor(x / 16)) as [number, number, number] + this.cameraSectionPos = new Vec3(...cameraPos) + for (const key in this.sectionObjects) { + const value = this.sectionObjects[key] if (!value) continue this.updatePosDataChunk(key) } @@ -95,7 +98,10 @@ export class WorldRendererThree extends WorldRendererCommon { mesh.name = 'mesh' object = new THREE.Group() object.add(mesh) - const boxHelper = new THREE.BoxHelper(mesh, 0xffff00) + // mesh with static dimensions: 16x16x16 + const staticChunkMesh = new THREE.Mesh(new THREE.BoxGeometry(16, 16, 16), new THREE.MeshBasicMaterial({ color: 0x000000, transparent: true, opacity: 0 })) + staticChunkMesh.position.set(data.geometry.sx, data.geometry.sy, data.geometry.sz) + const boxHelper = new THREE.BoxHelper(staticChunkMesh, 0xffff00) boxHelper.name = 'helper' object.add(boxHelper) object.name = 'chunk' @@ -117,6 +123,11 @@ export class WorldRendererThree extends WorldRendererCommon { } this.sectionObjects[data.key] = object this.updatePosDataChunk(data.key) + object.matrixAutoUpdate = false + mesh.onAfterRender = (renderer, scene, camera, geometry, material, group) => { + // mesh.matrixAutoUpdate = false + } + this.scene.add(object) } @@ -253,6 +264,24 @@ export class WorldRendererThree extends WorldRendererCommon { } } + readdChunks () { + for (const key of Object.keys(this.sectionObjects)) { + this.scene.remove(this.sectionObjects[key]) + } + setTimeout(() => { + for (const key of Object.keys(this.sectionObjects)) { + this.scene.add(this.sectionObjects[key]) + } + }, 500) + } + + disableUpdates (children = this.scene.children) { + for (const child of children) { + child.matrixWorldNeedsUpdate = false + this.disableUpdates(child.children ?? []) + } + } + removeColumn (x, z) { super.removeColumn(x, z) @@ -332,7 +361,7 @@ class StarField { this.points = new THREE.Points(geometry, material) this.scene.add(this.points) - const clock = new THREE.Clock(); + const clock = new THREE.Clock() this.points.onBeforeRender = (renderer, scene, camera) => { this.points?.position.copy?.(camera.position) material.uniforms.time.value = clock.getElapsedTime() * speed @@ -342,10 +371,10 @@ class StarField { remove () { if (this.points) { this.points.geometry.dispose(); - (this.points.material as THREE.Material).dispose(); + (this.points.material as THREE.Material).dispose() this.scene.remove(this.points) - this.points = undefined; + this.points = undefined } } } diff --git a/src/optionsGuiScheme.tsx b/src/optionsGuiScheme.tsx index 88e6115f..9be844d3 100644 --- a/src/optionsGuiScheme.tsx +++ b/src/optionsGuiScheme.tsx @@ -69,7 +69,8 @@ export const guiOptionsScheme: { enableWarning: 'Enabling it will make chunks load ~4x slower', disabledDuringGame: true }, - starfieldRendering: {} + starfieldRendering: {}, + renderEntities: {}, }, ], main: [ diff --git a/src/react/DebugOverlay.tsx b/src/react/DebugOverlay.tsx index 4b3c19b1..dd288b49 100644 --- a/src/react/DebugOverlay.tsx +++ b/src/react/DebugOverlay.tsx @@ -83,6 +83,16 @@ export default () => { packetsCountByNamePerSec.current.sent = {} }, 1000) + const freqUpdateInterval = setInterval(() => { + setPos(prev => { return { ...bot.entity.position } }) + setSkyL(prev => bot.world.getSkyLight(bot.entity.position)) + setBlockL(prev => bot.world.getBlockLight(bot.entity.position)) + setBiomeId(prev => bot.world.getBiome(bot.entity.position)) + setDimension(bot.game.dimension) + setDay(bot.time.day) + setCursorBlock(worldInteractions.cursorBlock) + }, 100) + // @ts-expect-error bot._client.on('packet', readPacket) // @ts-expect-error @@ -91,25 +101,12 @@ export default () => { sent.current.count++ managePackets('sent', name, data) }) - bot.on('move', () => { - setPos(prev => { return { ...bot.entity.position }}) - setSkyL(prev => bot.world.getSkyLight(bot.entity.position)) - setBlockL(prev => bot.world.getBlockLight(bot.entity.position)) - setBiomeId(prev => bot.world.getBiome(bot.entity.position)) - setDimension(bot.game.dimension) - }) - bot.on('time', () => { - setDay(bot.time.day) - }) bot.on('entitySpawn', () => { setEntitiesCount(Object.values(bot.entities).length) }) bot.on('entityGone', () => { setEntitiesCount(Object.values(bot.entities).length) }) - bot.on('physicsTick', () => { - setCursorBlock(worldInteractions.cursorBlock) - }) try { const gl = window.renderer.getContext() @@ -121,6 +118,7 @@ export default () => { return () => { document.removeEventListener('keydown', handleF3) clearInterval(packetsUpdateInterval) + clearInterval(freqUpdateInterval) } }, []) @@ -169,7 +167,7 @@ export default () => { ) } ) - : '' } + : ''} {cursorBlock ? (

Looking at: {cursorBlock.position.x} {cursorBlock.position.y} {cursorBlock.position.z}

) : ''} diff --git a/src/watchOptions.ts b/src/watchOptions.ts index 4ff34be4..e379cb50 100644 --- a/src/watchOptions.ts +++ b/src/watchOptions.ts @@ -41,7 +41,7 @@ export const watchOptionsAfterViewerInit = () => { }) watchValue(options, o => { - viewer.entities.setVisible(o.renderEntities) + viewer.entities.setRendering(o.renderEntities) }) // viewer.world.mesherConfig.smoothLighting = options.smoothLighting diff --git a/src/worldInteractions.ts b/src/worldInteractions.ts index 239c02c2..330dabd7 100644 --- a/src/worldInteractions.ts +++ b/src/worldInteractions.ts @@ -73,6 +73,7 @@ class WorldInteraction { this.blockBreakMesh = new THREE.Mesh(new THREE.BoxGeometry(1, 1, 1), breakMaterial) this.blockBreakMesh.visible = false this.blockBreakMesh.renderOrder = 999 + this.blockBreakMesh.name = 'blockBreakMesh' viewer.scene.add(this.blockBreakMesh) // Setup events From 95b80d93ba95cc887ccdf964484c396ab2cb06ee Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 4 Jun 2024 01:45:33 +0300 Subject: [PATCH 011/985] fix: waterlogged z-fighting fix --- prismarine-viewer/viewer/lib/mesher/models.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/prismarine-viewer/viewer/lib/mesher/models.ts b/prismarine-viewer/viewer/lib/mesher/models.ts index 40b82ea2..39148aaa 100644 --- a/prismarine-viewer/viewer/lib/mesher/models.ts +++ b/prismarine-viewer/viewer/lib/mesher/models.ts @@ -35,7 +35,7 @@ function prepareTints (tints) { }) } -const calculatedBlocksEntries = Object.entries(legacyJson.clientCalculatedBlocks); +const calculatedBlocksEntries = Object.entries(legacyJson.clientCalculatedBlocks) export function preflatBlockCalculation (block: Block, world: World, position: Vec3) { const type = calculatedBlocksEntries.find(([name, blocks]) => blocks.includes(block.name))?.[0] if (!type) return @@ -239,9 +239,9 @@ function renderLiquid (world, cursor, texture, type, biome, water, attr) { for (const pos of corners) { const height = cornerHeights[pos[2] * 2 + pos[0]] attr.t_positions.push( - (pos[0] ? 1 : 0) + (cursor.x & 15) - 8, - (pos[1] ? height : 0) + (cursor.y & 15) - 8, - (pos[2] ? 1 : 0) + (cursor.z & 15) - 8) + (pos[0] ? 0.999 : 0.001) + (cursor.x & 15) - 8, + (pos[1] ? height - 0.001 : 0.001) + (cursor.y & 15) - 8, + (pos[2] ? 0.999 : 0.001) + (cursor.z & 15) - 8) attr.t_normals.push(...dir) attr.t_uvs.push(pos[3] * su + u, pos[4] * sv * (pos[1] ? 1 : height) + v) attr.t_colors.push(tint[0], tint[1], tint[2]) From 28e24a7a870a8b217f4d1d3b85f2b39473765c4f Mon Sep 17 00:00:00 2001 From: Wolf2323 Date: Tue, 4 Jun 2024 01:34:29 +0200 Subject: [PATCH 012/985] fix: fix rendering of Decorated Pot (#134) --- .../viewer/lib/mesher/test/tests.test.ts | 1 - prismarine-viewer/viewer/prepare/atlas.ts | 42 ++++++++++++--- .../blockModels/1.20/decorated_pot.json | 47 +++++++++++++++++ .../blockStates/1.20/decorated_pot.json | 19 +++++++ .../data/1.20/blockModels/decorated_pot.json | 47 +++++++++++++++++ .../data/1.20/blockStates/decorated_pot.json | 19 +++++++ .../viewer/prepare/moreGeneratedBlocks.ts | 51 +++++++++++++++++-- 7 files changed, 214 insertions(+), 12 deletions(-) create mode 100644 prismarine-viewer/viewer/prepare/blockModels/1.20/decorated_pot.json create mode 100644 prismarine-viewer/viewer/prepare/blockStates/1.20/decorated_pot.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/decorated_pot.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/decorated_pot.json diff --git a/prismarine-viewer/viewer/lib/mesher/test/tests.test.ts b/prismarine-viewer/viewer/lib/mesher/test/tests.test.ts index 75dd98fa..5a80fa49 100644 --- a/prismarine-viewer/viewer/lib/mesher/test/tests.test.ts +++ b/prismarine-viewer/viewer/lib/mesher/test/tests.test.ts @@ -77,7 +77,6 @@ test('Known blocks are not rendered', () => { "cyan_wall_banner": true, "dark_oak_hanging_sign": true, "dark_oak_wall_hanging_sign": true, - "decorated_pot": true, "dragon_head": true, "dragon_wall_head": true, "end_gateway": true, diff --git a/prismarine-viewer/viewer/prepare/atlas.ts b/prismarine-viewer/viewer/prepare/atlas.ts index cb30b727..fc3e4029 100644 --- a/prismarine-viewer/viewer/prepare/atlas.ts +++ b/prismarine-viewer/viewer/prepare/atlas.ts @@ -35,7 +35,7 @@ export type JsonAtlas = { } } -export const makeTextureAtlas = (input: string[], getInputData: (name) => { contents: string, tileWidthMult?: number }, tilesCount = input.length, suSvOptimize: 'remove' | null = null): { +export const makeTextureAtlas = (input: string[], getInputData: (name) => { contents: string, tileWidthMult?: number, origSizeTextures?}, tilesCount = input.length, suSvOptimize: 'remove' | null = null): { image: Buffer, canvas: Canvas, json: JsonAtlas @@ -49,6 +49,7 @@ export const makeTextureAtlas = (input: string[], getInputData: (name) => { cont const texturesIndex = {} + let skipXY = [] as [x: number, y: number][] let offset = 0 const suSv = tileSize / imgSize for (const i in input) { @@ -56,20 +57,44 @@ export const makeTextureAtlas = (input: string[], getInputData: (name) => { cont const x = (pos % texSize) * tileSize const y = Math.floor(pos / texSize) * tileSize + if (skipXY.some(([sx, sy]) => sx === x + 1 && sy === y)) { + // todo more offsets + offset++ + } + const img = new Image() - const keyValue = input[i]; - const inputData = getInputData(keyValue); + const keyValue = input[i] + const inputData = getInputData(keyValue) img.src = inputData.contents - const renderWidth = tileSize * (inputData.tileWidthMult ?? 1) - g.drawImage(img, 0, 0, renderWidth, tileSize, x, y, renderWidth, tileSize) + let su = suSv + let sv = suSv + let renderWidth = tileSize * (inputData.tileWidthMult ?? 1) + let renderHeight = tileSize + if (inputData.origSizeTextures?.[keyValue]) { + // todo check have enough space + renderWidth = Math.ceil(img.width / tileSize) * tileSize + renderHeight = Math.ceil(img.height / tileSize) * tileSize + su = renderWidth / imgSize + sv = renderHeight / imgSize + if (renderWidth > tileSize) { + offset += Math.ceil(renderWidth / tileSize) - 1 + } + if (renderHeight > tileSize) { + const skipYs = Math.ceil(renderHeight / tileSize) - 1 + for (let i = 1; i <= skipYs; i++) { + skipXY.push([x, y + i]) + } + } + } + g.drawImage(img, 0, 0, renderWidth, renderHeight, x, y, renderWidth, renderHeight) const cleanName = keyValue.split('.').slice(0, -1).join('.') || keyValue texturesIndex[cleanName] = { u: x / imgSize, v: y / imgSize, ...suSvOptimize === 'remove' ? {} : { - su: suSv, - sv: suSv + su: su, + sv: sv } } } @@ -91,7 +116,7 @@ export function makeBlockTextureAtlas (mcAssets: McAssets) { // const textureFiles = mostEncounteredBlocks.map(x => x + '.png') textureFiles.unshift(...localTextures) - const { generated: additionalTextures, twoTileTextures } = getAdditionalTextures() + const { generated: additionalTextures, twoTileTextures, origSizeTextures } = getAdditionalTextures() textureFiles.push(...Object.keys(additionalTextures)) const atlas = makeTextureAtlas(textureFiles, name => { @@ -105,6 +130,7 @@ export function makeBlockTextureAtlas (mcAssets: McAssets) { return { contents, tileWidthMult: twoTileTextures.includes(name) ? 2 : undefined, + origSizeTextures } }) return atlas diff --git a/prismarine-viewer/viewer/prepare/blockModels/1.20/decorated_pot.json b/prismarine-viewer/viewer/prepare/blockModels/1.20/decorated_pot.json new file mode 100644 index 00000000..364c72d4 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/blockModels/1.20/decorated_pot.json @@ -0,0 +1,47 @@ +{ + "texture_size": [32, 32], + "textures": { + "0": "entity/decorated_pot/decorated_pot_base" + }, + "elements": [ + { + "name": "Body", + "from": [1, 0, 1], + "to": [15, 16, 15], + "faces": { + "north": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, + "east": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, + "south": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, + "west": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, + "up": {"uv": [7, 6.5, 14, 13.5], "texture": "#0"}, + "down": {"uv": [7, 6.5, 14, 13.5], "texture": "#0"} + } + }, + { + "name": "Neck", + "from": [5, 16, 5], + "to": [11, 17, 11], + "faces": { + "north": {"uv": [6, 5.5, 9, 6], "texture": "#0"}, + "east": {"uv": [9, 5.5, 12, 6], "texture": "#0"}, + "south": {"uv": [2.5, 5.5, 5.5, 6], "texture": "#0"}, + "west": {"uv": [0, 5.5, 3, 6], "texture": "#0"}, + "up": {"uv": [0, 0, 3, 3], "texture": "#0"}, + "down": {"uv": [0, 0, 3, 3], "texture": "#0"} + } + }, + { + "name": "Head", + "from": [4, 17, 4], + "to": [12, 20, 12], + "faces": { + "north": {"uv": [0, 4, 4, 5.5], "texture": "#0"}, + "east": {"uv": [4, 4, 8, 5.5], "texture": "#0"}, + "south": {"uv": [8, 4, 12, 5.5], "texture": "#0"}, + "west": {"uv": [12, 4, 16, 5.5], "texture": "#0"}, + "up": {"uv": [4, 0, 8, 4], "texture": "#0"}, + "down": {"uv": [8, 0, 12, 4], "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/blockStates/1.20/decorated_pot.json b/prismarine-viewer/viewer/prepare/blockStates/1.20/decorated_pot.json new file mode 100644 index 00000000..5b46a220 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/blockStates/1.20/decorated_pot.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "decorated_pot", + "y": 90 + }, + "facing=south": { + "model": "decorated_pot", + "y": 180 + }, + "facing=west": { + "model": "decorated_pot", + "y": 270 + }, + "facing=north": { + "model": "decorated_pot" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/decorated_pot.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/decorated_pot.json new file mode 100644 index 00000000..364c72d4 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/decorated_pot.json @@ -0,0 +1,47 @@ +{ + "texture_size": [32, 32], + "textures": { + "0": "entity/decorated_pot/decorated_pot_base" + }, + "elements": [ + { + "name": "Body", + "from": [1, 0, 1], + "to": [15, 16, 15], + "faces": { + "north": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, + "east": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, + "south": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, + "west": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, + "up": {"uv": [7, 6.5, 14, 13.5], "texture": "#0"}, + "down": {"uv": [7, 6.5, 14, 13.5], "texture": "#0"} + } + }, + { + "name": "Neck", + "from": [5, 16, 5], + "to": [11, 17, 11], + "faces": { + "north": {"uv": [6, 5.5, 9, 6], "texture": "#0"}, + "east": {"uv": [9, 5.5, 12, 6], "texture": "#0"}, + "south": {"uv": [2.5, 5.5, 5.5, 6], "texture": "#0"}, + "west": {"uv": [0, 5.5, 3, 6], "texture": "#0"}, + "up": {"uv": [0, 0, 3, 3], "texture": "#0"}, + "down": {"uv": [0, 0, 3, 3], "texture": "#0"} + } + }, + { + "name": "Head", + "from": [4, 17, 4], + "to": [12, 20, 12], + "faces": { + "north": {"uv": [0, 4, 4, 5.5], "texture": "#0"}, + "east": {"uv": [4, 4, 8, 5.5], "texture": "#0"}, + "south": {"uv": [8, 4, 12, 5.5], "texture": "#0"}, + "west": {"uv": [12, 4, 16, 5.5], "texture": "#0"}, + "up": {"uv": [4, 0, 8, 4], "texture": "#0"}, + "down": {"uv": [8, 0, 12, 4], "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/decorated_pot.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/decorated_pot.json new file mode 100644 index 00000000..5b46a220 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/decorated_pot.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "decorated_pot", + "y": 90 + }, + "facing=south": { + "model": "decorated_pot", + "y": 180 + }, + "facing=west": { + "model": "decorated_pot", + "y": 270 + }, + "facing=north": { + "model": "decorated_pot" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts b/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts index ffb1a705..695464ea 100644 --- a/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts +++ b/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts @@ -7,6 +7,7 @@ import { fileURLToPath } from 'url' // todo refactor const twoTileTextures: string[] = [] +const origSizeTextures: string[] = [] let currentImage: Jimp let currentBlockName: string let currentMcAssets: McAssets @@ -82,7 +83,7 @@ const getBlockTexturesFromJimp = async > (sides: for (const [side, jimp] of Object.entries(sides)) { const textureName = `${textureNameBase}_${side}` const sideTexture = withUv ? { uv: [0, 0, jimp.getWidth(), jimp.getHeight()], texture: textureName } : textureName - const base64 = await jimp.getBase64Async(jimp.getMIME()) + const base64Url = await jimp.getBase64Async(jimp.getMIME()) if (side === 'side') { sidesTextures['north'] = sideTexture sidesTextures['east'] = sideTexture @@ -91,7 +92,7 @@ const getBlockTexturesFromJimp = async > (sides: } else { sidesTextures[side] = sideTexture } - generatedImageTextures[textureName] = base64 + generatedImageTextures[textureName] = base64Url } return sidesTextures @@ -229,6 +230,7 @@ const handleSign = async (dataBase: string, match: RegExpExecArray) => { twoTileTextures.push(blockTextures.up.texture) } +// TODO! should not be there! move to data with signs! const chestModels = { chest: { "parent": "block/block", @@ -401,6 +403,32 @@ const handleChest = async (dataBase: string, match: RegExpExecArray) => { currentMcAssets.blocksStates[currentBlockName] = blockStates } +function getParsedJSON (block: string, type: string) { + const versionParts = currentMcAssets.version.split(".") + const version = versionParts[0] + "." + versionParts[1] + return JSON.parse(fs.readFileSync(path.join(__dirname, `${type}/${version}/${block}.json`), 'utf-8')) +} + +function getBlockState (match: string) { + return getParsedJSON(match, 'blockStates') +} + +async function loadBlockModelTextures (dataBase: string, blockModel: any) { + for (const key in Object.entries(blockModel.textures)) { + const texture: string = blockModel.textures[key] + currentImage = await Jimp.read(dataBase + texture + '.png') + blockModel.textures.particle = texture + generatedImageTextures[texture] = `data:image/png;base64,${fs.readFileSync(path.join(dataBase, texture + '.png'), 'base64')}` + origSizeTextures[texture] = true + } +} + +async function getBlockModel (dataBase: string, block: string) { + const blockModel = getParsedJSON(block, 'blockModels') + await loadBlockModelTextures(dataBase, blockModel) + return blockModel +} + const handlers = [ [/(.+)_shulker_box$/, handleShulkerBox], [/^shulker_box$/, handleShulkerBox], @@ -427,6 +455,21 @@ export const tryHandleBlockEntity = async (dataBase, blockName) => { } } +const handleExternalData = async (dataBase: string, version: string) => { + const [major, minor] = version.split(".") + const dataVer = `${major}.${minor}` + if (!fs.existsSync(path.join(__dirname, 'data', dataVer))) return + const allModels = fs.readdirSync(path.join(__dirname, 'data', dataVer, 'blockModels')).map(x => x.replace('.json', '')) + for (const model of allModels) { + currentMcAssets.blocksModels[model] = await getBlockModel(dataBase, model) + } + + const allBlockStates = fs.readdirSync(path.join(__dirname, 'data', dataVer, 'blockStates')).map(x => x.replace('.json', '')) + for (const blockState of allBlockStates) { + currentMcAssets.blocksStates[blockState] = await getBlockState(blockState) + } +} + export const prepareMoreGeneratedBlocks = async (mcAssets: McAssets) => { const mcData = minecraftData(mcAssets.version) const allTheBlocks = mcData.blocksArray.map(x => x.name) @@ -447,6 +490,8 @@ export const prepareMoreGeneratedBlocks = async (mcAssets: McAssets) => { } } + await handleExternalData(mcAssets.directory, mcAssets.version) + const warnings: string[] = [] for (const [name, model] of Object.entries(mcAssets.blocksModels)) { if (Object.keys(model).length === 1 && model.textures) { @@ -462,5 +507,5 @@ export const prepareMoreGeneratedBlocks = async (mcAssets: McAssets) => { } export const getAdditionalTextures = () => { - return { generated: generatedImageTextures, twoTileTextures } + return { generated: generatedImageTextures, twoTileTextures, origSizeTextures } } From 228039c2450dcdee4a858b77ad740b99278e0ada Mon Sep 17 00:00:00 2001 From: Wolf2323 Date: Tue, 4 Jun 2024 12:41:53 +0200 Subject: [PATCH 013/985] cleanup external data handling in more generated blocks (#141) Co-authored-by: Vitaly Turovsky --- .../blockModels/1.20/decorated_pot.json | 47 ------------------- .../blockStates/1.20/decorated_pot.json | 19 -------- .../viewer/prepare/moreGeneratedBlocks.ts | 37 ++++++--------- 3 files changed, 14 insertions(+), 89 deletions(-) delete mode 100644 prismarine-viewer/viewer/prepare/blockModels/1.20/decorated_pot.json delete mode 100644 prismarine-viewer/viewer/prepare/blockStates/1.20/decorated_pot.json diff --git a/prismarine-viewer/viewer/prepare/blockModels/1.20/decorated_pot.json b/prismarine-viewer/viewer/prepare/blockModels/1.20/decorated_pot.json deleted file mode 100644 index 364c72d4..00000000 --- a/prismarine-viewer/viewer/prepare/blockModels/1.20/decorated_pot.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "texture_size": [32, 32], - "textures": { - "0": "entity/decorated_pot/decorated_pot_base" - }, - "elements": [ - { - "name": "Body", - "from": [1, 0, 1], - "to": [15, 16, 15], - "faces": { - "north": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, - "east": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, - "south": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, - "west": {"uv": [0, 6.5, 7, 13.5], "texture": "#0"}, - "up": {"uv": [7, 6.5, 14, 13.5], "texture": "#0"}, - "down": {"uv": [7, 6.5, 14, 13.5], "texture": "#0"} - } - }, - { - "name": "Neck", - "from": [5, 16, 5], - "to": [11, 17, 11], - "faces": { - "north": {"uv": [6, 5.5, 9, 6], "texture": "#0"}, - "east": {"uv": [9, 5.5, 12, 6], "texture": "#0"}, - "south": {"uv": [2.5, 5.5, 5.5, 6], "texture": "#0"}, - "west": {"uv": [0, 5.5, 3, 6], "texture": "#0"}, - "up": {"uv": [0, 0, 3, 3], "texture": "#0"}, - "down": {"uv": [0, 0, 3, 3], "texture": "#0"} - } - }, - { - "name": "Head", - "from": [4, 17, 4], - "to": [12, 20, 12], - "faces": { - "north": {"uv": [0, 4, 4, 5.5], "texture": "#0"}, - "east": {"uv": [4, 4, 8, 5.5], "texture": "#0"}, - "south": {"uv": [8, 4, 12, 5.5], "texture": "#0"}, - "west": {"uv": [12, 4, 16, 5.5], "texture": "#0"}, - "up": {"uv": [4, 0, 8, 4], "texture": "#0"}, - "down": {"uv": [8, 0, 12, 4], "texture": "#0"} - } - } - ] -} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/blockStates/1.20/decorated_pot.json b/prismarine-viewer/viewer/prepare/blockStates/1.20/decorated_pot.json deleted file mode 100644 index 5b46a220..00000000 --- a/prismarine-viewer/viewer/prepare/blockStates/1.20/decorated_pot.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "variants": { - "facing=east": { - "model": "decorated_pot", - "y": 90 - }, - "facing=south": { - "model": "decorated_pot", - "y": 180 - }, - "facing=west": { - "model": "decorated_pot", - "y": 270 - }, - "facing=north": { - "model": "decorated_pot" - } - } -} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts b/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts index 695464ea..b343e595 100644 --- a/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts +++ b/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts @@ -403,18 +403,8 @@ const handleChest = async (dataBase: string, match: RegExpExecArray) => { currentMcAssets.blocksStates[currentBlockName] = blockStates } -function getParsedJSON (block: string, type: string) { - const versionParts = currentMcAssets.version.split(".") - const version = versionParts[0] + "." + versionParts[1] - return JSON.parse(fs.readFileSync(path.join(__dirname, `${type}/${version}/${block}.json`), 'utf-8')) -} - -function getBlockState (match: string) { - return getParsedJSON(match, 'blockStates') -} - async function loadBlockModelTextures (dataBase: string, blockModel: any) { - for (const key in Object.entries(blockModel.textures)) { + for (const key in blockModel.textures) { const texture: string = blockModel.textures[key] currentImage = await Jimp.read(dataBase + texture + '.png') blockModel.textures.particle = texture @@ -423,12 +413,6 @@ async function loadBlockModelTextures (dataBase: string, blockModel: any) { } } -async function getBlockModel (dataBase: string, block: string) { - const blockModel = getParsedJSON(block, 'blockModels') - await loadBlockModelTextures(dataBase, blockModel) - return blockModel -} - const handlers = [ [/(.+)_shulker_box$/, handleShulkerBox], [/^shulker_box$/, handleShulkerBox], @@ -458,15 +442,22 @@ export const tryHandleBlockEntity = async (dataBase, blockName) => { const handleExternalData = async (dataBase: string, version: string) => { const [major, minor] = version.split(".") const dataVer = `${major}.${minor}` - if (!fs.existsSync(path.join(__dirname, 'data', dataVer))) return - const allModels = fs.readdirSync(path.join(__dirname, 'data', dataVer, 'blockModels')).map(x => x.replace('.json', '')) - for (const model of allModels) { - currentMcAssets.blocksModels[model] = await getBlockModel(dataBase, model) + const baseDir = path.join(__dirname, 'data', dataVer) + if (!fs.existsSync(baseDir)) return + + const blockModelsDir = path.join(baseDir, 'blockModels') + const allBlockModels = fs.readdirSync(blockModelsDir).map(x => x.replace('.json', '')) + for (const blockModel of allBlockModels) { + const model = JSON.parse(fs.readFileSync(path.join(blockModelsDir, blockModel + '.json'), 'utf-8')) + currentMcAssets.blocksModels[blockModel] = model + await loadBlockModelTextures(dataBase, model) } - const allBlockStates = fs.readdirSync(path.join(__dirname, 'data', dataVer, 'blockStates')).map(x => x.replace('.json', '')) + const blockStatesDir = path.join(baseDir, 'blockStates') + const allBlockStates = fs.readdirSync(blockStatesDir).map(x => x.replace('.json', '')) for (const blockState of allBlockStates) { - currentMcAssets.blocksStates[blockState] = await getBlockState(blockState) + const state = JSON.parse(fs.readFileSync(path.join(blockStatesDir, blockState + '.json'), 'utf-8')) + currentMcAssets.blocksStates[blockState] = state } } From 32de8ebacda4e63ea93d73219e978ffd9c09123a Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 4 Jun 2024 18:00:42 +0300 Subject: [PATCH 014/985] fix: fix all known minecraft-protocol issues. Fixed auto-version. Fixed: kick messages are now always displayed! --- cypress/minecraft-server.mjs | 1 + pnpm-lock.yaml | 8 ++++---- src/index.ts | 27 +++++++++++++++++---------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/cypress/minecraft-server.mjs b/cypress/minecraft-server.mjs index 18f4e3db..32be0c9d 100644 --- a/cypress/minecraft-server.mjs +++ b/cypress/minecraft-server.mjs @@ -2,6 +2,7 @@ import mcServer from 'flying-squid' import defaultOptions from 'flying-squid/config/default-settings.json' assert { type: 'json' } +/** @type {Options} */ const serverOptions = { ...defaultOptions, 'online-mode': false, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6fdf4afa..8bf3f7d0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -138,7 +138,7 @@ importers: version: 2.0.4 net-browserify: specifier: github:zardoy/prismarinejs-net-browserify - version: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d827dba61bd2f9ac9a6086fe2079a0fccadd070 + version: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434 node-gzip: specifier: ^1.1.2 version: 1.1.2 @@ -6224,8 +6224,8 @@ packages: nested-error-stacks@2.1.1: resolution: {integrity: sha512-9iN1ka/9zmX1ZvLV9ewJYEk9h7RyRRtqdK0woXcqohu8EWIerfPUjYJPg0ULy0UqP7cslmdGc8xKDJcojlKiaw==} - net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d827dba61bd2f9ac9a6086fe2079a0fccadd070: - resolution: {tarball: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d827dba61bd2f9ac9a6086fe2079a0fccadd070} + net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434: + resolution: {tarball: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434} version: 0.2.4 nice-try@1.0.5: @@ -15990,7 +15990,7 @@ snapshots: nested-error-stacks@2.1.1: {} - net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d827dba61bd2f9ac9a6086fe2079a0fccadd070: + net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434: dependencies: body-parser: 1.20.2 express: 4.18.2 diff --git a/src/index.ts b/src/index.ts index d02f7b92..e89bc186 100644 --- a/src/index.ts +++ b/src/index.ts @@ -186,7 +186,7 @@ let lastMouseMove: number const updateCursor = () => { worldInteractions.update() } -function onCameraMove (e) { +function onCameraMove(e) { if (e.type !== 'touchmove' && !pointerLock.hasPointerLock) return e.stopPropagation?.() const now = performance.now() @@ -212,7 +212,7 @@ contro.on('stickMovement', ({ stick, vector }) => { miscUiState.usingGamepadInput = true }) -function hideCurrentScreens () { +function hideCurrentScreens() { activeModalStacks['main-menu'] = [...activeModalStack] insertActiveModalStack('', []) } @@ -220,7 +220,7 @@ function hideCurrentScreens () { const loadSingleplayer = (serverOverrides = {}, flattenedServerOverrides = {}) => { void connect({ singleplayer: true, username: options.localUsername, password: '', serverOverrides, serverOverridesFlat: flattenedServerOverrides }) } -function listenGlobalEvents () { +function listenGlobalEvents() { window.addEventListener('connect', e => { const options = (e as CustomEvent).detail void connect(options) @@ -261,7 +261,7 @@ const cleanConnectIp = (host: string | undefined, defaultPort: string | undefine } } -async function connect (connectOptions: ConnectOptions) { +async function connect(connectOptions: ConnectOptions) { if (miscUiState.gameLoaded) return miscUiState.hasErrors = false lastConnectOptions.value = connectOptions @@ -444,18 +444,18 @@ async function connect (connectOptions: ConnectOptions) { } : {}, ...singleplayer ? { version: serverOptions.version, - connect () { }, + connect() { }, Client: CustomChannelClient as any, } : {}, username, password, viewDistance: renderDistance, checkTimeoutInterval: 240 * 1000, - noPongTimeout: 240 * 1000, + // noPongTimeout: 240 * 1000, closeTimeout: 240 * 1000, respawn: options.autoRespawn, maxCatchupTicks: 0, - async versionSelectedHook (client) { + async versionSelectedHook(client) { await downloadMcData(client.version) setLoadingScreenStatus(initialLoadingText) }, @@ -484,6 +484,13 @@ async function connect (connectOptions: ConnectOptions) { //@ts-expect-error bot._client.socket._ws.addEventListener('close', () => { console.log('WebSocket connection closed') + setTimeout(() => { + if (bot) { + bot.emit('end', 'WebSocket connection closed with unknown reason') + } + }, 1000) + }) + bot._client.socket.on('close', () => { setTimeout(() => { if (bot) { bot.emit('end', 'WebSocket connection closed with unknown reason') @@ -606,7 +613,7 @@ async function connect (connectOptions: ConnectOptions) { dayCycle() // Bot position callback - function botPosition () { + function botPosition() { viewer.world.lastCamUpdate = Date.now() // this might cause lag, but not sure viewer.setFirstPersonCamera(bot.entity.position, bot.entity.yaw, bot.entity.pitch) @@ -626,7 +633,7 @@ async function connect (connectOptions: ConnectOptions) { bot.entity.yaw -= x } - function changeCallback () { + function changeCallback() { if (notificationProxy.id === 'pointerlockchange') { hideNotification() } @@ -895,7 +902,7 @@ downloadAndOpenFile().then((downloadAction) => { const unsubscribe = subscribe(miscUiState, checkCanDisplay) checkCanDisplay() // eslint-disable-next-line no-inner-declarations - function checkCanDisplay () { + function checkCanDisplay() { if (miscUiState.appConfig) { unsubscribe() openServerEditor() From 423aa6a49c75022e48e636b3eaa21509810bfef4 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 4 Jun 2024 18:04:34 +0300 Subject: [PATCH 015/985] fix eslint --- src/index.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index e89bc186..07781028 100644 --- a/src/index.ts +++ b/src/index.ts @@ -186,7 +186,7 @@ let lastMouseMove: number const updateCursor = () => { worldInteractions.update() } -function onCameraMove(e) { +function onCameraMove (e) { if (e.type !== 'touchmove' && !pointerLock.hasPointerLock) return e.stopPropagation?.() const now = performance.now() @@ -212,7 +212,7 @@ contro.on('stickMovement', ({ stick, vector }) => { miscUiState.usingGamepadInput = true }) -function hideCurrentScreens() { +function hideCurrentScreens () { activeModalStacks['main-menu'] = [...activeModalStack] insertActiveModalStack('', []) } @@ -220,7 +220,7 @@ function hideCurrentScreens() { const loadSingleplayer = (serverOverrides = {}, flattenedServerOverrides = {}) => { void connect({ singleplayer: true, username: options.localUsername, password: '', serverOverrides, serverOverridesFlat: flattenedServerOverrides }) } -function listenGlobalEvents() { +function listenGlobalEvents () { window.addEventListener('connect', e => { const options = (e as CustomEvent).detail void connect(options) @@ -261,7 +261,7 @@ const cleanConnectIp = (host: string | undefined, defaultPort: string | undefine } } -async function connect(connectOptions: ConnectOptions) { +async function connect (connectOptions: ConnectOptions) { if (miscUiState.gameLoaded) return miscUiState.hasErrors = false lastConnectOptions.value = connectOptions @@ -444,7 +444,7 @@ async function connect(connectOptions: ConnectOptions) { } : {}, ...singleplayer ? { version: serverOptions.version, - connect() { }, + connect () { }, Client: CustomChannelClient as any, } : {}, username, @@ -455,7 +455,7 @@ async function connect(connectOptions: ConnectOptions) { closeTimeout: 240 * 1000, respawn: options.autoRespawn, maxCatchupTicks: 0, - async versionSelectedHook(client) { + async versionSelectedHook (client) { await downloadMcData(client.version) setLoadingScreenStatus(initialLoadingText) }, @@ -613,7 +613,7 @@ async function connect(connectOptions: ConnectOptions) { dayCycle() // Bot position callback - function botPosition() { + function botPosition () { viewer.world.lastCamUpdate = Date.now() // this might cause lag, but not sure viewer.setFirstPersonCamera(bot.entity.position, bot.entity.yaw, bot.entity.pitch) @@ -633,7 +633,7 @@ async function connect(connectOptions: ConnectOptions) { bot.entity.yaw -= x } - function changeCallback() { + function changeCallback () { if (notificationProxy.id === 'pointerlockchange') { hideNotification() } @@ -902,7 +902,7 @@ downloadAndOpenFile().then((downloadAction) => { const unsubscribe = subscribe(miscUiState, checkCanDisplay) checkCanDisplay() // eslint-disable-next-line no-inner-declarations - function checkCanDisplay() { + function checkCanDisplay () { if (miscUiState.appConfig) { unsubscribe() openServerEditor() From 98da719e08495d75dfac919477ab0d71bf676a9e Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Wed, 5 Jun 2024 11:58:26 +0300 Subject: [PATCH 016/985] fix show ui when has modals --- src/reactUi.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/reactUi.tsx b/src/reactUi.tsx index 2f57e6f0..449d7883 100644 --- a/src/reactUi.tsx +++ b/src/reactUi.tsx @@ -4,7 +4,7 @@ import { useSnapshot } from 'valtio' import { QRCodeSVG } from 'qrcode.react' import { createPortal } from 'react-dom' import { useEffect, useMemo, useState } from 'react' -import { miscUiState } from './globalState' +import { activeModalStack, miscUiState } from './globalState' import DeathScreenProvider from './react/DeathScreenProvider' import OptionsRenderApp from './react/OptionsRenderApp' import MainMenuRenderApp from './react/MainMenuRenderApp' @@ -95,7 +95,9 @@ const InGameComponent = ({ children }) => { } const InGameUi = () => { - const { gameLoaded, showUI } = useSnapshot(miscUiState) + const { gameLoaded, showUI: showUIRaw } = useSnapshot(miscUiState) + const hasModals = useSnapshot(activeModalStack).length > 0 + const showUI = showUIRaw || hasModals if (!gameLoaded) return return <> From 9a41214674458eea922298a2ae66d263b74705fa Mon Sep 17 00:00:00 2001 From: Vitaly Date: Thu, 6 Jun 2024 16:52:05 +0300 Subject: [PATCH 017/985] fix: fix breaking mesh was highlighted --- src/worldInteractions.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/worldInteractions.ts b/src/worldInteractions.ts index 330dabd7..0245d418 100644 --- a/src/worldInteractions.ts +++ b/src/worldInteractions.ts @@ -68,7 +68,8 @@ class WorldInteraction { } const breakMaterial = new THREE.MeshBasicMaterial({ transparent: true, - blending: THREE.MultiplyBlending + blending: THREE.MultiplyBlending, + alphaTest: 0.5, }) this.blockBreakMesh = new THREE.Mesh(new THREE.BoxGeometry(1, 1, 1), breakMaterial) this.blockBreakMesh.visible = false From d04a66738ef5c713379f155ac1f2bfaf1d610e33 Mon Sep 17 00:00:00 2001 From: arhellist <92224498+arhellist@users.noreply.github.com> Date: Thu, 6 Jun 2024 18:23:43 +0400 Subject: [PATCH 018/985] fix game crash (#144) --- src/react/DebugOverlay.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/react/DebugOverlay.tsx b/src/react/DebugOverlay.tsx index dd288b49..c83418f5 100644 --- a/src/react/DebugOverlay.tsx +++ b/src/react/DebugOverlay.tsx @@ -73,7 +73,7 @@ export default () => { } } - useMemo(() => { + useEffect(() => { document.addEventListener('keydown', handleF3) const packetsUpdateInterval = setInterval(() => { setPacketsString(prev => `↓ ${received.current.count} (${(received.current.size / 1024).toFixed(2)} KB/s, ${getFixedFilesize(receivedTotal.current)}) ↑ ${sent.current.count}`) From fec59aac03c5d04c15f9e1932c154fb26b694582 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 6 Jun 2024 17:30:11 +0300 Subject: [PATCH 019/985] up mineflayer --- package.json | 2 +- pnpm-lock.yaml | 49 ++++++++++--------------------------------------- src/index.ts | 9 --------- 3 files changed, 11 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index 9451b266..fa28ae5d 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,7 @@ "http-server": "^14.1.1", "https-browserify": "^1.0.0", "minecraft-inventory-gui": "github:zardoy/minecraft-inventory-gui#next", - "mineflayer": "github:PrismarineJS/mineflayer", + "mineflayer": "github:zardoy/mineflayer", "mineflayer-pathfinder": "^2.4.4", "npm-run-all": "^4.1.5", "os-browserify": "^0.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8bf3f7d0..f9928dc6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -301,8 +301,8 @@ importers: specifier: github:zardoy/minecraft-inventory-gui#next version: https://codeload.github.com/zardoy/minecraft-inventory-gui/tar.gz/200902aca941475e7feb610070e662b172a000b5(@types/react@18.2.20)(react@18.2.0) mineflayer: - specifier: github:PrismarineJS/mineflayer - version: https://codeload.github.com/PrismarineJS/mineflayer/tar.gz/5a544cf2547a6e0f1f17786962d77a33c661c02f(encoding@0.1.13) + specifier: github:zardoy/mineflayer + version: https://codeload.github.com/zardoy/mineflayer/tar.gz/06061e07fe6b9716cb1801d4c1bf232581977192(encoding@0.1.13) mineflayer-pathfinder: specifier: ^2.4.4 version: 2.4.4 @@ -6039,10 +6039,6 @@ packages: resolution: {tarball: https://codeload.github.com/zardoy/minecraft-inventory-gui/tar.gz/200902aca941475e7feb610070e662b172a000b5} version: 1.0.1 - minecraft-protocol@1.47.0: - resolution: {integrity: sha512-IHL8faXLLIWv1O+2v2NgyKlooilu/OiSL9orI8Kqed/rZvVOrFPzs2PwMAYjpQX9gxLPhiSU19KqZ8CjfNuqhg==} - engines: {node: '>=14'} - minecraft-protocol@https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/495eed56ab230b2615596590064671356d86a2dc: resolution: {tarball: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/495eed56ab230b2615596590064671356d86a2dc} version: 1.47.0 @@ -6071,8 +6067,8 @@ packages: resolution: {integrity: sha512-QMMNPx4IyZE7ydAzjvGLQLCnQNUOfkk1qVZKxTTS9q3qPTAewz4GhsVUBtbQ8LSbHthe5RcQ1Sgxs4wlIma/Qw==} engines: {node: '>=18'} - mineflayer@https://codeload.github.com/PrismarineJS/mineflayer/tar.gz/5a544cf2547a6e0f1f17786962d77a33c661c02f: - resolution: {tarball: https://codeload.github.com/PrismarineJS/mineflayer/tar.gz/5a544cf2547a6e0f1f17786962d77a33c661c02f} + mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/06061e07fe6b9716cb1801d4c1bf232581977192: + resolution: {tarball: https://codeload.github.com/zardoy/mineflayer/tar.gz/06061e07fe6b9716cb1801d4c1bf232581977192} version: 4.20.1 engines: {node: '>=18'} @@ -15685,31 +15681,6 @@ snapshots: - '@types/react' - react - minecraft-protocol@1.47.0(patch_hash=2uxevyasyasdavsxuehfavgkjq)(encoding@0.1.13): - dependencies: - '@types/readable-stream': 4.0.12 - aes-js: 3.1.2 - buffer-equal: 1.0.1 - debug: 4.3.4(supports-color@8.1.1) - endian-toggle: 0.0.0 - lodash.get: 4.4.2 - lodash.merge: 4.6.2 - minecraft-data: 3.65.0 - minecraft-folder-path: 1.2.0 - node-fetch: 2.7.0(encoding@0.1.13) - node-rsa: 0.4.2 - prismarine-auth: 2.4.2(encoding@0.1.13) - prismarine-chat: 1.10.1 - prismarine-nbt: 2.5.0 - prismarine-realms: 1.3.2(encoding@0.1.13) - protodef: 1.15.0 - readable-stream: 4.5.2 - uuid-1345: 1.0.2 - yggdrasil: 1.7.0(encoding@0.1.13) - transitivePeerDependencies: - - encoding - - supports-color - minecraft-protocol@https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/495eed56ab230b2615596590064671356d86a2dc(patch_hash=2uxevyasyasdavsxuehfavgkjq)(encoding@0.1.13): dependencies: '@types/readable-stream': 4.0.12 @@ -15804,11 +15775,11 @@ snapshots: mineflayer@4.20.1(encoding@0.1.13): dependencies: minecraft-data: 3.65.0 - minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/ccab9fb39681f3ebe0d264e2a3f833aa3c5a1ac7(patch_hash=2uxevyasyasdavsxuehfavgkjq)(encoding@0.1.13) + minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/495eed56ab230b2615596590064671356d86a2dc(patch_hash=2uxevyasyasdavsxuehfavgkjq)(encoding@0.1.13) prismarine-biome: 1.3.0(minecraft-data@3.65.0)(prismarine-registry@1.7.0) prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 prismarine-chat: 1.10.1 - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/f32234a724a5c2482ffbaf85edc5e91c7ab9b38f(minecraft-data@3.65.0) + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/eb39a905761a36f733a456110e6b49d655bf5c16(minecraft-data@3.65.0) prismarine-entity: 2.3.1 prismarine-item: 1.14.0 prismarine-nbt: 2.5.0 @@ -15824,14 +15795,14 @@ snapshots: - encoding - supports-color - mineflayer@https://codeload.github.com/PrismarineJS/mineflayer/tar.gz/5a544cf2547a6e0f1f17786962d77a33c661c02f(encoding@0.1.13): + mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/06061e07fe6b9716cb1801d4c1bf232581977192(encoding@0.1.13): dependencies: minecraft-data: 3.65.0 - minecraft-protocol: 1.47.0(patch_hash=2uxevyasyasdavsxuehfavgkjq)(encoding@0.1.13) + minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/495eed56ab230b2615596590064671356d86a2dc(patch_hash=2uxevyasyasdavsxuehfavgkjq)(encoding@0.1.13) prismarine-biome: 1.3.0(minecraft-data@3.65.0)(prismarine-registry@1.7.0) prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 - prismarine-chat: 1.9.1 - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/f32234a724a5c2482ffbaf85edc5e91c7ab9b38f(minecraft-data@3.65.0) + prismarine-chat: 1.10.1 + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/eb39a905761a36f733a456110e6b49d655bf5c16(minecraft-data@3.65.0) prismarine-entity: 2.3.1 prismarine-item: 1.14.0 prismarine-nbt: 2.5.0 diff --git a/src/index.ts b/src/index.ts index 07781028..3b48a492 100644 --- a/src/index.ts +++ b/src/index.ts @@ -568,15 +568,6 @@ async function connect (connectOptions: ConnectOptions) { window.Vec3 = Vec3 window.pathfinder = pathfinder - // patch mineflayer - // todo move to mineflayer - bot.inventory.on('updateSlot', (index) => { - if ((index as unknown as number) === bot.quickBarSlot + bot.inventory.hotbarStart) { - //@ts-expect-error - bot.emit('heldItemChanged') - } - }) - miscUiState.gameLoaded = true miscUiState.loadedServerIndex = connectOptions.serverIndex ?? '' customEvents.emit('gameLoaded') From bd54b5bd807534bb30deb7e0314f089bcee8d715 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 6 Jun 2024 19:09:07 +0300 Subject: [PATCH 020/985] fix: username override of servers was never used --- src/react/ServersList.tsx | 18 ++++++++++-------- src/react/ServersListProvider.tsx | 17 +++++++++-------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/react/ServersList.tsx b/src/react/ServersList.tsx index f6b89452..f3759bce 100644 --- a/src/react/ServersList.tsx +++ b/src/react/ServersList.tsx @@ -5,14 +5,12 @@ import Singleplayer from './Singleplayer' import Input from './Input' import Button from './Button' import PixelartIcon from './PixelartIcon' +import { BaseServerInfo } from './AddServerOrConnect' interface Props extends React.ComponentProps { - joinServer: (ip: string, overrides: { - username?: string - password?: string - proxy?: string - versionOverride?: string + joinServer: (info: BaseServerInfo, additional: { shouldSave?: boolean + index?: number }) => void initialProxies: SavedProxiesLocalStorage updateProxies: (proxies: SavedProxiesLocalStorage) => void @@ -67,9 +65,11 @@ export default ({ initialProxies, updateProxies: updateProxiesProp, joinServer, version = parts.at(-1)! ip = parts.slice(0, -1).join(':') } - joinServer(ip, { - shouldSave: save, + joinServer({ + ip, versionOverride: version, + }, { + shouldSave: save, }) }} > @@ -116,7 +116,9 @@ export default ({ initialProxies, updateProxies: updateProxiesProp, joinServer, serversLayout onWorldAction={(action, serverName) => { if (action === 'load') { - joinServer(serverName, {}) + joinServer({ + ip: serverName, + }, {}) } props.onWorldAction?.(action, serverName) }} diff --git a/src/react/ServersListProvider.tsx b/src/react/ServersListProvider.tsx index bb23004f..9772c9b4 100644 --- a/src/react/ServersListProvider.tsx +++ b/src/react/ServersListProvider.tsx @@ -231,10 +231,11 @@ const Inner = () => { } return { + joinServer={(overrides, { shouldSave }) => { + const indexOrIp = overrides.ip let ip = indexOrIp let server: StoreServerItem | undefined - if (overrides.shouldSave === undefined) { + if (shouldSave === undefined) { // hack: inner component doesn't know of overrides for existing servers server = serversListSorted.find(s => s.index.toString() === indexOrIp)! ip = server.ip @@ -242,7 +243,7 @@ const Inner = () => { } const lastJoinedUsername = serversListSorted.find(s => s.usernameOverride)?.usernameOverride - let username = overrides.username || defaultUsername + let username = overrides.usernameOverride || defaultUsername if (!username) { username = prompt('Username', lastJoinedUsername || '') if (!username) return @@ -251,13 +252,13 @@ const Inner = () => { const options = { username, server: normalizeIp(ip), - proxy: overrides.proxy || selectedProxy, + proxy: overrides.proxyOverride || selectedProxy, botVersion: overrides.versionOverride ?? /* legacy */ overrides['version'], - password: overrides.password, + password: overrides.passwordOverride, ignoreQs: true, autoLoginPassword: server?.autoLogin?.[username], onSuccessfulPlay () { - if (overrides.shouldSave && !serversList.some(s => s.ip === ip)) { + if (shouldSave && !serversList.some(s => s.ip === ip)) { const newServersList: StoreServerItem[] = [...serversList, { ip, lastJoined: Date.now(), @@ -267,7 +268,7 @@ const Inner = () => { setNewServersList(newServersList) // component is not mounted } - if (overrides.shouldSave === undefined) { // loading saved + if (shouldSave === undefined) { // loading saved // find and update const server = serversList.find(s => s.ip === ip) if (server) { @@ -286,7 +287,7 @@ const Inner = () => { localStorage.setItem('selectedProxy', selectedProxy) } }, - serverIndex: overrides.shouldSave ? serversList.length.toString() : indexOrIp // assume last + serverIndex: shouldSave ? serversList.length.toString() : indexOrIp // assume last } satisfies ConnectOptions dispatchEvent(new CustomEvent('connect', { detail: options })) // qsOptions From aa18c3cbbdd1dd770f75f6695dd6bfff15b61a51 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 6 Jun 2024 19:52:12 +0300 Subject: [PATCH 021/985] add ping proxy implementation --- src/index.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/index.ts b/src/index.ts index 3b48a492..fe584b4d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -498,6 +498,22 @@ async function connect (connectOptions: ConnectOptions) { }) }) }) + let i = 0 + //@ts-expect-error + bot.pingProxy = async () => { + const curI = ++i + return new Promise(resolve => { + //@ts-expect-error + bot._client.socket._ws.send(`ping:${curI}`) + const date = Date.now() + const onPong = (received) => { + if (received !== curI.toString()) return + bot._client.socket.off('pong' as any, onPong) + resolve(Date.now() - date) + } + bot._client.socket.on('pong' as any, onPong) + }) + } } // socket setup actually can be delayed because of dns lookup if (bot._client.socket) { From 1e741c7c7a44fd783c2f76875b2d20cc618f8683 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 6 Jun 2024 19:53:08 +0300 Subject: [PATCH 022/985] up net-browserify --- pnpm-lock.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f9928dc6..7ced3b41 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -138,7 +138,7 @@ importers: version: 2.0.4 net-browserify: specifier: github:zardoy/prismarinejs-net-browserify - version: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434 + version: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d4650ff39943d1358a05d7197c3caa12fa8fb99 node-gzip: specifier: ^1.1.2 version: 1.1.2 @@ -6220,8 +6220,8 @@ packages: nested-error-stacks@2.1.1: resolution: {integrity: sha512-9iN1ka/9zmX1ZvLV9ewJYEk9h7RyRRtqdK0woXcqohu8EWIerfPUjYJPg0ULy0UqP7cslmdGc8xKDJcojlKiaw==} - net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434: - resolution: {tarball: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434} + net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d4650ff39943d1358a05d7197c3caa12fa8fb99: + resolution: {tarball: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d4650ff39943d1358a05d7197c3caa12fa8fb99} version: 0.2.4 nice-try@1.0.5: @@ -15961,7 +15961,7 @@ snapshots: nested-error-stacks@2.1.1: {} - net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/e7c50bf824ae5b4d987967fd921d8634dad03434: + net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d4650ff39943d1358a05d7197c3caa12fa8fb99: dependencies: body-parser: 1.20.2 express: 4.18.2 From 4c03d68b03f4748d41fe238a4aa81a8f14ed0089 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Fri, 7 Jun 2024 00:22:41 +0300 Subject: [PATCH 023/985] up browserify --- pnpm-lock.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7ced3b41..10add82d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -138,7 +138,7 @@ importers: version: 2.0.4 net-browserify: specifier: github:zardoy/prismarinejs-net-browserify - version: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d4650ff39943d1358a05d7197c3caa12fa8fb99 + version: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/2ed580ba422781addd1166ab31eede5914cd5f61 node-gzip: specifier: ^1.1.2 version: 1.1.2 @@ -6220,8 +6220,8 @@ packages: nested-error-stacks@2.1.1: resolution: {integrity: sha512-9iN1ka/9zmX1ZvLV9ewJYEk9h7RyRRtqdK0woXcqohu8EWIerfPUjYJPg0ULy0UqP7cslmdGc8xKDJcojlKiaw==} - net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d4650ff39943d1358a05d7197c3caa12fa8fb99: - resolution: {tarball: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d4650ff39943d1358a05d7197c3caa12fa8fb99} + net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/2ed580ba422781addd1166ab31eede5914cd5f61: + resolution: {tarball: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/2ed580ba422781addd1166ab31eede5914cd5f61} version: 0.2.4 nice-try@1.0.5: @@ -15961,7 +15961,7 @@ snapshots: nested-error-stacks@2.1.1: {} - net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/7d4650ff39943d1358a05d7197c3caa12fa8fb99: + net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/2ed580ba422781addd1166ab31eede5914cd5f61: dependencies: body-parser: 1.20.2 express: 4.18.2 From bbf8fbf4a5fed3387b2329f39d3037cde595dbff Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Fri, 7 Jun 2024 01:30:00 +0300 Subject: [PATCH 024/985] fix o.text.includes is not a function crash --- src/botUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/botUtils.ts b/src/botUtils.ts index 30e13834..79b10118 100644 --- a/src/botUtils.ts +++ b/src/botUtils.ts @@ -101,7 +101,7 @@ export const formatMessage = (message: MessageInput, mcData: IndexedData = globa msglist = msglist.map(msg => { // normalize § - if (!msg.text.includes('§')) return msg + if (!msg.text.includes?.('§')) return msg const newMsg = fromFormattedString(msg.text) return flat(newMsg) }).flat(Infinity) From 94c665d851f8366b31ca4aa8873526dd53840af8 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 8 Jun 2024 23:13:44 +0300 Subject: [PATCH 025/985] move everything to frequent update interval --- src/react/DebugOverlay.tsx | 7 +------ src/reactUi.tsx | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/react/DebugOverlay.tsx b/src/react/DebugOverlay.tsx index c83418f5..bb38672e 100644 --- a/src/react/DebugOverlay.tsx +++ b/src/react/DebugOverlay.tsx @@ -91,6 +91,7 @@ export default () => { setDimension(bot.game.dimension) setDay(bot.time.day) setCursorBlock(worldInteractions.cursorBlock) + setEntitiesCount(Object.values(bot.entities).length) }, 100) // @ts-expect-error @@ -101,12 +102,6 @@ export default () => { sent.current.count++ managePackets('sent', name, data) }) - bot.on('entitySpawn', () => { - setEntitiesCount(Object.values(bot.entities).length) - }) - bot.on('entityGone', () => { - setEntitiesCount(Object.values(bot.entities).length) - }) try { const gl = window.renderer.getContext() diff --git a/src/reactUi.tsx b/src/reactUi.tsx index 449d7883..8a9cc32c 100644 --- a/src/reactUi.tsx +++ b/src/reactUi.tsx @@ -98,7 +98,7 @@ const InGameUi = () => { const { gameLoaded, showUI: showUIRaw } = useSnapshot(miscUiState) const hasModals = useSnapshot(activeModalStack).length > 0 const showUI = showUIRaw || hasModals - if (!gameLoaded) return + if (!gameLoaded || !bot) return return <> From 6be0bc8c9a93d79f0524d0e8bdb7041941e5c27d Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 8 Jun 2024 23:20:07 +0300 Subject: [PATCH 026/985] fix: elytra equipped crashed hud bars fix sentry 5457375830 --- src/react/HudBarsProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/react/HudBarsProvider.tsx b/src/react/HudBarsProvider.tsx index 746d4819..ea78ae08 100644 --- a/src/react/HudBarsProvider.tsx +++ b/src/react/HudBarsProvider.tsx @@ -82,7 +82,7 @@ export default () => { const item = bot.inventory.slots[slotIndex] ?? null if (!item) continue const armorName = item.name.split('_') - points += armor[armorName[0]][armorName[1]] + points += armor[armorName[0]]?.[armorName[1]] ?? 0 } setArmorValue(points) } From 409577d8e0b272ec155e9cbfc96e94a0295b49de Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 9 Jun 2024 00:19:08 +0300 Subject: [PATCH 027/985] up net --- pnpm-lock.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 10add82d..38a9ebb6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -138,7 +138,7 @@ importers: version: 2.0.4 net-browserify: specifier: github:zardoy/prismarinejs-net-browserify - version: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/2ed580ba422781addd1166ab31eede5914cd5f61 + version: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/99434199f25d3c6bbe15833bb78ec40b07c2df6f node-gzip: specifier: ^1.1.2 version: 1.1.2 @@ -6220,8 +6220,8 @@ packages: nested-error-stacks@2.1.1: resolution: {integrity: sha512-9iN1ka/9zmX1ZvLV9ewJYEk9h7RyRRtqdK0woXcqohu8EWIerfPUjYJPg0ULy0UqP7cslmdGc8xKDJcojlKiaw==} - net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/2ed580ba422781addd1166ab31eede5914cd5f61: - resolution: {tarball: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/2ed580ba422781addd1166ab31eede5914cd5f61} + net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/99434199f25d3c6bbe15833bb78ec40b07c2df6f: + resolution: {tarball: https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/99434199f25d3c6bbe15833bb78ec40b07c2df6f} version: 0.2.4 nice-try@1.0.5: @@ -15961,7 +15961,7 @@ snapshots: nested-error-stacks@2.1.1: {} - net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/2ed580ba422781addd1166ab31eede5914cd5f61: + net-browserify@https://codeload.github.com/zardoy/prismarinejs-net-browserify/tar.gz/99434199f25d3c6bbe15833bb78ec40b07c2df6f: dependencies: body-parser: 1.20.2 express: 4.18.2 From 6268561e4148dbaec0de0c6965e3423ccb709849 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 9 Jun 2024 01:09:02 +0300 Subject: [PATCH 028/985] make inputs in server editor a bit smaller, fix proxy select --- src/react/AddServerOrConnect.tsx | 60 +++++++++++++++++++------------- src/react/ServersList.tsx | 4 +-- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/react/AddServerOrConnect.tsx b/src/react/AddServerOrConnect.tsx index 500c1e61..d74ff8fe 100644 --- a/src/react/AddServerOrConnect.tsx +++ b/src/react/AddServerOrConnect.tsx @@ -23,6 +23,8 @@ interface Props { defaults?: Pick } +const ELEMENTS_WIDTH = 190 + export default ({ onBack, onConfirm, title = 'Add a Server', initialData, parseQs, onQsConnect, defaults }: Props) => { const qsParams = parseQs ? new URLSearchParams(window.location.search) : undefined @@ -41,24 +43,25 @@ export default ({ onBack, onConfirm, title = 'Add a Server', initialData, parseQ const lockConnect = qsParams?.get('lockConnect') === 'true' return -
{ - e.preventDefault() - let ip = serverIp.includes(':') ? serverIp : `${serverIp}:${serverPort}` - ip = ip.replace(/:$/, '') - onConfirm({ - name: serverName, - ip, - versionOverride, - proxyOverride, - usernameOverride, - passwordOverride - }) - }} + { + e.preventDefault() + let ip = serverIp.includes(':') ? serverIp : `${serverIp}:${serverPort}` + ip = ip.replace(/:$/, '') + onConfirm({ + name: serverName, + ip, + versionOverride, + proxyOverride, + usernameOverride, + passwordOverride + }) + }} >
setProxyOverride(value)} placeholder={defaults?.proxyOverride} /> setUsernameOverride(value)} placeholder={defaults?.usernameOverride} /> setPasswordOverride(value)} /* placeholder='For advanced usage only' */ /> - {!lockConnect && <>} + {!lockConnect && <> + { + onBack() + }}>Cancel + Save + } {qsParams?.get('ip') &&
- + >Connect
}
} +const ButtonWrapper = ({ ...props }: React.ComponentProps) => { + props.style ??= {} + props.style.width = ELEMENTS_WIDTH + return
From 05a0d3a184ae4478470f11046b89d7f45160b4a1 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 9 Jun 2024 02:02:26 +0300 Subject: [PATCH 029/985] fix: attack entities on left click not on right click --- src/worldInteractions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/worldInteractions.ts b/src/worldInteractions.ts index 0245d418..49c21c2e 100644 --- a/src/worldInteractions.ts +++ b/src/worldInteractions.ts @@ -90,7 +90,7 @@ class WorldInteraction { const entity = getEntityCursor() - if (entity && e.button === 2) { + if (entity && e.button === 0) { bot.attack(entity) } else { // bot From 353bec4c6b718ab3a2b54f147a35d04fa274c058 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Sun, 9 Jun 2024 18:12:34 +0300 Subject: [PATCH 030/985] fix: fix entity label display for older versions of minecraft --- prismarine-viewer/viewer/lib/entities.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/prismarine-viewer/viewer/lib/entities.js b/prismarine-viewer/viewer/lib/entities.js index 28fc6d89..94f06e0c 100644 --- a/prismarine-viewer/viewer/lib/entities.js +++ b/prismarine-viewer/viewer/lib/entities.js @@ -267,11 +267,15 @@ export class Entities extends EventEmitter { } - displaySimpleText(jsonLike) { + parseEntityLabel(jsonLike) { if (!jsonLike) return - const parsed = typeof jsonLike === 'string' ? mojangson.simplify(mojangson.parse(jsonLike)) : nbt.simplify(jsonLike) - const text = flat(parsed).map(x => x.text) - return text.join('') + try { + const parsed = typeof jsonLike === 'string' ? mojangson.simplify(mojangson.parse(jsonLike)) : nbt.simplify(jsonLike) + const text = flat(parsed).map(x => x.text) + return text.join('') + } catch (err) { + return jsonLike + } } update(/** @type {import('prismarine-entity').Entity & {delete?, pos}} */entity, overrides) { @@ -410,7 +414,7 @@ export class Entities extends EventEmitter { } } // not player - const displayText = entity.metadata?.[3] && this.displaySimpleText(entity.metadata[2]) + const displayText = entity.metadata?.[3] && this.parseEntityLabel(entity.metadata[2]) if (entity.name !== 'player' && displayText) { addNametag({ ...entity, username: displayText }, this.entitiesOptions, this.entities[entity.id].children.find(c => c.name === 'mesh')) } From 7f3d5ca1f0ead78528f065c55ba3724f951b875b Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Mon, 10 Jun 2024 03:27:34 +0300 Subject: [PATCH 031/985] rename project to minecraft-web-client fixes issue146 --- README.NPM.MD | 2 +- package.json | 2 +- package.npm.json | 2 +- scripts/downloadSoundsMap.mjs | 2 +- scripts/prepareSounds.mjs | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.NPM.MD b/README.NPM.MD index 24c90bc9..c036adba 100644 --- a/README.NPM.MD +++ b/README.NPM.MD @@ -24,7 +24,7 @@ const App = () => { } ``` -See [Storybook](https://mcraft.fun/storybook/) or [Storybook (Mirror link)](https://mcon.vercel.app/storybook/) for more examples and full components list. Also take a look at the full [standalone example](https://github.com/zardoy/prismarine-web-client/tree/experiments/UiStandaloneExample.tsx). +See [Storybook](https://mcraft.fun/storybook/) or [Storybook (Mirror link)](https://mcon.vercel.app/storybook/) for more examples and full components list. Also take a look at the full [standalone example](https://github.com/zardoy/minecraft-web-client/tree/experiments/UiStandaloneExample.tsx). There are two types of components: diff --git a/package.json b/package.json index fa28ae5d..7bbde636 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "prismarine-web-client", + "name": "minecraft-web-client", "version": "0.0.0-dev", "description": "A minecraft client running in a browser", "scripts": { diff --git a/package.npm.json b/package.npm.json index bae8b60f..7e13d67b 100644 --- a/package.npm.json +++ b/package.npm.json @@ -26,7 +26,7 @@ }, "module": "./dist/react/npmReactComponents.js", "types": "./dist/react/npmReactComponents.d.ts", - "repository": "zardoy/prismarine-web-client", + "repository": "zardoy/minecraft-web-client", "version": "0.0.0-dev", "dependencies": {}, "peerDependencies": { diff --git a/scripts/downloadSoundsMap.mjs b/scripts/downloadSoundsMap.mjs index 066a3df7..3c335f8f 100644 --- a/scripts/downloadSoundsMap.mjs +++ b/scripts/downloadSoundsMap.mjs @@ -1,6 +1,6 @@ import fs from 'fs' -const url = 'https://github.com/zardoy/prismarine-web-client/raw/sounds-generated/sounds.js' +const url = 'https://github.com/zardoy/minecraft-web-client/raw/sounds-generated/sounds.js' const savePath = 'dist/sounds.js' fetch(url).then(res => res.text()).then(data => { fs.writeFileSync(savePath, data, 'utf8') diff --git a/scripts/prepareSounds.mjs b/scripts/prepareSounds.mjs index 4ed119cb..8f3e5bef 100644 --- a/scripts/prepareSounds.mjs +++ b/scripts/prepareSounds.mjs @@ -61,7 +61,7 @@ const downloadAllSounds = async () => { } prevSounds = soundAssets } - async function downloadSound ({ name, hash, size }, namePath, log) { + async function downloadSound({ name, hash, size }, namePath, log) { const savePath = path.resolve(`generated/sounds/${namePath}`) if (fs.existsSync(savePath)) { // console.log('skipped', name) @@ -86,7 +86,7 @@ const downloadAllSounds = async () => { } writer.close() } - async function downloadSounds (assets, addPath = '') { + async function downloadSounds(assets, addPath = '') { for (let i = 0; i < assets.length; i += 5) { await Promise.all(assets.slice(i, i + 5).map((asset, j) => downloadSound(asset, `${addPath}${asset.name}`, () => { console.log('downloading', addPath, asset.name, i + j, '/', assets.length) @@ -135,7 +135,7 @@ const convertSounds = async () => { } const CONCURRENCY = 5 - for(let i = 0; i < toConvert.length; i += CONCURRENCY) { + for (let i = 0; i < toConvert.length; i += CONCURRENCY) { await Promise.all(toConvert.slice(i, i + CONCURRENCY).map((oggPath, j) => convertSound(i + j))) } } @@ -221,7 +221,7 @@ const makeSoundsBundle = async () => { const allSoundsMeta = { format: 'mp3', - baseUrl: 'https://raw.githubusercontent.com/zardoy/prismarine-web-client/sounds-generated/sounds/' + baseUrl: 'https://raw.githubusercontent.com/zardoy/minecraft-web-client/sounds-generated/sounds/' } await build({ From 7f4edbedba20b22bd9b903c780a2c268679d6463 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 11 Jun 2024 03:26:24 +0300 Subject: [PATCH 032/985] rm manimali, replace with a better server --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 1bbbfd47..e4f86060 100644 --- a/config.json +++ b/config.json @@ -15,9 +15,9 @@ "description": "One of the best servers here. Join now!" }, { - "ip": "play.minemalia.com", + "ip": "sus.shhnowisnottheti.me", "version": "1.18.2", - "description": "Only login with existing accounts." + "description": "Creative, your own 'boxes' (islands)" } ] } From 38e4efc79b4054bfc354ccaaf6fe5c5f572a3978 Mon Sep 17 00:00:00 2001 From: Wolf2323 Date: Tue, 11 Jun 2024 20:14:58 +0200 Subject: [PATCH 033/985] fix: improve signs models & text, added all missing sign types (#143) Co-authored-by: Vitaly Turovsky --- prismarine-viewer/viewer/lib/mesher/models.ts | 4 +- .../viewer/lib/mesher/test/tests.test.ts | 22 -- .../viewer/lib/worldrendererThree.ts | 27 +- prismarine-viewer/viewer/prepare/atlas.ts | 49 +-- .../data/1.13/blockModels/sign/oak.json | 6 + .../data/1.13/blockModels/sign/oak_wall.json | 6 + .../data/1.13/blockModels/sign/sign.json | 140 +++++++ .../data/1.13/blockModels/sign/sign_wall.json | 72 ++++ .../data/1.13/blockStates/sign/sign.json | 67 ++++ .../data/1.13/blockStates/sign/wall_sign.json | 19 + .../data/1.14/blockModels/sign/acacia.json | 6 + .../1.14/blockModels/sign/acacia_wall.json | 6 + .../data/1.14/blockModels/sign/birch.json | 6 + .../1.14/blockModels/sign/birch_wall.json | 6 + .../data/1.14/blockModels/sign/dark_oak.json | 6 + .../1.14/blockModels/sign/dark_oak_wall.json | 6 + .../data/1.14/blockModels/sign/jungle.json | 6 + .../1.14/blockModels/sign/jungle_wall.json | 7 + .../data/1.14/blockModels/sign/spruce.json | 6 + .../1.14/blockModels/sign/spruce_wall.json | 6 + .../1.14/blockStates/sign/acacia_sign.json | 67 ++++ .../blockStates/sign/acacia_wall_sign.json | 19 + .../1.14/blockStates/sign/birch_sign.json | 67 ++++ .../blockStates/sign/birch_wall_sign.json | 19 + .../1.14/blockStates/sign/dark_oak_sign.json | 67 ++++ .../blockStates/sign/dark_oak_wall_sign.json | 19 + .../1.14/blockStates/sign/jungle_sign.json | 67 ++++ .../blockStates/sign/jungle_wall_sign.json | 19 + .../data/1.14/blockStates/sign/oak_sign.json | 67 ++++ .../1.14/blockStates/sign/oak_wall_sign.json | 19 + .../1.14/blockStates/sign/spruce_sign.json | 67 ++++ .../blockStates/sign/spruce_wall_sign.json | 19 + .../data/1.16/blockModels/sign/crimson.json | 6 + .../1.16/blockModels/sign/crimson_wall.json | 6 + .../data/1.16/blockModels/sign/warped.json | 6 + .../1.16/blockModels/sign/warped_wall.json | 6 + .../1.16/blockStates/sign/crimson_sign.json | 67 ++++ .../blockStates/sign/crimson_wall_sign.json | 19 + .../1.16/blockStates/sign/warped_sign.json | 67 ++++ .../blockStates/sign/warped_wall_sign.json | 19 + .../data/1.19/blockModels/sign/mangrove.json | 6 + .../1.19/blockModels/sign/mangrove_wall.json | 6 + .../1.19/blockStates/sign/mangrove_sign.json | 67 ++++ .../blockStates/sign/mangrove_wall_sign.json | 19 + .../1.20/blockModels/sign/acacia_hanging.json | 7 + .../blockModels/sign/acacia_wall_hanging.json | 7 + .../data/1.20/blockModels/sign/bamboo.json | 6 + .../1.20/blockModels/sign/bamboo_hanging.json | 7 + .../1.20/blockModels/sign/bamboo_wall.json | 6 + .../blockModels/sign/bamboo_wall_hanging.json | 7 + .../1.20/blockModels/sign/birch_hanging.json | 7 + .../blockModels/sign/birch_wall_hanging.json | 7 + .../data/1.20/blockModels/sign/cherry.json | 6 + .../1.20/blockModels/sign/cherry_hanging.json | 7 + .../1.20/blockModels/sign/cherry_wall.json | 6 + .../blockModels/sign/cherry_wall_hanging.json | 7 + .../blockModels/sign/crimson_hanging.json | 7 + .../sign/crimson_wall_hanging.json | 7 + .../blockModels/sign/dark_oak_hanging.json | 7 + .../sign/dark_oak_wall_hanging.json | 7 + .../data/1.20/blockModels/sign/hanging.json | 115 ++++++ .../1.20/blockModels/sign/jungle_hanging.json | 7 + .../blockModels/sign/jungle_wall_hanging.json | 7 + .../blockModels/sign/mangrove_hanging.json | 7 + .../sign/mangrove_wall_hanging.json | 7 + .../1.20/blockModels/sign/oak_hanging.json | 7 + .../blockModels/sign/oak_wall_hanging.json | 7 + .../1.20/blockModels/sign/spruce_hanging.json | 7 + .../blockModels/sign/spruce_wall_hanging.json | 7 + .../1.20/blockModels/sign/wall_hanging.json | 347 ++++++++++++++++++ .../1.20/blockModels/sign/warped_hanging.json | 7 + .../blockModels/sign/warped_wall_hanging.json | 7 + .../blockStates/sign/acacia_hanging_sign.json | 67 ++++ .../sign/acacia_wall_hanging_sign.json | 19 + .../blockStates/sign/bamboo_hanging_sign.json | 67 ++++ .../1.20/blockStates/sign/bamboo_sign.json | 67 ++++ .../sign/bamboo_wall_hanging_sign.json | 19 + .../blockStates/sign/bamboo_wall_sign.json | 19 + .../blockStates/sign/birch_hanging_sign.json | 67 ++++ .../sign/birch_wall_hanging_sign.json | 19 + .../blockStates/sign/cherry_hanging_sign.json | 67 ++++ .../1.20/blockStates/sign/cherry_sign.json | 67 ++++ .../sign/cherry_wall_hanging_sign.json | 19 + .../blockStates/sign/cherry_wall_sign.json | 19 + .../sign/crimson_hanging_sign.json | 67 ++++ .../sign/crimson_wall_hanging_sign.json | 19 + .../sign/dark_oak_hanging_sign.json | 67 ++++ .../sign/dark_oak_wall_hanging_sign.json | 19 + .../blockStates/sign/jungle_hanging_sign.json | 67 ++++ .../sign/jungle_wall_hanging_sign.json | 19 + .../sign/mangrove_hanging_sign.json | 67 ++++ .../sign/mangrove_wall_hanging_sign.json | 19 + .../blockStates/sign/oak_hanging_sign.json | 67 ++++ .../sign/oak_wall_hanging_sign.json | 19 + .../blockStates/sign/spruce_hanging_sign.json | 67 ++++ .../sign/spruce_wall_hanging_sign.json | 19 + .../blockStates/sign/warped_hanging_sign.json | 67 ++++ .../sign/warped_wall_hanging_sign.json | 19 + .../viewer/prepare/modelsBuilder.ts | 10 +- .../viewer/prepare/moreGeneratedBlocks.ts | 193 +++------- 100 files changed, 3048 insertions(+), 196 deletions(-) create mode 100644 prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/oak.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/oak_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/sign_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.13/blockStates/sign/sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.13/blockStates/sign/wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/acacia.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/acacia_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/birch.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/birch_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/dark_oak.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/dark_oak_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/jungle.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/jungle_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/spruce.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/spruce_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/acacia_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/acacia_wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/birch_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/birch_wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/dark_oak_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/dark_oak_wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/jungle_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/jungle_wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/oak_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/oak_wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/spruce_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/spruce_wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/crimson.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/crimson_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/warped.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/warped_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/crimson_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/crimson_wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/warped_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/warped_wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.19/blockModels/sign/mangrove.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.19/blockModels/sign/mangrove_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.19/blockStates/sign/mangrove_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.19/blockStates/sign/mangrove_wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/acacia_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/acacia_wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/birch_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/birch_wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_wall.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/crimson_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/crimson_wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/dark_oak_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/dark_oak_wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/jungle_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/jungle_wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/mangrove_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/mangrove_wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/oak_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/oak_wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/spruce_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/spruce_wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/warped_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/warped_wall_hanging.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/acacia_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/acacia_wall_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_wall_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/birch_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/birch_wall_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_wall_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_wall_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/crimson_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/crimson_wall_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/dark_oak_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/dark_oak_wall_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/jungle_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/jungle_wall_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/mangrove_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/mangrove_wall_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/oak_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/oak_wall_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/spruce_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/spruce_wall_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/warped_hanging_sign.json create mode 100644 prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/warped_wall_hanging_sign.json diff --git a/prismarine-viewer/viewer/lib/mesher/models.ts b/prismarine-viewer/viewer/lib/mesher/models.ts index 39148aaa..c978c240 100644 --- a/prismarine-viewer/viewer/lib/mesher/models.ts +++ b/prismarine-viewer/viewer/lib/mesher/models.ts @@ -520,9 +520,11 @@ export function getSectionGeometry (sx, sy, sz, world: World) { "west": 1, "east": 3 } - const isWall = block.name.endsWith('wall_sign') || block.name.endsWith('hanging_sign') + const isWall = block.name.endsWith('wall_sign') || block.name.endsWith('wall_hanging_sign') + const isHanging = block.name.endsWith('hanging_sign') attr.signs[key] = { isWall, + isHanging, rotation: isWall ? facingRotationMap[props.facing] : +props.rotation } } diff --git a/prismarine-viewer/viewer/lib/mesher/test/tests.test.ts b/prismarine-viewer/viewer/lib/mesher/test/tests.test.ts index 5a80fa49..de5db815 100644 --- a/prismarine-viewer/viewer/lib/mesher/test/tests.test.ts +++ b/prismarine-viewer/viewer/lib/mesher/test/tests.test.ts @@ -45,12 +45,6 @@ test('Known blocks are not rendered', () => { // should be fixed, but to avoid regressions & for visibility expect(invalidBlocks).toMatchInlineSnapshot(` { - "acacia_hanging_sign": true, - "acacia_wall_hanging_sign": true, - "bamboo_hanging_sign": true, - "bamboo_wall_hanging_sign": true, - "birch_hanging_sign": true, - "birch_wall_hanging_sign": true, "black_banner": true, "black_bed": true, "black_candle": true, @@ -65,18 +59,12 @@ test('Known blocks are not rendered', () => { "brown_wall_banner": true, "bubble_column": true, "candle": true, - "cherry_hanging_sign": true, - "cherry_wall_hanging_sign": true, "creeper_head": true, "creeper_wall_head": true, - "crimson_hanging_sign": true, - "crimson_wall_hanging_sign": true, "cyan_banner": true, "cyan_bed": true, "cyan_candle": true, "cyan_wall_banner": true, - "dark_oak_hanging_sign": true, - "dark_oak_wall_hanging_sign": true, "dragon_head": true, "dragon_wall_head": true, "end_gateway": true, @@ -89,8 +77,6 @@ test('Known blocks are not rendered', () => { "green_bed": true, "green_candle": true, "green_wall_banner": true, - "jungle_hanging_sign": true, - "jungle_wall_hanging_sign": true, "light_blue_banner": true, "light_blue_bed": true, "light_blue_candle": true, @@ -107,10 +93,6 @@ test('Known blocks are not rendered', () => { "magenta_bed": true, "magenta_candle": true, "magenta_wall_banner": true, - "mangrove_hanging_sign": true, - "mangrove_wall_hanging_sign": true, - "oak_hanging_sign": true, - "oak_wall_hanging_sign": true, "orange_banner": true, "orange_bed": true, "orange_candle": true, @@ -138,12 +120,8 @@ test('Known blocks are not rendered', () => { "skeleton_skull": true, "skeleton_wall_skull": true, "snow": true, - "spruce_hanging_sign": true, - "spruce_wall_hanging_sign": true, "structure_void": true, "turtle_egg": true, - "warped_hanging_sign": true, - "warped_wall_hanging_sign": true, "water_cauldron": true, "white_banner": true, "white_bed": true, diff --git a/prismarine-viewer/viewer/lib/worldrendererThree.ts b/prismarine-viewer/viewer/lib/worldrendererThree.ts index 4d28519a..095e5a94 100644 --- a/prismarine-viewer/viewer/lib/worldrendererThree.ts +++ b/prismarine-viewer/viewer/lib/worldrendererThree.ts @@ -112,11 +112,11 @@ export class WorldRendererThree extends WorldRendererCommon { } // should not compute it once if (Object.keys(data.geometry.signs).length) { - for (const [posKey, { isWall, rotation }] of Object.entries(data.geometry.signs)) { + for (const [posKey, { isWall, isHanging, rotation }] of Object.entries(data.geometry.signs)) { const [x, y, z] = posKey.split(',') const signBlockEntity = this.blockEntities[posKey] if (!signBlockEntity) continue - const sign = this.renderSign(new Vec3(+x, +y, +z), rotation, isWall, nbt.simplify(signBlockEntity)) + const sign = this.renderSign(new Vec3(+x, +y, +z), rotation, isWall, isHanging, nbt.simplify(signBlockEntity)) if (!sign) continue object.add(sign) } @@ -165,7 +165,7 @@ export class WorldRendererThree extends WorldRendererCommon { this.renderer.render(this.scene, this.camera) } - renderSign (position: Vec3, rotation: number, isWall: boolean, blockEntity) { + renderSign (position: Vec3, rotation: number, isWall: boolean, isHanging: boolean, blockEntity) { const tex = this.getSignTexture(position, blockEntity) if (!tex) return @@ -182,13 +182,16 @@ export class WorldRendererThree extends WorldRendererCommon { mesh.renderOrder = 999 // todo @sa2urami shouldnt all this be done in worker? - mesh.scale.set(1, 7 / 16, 1) - if (isWall) { - mesh.position.set(0, 0, -(8 - 1.5) / 16 + 0.001) + const lineHeight = 7 / 16; + const scaleFactor = isHanging ? 1.3 : 1 + mesh.scale.set(1 * scaleFactor, lineHeight * scaleFactor, 1 * scaleFactor) + + const thickness = (isHanging ? 2 : 1.5) / 16 + const wallSpacing = 0.25 / 16; + if (isWall && !isHanging) { + mesh.position.set(0, 0, -0.5 + thickness + wallSpacing + 0.0001) } else { - // standing - const faceEnd = 8.75 - mesh.position.set(0, 0, (faceEnd - 16 / 2) / 16 + 0.001) + mesh.position.set(0, 0, thickness / 2 + 0.0001) } const group = new THREE.Group() @@ -196,8 +199,10 @@ export class WorldRendererThree extends WorldRendererCommon { rotation * (isWall ? 90 : 45 / 2) ), 0) group.add(mesh) - const y = isWall ? 4.5 / 16 + mesh.scale.y / 2 : (1 - (mesh.scale.y / 2)) - group.position.set(position.x + 0.5, position.y + y, position.z + 0.5) + const height = (isHanging ? 10 : 8)/16 + const heightOffset = (isHanging ? 0 : isWall ? 4.333 : 9.333) / 16 + const textPosition = height/2 + heightOffset + group.position.set(position.x + 0.5, position.y + textPosition, position.z + 0.5) return group } diff --git a/prismarine-viewer/viewer/prepare/atlas.ts b/prismarine-viewer/viewer/prepare/atlas.ts index fc3e4029..cf73fdc4 100644 --- a/prismarine-viewer/viewer/prepare/atlas.ts +++ b/prismarine-viewer/viewer/prepare/atlas.ts @@ -49,19 +49,18 @@ export const makeTextureAtlas = (input: string[], getInputData: (name) => { cont const texturesIndex = {} - let skipXY = [] as [x: number, y: number][] - let offset = 0 + let nextX = 0 + let nextY = 0 + let rowMaxY = 0 + + const goToNextRow = () => { + nextX = 0 + nextY += rowMaxY + rowMaxY = 0 + } + const suSv = tileSize / imgSize for (const i in input) { - const pos = +i + offset - const x = (pos % texSize) * tileSize - const y = Math.floor(pos / texSize) * tileSize - - if (skipXY.some(([sx, sy]) => sx === x + 1 && sy === y)) { - // todo more offsets - offset++ - } - const img = new Image() const keyValue = input[i] const inputData = getInputData(keyValue) @@ -76,16 +75,24 @@ export const makeTextureAtlas = (input: string[], getInputData: (name) => { cont renderHeight = Math.ceil(img.height / tileSize) * tileSize su = renderWidth / imgSize sv = renderHeight / imgSize - if (renderWidth > tileSize) { - offset += Math.ceil(renderWidth / tileSize) - 1 - } - if (renderHeight > tileSize) { - const skipYs = Math.ceil(renderHeight / tileSize) - 1 - for (let i = 1; i <= skipYs; i++) { - skipXY.push([x, y + i]) - } + if (renderHeight > imgSize || renderWidth > imgSize) { + throw new Error('Texture ' + keyValue + ' is too big') } } + + if (nextX + renderWidth > imgSize) { + goToNextRow() + } + + const x = nextX + const y = nextY + + nextX += renderWidth + rowMaxY = Math.max(rowMaxY, renderHeight) + if (nextX >= imgSize) { + goToNextRow() + } + g.drawImage(img, 0, 0, renderWidth, renderHeight, x, y, renderWidth, renderHeight) const cleanName = keyValue.split('.').slice(0, -1).join('.') || keyValue @@ -116,7 +123,7 @@ export function makeBlockTextureAtlas (mcAssets: McAssets) { // const textureFiles = mostEncounteredBlocks.map(x => x + '.png') textureFiles.unshift(...localTextures) - const { generated: additionalTextures, twoTileTextures, origSizeTextures } = getAdditionalTextures() + const { generated: additionalTextures, origSizeTextures } = getAdditionalTextures() textureFiles.push(...Object.keys(additionalTextures)) const atlas = makeTextureAtlas(textureFiles, name => { @@ -129,7 +136,7 @@ export function makeBlockTextureAtlas (mcAssets: McAssets) { return { contents, - tileWidthMult: twoTileTextures.includes(name) ? 2 : undefined, + // tileWidthMult: twoTileTextures.includes(name) ? 2 : undefined, origSizeTextures } }) diff --git a/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/oak.json b/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/oak.json new file mode 100644 index 00000000..2f16a429 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/oak.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign", + "textures": { + "sign": "entity/sign" + } +} diff --git a/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/oak_wall.json b/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/oak_wall.json new file mode 100644 index 00000000..dfdb230f --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/oak_wall.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign_wall", + "textures": { + "sign": "entity/sign" + } +} diff --git a/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/sign.json b/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/sign.json new file mode 100644 index 00000000..4562cfae --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/sign.json @@ -0,0 +1,140 @@ +{ + "elements": [ + { + "from": [ + 7.25, + 0, + 7.25 + ], + "to": [ + 8.75, + 9.333, + 8.75 + ], + "faces": { + "north": { + "uv": [ + 1.5, + 8, + 2, + 15 + ], + "texture": "#sign" + }, + "east": { + "uv": [ + 1, + 8, + 1.5, + 15 + ], + "texture": "#sign" + }, + "south": { + "uv": [ + 0.5, + 8, + 1, + 15 + ], + "texture": "#sign" + }, + "west": { + "uv": [ + 0, + 8, + 0.5, + 15 + ], + "texture": "#sign" + }, + "up": { + "uv": [ + 0.5, + 7, + 1, + 8 + ], + "texture": "#sign" + }, + "down": { + "uv": [ + 1, + 7, + 1.5, + 8 + ], + "texture": "#sign" + } + } + }, + { + "from": [ + 0, + 9.333, + 7.25 + ], + "to": [ + 16, + 17.333, + 8.75 + ], + "faces": { + "north": { + "uv": [ + 7, + 1, + 13, + 7 + ], + "texture": "#sign" + }, + "east": { + "uv": [ + 6.5, + 1, + 7, + 7 + ], + "texture": "#sign" + }, + "south": { + "uv": [ + 0.5, + 1, + 6.5, + 7 + ], + "texture": "#sign" + }, + "west": { + "uv": [ + 0, + 1, + 0.5, + 7 + ], + "texture": "#sign" + }, + "up": { + "uv": [ + 0.5, + 0, + 6.5, + 1 + ], + "texture": "#sign" + }, + "down": { + "uv": [ + 6.5, + 1, + 12.5, + 0 + ], + "texture": "#sign" + } + } + } + ] +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/sign_wall.json b/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/sign_wall.json new file mode 100644 index 00000000..b743c983 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.13/blockModels/sign/sign_wall.json @@ -0,0 +1,72 @@ +{ + "elements": [ + { + "from": [ + 0, + 4.333, + 0.25 + ], + "to": [ + 16, + 12.333, + 1.75 + ], + "faces": { + "north": { + "uv": [ + 7, + 1, + 13, + 7 + ], + "texture": "#sign" + }, + "east": { + "uv": [ + 6.5, + 1, + 7, + 7 + ], + "texture": "#sign" + }, + "south": { + "uv": [ + 0.5, + 1, + 6.5, + 7 + ], + "texture": "#sign" + }, + "west": { + "uv": [ + 0, + 1, + 0.5, + 7 + ], + "texture": "#sign" + }, + "up": { + "uv": [ + 0.5, + 0, + 6.5, + 1 + ], + "texture": "#sign" + }, + "down": { + "uv": [ + 6.5, + 1, + 12.5, + 0 + ], + "texture": "#sign" + } + } + } + ] +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.13/blockStates/sign/sign.json b/prismarine-viewer/viewer/prepare/data/1.13/blockStates/sign/sign.json new file mode 100644 index 00000000..4ebcedcd --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.13/blockStates/sign/sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/oak" + }, + "rotation=1": { + "model": "sign/oak", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/oak", + "y": 45 + }, + "rotation=3": { + "model": "sign/oak", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/oak", + "y": 90 + }, + "rotation=5": { + "model": "sign/oak", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/oak", + "y": 135 + }, + "rotation=7": { + "model": "sign/oak", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/oak", + "y": 180 + }, + "rotation=9": { + "model": "sign/oak", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/oak", + "y": 225 + }, + "rotation=11": { + "model": "sign/oak", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/oak", + "y": 270 + }, + "rotation=13": { + "model": "sign/oak", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/oak", + "y": 315 + }, + "rotation=15": { + "model": "sign/oak", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.13/blockStates/sign/wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.13/blockStates/sign/wall_sign.json new file mode 100644 index 00000000..26453d53 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.13/blockStates/sign/wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/oak_wall" + }, + "facing=west": { + "model": "sign/oak_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/oak_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/oak_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/acacia.json b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/acacia.json new file mode 100644 index 00000000..7057ded0 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/acacia.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign", + "textures": { + "sign": "entity/signs/acacia" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/acacia_wall.json b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/acacia_wall.json new file mode 100644 index 00000000..70b755bf --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/acacia_wall.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign_wall", + "textures": { + "sign": "entity/signs/acacia" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/birch.json b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/birch.json new file mode 100644 index 00000000..d20d1438 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/birch.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign", + "textures": { + "sign": "entity/signs/birch" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/birch_wall.json b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/birch_wall.json new file mode 100644 index 00000000..c7983bee --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/birch_wall.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign_wall", + "textures": { + "sign": "entity/signs/birch" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/dark_oak.json b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/dark_oak.json new file mode 100644 index 00000000..803add52 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/dark_oak.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign", + "textures": { + "sign": "entity/signs/dark_oak" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/dark_oak_wall.json b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/dark_oak_wall.json new file mode 100644 index 00000000..b410acfe --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/dark_oak_wall.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign_wall", + "textures": { + "sign": "entity/signs/dark_oak" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/jungle.json b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/jungle.json new file mode 100644 index 00000000..17d52250 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/jungle.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign", + "textures": { + "sign": "entity/signs/jungle" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/jungle_wall.json b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/jungle_wall.json new file mode 100644 index 00000000..bfe6c8f8 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/jungle_wall.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/sign_wall", + "textures": { + "sign": "entity/signs/jungle" + } +} diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/spruce.json b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/spruce.json new file mode 100644 index 00000000..8f2b2179 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/spruce.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign", + "textures": { + "sign": "entity/signs/spruce" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/spruce_wall.json b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/spruce_wall.json new file mode 100644 index 00000000..1509eb3c --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockModels/sign/spruce_wall.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign_wall", + "textures": { + "sign": "entity/signs/spruce" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/acacia_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/acacia_sign.json new file mode 100644 index 00000000..370c2c84 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/acacia_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/acacia" + }, + "rotation=1": { + "model": "sign/acacia", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/acacia", + "y": 45 + }, + "rotation=3": { + "model": "sign/acacia", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/acacia", + "y": 90 + }, + "rotation=5": { + "model": "sign/acacia", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/acacia", + "y": 135 + }, + "rotation=7": { + "model": "sign/acacia", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/acacia", + "y": 180 + }, + "rotation=9": { + "model": "sign/acacia", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/acacia", + "y": 225 + }, + "rotation=11": { + "model": "sign/acacia", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/acacia", + "y": 270 + }, + "rotation=13": { + "model": "sign/acacia", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/acacia", + "y": 315 + }, + "rotation=15": { + "model": "sign/acacia", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/acacia_wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/acacia_wall_sign.json new file mode 100644 index 00000000..b524b126 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/acacia_wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/acacia_wall" + }, + "facing=west": { + "model": "sign/acacia_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/acacia_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/acacia_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/birch_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/birch_sign.json new file mode 100644 index 00000000..2ffe5fd5 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/birch_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/birch" + }, + "rotation=1": { + "model": "sign/birch", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/birch", + "y": 45 + }, + "rotation=3": { + "model": "sign/birch", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/birch", + "y": 90 + }, + "rotation=5": { + "model": "sign/birch", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/birch", + "y": 135 + }, + "rotation=7": { + "model": "sign/birch", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/birch", + "y": 180 + }, + "rotation=9": { + "model": "sign/birch", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/birch", + "y": 225 + }, + "rotation=11": { + "model": "sign/birch", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/birch", + "y": 270 + }, + "rotation=13": { + "model": "sign/birch", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/birch", + "y": 315 + }, + "rotation=15": { + "model": "sign/birch", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/birch_wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/birch_wall_sign.json new file mode 100644 index 00000000..622924b5 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/birch_wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/birch_wall" + }, + "facing=west": { + "model": "sign/birch_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/birch_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/birch_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/dark_oak_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/dark_oak_sign.json new file mode 100644 index 00000000..6001019b --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/dark_oak_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/dark_oak" + }, + "rotation=1": { + "model": "sign/dark_oak", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/dark_oak", + "y": 45 + }, + "rotation=3": { + "model": "sign/dark_oak", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/dark_oak", + "y": 90 + }, + "rotation=5": { + "model": "sign/dark_oak", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/dark_oak", + "y": 135 + }, + "rotation=7": { + "model": "sign/dark_oak", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/dark_oak", + "y": 180 + }, + "rotation=9": { + "model": "sign/dark_oak", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/dark_oak", + "y": 225 + }, + "rotation=11": { + "model": "sign/dark_oak", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/dark_oak", + "y": 270 + }, + "rotation=13": { + "model": "sign/dark_oak", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/dark_oak", + "y": 315 + }, + "rotation=15": { + "model": "sign/dark_oak", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/dark_oak_wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/dark_oak_wall_sign.json new file mode 100644 index 00000000..4b5cc921 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/dark_oak_wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/dark_oak_wall" + }, + "facing=west": { + "model": "sign/dark_oak_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/dark_oak_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/dark_oak_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/jungle_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/jungle_sign.json new file mode 100644 index 00000000..983c2d68 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/jungle_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/jungle" + }, + "rotation=1": { + "model": "sign/jungle", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/jungle", + "y": 45 + }, + "rotation=3": { + "model": "sign/jungle", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/jungle", + "y": 90 + }, + "rotation=5": { + "model": "sign/jungle", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/jungle", + "y": 135 + }, + "rotation=7": { + "model": "sign/jungle", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/jungle", + "y": 180 + }, + "rotation=9": { + "model": "sign/jungle", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/jungle", + "y": 225 + }, + "rotation=11": { + "model": "sign/jungle", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/jungle", + "y": 270 + }, + "rotation=13": { + "model": "sign/jungle", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/jungle", + "y": 315 + }, + "rotation=15": { + "model": "sign/jungle", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/jungle_wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/jungle_wall_sign.json new file mode 100644 index 00000000..898f7323 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/jungle_wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/jungle_wall" + }, + "facing=west": { + "model": "sign/jungle_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/jungle_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/jungle_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/oak_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/oak_sign.json new file mode 100644 index 00000000..4ebcedcd --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/oak_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/oak" + }, + "rotation=1": { + "model": "sign/oak", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/oak", + "y": 45 + }, + "rotation=3": { + "model": "sign/oak", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/oak", + "y": 90 + }, + "rotation=5": { + "model": "sign/oak", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/oak", + "y": 135 + }, + "rotation=7": { + "model": "sign/oak", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/oak", + "y": 180 + }, + "rotation=9": { + "model": "sign/oak", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/oak", + "y": 225 + }, + "rotation=11": { + "model": "sign/oak", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/oak", + "y": 270 + }, + "rotation=13": { + "model": "sign/oak", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/oak", + "y": 315 + }, + "rotation=15": { + "model": "sign/oak", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/oak_wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/oak_wall_sign.json new file mode 100644 index 00000000..26453d53 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/oak_wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/oak_wall" + }, + "facing=west": { + "model": "sign/oak_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/oak_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/oak_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/spruce_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/spruce_sign.json new file mode 100644 index 00000000..78722223 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/spruce_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/spruce" + }, + "rotation=1": { + "model": "sign/spruce", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/spruce", + "y": 45 + }, + "rotation=3": { + "model": "sign/spruce", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/spruce", + "y": 90 + }, + "rotation=5": { + "model": "sign/spruce", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/spruce", + "y": 135 + }, + "rotation=7": { + "model": "sign/spruce", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/spruce", + "y": 180 + }, + "rotation=9": { + "model": "sign/spruce", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/spruce", + "y": 225 + }, + "rotation=11": { + "model": "sign/spruce", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/spruce", + "y": 270 + }, + "rotation=13": { + "model": "sign/spruce", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/spruce", + "y": 315 + }, + "rotation=15": { + "model": "sign/spruce", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/spruce_wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/spruce_wall_sign.json new file mode 100644 index 00000000..8366709a --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.14/blockStates/sign/spruce_wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/spruce_wall" + }, + "facing=west": { + "model": "sign/spruce_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/spruce_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/spruce_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/crimson.json b/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/crimson.json new file mode 100644 index 00000000..201e42ad --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/crimson.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign", + "textures": { + "sign": "entity/signs/crimson" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/crimson_wall.json b/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/crimson_wall.json new file mode 100644 index 00000000..3faf8661 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/crimson_wall.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign_wall", + "textures": { + "sign": "entity/signs/crimson" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/warped.json b/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/warped.json new file mode 100644 index 00000000..6dd3269e --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/warped.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign", + "textures": { + "sign": "entity/signs/warped" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/warped_wall.json b/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/warped_wall.json new file mode 100644 index 00000000..a046ec14 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.16/blockModels/sign/warped_wall.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign_wall", + "textures": { + "sign": "entity/signs/warped" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/crimson_sign.json b/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/crimson_sign.json new file mode 100644 index 00000000..5df00a29 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/crimson_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/crimson" + }, + "rotation=1": { + "model": "sign/crimson", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/crimson", + "y": 45 + }, + "rotation=3": { + "model": "sign/crimson", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/crimson", + "y": 90 + }, + "rotation=5": { + "model": "sign/crimson", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/crimson", + "y": 135 + }, + "rotation=7": { + "model": "sign/crimson", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/crimson", + "y": 180 + }, + "rotation=9": { + "model": "sign/crimson", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/crimson", + "y": 225 + }, + "rotation=11": { + "model": "sign/crimson", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/crimson", + "y": 270 + }, + "rotation=13": { + "model": "sign/crimson", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/crimson", + "y": 315 + }, + "rotation=15": { + "model": "sign/crimson", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/crimson_wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/crimson_wall_sign.json new file mode 100644 index 00000000..149227b2 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/crimson_wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/crimson_wall" + }, + "facing=west": { + "model": "sign/crimson_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/crimson_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/crimson_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/warped_sign.json b/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/warped_sign.json new file mode 100644 index 00000000..4af216ca --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/warped_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/warped" + }, + "rotation=1": { + "model": "sign/warped", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/warped", + "y": 45 + }, + "rotation=3": { + "model": "sign/warped", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/warped", + "y": 90 + }, + "rotation=5": { + "model": "sign/warped", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/warped", + "y": 135 + }, + "rotation=7": { + "model": "sign/warped", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/warped", + "y": 180 + }, + "rotation=9": { + "model": "sign/warped", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/warped", + "y": 225 + }, + "rotation=11": { + "model": "sign/warped", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/warped", + "y": 270 + }, + "rotation=13": { + "model": "sign/warped", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/warped", + "y": 315 + }, + "rotation=15": { + "model": "sign/warped", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/warped_wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/warped_wall_sign.json new file mode 100644 index 00000000..b1d7f5e0 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.16/blockStates/sign/warped_wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/warped_wall" + }, + "facing=west": { + "model": "sign/warped_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/warped_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/warped_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.19/blockModels/sign/mangrove.json b/prismarine-viewer/viewer/prepare/data/1.19/blockModels/sign/mangrove.json new file mode 100644 index 00000000..bb82e85a --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.19/blockModels/sign/mangrove.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign", + "textures": { + "sign": "entity/signs/mangrove" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.19/blockModels/sign/mangrove_wall.json b/prismarine-viewer/viewer/prepare/data/1.19/blockModels/sign/mangrove_wall.json new file mode 100644 index 00000000..30e9bd55 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.19/blockModels/sign/mangrove_wall.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign_wall", + "textures": { + "sign": "entity/signs/mangrove" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.19/blockStates/sign/mangrove_sign.json b/prismarine-viewer/viewer/prepare/data/1.19/blockStates/sign/mangrove_sign.json new file mode 100644 index 00000000..54a92e7e --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.19/blockStates/sign/mangrove_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/mangrove" + }, + "rotation=1": { + "model": "sign/mangrove", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/mangrove", + "y": 45 + }, + "rotation=3": { + "model": "sign/mangrove", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/mangrove", + "y": 90 + }, + "rotation=5": { + "model": "sign/mangrove", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/mangrove", + "y": 135 + }, + "rotation=7": { + "model": "sign/mangrove", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/mangrove", + "y": 180 + }, + "rotation=9": { + "model": "sign/mangrove", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/mangrove", + "y": 225 + }, + "rotation=11": { + "model": "sign/mangrove", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/mangrove", + "y": 270 + }, + "rotation=13": { + "model": "sign/mangrove", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/mangrove", + "y": 315 + }, + "rotation=15": { + "model": "sign/mangrove", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.19/blockStates/sign/mangrove_wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.19/blockStates/sign/mangrove_wall_sign.json new file mode 100644 index 00000000..d00760e7 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.19/blockStates/sign/mangrove_wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/mangrove_wall" + }, + "facing=west": { + "model": "sign/mangrove_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/mangrove_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/mangrove_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/acacia_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/acacia_hanging.json new file mode 100644 index 00000000..13702388 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/acacia_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/hanging", + "textures": { + "wood": "entity/signs/hanging/acacia" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/acacia_wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/acacia_wall_hanging.json new file mode 100644 index 00000000..1e2a9d85 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/acacia_wall_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/wall_hanging", + "textures": { + "wood": "entity/signs/hanging/acacia" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo.json new file mode 100644 index 00000000..6c9fd930 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign", + "textures": { + "sign": "entity/signs/bamboo" + } +} diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_hanging.json new file mode 100644 index 00000000..c5302b1b --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/hanging", + "textures": { + "wood": "entity/signs/hanging/bamboo" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_wall.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_wall.json new file mode 100644 index 00000000..bf726f10 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_wall.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign_wall", + "textures": { + "sign": "entity/signs/bamboo" + } +} diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_wall_hanging.json new file mode 100644 index 00000000..d3a46453 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/bamboo_wall_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/wall_hanging", + "textures": { + "wood": "entity/signs/hanging/bamboo" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/birch_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/birch_hanging.json new file mode 100644 index 00000000..71a4b708 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/birch_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/hanging", + "textures": { + "wood": "entity/signs/hanging/birch" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/birch_wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/birch_wall_hanging.json new file mode 100644 index 00000000..13b215a5 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/birch_wall_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/wall_hanging", + "textures": { + "wood": "entity/signs/hanging/birch" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry.json new file mode 100644 index 00000000..406c6318 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign", + "textures": { + "sign": "entity/signs/cherry" + } +} diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_hanging.json new file mode 100644 index 00000000..6ff4c5b7 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/hanging", + "textures": { + "wood": "entity/signs/hanging/cherry" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_wall.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_wall.json new file mode 100644 index 00000000..b3b07061 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_wall.json @@ -0,0 +1,6 @@ +{ + "parent": "sign/sign_wall", + "textures": { + "sign": "entity/signs/cherry" + } +} diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_wall_hanging.json new file mode 100644 index 00000000..aeef94bd --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/cherry_wall_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/wall_hanging", + "textures": { + "wood": "entity/signs/hanging/cherry" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/crimson_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/crimson_hanging.json new file mode 100644 index 00000000..a6c9286a --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/crimson_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/hanging", + "textures": { + "wood": "entity/signs/hanging/crimson" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/crimson_wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/crimson_wall_hanging.json new file mode 100644 index 00000000..20889940 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/crimson_wall_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/wall_hanging", + "textures": { + "wood": "entity/signs/hanging/crimson" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/dark_oak_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/dark_oak_hanging.json new file mode 100644 index 00000000..506c4440 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/dark_oak_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/hanging", + "textures": { + "wood": "entity/signs/hanging/dark_oak" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/dark_oak_wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/dark_oak_wall_hanging.json new file mode 100644 index 00000000..21c1ebd5 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/dark_oak_wall_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/wall_hanging", + "textures": { + "wood": "entity/signs/hanging/dark_oak" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/hanging.json new file mode 100644 index 00000000..52d90ee3 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/hanging.json @@ -0,0 +1,115 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "ambientocclusion": false, + "texture_size": [ + 64, + 32 + ], + "textures": { + "wood": "entity/signs/hanging/oak" + }, + "elements": [ + { + "name": "Sign", + "from": [ + 1, + 0, + 7 + ], + "to": [ + 15, + 10, + 9 + ], + "faces": { + "north": { + "uv": [ + 4.5, + 7, + 8, + 12 + ], + "texture": "#wood" + }, + "east": { + "uv": [ + 4, + 7, + 4.5, + 12 + ], + "texture": "#wood" + }, + "south": { + "uv": [ + 0.5, + 7, + 4, + 12 + ], + "texture": "#wood" + }, + "west": { + "uv": [ + 0, + 7, + 0.5, + 12 + ], + "texture": "#wood" + }, + "up": { + "uv": [ + 4, + 6, + 0.5, + 7 + ], + "rotation": 180, + "texture": "#wood" + }, + "down": { + "uv": [ + 4, + 7, + 7.5, + 6 + ], + "texture": "#wood" + } + } + }, + { + "from": [ + 2, + 10, + 8 + ], + "to": [ + 14, + 16, + 8 + ], + "faces": { + "north": { + "uv": [ + 3.5, + 3, + 6.5, + 6 + ], + "texture": "#wood" + }, + "south": { + "uv": [ + 3.5, + 3, + 6.5, + 6 + ], + "texture": "#wood" + } + } + } + ] +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/jungle_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/jungle_hanging.json new file mode 100644 index 00000000..db141f6d --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/jungle_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/hanging", + "textures": { + "wood": "entity/signs/hanging/jungle" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/jungle_wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/jungle_wall_hanging.json new file mode 100644 index 00000000..aefe92f3 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/jungle_wall_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/wall_hanging", + "textures": { + "wood": "entity/signs/hanging/jungle" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/mangrove_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/mangrove_hanging.json new file mode 100644 index 00000000..e84c41f2 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/mangrove_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/hanging", + "textures": { + "wood": "entity/signs/hanging/mangrove" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/mangrove_wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/mangrove_wall_hanging.json new file mode 100644 index 00000000..e5feb72e --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/mangrove_wall_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/wall_hanging", + "textures": { + "wood": "entity/signs/hanging/mangrove" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/oak_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/oak_hanging.json new file mode 100644 index 00000000..7437c82f --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/oak_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/hanging", + "textures": { + "wood": "entity/signs/hanging/oak" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/oak_wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/oak_wall_hanging.json new file mode 100644 index 00000000..3c8d9e5e --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/oak_wall_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/wall_hanging", + "textures": { + "wood": "entity/signs/hanging/oak" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/spruce_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/spruce_hanging.json new file mode 100644 index 00000000..3dee635d --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/spruce_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/hanging", + "textures": { + "wood": "entity/signs/hanging/spruce" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/spruce_wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/spruce_wall_hanging.json new file mode 100644 index 00000000..71e66b9c --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/spruce_wall_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/wall_hanging", + "textures": { + "wood": "entity/signs/hanging/spruce" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/wall_hanging.json new file mode 100644 index 00000000..424ffe37 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/wall_hanging.json @@ -0,0 +1,347 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "ambientocclusion": false, + "texture_size": [ + 64, + 32 + ], + "textures": { + "wood": "entity/signs/hanging/oak" + }, + "elements": [ + { + "name": "Sign", + "from": [ + 1, + 0, + 7 + ], + "to": [ + 15, + 10, + 9 + ], + "rotation": { + "angle": 0, + "axis": "y", + "origin": [ + 8, + 8, + 8 + ] + }, + "faces": { + "north": { + "uv": [ + 4.5, + 7, + 8, + 12 + ], + "texture": "#wood" + }, + "east": { + "uv": [ + 4, + 7, + 4.5, + 12 + ], + "texture": "#wood" + }, + "south": { + "uv": [ + 0.5, + 7, + 4, + 12 + ], + "texture": "#wood" + }, + "west": { + "uv": [ + 0, + 7, + 0.5, + 12 + ], + "texture": "#wood" + }, + "up": { + "uv": [ + 4, + 6, + 0.5, + 7 + ], + "rotation": 180, + "texture": "#wood" + }, + "down": { + "uv": [ + 4, + 7, + 7.5, + 6 + ], + "texture": "#wood" + } + } + }, + { + "name": "Hanger", + "from": [ + 0, + 14, + 6 + ], + "to": [ + 16, + 16, + 10 + ], + "rotation": { + "angle": 0, + "axis": "y", + "origin": [ + 8, + 8, + 8 + ] + }, + "faces": { + "north": { + "uv": [ + 6, + 2, + 10, + 3 + ], + "texture": "#wood" + }, + "east": { + "uv": [ + 0, + 2, + 1, + 3 + ], + "texture": "#wood" + }, + "south": { + "uv": [ + 1, + 2, + 5, + 3 + ], + "texture": "#wood" + }, + "west": { + "uv": [ + 0, + 2, + 1, + 3 + ], + "texture": "#wood" + }, + "up": { + "uv": [ + 1, + 0, + 5, + 2 + ], + "rotation": 180, + "texture": "#wood" + }, + "down": { + "uv": [ + 5, + 0, + 9, + 2 + ], + "texture": "#wood" + } + } + }, + { + "name": "ChainA1", + "from": [ + 4.8, + 10, + 10.5 + ], + "to": [ + 6.2, + 14, + 10.5 + ], + "shade": false, + "rotation": { + "angle": -45, + "axis": "y", + "origin": [ + 8, + 8, + 8 + ], + "rescale": true + }, + "faces": { + "north": { + "uv": [ + 1.5, + 3, + 2.25, + 6 + ], + "texture": "#wood" + }, + "south": { + "uv": [ + 1.5, + 3, + 2.25, + 6 + ], + "texture": "#wood" + } + } + }, + { + "name": "ChainB2", + "from": [ + 10.5, + 10, + 4.8 + ], + "to": [ + 10.5, + 14, + 6.2 + ], + "shade": false, + "rotation": { + "angle": -45, + "axis": "y", + "origin": [ + 8, + 8, + 8 + ], + "rescale": true + }, + "faces": { + "east": { + "uv": [ + 0, + 3, + 0.75, + 6 + ], + "texture": "#wood" + }, + "west": { + "uv": [ + 0, + 3, + 0.75, + 6 + ], + "texture": "#wood" + } + } + }, + { + "name": "ChainB1", + "from": [ + 9.8, + 10, + 5.5 + ], + "to": [ + 11.2, + 14, + 5.5 + ], + "shade": false, + "rotation": { + "angle": -45, + "axis": "y", + "origin": [ + 8, + 8, + 8 + ], + "rescale": true + }, + "faces": { + "north": { + "uv": [ + 1.5, + 3, + 2.25, + 6 + ], + "texture": "#wood" + }, + "south": { + "uv": [ + 1.5, + 3, + 2.25, + 6 + ], + "texture": "#wood" + } + } + }, + { + "name": "ChainA2", + "from": [ + 5.5, + 10, + 9.8 + ], + "to": [ + 5.5, + 14, + 11.2 + ], + "shade": false, + "rotation": { + "angle": -45, + "axis": "y", + "origin": [ + 8, + 8, + 8 + ], + "rescale": true + }, + "faces": { + "east": { + "uv": [ + 0, + 3, + 0.75, + 6 + ], + "texture": "#wood" + }, + "west": { + "uv": [ + 0, + 3, + 0.75, + 6 + ], + "texture": "#wood" + } + } + } + ] +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/warped_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/warped_hanging.json new file mode 100644 index 00000000..015ba2c0 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/warped_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/hanging", + "textures": { + "wood": "entity/signs/hanging/warped" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/warped_wall_hanging.json b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/warped_wall_hanging.json new file mode 100644 index 00000000..8870c317 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockModels/sign/warped_wall_hanging.json @@ -0,0 +1,7 @@ +{ + "credit": "Made with Blockbench by TyBraniff for Bluemaps support.", + "parent": "sign/wall_hanging", + "textures": { + "wood": "entity/signs/hanging/warped" + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/acacia_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/acacia_hanging_sign.json new file mode 100644 index 00000000..18a25013 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/acacia_hanging_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/acacia_hanging", + "y": 180 + }, + "rotation=1": { + "model": "sign/acacia_hanging", + "y": 202.5 + }, + "rotation=2": { + "model": "sign/acacia_hanging", + "y": 225 + }, + "rotation=3": { + "model": "sign/acacia_hanging", + "y": 247.5 + }, + "rotation=4": { + "model": "sign/acacia_hanging", + "y": 270 + }, + "rotation=5": { + "model": "sign/acacia_hanging", + "y": 292.5 + }, + "rotation=6": { + "model": "sign/acacia_hanging", + "y": 315 + }, + "rotation=7": { + "model": "sign/acacia_hanging", + "y": 337.5 + }, + "rotation=8": { + "model": "sign/acacia_hanging" + }, + "rotation=9": { + "model": "sign/acacia_hanging", + "y": 22.5 + }, + "rotation=10": { + "model": "sign/acacia_hanging", + "y": 45 + }, + "rotation=11": { + "model": "sign/acacia_hanging", + "y": 67.5 + }, + "rotation=12": { + "model": "sign/acacia_hanging", + "y": 90 + }, + "rotation=13": { + "model": "sign/acacia_hanging", + "y": 112.5 + }, + "rotation=14": { + "model": "sign/acacia_hanging", + "y": 135 + }, + "rotation=15": { + "model": "sign/acacia_hanging", + "y": 157.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/acacia_wall_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/acacia_wall_hanging_sign.json new file mode 100644 index 00000000..edbae40d --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/acacia_wall_hanging_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "sign/acacia_wall_hanging", + "y": 90 + }, + "facing=south": { + "model": "sign/acacia_wall_hanging", + "y": 180 + }, + "facing=west": { + "model": "sign/acacia_wall_hanging", + "y": 270 + }, + "facing=north": { + "model": "sign/acacia_wall_hanging" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_hanging_sign.json new file mode 100644 index 00000000..5ff1854b --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_hanging_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/bamboo_hanging", + "y": 180 + }, + "rotation=1": { + "model": "sign/bamboo_hanging", + "y": 202.5 + }, + "rotation=2": { + "model": "sign/bamboo_hanging", + "y": 225 + }, + "rotation=3": { + "model": "sign/bamboo_hanging", + "y": 247.5 + }, + "rotation=4": { + "model": "sign/bamboo_hanging", + "y": 270 + }, + "rotation=5": { + "model": "sign/bamboo_hanging", + "y": 292.5 + }, + "rotation=6": { + "model": "sign/bamboo_hanging", + "y": 315 + }, + "rotation=7": { + "model": "sign/bamboo_hanging", + "y": 337.5 + }, + "rotation=8": { + "model": "sign/bamboo_hanging" + }, + "rotation=9": { + "model": "sign/bamboo_hanging", + "y": 22.5 + }, + "rotation=10": { + "model": "sign/bamboo_hanging", + "y": 45 + }, + "rotation=11": { + "model": "sign/bamboo_hanging", + "y": 67.5 + }, + "rotation=12": { + "model": "sign/bamboo_hanging", + "y": 90 + }, + "rotation=13": { + "model": "sign/bamboo_hanging", + "y": 112.5 + }, + "rotation=14": { + "model": "sign/bamboo_hanging", + "y": 135 + }, + "rotation=15": { + "model": "sign/bamboo_hanging", + "y": 157.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_sign.json new file mode 100644 index 00000000..1041460a --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/bamboo" + }, + "rotation=1": { + "model": "sign/bamboo", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/bamboo", + "y": 45 + }, + "rotation=3": { + "model": "sign/bamboo", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/bamboo", + "y": 90 + }, + "rotation=5": { + "model": "sign/bamboo", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/bamboo", + "y": 135 + }, + "rotation=7": { + "model": "sign/bamboo", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/bamboo", + "y": 180 + }, + "rotation=9": { + "model": "sign/bamboo", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/bamboo", + "y": 225 + }, + "rotation=11": { + "model": "sign/bamboo", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/bamboo", + "y": 270 + }, + "rotation=13": { + "model": "sign/bamboo", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/bamboo", + "y": 315 + }, + "rotation=15": { + "model": "sign/bamboo", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_wall_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_wall_hanging_sign.json new file mode 100644 index 00000000..3bd24804 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_wall_hanging_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "sign/bamboo_wall_hanging", + "y": 90 + }, + "facing=south": { + "model": "sign/bamboo_wall_hanging", + "y": 180 + }, + "facing=west": { + "model": "sign/bamboo_wall_hanging", + "y": 270 + }, + "facing=north": { + "model": "sign/bamboo_wall_hanging" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_wall_sign.json new file mode 100644 index 00000000..8b5ce481 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/bamboo_wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/bamboo_wall" + }, + "facing=west": { + "model": "sign/bamboo_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/bamboo_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/bamboo_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/birch_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/birch_hanging_sign.json new file mode 100644 index 00000000..6052d4f7 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/birch_hanging_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/birch_hanging", + "y": 180 + }, + "rotation=1": { + "model": "sign/birch_hanging", + "y": 202.5 + }, + "rotation=2": { + "model": "sign/birch_hanging", + "y": 225 + }, + "rotation=3": { + "model": "sign/birch_hanging", + "y": 247.5 + }, + "rotation=4": { + "model": "sign/birch_hanging", + "y": 270 + }, + "rotation=5": { + "model": "sign/birch_hanging", + "y": 292.5 + }, + "rotation=6": { + "model": "sign/birch_hanging", + "y": 315 + }, + "rotation=7": { + "model": "sign/birch_hanging", + "y": 337.5 + }, + "rotation=8": { + "model": "sign/birch_hanging" + }, + "rotation=9": { + "model": "sign/birch_hanging", + "y": 22.5 + }, + "rotation=10": { + "model": "sign/birch_hanging", + "y": 45 + }, + "rotation=11": { + "model": "sign/birch_hanging", + "y": 67.5 + }, + "rotation=12": { + "model": "sign/birch_hanging", + "y": 90 + }, + "rotation=13": { + "model": "sign/birch_hanging", + "y": 112.5 + }, + "rotation=14": { + "model": "sign/birch_hanging", + "y": 135 + }, + "rotation=15": { + "model": "sign/birch_hanging", + "y": 157.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/birch_wall_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/birch_wall_hanging_sign.json new file mode 100644 index 00000000..656e8093 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/birch_wall_hanging_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "sign/birch_wall_hanging", + "y": 90 + }, + "facing=south": { + "model": "sign/birch_wall_hanging", + "y": 180 + }, + "facing=west": { + "model": "sign/birch_wall_hanging", + "y": 270 + }, + "facing=north": { + "model": "sign/birch_wall_hanging" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_hanging_sign.json new file mode 100644 index 00000000..32ce33dc --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_hanging_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/cherry_hanging", + "y": 180 + }, + "rotation=1": { + "model": "sign/cherry_hanging", + "y": 202.5 + }, + "rotation=2": { + "model": "sign/cherry_hanging", + "y": 225 + }, + "rotation=3": { + "model": "sign/cherry_hanging", + "y": 247.5 + }, + "rotation=4": { + "model": "sign/cherry_hanging", + "y": 270 + }, + "rotation=5": { + "model": "sign/cherry_hanging", + "y": 292.5 + }, + "rotation=6": { + "model": "sign/cherry_hanging", + "y": 315 + }, + "rotation=7": { + "model": "sign/cherry_hanging", + "y": 337.5 + }, + "rotation=8": { + "model": "sign/cherry_hanging" + }, + "rotation=9": { + "model": "sign/cherry_hanging", + "y": 22.5 + }, + "rotation=10": { + "model": "sign/cherry_hanging", + "y": 45 + }, + "rotation=11": { + "model": "sign/cherry_hanging", + "y": 67.5 + }, + "rotation=12": { + "model": "sign/cherry_hanging", + "y": 90 + }, + "rotation=13": { + "model": "sign/cherry_hanging", + "y": 112.5 + }, + "rotation=14": { + "model": "sign/cherry_hanging", + "y": 135 + }, + "rotation=15": { + "model": "sign/cherry_hanging", + "y": 157.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_sign.json new file mode 100644 index 00000000..4e562a26 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/cherry" + }, + "rotation=1": { + "model": "sign/cherry", + "y": 22.5 + }, + "rotation=2": { + "model": "sign/cherry", + "y": 45 + }, + "rotation=3": { + "model": "sign/cherry", + "y": 67.5 + }, + "rotation=4": { + "model": "sign/cherry", + "y": 90 + }, + "rotation=5": { + "model": "sign/cherry", + "y": 112.5 + }, + "rotation=6": { + "model": "sign/cherry", + "y": 135 + }, + "rotation=7": { + "model": "sign/cherry", + "y": 157.5 + }, + "rotation=8": { + "model": "sign/cherry", + "y": 180 + }, + "rotation=9": { + "model": "sign/cherry", + "y": 202.5 + }, + "rotation=10": { + "model": "sign/cherry", + "y": 225 + }, + "rotation=11": { + "model": "sign/cherry", + "y": 247.5 + }, + "rotation=12": { + "model": "sign/cherry", + "y": 270 + }, + "rotation=13": { + "model": "sign/cherry", + "y": 292.5 + }, + "rotation=14": { + "model": "sign/cherry", + "y": 315 + }, + "rotation=15": { + "model": "sign/cherry", + "y": 337.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_wall_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_wall_hanging_sign.json new file mode 100644 index 00000000..3e0a2d04 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_wall_hanging_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "sign/cherry_wall_hanging", + "y": 90 + }, + "facing=south": { + "model": "sign/cherry_wall_hanging", + "y": 180 + }, + "facing=west": { + "model": "sign/cherry_wall_hanging", + "y": 270 + }, + "facing=north": { + "model": "sign/cherry_wall_hanging" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_wall_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_wall_sign.json new file mode 100644 index 00000000..1b13342c --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/cherry_wall_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "sign/cherry_wall" + }, + "facing=west": { + "model": "sign/cherry_wall", + "y": 90 + }, + "facing=north": { + "model": "sign/cherry_wall", + "y": 180 + }, + "facing=east": { + "model": "sign/cherry_wall", + "y": 270 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/crimson_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/crimson_hanging_sign.json new file mode 100644 index 00000000..6e4131f2 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/crimson_hanging_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/crimson_hanging", + "y": 180 + }, + "rotation=1": { + "model": "sign/crimson_hanging", + "y": 202.5 + }, + "rotation=2": { + "model": "sign/crimson_hanging", + "y": 225 + }, + "rotation=3": { + "model": "sign/crimson_hanging", + "y": 247.5 + }, + "rotation=4": { + "model": "sign/crimson_hanging", + "y": 270 + }, + "rotation=5": { + "model": "sign/crimson_hanging", + "y": 292.5 + }, + "rotation=6": { + "model": "sign/crimson_hanging", + "y": 315 + }, + "rotation=7": { + "model": "sign/crimson_hanging", + "y": 337.5 + }, + "rotation=8": { + "model": "sign/crimson_hanging" + }, + "rotation=9": { + "model": "sign/crimson_hanging", + "y": 22.5 + }, + "rotation=10": { + "model": "sign/crimson_hanging", + "y": 45 + }, + "rotation=11": { + "model": "sign/crimson_hanging", + "y": 67.5 + }, + "rotation=12": { + "model": "sign/crimson_hanging", + "y": 90 + }, + "rotation=13": { + "model": "sign/crimson_hanging", + "y": 112.5 + }, + "rotation=14": { + "model": "sign/crimson_hanging", + "y": 135 + }, + "rotation=15": { + "model": "sign/crimson_hanging", + "y": 157.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/crimson_wall_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/crimson_wall_hanging_sign.json new file mode 100644 index 00000000..63c560ae --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/crimson_wall_hanging_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "sign/crimson_wall_hanging", + "y": 90 + }, + "facing=south": { + "model": "sign/crimson_wall_hanging", + "y": 180 + }, + "facing=west": { + "model": "sign/crimson_wall_hanging", + "y": 270 + }, + "facing=north": { + "model": "sign/crimson_wall_hanging" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/dark_oak_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/dark_oak_hanging_sign.json new file mode 100644 index 00000000..a2bc0458 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/dark_oak_hanging_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/dark_oak_hanging", + "y": 180 + }, + "rotation=1": { + "model": "sign/dark_oak_hanging", + "y": 202.5 + }, + "rotation=2": { + "model": "sign/dark_oak_hanging", + "y": 225 + }, + "rotation=3": { + "model": "sign/dark_oak_hanging", + "y": 247.5 + }, + "rotation=4": { + "model": "sign/dark_oak_hanging", + "y": 270 + }, + "rotation=5": { + "model": "sign/dark_oak_hanging", + "y": 292.5 + }, + "rotation=6": { + "model": "sign/dark_oak_hanging", + "y": 315 + }, + "rotation=7": { + "model": "sign/dark_oak_hanging", + "y": 337.5 + }, + "rotation=8": { + "model": "sign/dark_oak_hanging" + }, + "rotation=9": { + "model": "sign/dark_oak_hanging", + "y": 22.5 + }, + "rotation=10": { + "model": "sign/dark_oak_hanging", + "y": 45 + }, + "rotation=11": { + "model": "sign/dark_oak_hanging", + "y": 67.5 + }, + "rotation=12": { + "model": "sign/dark_oak_hanging", + "y": 90 + }, + "rotation=13": { + "model": "sign/dark_oak_hanging", + "y": 112.5 + }, + "rotation=14": { + "model": "sign/dark_oak_hanging", + "y": 135 + }, + "rotation=15": { + "model": "sign/dark_oak_hanging", + "y": 157.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/dark_oak_wall_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/dark_oak_wall_hanging_sign.json new file mode 100644 index 00000000..138154f9 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/dark_oak_wall_hanging_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "sign/dark_oak_wall_hanging", + "y": 90 + }, + "facing=south": { + "model": "sign/dark_oak_wall_hanging", + "y": 180 + }, + "facing=west": { + "model": "sign/dark_oak_wall_hanging", + "y": 270 + }, + "facing=north": { + "model": "sign/dark_oak_wall_hanging" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/jungle_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/jungle_hanging_sign.json new file mode 100644 index 00000000..9f1f9eeb --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/jungle_hanging_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/jungle_hanging", + "y": 180 + }, + "rotation=1": { + "model": "sign/jungle_hanging", + "y": 202.5 + }, + "rotation=2": { + "model": "sign/jungle_hanging", + "y": 225 + }, + "rotation=3": { + "model": "sign/jungle_hanging", + "y": 247.5 + }, + "rotation=4": { + "model": "sign/jungle_hanging", + "y": 270 + }, + "rotation=5": { + "model": "sign/jungle_hanging", + "y": 292.5 + }, + "rotation=6": { + "model": "sign/jungle_hanging", + "y": 315 + }, + "rotation=7": { + "model": "sign/jungle_hanging", + "y": 337.5 + }, + "rotation=8": { + "model": "sign/jungle_hanging" + }, + "rotation=9": { + "model": "sign/jungle_hanging", + "y": 22.5 + }, + "rotation=10": { + "model": "sign/jungle_hanging", + "y": 45 + }, + "rotation=11": { + "model": "sign/jungle_hanging", + "y": 67.5 + }, + "rotation=12": { + "model": "sign/jungle_hanging", + "y": 90 + }, + "rotation=13": { + "model": "sign/jungle_hanging", + "y": 112.5 + }, + "rotation=14": { + "model": "sign/jungle_hanging", + "y": 135 + }, + "rotation=15": { + "model": "sign/jungle_hanging", + "y": 157.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/jungle_wall_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/jungle_wall_hanging_sign.json new file mode 100644 index 00000000..3bdb8191 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/jungle_wall_hanging_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "sign/jungle_wall_hanging", + "y": 90 + }, + "facing=south": { + "model": "sign/jungle_wall_hanging", + "y": 180 + }, + "facing=west": { + "model": "sign/jungle_wall_hanging", + "y": 270 + }, + "facing=north": { + "model": "sign/jungle_wall_hanging" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/mangrove_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/mangrove_hanging_sign.json new file mode 100644 index 00000000..ff977160 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/mangrove_hanging_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/mangrove_hanging", + "y": 180 + }, + "rotation=1": { + "model": "sign/mangrove_hanging", + "y": 202.5 + }, + "rotation=2": { + "model": "sign/mangrove_hanging", + "y": 225 + }, + "rotation=3": { + "model": "sign/mangrove_hanging", + "y": 247.5 + }, + "rotation=4": { + "model": "sign/mangrove_hanging", + "y": 270 + }, + "rotation=5": { + "model": "sign/mangrove_hanging", + "y": 292.5 + }, + "rotation=6": { + "model": "sign/mangrove_hanging", + "y": 315 + }, + "rotation=7": { + "model": "sign/mangrove_hanging", + "y": 337.5 + }, + "rotation=8": { + "model": "sign/mangrove_hanging" + }, + "rotation=9": { + "model": "sign/mangrove_hanging", + "y": 22.5 + }, + "rotation=10": { + "model": "sign/mangrove_hanging", + "y": 45 + }, + "rotation=11": { + "model": "sign/mangrove_hanging", + "y": 67.5 + }, + "rotation=12": { + "model": "sign/mangrove_hanging", + "y": 90 + }, + "rotation=13": { + "model": "sign/mangrove_hanging", + "y": 112.5 + }, + "rotation=14": { + "model": "sign/mangrove_hanging", + "y": 135 + }, + "rotation=15": { + "model": "sign/mangrove_hanging", + "y": 157.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/mangrove_wall_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/mangrove_wall_hanging_sign.json new file mode 100644 index 00000000..9d1d019a --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/mangrove_wall_hanging_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "sign/mangrove_wall_hanging", + "y": 90 + }, + "facing=south": { + "model": "sign/mangrove_wall_hanging", + "y": 180 + }, + "facing=west": { + "model": "sign/mangrove_wall_hanging", + "y": 270 + }, + "facing=north": { + "model": "sign/mangrove_wall_hanging" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/oak_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/oak_hanging_sign.json new file mode 100644 index 00000000..01e66da8 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/oak_hanging_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/oak_hanging", + "y": 180 + }, + "rotation=1": { + "model": "sign/oak_hanging", + "y": 202.5 + }, + "rotation=2": { + "model": "sign/oak_hanging", + "y": 225 + }, + "rotation=3": { + "model": "sign/oak_hanging", + "y": 247.5 + }, + "rotation=4": { + "model": "sign/oak_hanging", + "y": 270 + }, + "rotation=5": { + "model": "sign/oak_hanging", + "y": 292.5 + }, + "rotation=6": { + "model": "sign/oak_hanging", + "y": 315 + }, + "rotation=7": { + "model": "sign/oak_hanging", + "y": 337.5 + }, + "rotation=8": { + "model": "sign/oak_hanging" + }, + "rotation=9": { + "model": "sign/oak_hanging", + "y": 22.5 + }, + "rotation=10": { + "model": "sign/oak_hanging", + "y": 45 + }, + "rotation=11": { + "model": "sign/oak_hanging", + "y": 67.5 + }, + "rotation=12": { + "model": "sign/oak_hanging", + "y": 90 + }, + "rotation=13": { + "model": "sign/oak_hanging", + "y": 112.5 + }, + "rotation=14": { + "model": "sign/oak_hanging", + "y": 135 + }, + "rotation=15": { + "model": "sign/oak_hanging", + "y": 157.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/oak_wall_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/oak_wall_hanging_sign.json new file mode 100644 index 00000000..9af80947 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/oak_wall_hanging_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "sign/oak_wall_hanging", + "y": 90 + }, + "facing=south": { + "model": "sign/oak_wall_hanging", + "y": 180 + }, + "facing=west": { + "model": "sign/oak_wall_hanging", + "y": 270 + }, + "facing=north": { + "model": "sign/oak_wall_hanging" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/spruce_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/spruce_hanging_sign.json new file mode 100644 index 00000000..ee9509f6 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/spruce_hanging_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/spruce_hanging", + "y": 180 + }, + "rotation=1": { + "model": "sign/spruce_hanging", + "y": 202.5 + }, + "rotation=2": { + "model": "sign/spruce_hanging", + "y": 225 + }, + "rotation=3": { + "model": "sign/spruce_hanging", + "y": 247.5 + }, + "rotation=4": { + "model": "sign/spruce_hanging", + "y": 270 + }, + "rotation=5": { + "model": "sign/spruce_hanging", + "y": 292.5 + }, + "rotation=6": { + "model": "sign/spruce_hanging", + "y": 315 + }, + "rotation=7": { + "model": "sign/spruce_hanging", + "y": 337.5 + }, + "rotation=8": { + "model": "sign/spruce_hanging" + }, + "rotation=9": { + "model": "sign/spruce_hanging", + "y": 22.5 + }, + "rotation=10": { + "model": "sign/spruce_hanging", + "y": 45 + }, + "rotation=11": { + "model": "sign/spruce_hanging", + "y": 67.5 + }, + "rotation=12": { + "model": "sign/spruce_hanging", + "y": 90 + }, + "rotation=13": { + "model": "sign/spruce_hanging", + "y": 112.5 + }, + "rotation=14": { + "model": "sign/spruce_hanging", + "y": 135 + }, + "rotation=15": { + "model": "sign/spruce_hanging", + "y": 157.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/spruce_wall_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/spruce_wall_hanging_sign.json new file mode 100644 index 00000000..0b9ec25a --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/spruce_wall_hanging_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "sign/spruce_wall_hanging", + "y": 90 + }, + "facing=south": { + "model": "sign/spruce_wall_hanging", + "y": 180 + }, + "facing=west": { + "model": "sign/spruce_wall_hanging", + "y": 270 + }, + "facing=north": { + "model": "sign/spruce_wall_hanging" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/warped_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/warped_hanging_sign.json new file mode 100644 index 00000000..93764856 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/warped_hanging_sign.json @@ -0,0 +1,67 @@ +{ + "variants": { + "rotation=0": { + "model": "sign/warped_hanging", + "y": 180 + }, + "rotation=1": { + "model": "sign/warped_hanging", + "y": 202.5 + }, + "rotation=2": { + "model": "sign/warped_hanging", + "y": 225 + }, + "rotation=3": { + "model": "sign/warped_hanging", + "y": 247.5 + }, + "rotation=4": { + "model": "sign/warped_hanging", + "y": 270 + }, + "rotation=5": { + "model": "sign/warped_hanging", + "y": 292.5 + }, + "rotation=6": { + "model": "sign/warped_hanging", + "y": 315 + }, + "rotation=7": { + "model": "sign/warped_hanging", + "y": 337.5 + }, + "rotation=8": { + "model": "sign/warped_hanging" + }, + "rotation=9": { + "model": "sign/warped_hanging", + "y": 22.5 + }, + "rotation=10": { + "model": "sign/warped_hanging", + "y": 45 + }, + "rotation=11": { + "model": "sign/warped_hanging", + "y": 67.5 + }, + "rotation=12": { + "model": "sign/warped_hanging", + "y": 90 + }, + "rotation=13": { + "model": "sign/warped_hanging", + "y": 112.5 + }, + "rotation=14": { + "model": "sign/warped_hanging", + "y": 135 + }, + "rotation=15": { + "model": "sign/warped_hanging", + "y": 157.5 + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/warped_wall_hanging_sign.json b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/warped_wall_hanging_sign.json new file mode 100644 index 00000000..378e80f8 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/data/1.20/blockStates/sign/warped_wall_hanging_sign.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=east": { + "model": "sign/warped_wall_hanging", + "y": 90 + }, + "facing=south": { + "model": "sign/warped_wall_hanging", + "y": 180 + }, + "facing=west": { + "model": "sign/warped_wall_hanging", + "y": 270 + }, + "facing=north": { + "model": "sign/warped_wall_hanging" + } + } +} \ No newline at end of file diff --git a/prismarine-viewer/viewer/prepare/modelsBuilder.ts b/prismarine-viewer/viewer/prepare/modelsBuilder.ts index 2a0cac57..b6e5268f 100644 --- a/prismarine-viewer/viewer/prepare/modelsBuilder.ts +++ b/prismarine-viewer/viewer/prepare/modelsBuilder.ts @@ -161,7 +161,7 @@ function prepareModel (model: BlockModel, texturesJson) { const getFinalTexture = (originalBlockName) => { // texture name e.g. blocks/anvil_base - const cleanBlockName = cleanupBlockName(originalBlockName); + const cleanBlockName = cleanupBlockName(originalBlockName) return { ...texturesJson[cleanBlockName], /* __debugName: cleanBlockName */ } } @@ -187,10 +187,12 @@ function prepareModel (model: BlockModel, texturesJson) { for (const sideName of Object.keys(elem.faces)) { const face = elem.faces[sideName] + const textureRaw = face.texture.charAt(0) === '#' + ? finalTextures![face.texture.slice(1)] + : getFinalTexture(face.texture) + if (!textureRaw) throw new Error(`Texture ${face.texture} in ${JSON.stringify(model.textures)} not found`) const finalTexture = deepCopy( - face.texture.charAt(0) === '#' - ? finalTextures![face.texture.slice(1)] - : getFinalTexture(face.texture) + textureRaw ) const _from = elem.from diff --git a/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts b/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts index b343e595..e64b7cff 100644 --- a/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts +++ b/prismarine-viewer/viewer/prepare/moreGeneratedBlocks.ts @@ -4,9 +4,10 @@ import { McAssets } from './modelsBuilder' import path from 'path' import fs from 'fs' import { fileURLToPath } from 'url' +import { versionToNumber } from './utils' // todo refactor -const twoTileTextures: string[] = [] +const handledBlocks = ['water', 'lava', 'barrier'] const origSizeTextures: string[] = [] let currentImage: Jimp let currentBlockName: string @@ -121,115 +122,6 @@ const handleShulkerBox = async (dataBase: string, match: RegExpExecArray) => { await addSimpleCubeWithSides(shulkerBoxTextures) } -const handleSign = async (dataBase: string, match: RegExpExecArray) => { - const states = getBlockStates(currentBlockName) - if (!states) return - - const [, signMaterial = ''] = match - currentImage = await Jimp.read(`${dataBase}entity/${signMaterial ? `signs/${signMaterial}` : 'sign'}.png`) - // todo cache - const signTextures = { - // todo correct mapping - // todo alg to fit to the side - signboard_side: justCrop(0, 2, 2, 12), - face: justCrop(2, 2, 24, 12), - up: justCrop(2, 0, 24, 2), - support: justCrop(0, 16, 2, 14) - } - const blockTextures = await getBlockTexturesFromJimp(signTextures, true) - - const isWall = currentBlockName.includes('wall_') - const isHanging = currentBlockName.includes('hanging_') - const rotationState = states.find(state => state.name === 'rotation') - const faceTexture = { texture: blockTextures.face.texture, uv: blockTextures.face.uv } - if (isWall || isHanging) { - // todo isHanging - if (!isHanging) { - const facingState = states.find(state => state.name === 'facing')! - const facingMap = { - south: 0, - west: 90, - north: 180, - east: 270 - } - - currentMcAssets.blocksStates[currentBlockName] = { - "variants": Object.fromEntries( - facingState.values!.map((_val, i) => { - const val = _val as string - return [`facing=${val}`, { - "model": currentBlockName, - y: facingMap[val], - }] - }) - ) - } - currentMcAssets.blocksModels[currentBlockName] = { - elements: [ - { - // signboard - "from": [0, 4.5, 0], - "to": [16, 11.5, 1.5], - faces: { - south: faceTexture, - east: blockTextures.signboard_side, - west: blockTextures.signboard_side, - up: blockTextures.up, - down: blockTextures.up, - }, - } - ], - } - } - } else if (rotationState) { - currentMcAssets.blocksStates[currentBlockName] = { - "variants": Object.fromEntries( - Array.from({ length: 16 }).map((_val, i) => { - return [`rotation=${i}`, { - "model": currentBlockName, - y: i * (45 / 2), - }] - }) - ) - } - - const supportTexture = blockTextures.support - // TODO fix models.ts, apply textures for signs correctly! - // const supportTexture = { texture: supportTextureImg, uv: [0, 0, 16, 16] } - currentMcAssets.blocksModels[currentBlockName] = { - elements: [ - { - // support post - "from": [7.5, 0, 7.5], - "to": [8.5, 9, 8.5], - faces: { - // todo 14 - north: supportTexture, - east: supportTexture, - south: supportTexture, - west: supportTexture, - } - }, - { - // signboard - "from": [0, 9, 7.25], - "to": [16, 16, 8.75], - faces: { - north: faceTexture, - south: faceTexture, - east: blockTextures.signboard_side, - west: blockTextures.signboard_side, - up: blockTextures.up, - down: blockTextures.up, - }, - } - ], - } - } - twoTileTextures.push(blockTextures.face.texture) - twoTileTextures.push(blockTextures.up.texture) -} - // TODO! should not be there! move to data with signs! const chestModels = { chest: { @@ -405,10 +297,10 @@ const handleChest = async (dataBase: string, match: RegExpExecArray) => { async function loadBlockModelTextures (dataBase: string, blockModel: any) { for (const key in blockModel.textures) { - const texture: string = blockModel.textures[key] - currentImage = await Jimp.read(dataBase + texture + '.png') + let texture: string = blockModel.textures[key] + const useAssetsPath = !!texture.match(/^[0-9.]+\//) blockModel.textures.particle = texture - generatedImageTextures[texture] = `data:image/png;base64,${fs.readFileSync(path.join(dataBase, texture + '.png'), 'base64')}` + generatedImageTextures[texture] = `data:image/png;base64,${fs.readFileSync(path.join(dataBase, useAssetsPath ? '..' : '', texture + '.png'), 'base64')}` origSizeTextures[texture] = true } } @@ -416,11 +308,6 @@ async function loadBlockModelTextures (dataBase: string, blockModel: any) { const handlers = [ [/(.+)_shulker_box$/, handleShulkerBox], [/^shulker_box$/, handleShulkerBox], - [/^sign$/, handleSign], - [/^standing_sign$/, handleSign], - [/^wall_sign$/, handleSign], - [/(.+)_wall_sign$/, handleSign], - [/(.+)_sign$/, handleSign], [/^(?:(ender|trapped)_)?chest$/, handleChest], // [/(^|(.+)_)bed$/, handleBed], // no-op just suppress warning @@ -439,25 +326,58 @@ export const tryHandleBlockEntity = async (dataBase, blockName) => { } } -const handleExternalData = async (dataBase: string, version: string) => { - const [major, minor] = version.split(".") - const dataVer = `${major}.${minor}` - const baseDir = path.join(__dirname, 'data', dataVer) - if (!fs.existsSync(baseDir)) return +async function readAllBlockStates (blockStatesDir: string) { + const files = fs.readdirSync(blockStatesDir) + for (const file of files) { + if (file.endsWith('.json')) { + const state = JSON.parse(fs.readFileSync(path.join(blockStatesDir, file), 'utf-8')) + const name = file.replace('.json', '') + currentMcAssets.blocksStates[name] = state + handledBlocks.push(name) + } else { + await readAllBlockStates(path.join(blockStatesDir, file)) + } + } +} - const blockModelsDir = path.join(baseDir, 'blockModels') - const allBlockModels = fs.readdirSync(blockModelsDir).map(x => x.replace('.json', '')) - for (const blockModel of allBlockModels) { - const model = JSON.parse(fs.readFileSync(path.join(blockModelsDir, blockModel + '.json'), 'utf-8')) - currentMcAssets.blocksModels[blockModel] = model - await loadBlockModelTextures(dataBase, model) +async function readAllBlockModels (dataBase: string, blockModelsDir: string, completePath: string) { + const actualPath = completePath.length ? completePath + "/" : "" + const files = fs.readdirSync(blockModelsDir) + for (const file of files) { + if (file.endsWith('.json')) { + const model = JSON.parse(fs.readFileSync(path.join(blockModelsDir, file), 'utf-8')) + const name = actualPath + file.replace('.json', '') + currentMcAssets.blocksModels[name] = model + await loadBlockModelTextures(dataBase, model) + } else { + await readAllBlockModels(dataBase, path.join(blockModelsDir, file), actualPath + file) + } + } +} + +const handleExternalData = async (assetsPathRoot: string, version: string) => { + const currentVersionNumber = versionToNumber(version) + const versions = fs.readdirSync(path.join(__dirname, 'data'), { withFileTypes: true }) + .filter(x => x.isDirectory()) + .map(x => x.name) + .sort((a, b) => versionToNumber(b) - versionToNumber(a)) + + const allAssetsVersions = fs.readdirSync(assetsPathRoot, { withFileTypes: true }) + .filter(x => x.isDirectory()) + .map(x => x.name) + .sort((a, b) => versionToNumber(b) - versionToNumber(a)) + + const getAssetsVersion = (version: string) => { + return allAssetsVersions[version] ?? allAssetsVersions.find(x => x.startsWith(version)) } - const blockStatesDir = path.join(baseDir, 'blockStates') - const allBlockStates = fs.readdirSync(blockStatesDir).map(x => x.replace('.json', '')) - for (const blockState of allBlockStates) { - const state = JSON.parse(fs.readFileSync(path.join(blockStatesDir, blockState + '.json'), 'utf-8')) - currentMcAssets.blocksStates[blockState] = state + for (const curVer of versions) { + const baseDir = path.join(__dirname, 'data', curVer) + if (versionToNumber(curVer) > currentVersionNumber) continue + + const assetsVersion = getAssetsVersion(curVer) + await readAllBlockStates(path.join(baseDir, 'blockStates')) + await readAllBlockModels(path.join(assetsPathRoot, assetsVersion), path.join(baseDir, 'blockModels'), "") } } @@ -466,7 +386,6 @@ export const prepareMoreGeneratedBlocks = async (mcAssets: McAssets) => { const allTheBlocks = mcData.blocksArray.map(x => x.name) currentMcAssets = mcAssets - const handledBlocks = ['water', 'lava', 'barrier'] // todo const ignoredBlocks = ['skull', 'structure_void', 'banner', 'bed', 'end_portal'] @@ -481,7 +400,7 @@ export const prepareMoreGeneratedBlocks = async (mcAssets: McAssets) => { } } - await handleExternalData(mcAssets.directory, mcAssets.version) + await handleExternalData(path.join(mcAssets.directory, '..'), mcAssets.version) const warnings: string[] = [] for (const [name, model] of Object.entries(mcAssets.blocksModels)) { @@ -498,5 +417,5 @@ export const prepareMoreGeneratedBlocks = async (mcAssets: McAssets) => { } export const getAdditionalTextures = () => { - return { generated: generatedImageTextures, twoTileTextures, origSizeTextures } + return { generated: generatedImageTextures, origSizeTextures } } From 2d4b89651cdd8ff4ad9268d51aeb1c90f01b8968 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 11 Jun 2024 21:17:07 +0300 Subject: [PATCH 034/985] format, remove useless comment --- .../viewer/lib/worldrendererThree.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/prismarine-viewer/viewer/lib/worldrendererThree.ts b/prismarine-viewer/viewer/lib/worldrendererThree.ts index 095e5a94..9a76474b 100644 --- a/prismarine-viewer/viewer/lib/worldrendererThree.ts +++ b/prismarine-viewer/viewer/lib/worldrendererThree.ts @@ -22,7 +22,7 @@ export class WorldRendererThree extends WorldRendererCommon { return Object.values(this.sectionObjects).reduce((acc, obj) => acc + (obj as any).tilesCount, 0) } - constructor(public scene: THREE.Scene, public renderer: THREE.WebGLRenderer, public config: WorldRendererConfig) { + constructor (public scene: THREE.Scene, public renderer: THREE.WebGLRenderer, public config: WorldRendererConfig) { super(config) this.starField = new StarField(scene) } @@ -181,13 +181,12 @@ export class WorldRendererThree extends WorldRendererCommon { const mesh = new THREE.Mesh(new THREE.PlaneGeometry(1, 1), new THREE.MeshBasicMaterial({ map: tex, transparent: true, })) mesh.renderOrder = 999 - // todo @sa2urami shouldnt all this be done in worker? - const lineHeight = 7 / 16; + const lineHeight = 7 / 16 const scaleFactor = isHanging ? 1.3 : 1 mesh.scale.set(1 * scaleFactor, lineHeight * scaleFactor, 1 * scaleFactor) const thickness = (isHanging ? 2 : 1.5) / 16 - const wallSpacing = 0.25 / 16; + const wallSpacing = 0.25 / 16 if (isWall && !isHanging) { mesh.position.set(0, 0, -0.5 + thickness + wallSpacing + 0.0001) } else { @@ -199,9 +198,9 @@ export class WorldRendererThree extends WorldRendererCommon { rotation * (isWall ? 90 : 45 / 2) ), 0) group.add(mesh) - const height = (isHanging ? 10 : 8)/16 + const height = (isHanging ? 10 : 8) / 16 const heightOffset = (isHanging ? 0 : isWall ? 4.333 : 9.333) / 16 - const textPosition = height/2 + heightOffset + const textPosition = height / 2 + heightOffset group.position.set(position.x + 0.5, position.y + textPosition, position.z + 0.5) return group } @@ -322,7 +321,7 @@ class StarField { } } - constructor(private scene: THREE.Scene) { + constructor (private scene: THREE.Scene) { } addToScene () { @@ -386,7 +385,7 @@ class StarField { const version = parseInt(THREE.REVISION.replace(/\D+/g, '')) class StarfieldMaterial extends THREE.ShaderMaterial { - constructor() { + constructor () { super({ uniforms: { time: { value: 0.0 }, fade: { value: 1.0 } }, vertexShader: /* glsl */ ` From 4f20e2481947d813317b3888e75e77b0b85f39dc Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Wed, 12 Jun 2024 21:14:48 +0300 Subject: [PATCH 035/985] up flying squid --- package.json | 2 +- pnpm-lock.yaml | 79 ++++++++++++++++++++++++-------------------------- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index 7bbde636..f5f55c7f 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "esbuild-plugin-polyfill-node": "^0.3.0", "express": "^4.18.2", "filesize": "^10.0.12", - "flying-squid": "npm:@zardoy/flying-squid@^0.0.24", + "flying-squid": "npm:@zardoy/flying-squid@^0.0.26", "fs-extra": "^11.1.1", "google-drive-browserfs": "github:zardoy/browserfs#google-drive", "iconify-icon": "^1.0.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 38a9ebb6..3cbab433 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -104,8 +104,8 @@ importers: specifier: ^10.0.12 version: 10.0.12 flying-squid: - specifier: npm:@zardoy/flying-squid@^0.0.24 - version: '@zardoy/flying-squid@0.0.24(encoding@0.1.13)' + specifier: npm:@zardoy/flying-squid@^0.0.26 + version: '@zardoy/flying-squid@0.0.26(encoding@0.1.13)' fs-extra: specifier: ^11.1.1 version: 11.1.1 @@ -386,7 +386,7 @@ importers: version: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 prismarine-chunk: specifier: github:zardoy/prismarine-chunk - version: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/f32234a724a5c2482ffbaf85edc5e91c7ab9b38f(minecraft-data@3.65.0) + version: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) prismarine-schematic: specifier: ^1.2.0 version: 1.2.3 @@ -3054,8 +3054,8 @@ packages: resolution: {integrity: sha512-6xm38yGVIa6mKm/DUCF2zFFJhERh/QWp1ufm4cNUvxsONBmfPg8uZ9pZBdOmF6qFGr/HlT6ABBkCSx/dlEtvWg==} engines: {node: '>=12 <14 || 14.2 - 14.9 || >14.10.0'} - '@zardoy/flying-squid@0.0.24': - resolution: {integrity: sha512-C+VNHyh9yYB7aG9OL6r9NR5bF73fyRQ0rHhkvvz901hLBZI3+5nOPdcA6XwJm9XX9BYStXbLTHp6shmo20JRHQ==} + '@zardoy/flying-squid@0.0.26': + resolution: {integrity: sha512-JUGrr+9I4vgXrgjop5iRpulRhWUgRbPC1j+xPapgICtJPEGuekpXIOOBjAL+X7yu7I5IcrmtG4XCjvTKcC0lIQ==} engines: {node: '>=8'} hasBin: true @@ -6718,13 +6718,8 @@ packages: prismarine-chat@1.9.1: resolution: {integrity: sha512-x7WWa5MNhiLZSO6tw+YyKpzquFZ+DNISVgiV6K3SU0GsishMXe+nto02WhF/4AuFerKdugm9u1d/r4C4zSkJOg==} - prismarine-chunk@https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/eb39a905761a36f733a456110e6b49d655bf5c16: - resolution: {tarball: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/eb39a905761a36f733a456110e6b49d655bf5c16} - version: 1.35.0 - engines: {node: '>=14'} - - prismarine-chunk@https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/f32234a724a5c2482ffbaf85edc5e91c7ab9b38f: - resolution: {tarball: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/f32234a724a5c2482ffbaf85edc5e91c7ab9b38f} + prismarine-chunk@https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a: + resolution: {tarball: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a} version: 1.35.0 engines: {node: '>=14'} @@ -6747,6 +6742,10 @@ packages: resolution: {tarball: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/02d81b0eba6ab1c362862970954f9a3c150c9a29} version: 2.7.0 + prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/422aed5db94f341c3807f1a918c7b83c9ebcfe20: + resolution: {tarball: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/422aed5db94f341c3807f1a918c7b83c9ebcfe20} + version: 2.8.0 + prismarine-realms@1.3.2: resolution: {integrity: sha512-5apl9Ru8veTj5q2OozRc4GZOuSIcs3yY4UEtALiLKHstBe8bRw8vNlaz4Zla3jsQ8yP/ul1b1IJINTRbocuA6g==} @@ -6764,9 +6763,9 @@ packages: prismarine-windows@2.9.0: resolution: {integrity: sha512-fm4kOLjGFPov7TEJRmXHoiPabxIQrG36r2mDjlNxfkcLfMHFb3/1ML6mp4iRQa7wL0GK4DIAyiBqCWoeWDxARg==} - prismarine-world@https://codeload.github.com/zardoy/prismarine-world/tar.gz/6ae6f009d38460de284f8c226c665f04cbad9465: - resolution: {tarball: https://codeload.github.com/zardoy/prismarine-world/tar.gz/6ae6f009d38460de284f8c226c665f04cbad9465} - version: 3.6.2 + prismarine-world@https://codeload.github.com/zardoy/prismarine-world/tar.gz/187a87f6d71cba12881a7bbaa510ed9085bf6da7: + resolution: {tarball: https://codeload.github.com/zardoy/prismarine-world/tar.gz/187a87f6d71cba12881a7bbaa510ed9085bf6da7} + version: 3.6.3 engines: {node: '>=8.0.0'} process-nextick-args@2.0.1: @@ -11931,7 +11930,7 @@ snapshots: '@types/emscripten': 1.39.8 tslib: 1.14.1 - '@zardoy/flying-squid@0.0.24(encoding@0.1.13)': + '@zardoy/flying-squid@0.0.26(encoding@0.1.13)': dependencies: '@tootallnate/once': 2.0.0 change-case: 4.1.2 @@ -11946,13 +11945,13 @@ snapshots: mkdirp: 2.1.6 node-gzip: 1.1.2 node-rsa: 1.1.1 - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/eb39a905761a36f733a456110e6b49d655bf5c16(minecraft-data@3.65.0) + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) 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/02d81b0eba6ab1c362862970954f9a3c150c9a29(minecraft-data@3.65.0) + prismarine-provider-anvil: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/422aed5db94f341c3807f1a918c7b83c9ebcfe20(minecraft-data@3.65.0) prismarine-windows: 2.9.0 - prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/6ae6f009d38460de284f8c226c665f04cbad9465 + prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/187a87f6d71cba12881a7bbaa510ed9085bf6da7 rambda: 9.2.0 random-seed: 0.3.0 range: 0.0.3 @@ -13212,7 +13211,7 @@ snapshots: diamond-square@https://codeload.github.com/zardoy/diamond-square/tar.gz/915fce8e27fe8eb45464d89b9563956afa4f7687: dependencies: minecraft-data: 3.65.0 - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/eb39a905761a36f733a456110e6b49d655bf5c16(minecraft-data@3.65.0) + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) random-seed: 0.3.0 vec3: 0.1.8 @@ -15779,7 +15778,7 @@ snapshots: prismarine-biome: 1.3.0(minecraft-data@3.65.0)(prismarine-registry@1.7.0) prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 prismarine-chat: 1.10.1 - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/eb39a905761a36f733a456110e6b49d655bf5c16(minecraft-data@3.65.0) + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) prismarine-entity: 2.3.1 prismarine-item: 1.14.0 prismarine-nbt: 2.5.0 @@ -15787,7 +15786,7 @@ snapshots: prismarine-recipe: 1.3.1(prismarine-registry@1.7.0) prismarine-registry: 1.7.0 prismarine-windows: 2.9.0 - prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/6ae6f009d38460de284f8c226c665f04cbad9465 + prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/187a87f6d71cba12881a7bbaa510ed9085bf6da7 protodef: 1.15.0 typed-emitter: 1.4.0 vec3: 0.1.8 @@ -15802,7 +15801,7 @@ snapshots: prismarine-biome: 1.3.0(minecraft-data@3.65.0)(prismarine-registry@1.7.0) prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 prismarine-chat: 1.10.1 - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/eb39a905761a36f733a456110e6b49d655bf5c16(minecraft-data@3.65.0) + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) prismarine-entity: 2.3.1 prismarine-item: 1.14.0 prismarine-nbt: 2.5.0 @@ -15810,7 +15809,7 @@ snapshots: prismarine-recipe: 1.3.1(prismarine-registry@1.7.0) prismarine-registry: 1.7.0 prismarine-windows: 2.9.0 - prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/6ae6f009d38460de284f8c226c665f04cbad9465 + prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/187a87f6d71cba12881a7bbaa510ed9085bf6da7 protodef: 1.15.0 typed-emitter: 1.4.0 vec3: 0.1.8 @@ -16526,20 +16525,7 @@ snapshots: prismarine-nbt: 2.5.0 prismarine-registry: 1.7.0 - prismarine-chunk@https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/eb39a905761a36f733a456110e6b49d655bf5c16(minecraft-data@3.65.0): - dependencies: - prismarine-biome: 1.3.0(minecraft-data@3.65.0)(prismarine-registry@1.7.0) - prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 - prismarine-nbt: 2.5.0 - prismarine-registry: 1.7.0 - smart-buffer: 4.2.0 - uint4: 0.1.2 - vec3: 0.1.8 - xxhash-wasm: 0.4.2 - transitivePeerDependencies: - - minecraft-data - - prismarine-chunk@https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/f32234a724a5c2482ffbaf85edc5e91c7ab9b38f(minecraft-data@3.65.0): + prismarine-chunk@https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0): dependencies: prismarine-biome: 1.3.0(minecraft-data@3.65.0)(prismarine-registry@1.7.0) prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 @@ -16580,13 +16566,24 @@ snapshots: prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/02d81b0eba6ab1c362862970954f9a3c150c9a29(minecraft-data@3.65.0): dependencies: - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/f32234a724a5c2482ffbaf85edc5e91c7ab9b38f(minecraft-data@3.65.0) + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) prismarine-nbt: 2.5.0 uint4: 0.1.2 vec3: 0.1.8 transitivePeerDependencies: - minecraft-data + prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/422aed5db94f341c3807f1a918c7b83c9ebcfe20(minecraft-data@3.65.0): + dependencies: + prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) + prismarine-nbt: 2.5.0 + prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/187a87f6d71cba12881a7bbaa510ed9085bf6da7 + uint4: 0.1.2 + vec3: 0.1.8 + transitivePeerDependencies: + - minecraft-data + prismarine-realms@1.3.2(encoding@0.1.13): dependencies: debug: 4.3.4(supports-color@8.1.1) @@ -16609,7 +16606,7 @@ snapshots: minecraft-data: 3.65.0 prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 prismarine-nbt: 2.2.1 - prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/6ae6f009d38460de284f8c226c665f04cbad9465 + prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/187a87f6d71cba12881a7bbaa510ed9085bf6da7 vec3: 0.1.8 prismarine-windows@2.9.0: @@ -16618,7 +16615,7 @@ snapshots: prismarine-registry: 1.7.0 typed-emitter: 2.1.0 - prismarine-world@https://codeload.github.com/zardoy/prismarine-world/tar.gz/6ae6f009d38460de284f8c226c665f04cbad9465: + prismarine-world@https://codeload.github.com/zardoy/prismarine-world/tar.gz/187a87f6d71cba12881a7bbaa510ed9085bf6da7: dependencies: vec3: 0.1.8 From 5be093a25f88dae99d216416b6f4cd64bc06ecd2 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 13 Jun 2024 03:46:59 +0300 Subject: [PATCH 036/985] feat: support world saves for all versions of Minecraft Java! --- package.json | 2 +- pnpm-lock.yaml | 100 +++++++----------- .../viewer/lib/worldDataEmitter.ts | 2 +- src/createLocalServer.ts | 2 +- src/getCollisionShapes.ts | 6 +- src/globals.d.ts | 4 +- src/loadSave.ts | 10 +- src/react/MainMenu.tsx | 2 +- src/soundSystem.ts | 10 +- src/water.ts | 2 +- 10 files changed, 61 insertions(+), 79 deletions(-) diff --git a/package.json b/package.json index f5f55c7f..37e24dbb 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "esbuild-plugin-polyfill-node": "^0.3.0", "express": "^4.18.2", "filesize": "^10.0.12", - "flying-squid": "npm:@zardoy/flying-squid@^0.0.26", + "flying-squid": "npm:@zardoy/flying-squid@^0.0.27", "fs-extra": "^11.1.1", "google-drive-browserfs": "github:zardoy/browserfs#google-drive", "iconify-icon": "^1.0.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3cbab433..052069c8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -104,8 +104,8 @@ importers: specifier: ^10.0.12 version: 10.0.12 flying-squid: - specifier: npm:@zardoy/flying-squid@^0.0.26 - version: '@zardoy/flying-squid@0.0.26(encoding@0.1.13)' + specifier: npm:@zardoy/flying-squid@^0.0.27 + version: '@zardoy/flying-squid@0.0.27(encoding@0.1.13)' fs-extra: specifier: ^11.1.1 version: 11.1.1 @@ -150,7 +150,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/02d81b0eba6ab1c362862970954f9a3c150c9a29(minecraft-data@3.65.0) + version: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/2663cad29c8f231c299f63e31c5040b6c1872bcc(minecraft-data@3.65.0) prosemirror-example-setup: specifier: ^1.2.2 version: 1.2.2 @@ -302,7 +302,7 @@ importers: version: https://codeload.github.com/zardoy/minecraft-inventory-gui/tar.gz/200902aca941475e7feb610070e662b172a000b5(@types/react@18.2.20)(react@18.2.0) mineflayer: specifier: github:zardoy/mineflayer - version: https://codeload.github.com/zardoy/mineflayer/tar.gz/06061e07fe6b9716cb1801d4c1bf232581977192(encoding@0.1.13) + version: https://codeload.github.com/zardoy/mineflayer/tar.gz/f80ba0f8ebbcc15d6c44ade84007f8b4a0ee08ec(encoding@0.1.13) mineflayer-pathfinder: specifier: ^2.4.4 version: 2.4.4 @@ -383,10 +383,10 @@ importers: version: 1.3.6 prismarine-block: specifier: github:zardoy/prismarine-block#next-era - version: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 + version: https://codeload.github.com/zardoy/prismarine-block/tar.gz/dd4954fff3b334f8ce063d18e39b2e9414ece5b8 prismarine-chunk: specifier: github:zardoy/prismarine-chunk - version: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) + version: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/9662306deea57d8d0ba0a2a3f3f7adb95f0131e3(minecraft-data@3.65.0) prismarine-schematic: specifier: ^1.2.0 version: 1.2.3 @@ -3054,8 +3054,8 @@ packages: resolution: {integrity: sha512-6xm38yGVIa6mKm/DUCF2zFFJhERh/QWp1ufm4cNUvxsONBmfPg8uZ9pZBdOmF6qFGr/HlT6ABBkCSx/dlEtvWg==} engines: {node: '>=12 <14 || 14.2 - 14.9 || >14.10.0'} - '@zardoy/flying-squid@0.0.26': - resolution: {integrity: sha512-JUGrr+9I4vgXrgjop5iRpulRhWUgRbPC1j+xPapgICtJPEGuekpXIOOBjAL+X7yu7I5IcrmtG4XCjvTKcC0lIQ==} + '@zardoy/flying-squid@0.0.27': + resolution: {integrity: sha512-8QlPCyLqNQYxsGBMBNNGbfc1HdRPO/t3nBr5NzINEridj772DEbgGHxl252rjZWWELt/3t/k3m6e4k9qS7/ZdA==} engines: {node: '>=8'} hasBin: true @@ -4097,8 +4097,8 @@ packages: devlop@1.1.0: resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} - diamond-square@https://codeload.github.com/zardoy/diamond-square/tar.gz/915fce8e27fe8eb45464d89b9563956afa4f7687: - resolution: {tarball: https://codeload.github.com/zardoy/diamond-square/tar.gz/915fce8e27fe8eb45464d89b9563956afa4f7687} + diamond-square@https://codeload.github.com/zardoy/diamond-square/tar.gz/4bbe28dcad35403abaa925055e91f601a61b9015: + resolution: {tarball: https://codeload.github.com/zardoy/diamond-square/tar.gz/4bbe28dcad35403abaa925055e91f601a61b9015} version: 1.3.0 diff-sequences@29.6.3: @@ -6067,8 +6067,8 @@ packages: resolution: {integrity: sha512-QMMNPx4IyZE7ydAzjvGLQLCnQNUOfkk1qVZKxTTS9q3qPTAewz4GhsVUBtbQ8LSbHthe5RcQ1Sgxs4wlIma/Qw==} engines: {node: '>=18'} - mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/06061e07fe6b9716cb1801d4c1bf232581977192: - resolution: {tarball: https://codeload.github.com/zardoy/mineflayer/tar.gz/06061e07fe6b9716cb1801d4c1bf232581977192} + mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/f80ba0f8ebbcc15d6c44ade84007f8b4a0ee08ec: + resolution: {tarball: https://codeload.github.com/zardoy/mineflayer/tar.gz/f80ba0f8ebbcc15d6c44ade84007f8b4a0ee08ec} version: 4.20.1 engines: {node: '>=18'} @@ -6708,18 +6708,15 @@ packages: minecraft-data: 3.65.0 prismarine-registry: ^1.1.0 - prismarine-block@https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0: - resolution: {tarball: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0} + prismarine-block@https://codeload.github.com/zardoy/prismarine-block/tar.gz/dd4954fff3b334f8ce063d18e39b2e9414ece5b8: + resolution: {tarball: https://codeload.github.com/zardoy/prismarine-block/tar.gz/dd4954fff3b334f8ce063d18e39b2e9414ece5b8} version: 1.17.1 prismarine-chat@1.10.1: resolution: {integrity: sha512-XukYcuueuhDxzEXG7r8BZyt6jOObrPPB4JESCgb+/XenB9nExoSHF8eTQWWj8faKPLqm1dRQaYwFJlNBlJZJUw==} - prismarine-chat@1.9.1: - resolution: {integrity: sha512-x7WWa5MNhiLZSO6tw+YyKpzquFZ+DNISVgiV6K3SU0GsishMXe+nto02WhF/4AuFerKdugm9u1d/r4C4zSkJOg==} - - prismarine-chunk@https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a: - resolution: {tarball: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a} + prismarine-chunk@https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/9662306deea57d8d0ba0a2a3f3f7adb95f0131e3: + resolution: {tarball: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/9662306deea57d8d0ba0a2a3f3f7adb95f0131e3} version: 1.35.0 engines: {node: '>=14'} @@ -6738,12 +6735,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/02d81b0eba6ab1c362862970954f9a3c150c9a29: - resolution: {tarball: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/02d81b0eba6ab1c362862970954f9a3c150c9a29} - version: 2.7.0 - - prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/422aed5db94f341c3807f1a918c7b83c9ebcfe20: - resolution: {tarball: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/422aed5db94f341c3807f1a918c7b83c9ebcfe20} + prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/2663cad29c8f231c299f63e31c5040b6c1872bcc: + resolution: {tarball: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/2663cad29c8f231c299f63e31c5040b6c1872bcc} version: 2.8.0 prismarine-realms@1.3.2: @@ -11930,12 +11923,12 @@ snapshots: '@types/emscripten': 1.39.8 tslib: 1.14.1 - '@zardoy/flying-squid@0.0.26(encoding@0.1.13)': + '@zardoy/flying-squid@0.0.27(encoding@0.1.13)': dependencies: '@tootallnate/once': 2.0.0 change-case: 4.1.2 colors: 1.4.0 - diamond-square: https://codeload.github.com/zardoy/diamond-square/tar.gz/915fce8e27fe8eb45464d89b9563956afa4f7687 + diamond-square: https://codeload.github.com/zardoy/diamond-square/tar.gz/4bbe28dcad35403abaa925055e91f601a61b9015 emit-then: 2.0.0 exit-hook: 2.2.1 flatmap: 0.0.3 @@ -11945,11 +11938,11 @@ snapshots: mkdirp: 2.1.6 node-gzip: 1.1.2 node-rsa: 1.1.1 - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/9662306deea57d8d0ba0a2a3f3f7adb95f0131e3(minecraft-data@3.65.0) 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/422aed5db94f341c3807f1a918c7b83c9ebcfe20(minecraft-data@3.65.0) + prismarine-provider-anvil: https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/2663cad29c8f231c299f63e31c5040b6c1872bcc(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 @@ -13208,10 +13201,11 @@ snapshots: dependencies: dequal: 2.0.3 - diamond-square@https://codeload.github.com/zardoy/diamond-square/tar.gz/915fce8e27fe8eb45464d89b9563956afa4f7687: + diamond-square@https://codeload.github.com/zardoy/diamond-square/tar.gz/4bbe28dcad35403abaa925055e91f601a61b9015: dependencies: minecraft-data: 3.65.0 - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/9662306deea57d8d0ba0a2a3f3f7adb95f0131e3(minecraft-data@3.65.0) + prismarine-registry: 1.7.0 random-seed: 0.3.0 vec3: 0.1.8 @@ -15764,7 +15758,7 @@ snapshots: mineflayer-pathfinder@2.4.4: dependencies: minecraft-data: 3.65.0 - prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 + prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/dd4954fff3b334f8ce063d18e39b2e9414ece5b8 prismarine-entity: 2.3.1 prismarine-item: 1.14.0 prismarine-nbt: 2.2.1 @@ -15776,9 +15770,9 @@ snapshots: minecraft-data: 3.65.0 minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/495eed56ab230b2615596590064671356d86a2dc(patch_hash=2uxevyasyasdavsxuehfavgkjq)(encoding@0.1.13) prismarine-biome: 1.3.0(minecraft-data@3.65.0)(prismarine-registry@1.7.0) - prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 + prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/dd4954fff3b334f8ce063d18e39b2e9414ece5b8 prismarine-chat: 1.10.1 - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/9662306deea57d8d0ba0a2a3f3f7adb95f0131e3(minecraft-data@3.65.0) prismarine-entity: 2.3.1 prismarine-item: 1.14.0 prismarine-nbt: 2.5.0 @@ -15794,14 +15788,14 @@ snapshots: - encoding - supports-color - mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/06061e07fe6b9716cb1801d4c1bf232581977192(encoding@0.1.13): + mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/f80ba0f8ebbcc15d6c44ade84007f8b4a0ee08ec(encoding@0.1.13): dependencies: minecraft-data: 3.65.0 minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/495eed56ab230b2615596590064671356d86a2dc(patch_hash=2uxevyasyasdavsxuehfavgkjq)(encoding@0.1.13) prismarine-biome: 1.3.0(minecraft-data@3.65.0)(prismarine-registry@1.7.0) - prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 + prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/dd4954fff3b334f8ce063d18e39b2e9414ece5b8 prismarine-chat: 1.10.1 - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/9662306deea57d8d0ba0a2a3f3f7adb95f0131e3(minecraft-data@3.65.0) prismarine-entity: 2.3.1 prismarine-item: 1.14.0 prismarine-nbt: 2.5.0 @@ -16503,11 +16497,11 @@ snapshots: minecraft-data: 3.65.0 prismarine-registry: 1.7.0 - prismarine-block@https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0: + prismarine-block@https://codeload.github.com/zardoy/prismarine-block/tar.gz/dd4954fff3b334f8ce063d18e39b2e9414ece5b8: dependencies: minecraft-data: 3.65.0 prismarine-biome: 1.3.0(minecraft-data@3.65.0)(prismarine-registry@1.7.0) - prismarine-chat: 1.9.1 + prismarine-chat: 1.10.1 prismarine-item: 1.14.0 prismarine-nbt: 2.5.0 prismarine-registry: 1.7.0 @@ -16518,17 +16512,10 @@ snapshots: prismarine-nbt: 2.5.0 prismarine-registry: 1.7.0 - prismarine-chat@1.9.1: - dependencies: - mojangson: 2.0.4 - prismarine-item: 1.14.0 - prismarine-nbt: 2.5.0 - prismarine-registry: 1.7.0 - - prismarine-chunk@https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0): + prismarine-chunk@https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/9662306deea57d8d0ba0a2a3f3f7adb95f0131e3(minecraft-data@3.65.0): dependencies: prismarine-biome: 1.3.0(minecraft-data@3.65.0)(prismarine-registry@1.7.0) - prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 + prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/dd4954fff3b334f8ce063d18e39b2e9414ece5b8 prismarine-nbt: 2.5.0 prismarine-registry: 1.7.0 smart-buffer: 4.2.0 @@ -16564,19 +16551,10 @@ snapshots: prismarine-nbt: 2.5.0 vec3: 0.1.8 - prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/02d81b0eba6ab1c362862970954f9a3c150c9a29(minecraft-data@3.65.0): + prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/2663cad29c8f231c299f63e31c5040b6c1872bcc(minecraft-data@3.65.0): dependencies: - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) - prismarine-nbt: 2.5.0 - uint4: 0.1.2 - vec3: 0.1.8 - transitivePeerDependencies: - - minecraft-data - - prismarine-provider-anvil@https://codeload.github.com/zardoy/prismarine-provider-anvil/tar.gz/422aed5db94f341c3807f1a918c7b83c9ebcfe20(minecraft-data@3.65.0): - dependencies: - prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 - prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/45f0da31a6ab7107204f2b0a5d56dccb6059025a(minecraft-data@3.65.0) + prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/dd4954fff3b334f8ce063d18e39b2e9414ece5b8 + prismarine-chunk: https://codeload.github.com/zardoy/prismarine-chunk/tar.gz/9662306deea57d8d0ba0a2a3f3f7adb95f0131e3(minecraft-data@3.65.0) prismarine-nbt: 2.5.0 prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/187a87f6d71cba12881a7bbaa510ed9085bf6da7 uint4: 0.1.2 @@ -16604,7 +16582,7 @@ snapshots: prismarine-schematic@1.2.3: dependencies: minecraft-data: 3.65.0 - prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 + prismarine-block: https://codeload.github.com/zardoy/prismarine-block/tar.gz/dd4954fff3b334f8ce063d18e39b2e9414ece5b8 prismarine-nbt: 2.2.1 prismarine-world: https://codeload.github.com/zardoy/prismarine-world/tar.gz/187a87f6d71cba12881a7bbaa510ed9085bf6da7 vec3: 0.1.8 diff --git a/prismarine-viewer/viewer/lib/worldDataEmitter.ts b/prismarine-viewer/viewer/lib/worldDataEmitter.ts index 3a8fbd40..ed578040 100644 --- a/prismarine-viewer/viewer/lib/worldDataEmitter.ts +++ b/prismarine-viewer/viewer/lib/worldDataEmitter.ts @@ -83,7 +83,7 @@ export class WorldDataEmitter extends EventEmitter { get (_target, posKey, receiver) { if (typeof posKey !== 'string') return const [x, y, z] = posKey.split(',').map(Number) - return bot.world.getBlock(new Vec3(x, y, z)).entity + return bot.world.getBlock(new Vec3(x, y, z))?.entity }, })) this.emitter.emit('renderDistance', this.viewDistance) diff --git a/src/createLocalServer.ts b/src/createLocalServer.ts index 44bc2187..d0beac9a 100644 --- a/src/createLocalServer.ts +++ b/src/createLocalServer.ts @@ -14,4 +14,4 @@ export const startLocalServer = (serverOptions) => { // features that flying-squid doesn't support at all // todo move & generate in flying-squid -export const unsupportedLocalServerFeatures = ['transactionPacketExists', 'teleportUsesOwnPacket', 'dimensionDataIsAvailable'] +export const unsupportedLocalServerFeatures = ['transactionPacketExists', 'teleportUsesOwnPacket'] diff --git a/src/getCollisionShapes.ts b/src/getCollisionShapes.ts index 0faf5b6a..4ee0e802 100644 --- a/src/getCollisionShapes.ts +++ b/src/getCollisionShapes.ts @@ -1,4 +1,4 @@ -import { adoptBlockOrItemNamesFromLatest } from 'flying-squid/dist/blockRenames' +import { getRenamedData } from 'flying-squid/dist/blockRenames' import collisionShapesInit from '../generated/latestBlockCollisionsShapes.json' import outputInteractionShapesJson from './interactionShapesGenerated.json' @@ -6,7 +6,7 @@ import outputInteractionShapesJson from './interactionShapesGenerated.json' window.globalGetCollisionShapes = (version) => { // todo use the same in resourcepack const versionFrom = collisionShapesInit.version - const renamedBlocks = adoptBlockOrItemNamesFromLatest('blocks', Object.keys(collisionShapesInit.blocks), versionFrom, version) + const renamedBlocks = getRenamedData('blocks', Object.keys(collisionShapesInit.blocks), versionFrom, version) const collisionShapes = { ...collisionShapesInit, blocks: Object.fromEntries(Object.entries(collisionShapesInit.blocks).map(([, shape], i) => [renamedBlocks[i], shape])) @@ -17,7 +17,7 @@ window.globalGetCollisionShapes = (version) => { export default () => { customEvents.on('gameLoaded', () => { // todo also remap block states (e.g. redstone)! - const renamedBlocksInteraction = adoptBlockOrItemNamesFromLatest('blocks', Object.keys(outputInteractionShapesJson), '1.20.2', bot.version) + const renamedBlocksInteraction = getRenamedData('blocks', Object.keys(outputInteractionShapesJson), '1.20.2', bot.version) const interactionShapes = { ...outputInteractionShapesJson, ...Object.fromEntries(Object.entries(outputInteractionShapesJson).map(([block, shape], i) => [renamedBlocksInteraction[i], shape])) diff --git a/src/globals.d.ts b/src/globals.d.ts index 6a38a21d..05b29a14 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -3,7 +3,9 @@ declare const THREE: typeof import('three') // todo make optional declare const bot: Omit & { - world: import('prismarine-world').world.WorldSync + world: Omit & { + getBlock: (pos: import('vec3').Vec3) => import('prismarine-block').Block | null + } _client: Omit & { write: typeof import('./generatedClientPackets').clientWrite on: typeof import('./generatedServerPackets').clientOn diff --git a/src/loadSave.ts b/src/loadSave.ts index af9d078c..7ca454ff 100644 --- a/src/loadSave.ts +++ b/src/loadSave.ts @@ -1,15 +1,16 @@ import fs from 'fs' import path from 'path' -import { supportedVersions } from 'flying-squid/dist/lib/version' import * as nbt from 'prismarine-nbt' import { proxy } from 'valtio' import { gzip } from 'node-gzip' +import { versionToNumber } from 'prismarine-viewer/viewer/prepare/utils' import { options } from './optionsStorage' import { nameToMcOfflineUUID, disconnect } from './flyingSquidUtils' import { existsViaStats, forceCachedDataPaths, forceRedirectPaths, mkdirRecursive } from './browserfs' import { isMajorVersionGreater } from './utils' import { activeModalStacks, insertActiveModalStack, miscUiState } from './globalState' +import supportedVersions from './supportedVersions.mjs' // todo include name of opened handle (zip)! // additional fs metadata @@ -91,13 +92,12 @@ export const loadSave = async (root = '/world') => { const newVersion = '1.8.8' version = newVersion } - // const lastSupportedVersion = supportedVersions.at(-1)! - const lastTestedVersion = '1.18.2' + const lastSupportedVersion = supportedVersions.at(-1)! const firstSupportedVersion = supportedVersions[0] const lowerBound = isMajorVersionGreater(firstSupportedVersion, version) - const upperBound = isMajorVersionGreater(version, lastTestedVersion) + const upperBound = versionToNumber(version) > versionToNumber(lastSupportedVersion) if (lowerBound || upperBound) { - version = prompt(`Version ${version} is not supported, supported versions are ${supportedVersions.join(', ')}, what try to use instead?`, lowerBound ? firstSupportedVersion : lastTestedVersion) + version = prompt(`Version ${version} is not supported, supported versions are ${supportedVersions.join(', ')}, what try to use instead?`, lowerBound ? firstSupportedVersion : lastSupportedVersion) if (!version) return } if (levelDat.WorldGenSettings) { diff --git a/src/react/MainMenu.tsx b/src/react/MainMenu.tsx index 3e3170f4..43908645 100644 --- a/src/react/MainMenu.tsx +++ b/src/react/MainMenu.tsx @@ -103,7 +103,7 @@ export default ({ connectToServerAction, mapsProvider, singleplayerAction, optio icon='pixelarticons:folder' onClick={openFileAction} initialTooltip={{ - content: 'Load any 1.8-1.16 Java world' + (haveDirectoryPicker() ? '' : ' (zip)'), + content: 'Load any Java world save' + (haveDirectoryPicker() ? '' : ' (zip)!'), placement: 'bottom-start', }} /> diff --git a/src/soundSystem.ts b/src/soundSystem.ts index a2cc1f70..e7fdaee7 100644 --- a/src/soundSystem.ts +++ b/src/soundSystem.ts @@ -144,10 +144,12 @@ subscribeKey(miscUiState, 'gameLoaded', async () => { // movement happening if (Date.now() - lastStepSound > 300) { const blockUnder = bot.world.getBlock(bot.entity.position.offset(0, -1, 0)) - const stepSound = getStepSound(blockUnder) - if (stepSound) { - await playHardcodedSound(stepSound, undefined, 0.6)// todo not sure why 0.6 - lastStepSound = Date.now() + if (blockUnder) { + const stepSound = getStepSound(blockUnder) + if (stepSound) { + await playHardcodedSound(stepSound, undefined, 0.6)// todo not sure why 0.6 + lastStepSound = Date.now() + } } } } diff --git a/src/water.ts b/src/water.ts index 9f8ec557..d8b4b41c 100644 --- a/src/water.ts +++ b/src/water.ts @@ -19,7 +19,7 @@ customEvents.on('gameLoaded', () => { } bot.on('physicsTick', () => { // todo - const _inWater = bot.world.getBlock(bot.entity.position.offset(0, 1, 0)).name === 'water' + const _inWater = bot.world.getBlock(bot.entity.position.offset(0, 1, 0))?.name === 'water' if (_inWater !== inWater) { inWater = _inWater updateInWater() From 216b1712c2dd418636d9fcc9c6e632137555e2d9 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 13 Jun 2024 19:47:48 +0300 Subject: [PATCH 037/985] more basic tests. test joining to a local java vanilla server, movement! --- .eslintrc.json | 17 +++++++++ .gitignore | 1 + cypress/e2e/index.spec.ts | 57 ++++++++++++++++++++++++++++- cypress/e2e/shared.ts | 3 ++ cypress/plugins/index.js | 9 ++++- cypress/plugins/server.properties | 61 +++++++++++++++++++++++++++++++ cypress/plugins/startServer.ts | 45 +++++++++++++++++++++++ index.html | 2 +- src/index.ts | 7 +++- src/react/Chat.tsx | 3 +- src/worldInteractions.ts | 3 +- 11 files changed, 200 insertions(+), 8 deletions(-) create mode 100644 cypress/plugins/server.properties create mode 100644 cypress/plugins/startServer.ts diff --git a/.eslintrc.json b/.eslintrc.json index 98388260..a91015d2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -96,5 +96,22 @@ "unicorn/filename-case": "off", "max-depth": "off" }, + "overrides": [ + { + "files": [ + "*.js" + ], + "rules": { + "space-before-function-paren": [ + "error", + { + "anonymous": "always", + "named": "never", + "asyncArrow": "always" + } + ] + } + } + ], "root": true } diff --git a/.gitignore b/.gitignore index 240b751a..3a188862 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,6 @@ out .vercel generated storybook-static +server-jar src/react/npmReactComponents.ts diff --git a/cypress/e2e/index.spec.ts b/cypress/e2e/index.spec.ts index 05b50211..ec7d84e7 100644 --- a/cypress/e2e/index.spec.ts +++ b/cypress/e2e/index.spec.ts @@ -1,4 +1,6 @@ +/* eslint-disable max-nested-callbacks */ /// +import supportedVersions from '../../src/supportedVersions.mjs' import { setOptions, cleanVisit, visit } from './shared' // todo use ssl @@ -12,7 +14,7 @@ const compareRenderedFlatWorld = () => { } const testWorldLoad = () => { - cy.document().then({ timeout: 20_000 }, doc => { + return cy.document().then({ timeout: 20_000 }, doc => { return new Cypress.Promise(resolve => { doc.addEventListener('cypress-world-ready', resolve) }) @@ -36,7 +38,7 @@ it('Loads & renders singleplayer', () => { testWorldLoad() }) -it('Joins to server', () => { +it('Joins to local flying-squid server', () => { visit('/?ip=localhost&version=1.16.1') window.localStorage.version = '' // todo replace with data-test @@ -47,9 +49,60 @@ it('Joins to server', () => { testWorldLoad() }) +it('Joins to local latest Java vanilla server', () => { + const version = supportedVersions.at(-1)! + cy.task('startServer', [version, 25_590]).then(() => { + visit('/?ip=localhost:25590&username=bot') + cy.get('[data-test-id="connect-qs"]').click() + testWorldLoad().then(() => { + let x = 0 + let z = 0 + cy.window().then((win) => { + x = win.bot.entity.position.x + z = win.bot.entity.position.z + }) + cy.document().trigger('keydown', { code: 'KeyW' }) + cy.wait(1500).then(() => { + cy.document().trigger('keyup', { code: 'KeyW' }) + cy.window().then(async (win) => { + // eslint-disable-next-line prefer-destructuring + const bot: typeof __type_bot = win.bot + // todo use f3 stats instead + if (bot.entity.position.x === x && bot.entity.position.z === z) { + throw new Error('Player not moved') + } + + bot.chat('Hello') // todo assert + bot.chat('/gamemode creative') + // bot.on('message', () => { + void bot.creative.setInventorySlot(bot.inventory.hotbarStart, new win.PrismarineItem(1, 1, 0)) + // }) + await bot.lookAt(bot.entity.position.offset(1, 0, 1)) + }).then(() => { + cy.document().trigger('mousedown', { button: 2, isTrusted: true, force: true }) // right click + cy.document().trigger('mouseup', { button: 2, isTrusted: true, force: true }) + cy.wait(1000) + }) + }) + }) + }) +}) + it('Loads & renders zip world', () => { cleanVisit() cy.get('[data-test-id="select-file-folder"]').click({ shiftKey: true }) cy.get('input[type="file"]').selectFile('cypress/superflat.zip', { force: true }) testWorldLoad() }) + + +it.skip('Loads & renders world from folder', () => { + cleanVisit() + // dragndrop folder + cy.get('[data-test-id="select-file-folder"]').click() + cy.get('input[type="file"]').selectFile('server-jar/world', { + force: true, + // action: 'drag-drop', + }) + testWorldLoad() +}) diff --git a/cypress/e2e/shared.ts b/cypress/e2e/shared.ts index 9292a8d5..47518f1b 100644 --- a/cypress/e2e/shared.ts +++ b/cypress/e2e/shared.ts @@ -3,6 +3,9 @@ import { AppOptions } from '../../src/optionsStorage' export const cleanVisit = (url?) => { cy.clearLocalStorage() visit(url) + window.localStorage.options = { + chatOpacity: 0 + } } export const visit = (url = '/') => { window.localStorage.cypress = 'true' diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 35dc2989..e55f5d26 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -2,11 +2,13 @@ const { cypressEsbuildPreprocessor } = require('cypress-esbuild-preprocessor') const { initPlugin } = require('cypress-plugin-snapshots/plugin') const polyfill = require('esbuild-plugin-polyfill-node') +const { startMinecraftServer } = require('./startServer') module.exports = (on, config) => { initPlugin(on, config) on('file:preprocessor', cypressEsbuildPreprocessor({ esbuildOptions: { + sourcemap: true, plugins: [ polyfill.polyfillNode({ polyfills: { @@ -17,10 +19,15 @@ module.exports = (on, config) => { }, })) on('task', { - log (message) { + log(message) { console.log(message) return null }, }) + on('task', { + async startServer([version, port]) { + return startMinecraftServer(version, port) + } + }) return config } diff --git a/cypress/plugins/server.properties b/cypress/plugins/server.properties new file mode 100644 index 00000000..5873a1aa --- /dev/null +++ b/cypress/plugins/server.properties @@ -0,0 +1,61 @@ +#Minecraft server properties +allow-flight=false +allow-nether=true +broadcast-console-to-ops=true +broadcast-rcon-to-ops=true +difficulty=peaceful +enable-command-block=false +enable-jmx-monitoring=false +enable-query=false +enable-rcon=false +enable-status=true +enforce-secure-profile=true +enforce-whitelist=false +entity-broadcast-range-percentage=100 +force-gamemode=false +function-permission-level=2 +gamemode=survival +generate-structures=true +generator-settings={} +hardcore=false +hide-online-players=false +initial-disabled-packs= +initial-enabled-packs=vanilla +level-name=world +level-seed= +level-type=flat +log-ips=true +max-build-height=256 +max-chained-neighbor-updates=1000000 +max-players=20 +max-tick-time=60000 +max-world-size=29999984 +motd=A Minecraft Server +network-compression-threshold=256 +online-mode=false +op-permission-level=4 +player-idle-timeout=0 +prevent-proxy-connections=false +pvp=true +query.port=25565 +rate-limit=0 +rcon.password= +rcon.port=25575 +require-resource-pack=false +resource-pack= +resource-pack-id= +resource-pack-prompt= +resource-pack-sha1= +server-ip= +server-port=25565 +simulation-distance=10 +snooper-enabled=true +spawn-animals=true +spawn-monsters=true +spawn-npcs=true +spawn-protection=16 +sync-chunk-writes=true +text-filtering-config= +use-native-transport=true +view-distance=10 +white-list=false diff --git a/cypress/plugins/startServer.ts b/cypress/plugins/startServer.ts new file mode 100644 index 00000000..ecf0d210 --- /dev/null +++ b/cypress/plugins/startServer.ts @@ -0,0 +1,45 @@ +import { ChildProcess, spawn } from 'child_process' +import * as fs from 'fs' +import * as path from 'path' +import { promisify } from 'util' +import { downloadServer } from 'minecraft-wrap' +import * as waitOn from 'wait-on' + +let prevProcess: ChildProcess | null = null +export const startMinecraftServer = async (version: string, port: number) => { + if (prevProcess) return null + const jar = `./server-jar/${version}.jar` + + const start = () => { + // if (prevProcess) { + // prevProcess.kill() + // } + + prevProcess = spawn('java', ['-jar', path.basename(jar), 'nogui', '--port', `${port}`], { + stdio: 'inherit', + cwd: path.dirname(jar), + }) + } + + let coldStart = false + if (fs.existsSync(jar)) { + start() + } else { + coldStart = true + promisify(downloadServer)(version, jar).then(() => { + // add eula.txt + fs.writeFileSync(path.join(path.dirname(jar), 'eula.txt'), 'eula=true') + // copy cypress/plugins/server.properties + fs.copyFileSync(path.join(__dirname, 'server.properties'), path.join(path.dirname(jar), 'server.properties')) + // copy ops.json + fs.copyFileSync(path.join(__dirname, 'ops.json'), path.join(path.dirname(jar), 'ops.json')) + start() + }) + } + + return new Promise((res) => { + waitOn({ resources: [`tcp:localhost:${port}`] }, () => { + setTimeout(() => res(null), coldStart ? 6500 : 2000) // todo retry instead of timeout + }) + }) +} diff --git a/index.html b/index.html index 6d3b326b..62e109cd 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@
Loading...
-
A true Minecraft client in your browser!
+
A true Minecraft client in your browser!
` diff --git a/src/index.ts b/src/index.ts index fe584b4d..72f270d4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,6 +17,7 @@ import './scaleInterface' import itemsPng from 'prismarine-viewer/public/textures/items.png' import { initWithRenderer } from './topRightStats' import PrismarineBlock from 'prismarine-block' +import PrismarineItem from 'prismarine-item' import { options, watchValue } from './optionsStorage' import './reactUi.jsx' @@ -580,6 +581,7 @@ async function connect (connectOptions: ConnectOptions) { errorAbortController.abort() const mcData = MinecraftData(bot.version) window.PrismarineBlock = PrismarineBlock(mcData.version.minecraftVersion!) + window.PrismarineItem = PrismarineItem(mcData.version.minecraftVersion!) window.loadedData = mcData window.Vec3 = Vec3 window.pathfinder = pathfinder @@ -825,9 +827,12 @@ listenGlobalEvents() watchValue(miscUiState, async s => { if (s.appLoaded) { // fs ready const qs = new URLSearchParams(window.location.search) + const moreServerOptions = {} as Record + if (qs.has('version')) moreServerOptions.version = qs.get('version') if (qs.get('singleplayer') === '1') { loadSingleplayer({}, { - worldFolder: undefined + worldFolder: undefined, + ...moreServerOptions }) } if (qs.get('loadSave')) { diff --git a/src/react/Chat.tsx b/src/react/Chat.tsx index b05f9930..981878c8 100644 --- a/src/react/Chat.tsx +++ b/src/react/Chat.tsx @@ -1,6 +1,5 @@ import { proxy, subscribe } from 'valtio' import { useEffect, useMemo, useRef, useState } from 'react' -import { isCypress } from '../standaloneUtils' import { MessageFormatPart } from '../botUtils' import { MessagePart } from './MessageFormatted' import './Chat.css' @@ -200,7 +199,7 @@ export default ({ messages, opacity = 1, fetchCompletionItems, opened, sendMessa return ( <> - diff --git a/src/react/ServersListProvider.tsx b/src/react/ServersListProvider.tsx index 9772c9b4..ca749560 100644 --- a/src/react/ServersListProvider.tsx +++ b/src/react/ServersListProvider.tsx @@ -7,6 +7,7 @@ import ServersList from './ServersList' import AddServerOrConnect, { BaseServerInfo } from './AddServerOrConnect' import { useDidUpdateEffect } from './utils' import { useIsModalActive } from './utilsApp' +import { showOptionsModal } from './SelectOption' interface StoreServerItem extends BaseServerInfo { lastJoined?: number @@ -46,6 +47,15 @@ type AdditionalDisplayData = { icon?: string } +export interface AuthenticatedAccount { + // type: 'microsoft' + username: string + cachedTokens?: { + data: any + expiresOn: number + } +} + const getInitialServersList = () => { if (localStorage['serversList']) return JSON.parse(localStorage['serversList']) as StoreServerItem[] @@ -62,7 +72,6 @@ const getInitialServersList = () => { if (localStorage['server']) { const legacyLastJoinedServer: StoreServerItem = { ip: localStorage['server'], - passwordOverride: localStorage['password'], versionOverride: localStorage['version'], lastJoined: Date.now() } @@ -104,16 +113,21 @@ const getInitialProxies = () => { return proxies } -export const updateLoadedServerData = (callback: (data: StoreServerItem) => StoreServerItem) => { +export const updateLoadedServerData = (callback: (data: StoreServerItem) => StoreServerItem, index = miscUiState.loadedServerIndex) => { + if (!index) return // function assumes component is not mounted to avoid sync issues after save - const { loadedServerIndex } = miscUiState - if (!loadedServerIndex) return const servers = getInitialServersList() - const server = servers[loadedServerIndex] - servers[loadedServerIndex] = callback(server) + const server = servers[index] + servers[index] = callback(server) setNewServersList(servers) } +export const updateAuthenticatedAccountData = (callback: (data: AuthenticatedAccount[]) => AuthenticatedAccount[]) => { + const accounts = JSON.parse(localStorage['authenticatedAccounts'] || '[]') as AuthenticatedAccount[] + const newAccounts = callback(accounts) + localStorage['authenticatedAccounts'] = JSON.stringify(newAccounts) +} + // todo move to base const normalizeIp = (ip: string) => ip.replace(/https?:\/\//, '').replace(/\/(:|$)/, '') @@ -122,6 +136,11 @@ const Inner = () => { const [selectedProxy, setSelectedProxy] = useState(localStorage.getItem('selectedProxy') ?? proxies?.[0] ?? '') const [serverEditScreen, setServerEditScreen] = useState(null) // true for add const [defaultUsername, setDefaultUsername] = useState(localStorage['username'] ?? (`mcrafter${Math.floor(Math.random() * 1000)}`)) + const [authenticatedAccounts, setAuthenticatedAccounts] = useState(JSON.parse(localStorage['authenticatedAccounts'] || '[]')) + + useEffect(() => { + localStorage.setItem('authenticatedAccounts', JSON.stringify(authenticatedAccounts)) + }, [authenticatedAccounts]) useEffect(() => { localStorage.setItem('username', defaultUsername) @@ -215,6 +234,7 @@ const Inner = () => { } setServerEditScreen(null) }} + accounts={authenticatedAccounts.map(a => a.username)} initialData={!serverEditScreen || serverEditScreen === true ? undefined : serverEditScreen} onQsConnect={(info) => { const connectOptions: ConnectOptions = { @@ -222,7 +242,6 @@ const Inner = () => { server: normalizeIp(info.ip), proxy: info.proxyOverride || selectedProxy, botVersion: info.versionOverride, - password: info.passwordOverride, ignoreQs: true, } dispatchEvent(new CustomEvent('connect', { detail: connectOptions })) @@ -249,14 +268,22 @@ const Inner = () => { if (!username) return setDefaultUsername(username) } + let authenticatedAccount: AuthenticatedAccount | true | undefined + if (overrides.authenticatedAccountOverride) { + if (overrides.authenticatedAccountOverride === true) { + authenticatedAccount = true + } else { + authenticatedAccount = authenticatedAccounts.find(a => a.username === overrides.authenticatedAccountOverride) ?? true + } + } const options = { username, server: normalizeIp(ip), proxy: overrides.proxyOverride || selectedProxy, botVersion: overrides.versionOverride ?? /* legacy */ overrides['version'], - password: overrides.passwordOverride, ignoreQs: true, autoLoginPassword: server?.autoLogin?.[username], + authenticatedAccount, onSuccessfulPlay () { if (shouldSave && !serversList.some(s => s.ip === ip)) { const newServersList: StoreServerItem[] = [...serversList, { @@ -294,6 +321,11 @@ const Inner = () => { }} username={defaultUsername} setUsername={setDefaultUsername} + onProfileClick={async () => { + const username = await showOptionsModal('Select authenticated account to remove', authenticatedAccounts.map(a => a.username)) + if (!username) return + setAuthenticatedAccounts(old => old.filter(a => a.username !== username)) + }} onWorldAction={(action, index) => { const server = serversList[index] if (!server) return diff --git a/src/react/SignInMessage.stories.tsx b/src/react/SignInMessage.stories.tsx new file mode 100644 index 00000000..16528700 --- /dev/null +++ b/src/react/SignInMessage.stories.tsx @@ -0,0 +1,18 @@ +import type { Meta, StoryObj } from '@storybook/react' +import SignInMessage from './SignInMessage' + +const meta: Meta<{ open }> = { + component: SignInMessage as any, + render ({ open }) { + return + }, +} + +export default meta +type Story = StoryObj<{ open }> + +export const Primary: Story = { + args: { + }, +} diff --git a/src/react/SignInMessage.tsx b/src/react/SignInMessage.tsx new file mode 100644 index 00000000..2ec38816 --- /dev/null +++ b/src/react/SignInMessage.tsx @@ -0,0 +1,107 @@ +import { useState } from 'react' +import { useUtilsEffect } from '@zardoy/react-util' +import PixelartIcon from './PixelartIcon' +import Screen from './Screen' +import Button from './Button' + +export default ({ + code = 'ABCD-EFGH-IJKL-MNOP', + loginLink = 'https://aka.ms/devicelogin', + connectingServer = 'mc.example.comsdlfjsklfjsfjdskfjsj', + warningText = true, + expiresEnd = Date.now() + 1000 * 60 * 5, + setSaveToken = (() => { }) as ((state: boolean) => void) | undefined, + defaultSaveToken = true, + onCancel = () => { }, + directLink = 'https://aka.ms/devicelogin' +}) => { + if (connectingServer.length > 30) connectingServer = connectingServer.slice(0, 30) + '...' + const [timeLeft, setTimeLeft] = useState(``) + + useUtilsEffect(({ interval }) => { + interval(1000, () => { + const timeLeft = Math.max(0, Math.ceil((expiresEnd - Date.now()) / 1000)) + const minutes = Math.floor(timeLeft / 60) + const seconds = timeLeft % 60 + setTimeLeft(`${minutes}:${seconds.toString().padStart(2, '0')}`) + if (timeLeft <= 0) setTimeLeft('Code expired!') + }) + }, []) + + return + + + +} diff --git a/src/react/SignInMessageProvider.tsx b/src/react/SignInMessageProvider.tsx new file mode 100644 index 00000000..68ea83aa --- /dev/null +++ b/src/react/SignInMessageProvider.tsx @@ -0,0 +1,32 @@ +import { proxy, ref, useSnapshot } from 'valtio' +import SignInMessage from './SignInMessage' +import { lastConnectOptions } from './AppStatusProvider' + +export const signInMessageState = proxy({ + code: '', + link: '', + expiresOn: 0, + shouldSaveToken: true, + abortController: ref(new AbortController()), +}) + +export default () => { + const { code, expiresOn, link, shouldSaveToken } = useSnapshot(signInMessageState) + + if (!code) return null + + return { + signInMessageState.shouldSaveToken = state + }} + connectingServer={lastConnectOptions.value?.server ?? ''} + onCancel={() => { + signInMessageState.abortController.abort() + }} + directLink={`http://microsoft.com/link?otc=${code}`} + /> +} diff --git a/src/react/globals.d.ts b/src/react/globals.d.ts index 108fae54..7b0f64bb 100644 --- a/src/react/globals.d.ts +++ b/src/react/globals.d.ts @@ -32,9 +32,9 @@ declare module '*.svg' { interface PromiseConstructor { withResolvers (): { - resolve: (value: T) => void; - reject: (reason: any) => void; - promise: Promise; + resolve: (value: T) => void + reject: (reason: any) => void + promise: Promise } } @@ -44,6 +44,7 @@ declare namespace JSX { icon: string style?: React.CSSProperties class?: string + onClick?: (e) => void } } } diff --git a/src/reactUi.tsx b/src/reactUi.tsx index f140326e..34a567cd 100644 --- a/src/reactUi.tsx +++ b/src/reactUi.tsx @@ -40,6 +40,7 @@ import KeybindingsScreenProvider from './react/KeybindingsScreenProvider' import HeldMapUi from './react/HeldMapUi' import BedTime from './react/BedTime' import NoModalFoundProvider from './react/NoModalFoundProvider' +import SignInMessageProvider from './react/SignInMessageProvider' const RobustPortal = ({ children, to }) => { return createPortal({children}, to) @@ -173,6 +174,7 @@ const App = () => { + {/* */} @@ -191,7 +193,7 @@ const App = () => { const PerComponentErrorBoundary = ({ children }) => { return children.map((child, i) => { const componentNameClean = (child.type.name || child.type.displayName || 'Unknown').replaceAll(/__|_COMPONENT/g, '') - showNotification(`UI component ${componentNameClean} crashed!`, 'Please report this. Use console to see more info.', true, undefined) + showNotification(`UI component ${componentNameClean} crashed!`, 'Please report this. Use console for more.', true, undefined) return null }}>{child}) } diff --git a/src/yggdrasilReplacement.ts b/src/yggdrasilReplacement.ts new file mode 100644 index 00000000..e0cab6f0 --- /dev/null +++ b/src/yggdrasilReplacement.ts @@ -0,0 +1,27 @@ +export const server = ({ host: sessionServer }) => { + return { + async join (accessToken, sessionSelectedProfileId, serverId, sharedSecret, publicKey, cb) { + try { + const result = await fetch(`${sessionServer}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + accessToken, + selectedProfile: sessionSelectedProfileId, + serverId, + sharedSecret, + publicKey, + }), + }) + if (!result.ok) { + throw new Error(`Request failed ${await result.text()}`) + } + cb(null) + } catch (err) { + cb(err) + } + } + } +} From 324c08ef436ec66672d544109eacc08d27dd2dcc Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 7 Jul 2024 00:32:04 +0300 Subject: [PATCH 073/985] finally update dockerfile to a working one! uses 6gb of ram to build btw. image size: 2.4gb, ~200mb when running --- .dockerignore | 2 -- Dockerfile | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index 285d1303..38ca0016 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,3 @@ -# we dont want default config to be loaded in the dockerfile, but rather using a volume -config.json # build stuff node_modules public \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index aa9eb3dc..086240b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,22 @@ -FROM node:14-alpine +FROM node:18-alpine # Without git installing the npm packages fails RUN apk add git RUN mkdir /app WORKDIR /app COPY . /app -RUN npm install -RUN npm run build +# install python and other dependencies +RUN apk add python3 make g++ cairo-dev pango-dev jpeg-dev giflib-dev librsvg-dev +# install pnpm +RUN npm i -g pnpm@9.0.4 +RUN pnpm install +# only for prod +RUN pnpm run build +# --- +EXPOSE 8080 +# uncomment for development +# EXPOSE 9090 +# VOLUME /app/src +# VOLUME /app/prismarine-viewer +# ENTRYPOINT ["pnpm", "run", "run-all"] +# only for prod ENTRYPOINT ["npm", "run", "prod-start"] From d80b71ede74a110debac25c1ea5b45f802b5d41d Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 6 Jul 2024 23:20:40 +0300 Subject: [PATCH 074/985] add demo to npm readme file --- README.NPM.MD | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.NPM.MD b/README.NPM.MD index c036adba..c44492c6 100644 --- a/README.NPM.MD +++ b/README.NPM.MD @@ -1,9 +1,13 @@ # Minecraft React +Minecraft UI components for React. + ```bash -yarn add minecraft-react +pnpm i minecraft-react ``` +![demo](https://github-production-user-asset-6210df.s3.amazonaws.com/46503702/346295584-80f3ed4a-cab6-45d2-8896-5e20233cc9b1.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240706%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240706T195400Z&X-Amz-Expires=300&X-Amz-Signature=5b063823a57057c4042c15edd1db3edd107e00940fd0e66a2ba1df4e564a2809&X-Amz-SignedHeaders=host&actor_id=46503702&key_id=0&repo_id=432411890) + ## Usage ```jsx From d1d0959cb40af0e7872f12996db1ce6ce1f364e1 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 7 Jul 2024 01:12:25 +0300 Subject: [PATCH 075/985] feat: add Sonar bypass making possible to join to projects like ruhypixel.net wip: packets replay feature! --- pnpm-lock.yaml | 8 ++++---- src/index.ts | 14 ++++++++++++-- src/inventoryWindows.ts | 4 ++-- src/optionsGuiScheme.tsx | 22 ++++++++++++++++++++++ src/react/AppStatusProvider.tsx | 7 ++++++- src/react/ServersListProvider.tsx | 2 ++ src/react/SignInMessage.tsx | 2 ++ 7 files changed, 50 insertions(+), 9 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 98618ba5..cf890476 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -311,7 +311,7 @@ importers: version: https://codeload.github.com/zardoy/minecraft-inventory-gui/tar.gz/c50afc54e39817f7e4d313ce0f6fdaad71e7e4f4(@types/react@18.2.20)(react@18.2.0) mineflayer: specifier: github:zardoy/mineflayer - version: https://codeload.github.com/zardoy/mineflayer/tar.gz/a4b1b4ba7f8c972cee9c0a16eb1191ff4d21fe23(encoding@0.1.13) + version: https://codeload.github.com/zardoy/mineflayer/tar.gz/dddc683544317f117172077a9245a07be1b12479(encoding@0.1.13) mineflayer-pathfinder: specifier: ^2.4.4 version: 2.4.4 @@ -6089,8 +6089,8 @@ packages: resolution: {integrity: sha512-QMMNPx4IyZE7ydAzjvGLQLCnQNUOfkk1qVZKxTTS9q3qPTAewz4GhsVUBtbQ8LSbHthe5RcQ1Sgxs4wlIma/Qw==} engines: {node: '>=18'} - mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/a4b1b4ba7f8c972cee9c0a16eb1191ff4d21fe23: - resolution: {tarball: https://codeload.github.com/zardoy/mineflayer/tar.gz/a4b1b4ba7f8c972cee9c0a16eb1191ff4d21fe23} + mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/dddc683544317f117172077a9245a07be1b12479: + resolution: {tarball: https://codeload.github.com/zardoy/mineflayer/tar.gz/dddc683544317f117172077a9245a07be1b12479} version: 4.20.1 engines: {node: '>=18'} @@ -15831,7 +15831,7 @@ snapshots: - encoding - supports-color - mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/a4b1b4ba7f8c972cee9c0a16eb1191ff4d21fe23(encoding@0.1.13): + mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/dddc683544317f117172077a9245a07be1b12479(encoding@0.1.13): dependencies: minecraft-data: 3.65.0 minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/495eed56ab230b2615596590064671356d86a2dc(patch_hash=7otpchsbv7hxsuis4rrrwdtbve)(encoding@0.1.13) diff --git a/src/index.ts b/src/index.ts index 5fd50ce3..e73e8240 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,6 +42,7 @@ import * as THREE from 'three' import MinecraftData, { versionsByMinecraftVersion } from 'minecraft-data' import debug from 'debug' import { defaultsDeep } from 'lodash-es' +import initializePacketsReplay from './packetsReplay' import { initVR } from './vr' import { @@ -97,6 +98,7 @@ import { ref, subscribe } from 'valtio' import { signInMessageState } from './react/SignInMessageProvider' import { updateAuthenticatedAccountData, updateLoadedServerData } from './react/ServersListProvider' import { versionToNumber } from 'prismarine-viewer/viewer/prepare/utils' +import packetsPatcher from './packetsPatcher' window.debug = debug window.THREE = THREE @@ -108,6 +110,8 @@ window.beforeRenderFrame = [] void registerServiceWorker() watchFov() initCollisionShapes() +initializePacketsReplay() +packetsPatcher() // Create three.js context, add to page let renderer: THREE.WebGLRenderer @@ -361,6 +365,7 @@ async function connect (connectOptions: ConnectOptions) { } const renderDistance = singleplayer ? renderDistanceSingleplayer : multiplayerRenderDistance + let updateDataAfterJoin = () => { } let localServer try { const serverOptions = defaultsDeep({}, connectOptions.serverOverrides ?? {}, options.localServerOptions, defaultServerOptions) @@ -506,9 +511,13 @@ async function connect (connectOptions: ConnectOptions) { } return accounts }) - updateLoadedServerData(s => ({ ...s, authenticatedAccountOverride: client.username }), connectOptions.serverIndex) + updateDataAfterJoin = () => { + updateLoadedServerData(s => ({ ...s, authenticatedAccountOverride: client.username }), connectOptions.serverIndex) + } } else { - updateLoadedServerData(s => ({ ...s, authenticatedAccountOverride: undefined }), connectOptions.serverIndex) + updateDataAfterJoin = () => { + updateLoadedServerData(s => ({ ...s, authenticatedAccountOverride: undefined }), connectOptions.serverIndex) + } } setLoadingScreenStatus('Authentication successful. Logging in to server') } finally { @@ -660,6 +669,7 @@ async function connect (connectOptions: ConnectOptions) { setLoadingScreenStatus('Placing blocks (starting viewer)') localStorage.lastConnectOptions = JSON.stringify(connectOptions) connectOptions.onSuccessfulPlay?.() + updateDataAfterJoin() if (connectOptions.autoLoginPassword) { bot.chat(`/login ${connectOptions.autoLoginPassword}`) } diff --git a/src/inventoryWindows.ts b/src/inventoryWindows.ts index 5f7fc0a5..fd213509 100644 --- a/src/inventoryWindows.ts +++ b/src/inventoryWindows.ts @@ -328,9 +328,9 @@ export const getItemNameRaw = (item: Pick return parsed as MessageFormatPart } } catch (err) { - return [{ + return { text: customName - }] + } } } diff --git a/src/optionsGuiScheme.tsx b/src/optionsGuiScheme.tsx index d7636392..76799a60 100644 --- a/src/optionsGuiScheme.tsx +++ b/src/optionsGuiScheme.tsx @@ -9,6 +9,7 @@ import Slider from './react/Slider' import { getScreenRefreshRate, setLoadingScreenStatus } from './utils' import { openFilePicker, resetLocalStorageWithoutWorld } from './browserfs' import { getResourcePackName, resourcePackState, uninstallTexturePack } from './texturePack' +import { downloadPacketsReplay, packetsReplaceSessionState } from './packetsReplay' export const guiOptionsScheme: { @@ -309,6 +310,27 @@ export const guiOptionsScheme: { if (confirm('Are you sure you want to reset all settings?')) resetLocalStorageWithoutWorld() }}>Reset all settings }, + }, + { + custom () { + return Developer + }, + }, + { + custom () { + const { active } = useSnapshot(packetsReplaceSessionState) + return + }, + }, + { + custom () { + const { active } = useSnapshot(packetsReplaceSessionState) + return + }, } ], } diff --git a/src/react/AppStatusProvider.tsx b/src/react/AppStatusProvider.tsx index 0b12390c..c905be12 100644 --- a/src/react/AppStatusProvider.tsx +++ b/src/react/AppStatusProvider.tsx @@ -5,6 +5,7 @@ import { resetLocalStorageWorld } from '../browserfs' import { fsState } from '../loadSave' import { guessProblem } from '../errorLoadingScreenHelpers' import { ConnectOptions } from '../connect' +import { downloadPacketsReplay, packetsReplaceSessionState } from '../packetsReplay' import AppStatus from './AppStatus' import DiveTransition from './DiveTransition' import { useDidUpdateEffect } from './utils' @@ -32,6 +33,7 @@ export const lastConnectOptions = { export default () => { const { isError, lastStatus, maybeRecoverable, status, hideDots, descriptionHint } = useSnapshot(appStatusState) + const { active: replayActive } = useSnapshot(packetsReplaceSessionState) const isOpen = useIsModalActive('app-status') @@ -103,7 +105,10 @@ export default () => { } } : undefined} actionsSlot={ - displayAuthButton && diff --git a/src/react/ConceptCommandsGui.stories.tsx b/src/react/ConceptCommandsGui.stories.tsx index 89cb6eff..4f3586d4 100644 --- a/src/react/ConceptCommandsGui.stories.tsx +++ b/src/react/ConceptCommandsGui.stories.tsx @@ -11,7 +11,6 @@ const Button2 = ({ title, icon }) => {
{title}
- {/* { // const sessionEndpoint = 'http://localhost:3000/session' let authEndpoint = '' let sessionEndpoint = '' + if (!proxyBaseUrl.startsWith('http')) proxyBaseUrl = `${isPageSecure() ? 'https' : 'http'}://${proxyBaseUrl}` + const url = proxyBaseUrl + '/api/vm/net/connect' + let result: Response + try { + result = await fetch(url) + } catch (err) { + throw new Error(`Selected proxy server ${proxyBaseUrl} most likely is down`) + } try { - if (!proxyBaseUrl.startsWith('http')) proxyBaseUrl = `${isPageSecure() ? 'https' : 'http'}://${proxyBaseUrl}` - const url = proxyBaseUrl + '/api/vm/net/connect' - const result = await fetch(url) const json = await result.json() authEndpoint = urlWithBase(json.capabilities.authEndpoint, proxyBaseUrl) sessionEndpoint = urlWithBase(json.capabilities.sessionEndpoint, proxyBaseUrl) diff --git a/src/react/AppStatus.tsx b/src/react/AppStatus.tsx index 10cc5793..9ebecf93 100644 --- a/src/react/AppStatus.tsx +++ b/src/react/AppStatus.tsx @@ -28,6 +28,7 @@ export default ({ status, isError, hideDots = false, lastStatus = '', backAction return ( diff --git a/src/react/Chat.css b/src/react/Chat.css index 41917783..cba0a1aa 100644 --- a/src/react/Chat.css +++ b/src/react/Chat.css @@ -24,6 +24,13 @@ div.chat-wrapper { left: 1px; box-sizing: border-box; background-color: rgba(0, 0, 0, 0); + display: flex; + align-items: center; + gap: 1px; +} + +.chat-input-wrapper form { + display: flex; } .chat-input { @@ -103,7 +110,8 @@ div.chat-wrapper { } .input-mobile #chatinput { - height: 20px; + height: 24px; + font-size: 13px; } .display-mobile { diff --git a/src/react/Chat.tsx b/src/react/Chat.tsx index 89b2aa8b..60467171 100644 --- a/src/react/Chat.tsx +++ b/src/react/Chat.tsx @@ -4,6 +4,8 @@ import { MessageFormatPart } from '../botUtils' import { MessagePart } from './MessageFormatted' import './Chat.css' import { isIos, reactKeyForMessage } from './utils' +import Button from './Button' +import { pixelartIcons } from './PixelartIcon' export type Message = { parts: MessageFormatPart[], @@ -221,6 +223,8 @@ export default ({ diff --git a/src/react/EnterFullscreenButton.tsx b/src/react/EnterFullscreenButton.tsx index ad78ddad..3901b9ae 100644 --- a/src/react/EnterFullscreenButton.tsx +++ b/src/react/EnterFullscreenButton.tsx @@ -1,6 +1,11 @@ import { useEffect, useState } from 'react' +import { useSnapshot } from 'valtio' +import { activeModalStack, miscUiState } from '../globalState' import Button from './Button' import { useUsingTouch } from './utilsApp' +import { pixelartIcons } from './PixelartIcon' + +const hideOnModals = new Set(['chat']) export default () => { const [fullScreen, setFullScreen] = useState(false) @@ -9,16 +14,23 @@ export default () => { setFullScreen(!!document.fullscreenElement) }) }, []) + const { gameLoaded } = useSnapshot(miscUiState) + + const activeStack = useSnapshot(activeModalStack) + + const inMainMenu = activeStack.length === 0 && !gameLoaded const usingTouch = useUsingTouch() - if (!usingTouch || !document.documentElement.requestFullscreen || fullScreen) return null + const hideButton = activeStack.some(x => hideOnModals.has(x.reactType)) + + if (hideButton || !usingTouch || !document.documentElement.requestFullscreen || fullScreen) return null return + {!lockConnect && <> + + } } From d02008c2ef4bfff93fad0edbeaffca3d60399bcc Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 11 Jul 2024 18:33:16 +0300 Subject: [PATCH 087/985] fix(regression): signs lighting was compltely broken --- prismarine-viewer/viewer/lib/mesher/models.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prismarine-viewer/viewer/lib/mesher/models.ts b/prismarine-viewer/viewer/lib/mesher/models.ts index ab77d516..c978c240 100644 --- a/prismarine-viewer/viewer/lib/mesher/models.ts +++ b/prismarine-viewer/viewer/lib/mesher/models.ts @@ -624,7 +624,7 @@ export function getSectionGeometry (sx, sy, sz, world: World) { delete attr.t_uvs attr.positions = new Float32Array(attr.positions) as any - attr.normals = new Int8Array(attr.normals) as any + attr.normals = new Float32Array(attr.normals) as any attr.colors = new Float32Array(attr.colors) as any attr.uvs = new Float32Array(attr.uvs) as any From d0205a970b823ed49e4a01dea237e175a096d777 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 11 Jul 2024 20:08:10 +0300 Subject: [PATCH 088/985] up mineflayer for better vehicle move --- pnpm-lock.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 45ebdda4..9d370f17 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -314,7 +314,7 @@ importers: version: https://codeload.github.com/zardoy/minecraft-inventory-gui/tar.gz/c50afc54e39817f7e4d313ce0f6fdaad71e7e4f4(@types/react@18.2.20)(react@18.2.0) mineflayer: specifier: github:zardoy/mineflayer - version: https://codeload.github.com/zardoy/mineflayer/tar.gz/dddc683544317f117172077a9245a07be1b12479(encoding@0.1.13) + version: https://codeload.github.com/zardoy/mineflayer/tar.gz/c03c76ef2acfc747bfe8cd1e290106c81f399848(encoding@0.1.13) mineflayer-pathfinder: specifier: ^2.4.4 version: 2.4.4 @@ -6086,8 +6086,8 @@ packages: resolution: {integrity: sha512-QMMNPx4IyZE7ydAzjvGLQLCnQNUOfkk1qVZKxTTS9q3qPTAewz4GhsVUBtbQ8LSbHthe5RcQ1Sgxs4wlIma/Qw==} engines: {node: '>=18'} - mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/dddc683544317f117172077a9245a07be1b12479: - resolution: {tarball: https://codeload.github.com/zardoy/mineflayer/tar.gz/dddc683544317f117172077a9245a07be1b12479} + mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/c03c76ef2acfc747bfe8cd1e290106c81f399848: + resolution: {tarball: https://codeload.github.com/zardoy/mineflayer/tar.gz/c03c76ef2acfc747bfe8cd1e290106c81f399848} version: 4.20.1 engines: {node: '>=18'} @@ -15825,7 +15825,7 @@ snapshots: - encoding - supports-color - mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/dddc683544317f117172077a9245a07be1b12479(encoding@0.1.13): + mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/c03c76ef2acfc747bfe8cd1e290106c81f399848(encoding@0.1.13): dependencies: minecraft-data: 3.65.0 minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/495eed56ab230b2615596590064671356d86a2dc(patch_hash=7otpchsbv7hxsuis4rrrwdtbve)(encoding@0.1.13) From 07002a743748899f58767011c3bf99da2658c63b Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 13 Jul 2024 05:49:38 +0300 Subject: [PATCH 089/985] fix: remove entities from the scene on login packet (usually on the world switch) --- pnpm-lock.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9d370f17..9deb9a7e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -314,7 +314,7 @@ importers: version: https://codeload.github.com/zardoy/minecraft-inventory-gui/tar.gz/c50afc54e39817f7e4d313ce0f6fdaad71e7e4f4(@types/react@18.2.20)(react@18.2.0) mineflayer: specifier: github:zardoy/mineflayer - version: https://codeload.github.com/zardoy/mineflayer/tar.gz/c03c76ef2acfc747bfe8cd1e290106c81f399848(encoding@0.1.13) + version: https://codeload.github.com/zardoy/mineflayer/tar.gz/7f65e46a048f1bc2b57775d84b32400dce707321(encoding@0.1.13) mineflayer-pathfinder: specifier: ^2.4.4 version: 2.4.4 @@ -6086,8 +6086,8 @@ packages: resolution: {integrity: sha512-QMMNPx4IyZE7ydAzjvGLQLCnQNUOfkk1qVZKxTTS9q3qPTAewz4GhsVUBtbQ8LSbHthe5RcQ1Sgxs4wlIma/Qw==} engines: {node: '>=18'} - mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/c03c76ef2acfc747bfe8cd1e290106c81f399848: - resolution: {tarball: https://codeload.github.com/zardoy/mineflayer/tar.gz/c03c76ef2acfc747bfe8cd1e290106c81f399848} + mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/7f65e46a048f1bc2b57775d84b32400dce707321: + resolution: {tarball: https://codeload.github.com/zardoy/mineflayer/tar.gz/7f65e46a048f1bc2b57775d84b32400dce707321} version: 4.20.1 engines: {node: '>=18'} @@ -15825,7 +15825,7 @@ snapshots: - encoding - supports-color - mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/c03c76ef2acfc747bfe8cd1e290106c81f399848(encoding@0.1.13): + mineflayer@https://codeload.github.com/zardoy/mineflayer/tar.gz/7f65e46a048f1bc2b57775d84b32400dce707321(encoding@0.1.13): dependencies: minecraft-data: 3.65.0 minecraft-protocol: https://codeload.github.com/PrismarineJS/node-minecraft-protocol/tar.gz/495eed56ab230b2615596590064671356d86a2dc(patch_hash=7otpchsbv7hxsuis4rrrwdtbve)(encoding@0.1.13) From 04b5d1ac3f03e5053df6a6142ede7d0c4539d480 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 13 Jul 2024 06:17:47 +0300 Subject: [PATCH 090/985] add handled packets stats TODO make auto-updated --- docs-assets/handled-packets.md | 169 +++++++++++++++++++++++++++++++ scripts/updateHandledPackets.mjs | 60 +++++++++++ 2 files changed, 229 insertions(+) create mode 100644 docs-assets/handled-packets.md create mode 100644 scripts/updateHandledPackets.mjs diff --git a/docs-assets/handled-packets.md b/docs-assets/handled-packets.md new file mode 100644 index 00000000..0671987c --- /dev/null +++ b/docs-assets/handled-packets.md @@ -0,0 +1,169 @@ +# Handled Packets + +## Server -> Client + +❌ statistics +❌ advancements +❌ face_player +❌ nbt_query_response +❌ chat_suggestions +❌ trade_list +❌ vehicle_move +❌ open_book +❌ craft_recipe_response +❌ end_combat_event +❌ enter_combat_event +❌ unlock_recipes +❌ camera +❌ update_view_position +❌ update_view_distance +❌ entity_sound_effect +❌ stop_sound +❌ feature_flags +❌ select_advancement_tab +❌ declare_recipes +❌ tags +❌ acknowledge_player_digging +❌ initialize_world_border +❌ world_border_center +❌ world_border_lerp_size +❌ world_border_size +❌ world_border_warning_delay +❌ world_border_warning_reach +❌ simulation_distance +❌ chunk_biomes +❌ damage_event +❌ hurt_animation +✅ spawn_entity +✅ spawn_entity_experience_orb +✅ named_entity_spawn +✅ animation +✅ block_break_animation +✅ tile_entity_data +✅ block_action +✅ block_change +✅ boss_bar +✅ difficulty +✅ tab_complete +✅ declare_commands +✅ multi_block_change +✅ close_window +✅ open_window +✅ window_items +✅ craft_progress_bar +✅ set_slot +✅ set_cooldown +✅ custom_payload +✅ hide_message +✅ kick_disconnect +✅ profileless_chat +✅ entity_status +✅ explosion +✅ unload_chunk +✅ game_state_change +✅ open_horse_window +✅ keep_alive +✅ map_chunk +✅ world_event +✅ world_particles +✅ update_light +✅ login +✅ map +✅ rel_entity_move +✅ entity_move_look +✅ entity_look +✅ open_sign_entity +✅ abilities +✅ player_chat +✅ death_combat_event +✅ player_remove +✅ player_info +✅ position +✅ entity_destroy +✅ remove_entity_effect +✅ resource_pack_send +✅ respawn +✅ entity_head_rotation +✅ held_item_slot +✅ scoreboard_display_objective +✅ entity_metadata +✅ attach_entity +✅ entity_velocity +✅ entity_equipment +✅ experience +✅ update_health +✅ scoreboard_objective +✅ set_passengers +✅ teams +✅ scoreboard_score +✅ spawn_position +✅ update_time +✅ sound_effect +✅ system_chat +✅ playerlist_header +✅ collect +✅ entity_teleport +✅ entity_update_attributes +✅ entity_effect +✅ server_data +✅ clear_titles +✅ action_bar +✅ ping +✅ set_title_subtitle +✅ set_title_text +✅ set_title_time +✅ packet + +## Client -> Server + +❌ query_block_nbt +❌ set_difficulty +❌ query_entity_nbt +❌ pick_item +❌ set_beacon_effect +❌ update_command_block_minecart +❌ update_structure_block +❌ generate_structure +❌ lock_difficulty +❌ craft_recipe_request +❌ displayed_recipe +❌ recipe_book +❌ update_jigsaw_block +❌ spectate +❌ advancement_tab +✅ teleport_confirm +✅ chat_command +✅ chat_message +✅ message_acknowledgement +✅ edit_book +✅ name_item +✅ select_trade +✅ update_command_block +✅ tab_complete +✅ client_command +✅ settings +✅ enchant_item +✅ window_click +✅ close_window +✅ custom_payload +✅ use_entity +✅ keep_alive +✅ position +✅ position_look +✅ look +✅ flying +✅ vehicle_move +✅ steer_boat +✅ abilities +✅ block_dig +✅ entity_action +✅ steer_vehicle +✅ resource_pack_receive +✅ held_item_slot +✅ set_creative_slot +✅ update_sign +✅ arm_animation +✅ block_place +✅ use_item +✅ pong +✅ chat_session_update diff --git a/scripts/updateHandledPackets.mjs b/scripts/updateHandledPackets.mjs new file mode 100644 index 00000000..080eaf44 --- /dev/null +++ b/scripts/updateHandledPackets.mjs @@ -0,0 +1,60 @@ +import fs from 'fs' +import path from 'path' +import minecraftData from 'minecraft-data' + +const lastVersion = minecraftData.versions.pc[0] +// console.log('last proto ver', lastVersion.minecraftVersion) +const allPackets = minecraftData(lastVersion.minecraftVersion).protocol +const getPackets = ({ types }) => { + return Object.keys(types).map(type => type.replace('packet_', '')) +} +// todo test against all versions +const allFromServerPackets = getPackets(allPackets.play.toClient) +const allToServerPackets = getPackets(allPackets.play.toServer).filter(x => !['packet'].includes(x)) + +const buildFile = './dist/index.js' + +const file = fs.readFileSync(buildFile, 'utf8') + +const packetsReceiveRegex = /client\.on\("(\w+)"/g +const packetsReceiveSend = /client\.write\("(\w+)"/g + +let allSupportedReceive = [...new Set([...file.matchAll(packetsReceiveRegex)].map(x => x[1]))] +let allSupportedSend = [...new Set([...file.matchAll(packetsReceiveSend)].map(x => x[1]))] + +let md = '# Handled Packets\n' + +md += '\n## Server -> Client\n\n' +let notSupportedRows = [] +let supportedRows = [] +for (const packet of allFromServerPackets) { + const includes = allSupportedReceive.includes(packet); + (includes ? supportedRows : notSupportedRows).push(packet) +} + +for (const row of notSupportedRows) { + md += `❌ ${row}\n` +} +for (const row of supportedRows) { + md += `✅ ${row}\n` +} + +md += '\n' + +notSupportedRows = [] +supportedRows = [] + +md += '## Client -> Server\n\n' +for (const packet of allToServerPackets) { + const includes = allSupportedSend.includes(packet); + (includes ? supportedRows : notSupportedRows).push(packet) +} + +for (const row of notSupportedRows) { + md += `❌ ${row}\n` +} +for (const row of supportedRows) { + md += `✅ ${row}\n` +} + +fs.writeFileSync('./docs-assets/handled-packets.md', md) From 6c5f72e1f286f2b73f8b940d117b9cec4b197ae1 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 13 Jul 2024 20:31:27 +0300 Subject: [PATCH 091/985] feat: implement pitch which was required for note blocks to work properly --- prismarine-viewer/viewer/lib/viewer.ts | 5 +++-- src/soundSystem.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/prismarine-viewer/viewer/lib/viewer.ts b/prismarine-viewer/viewer/lib/viewer.ts index c95127f2..504c4637 100644 --- a/prismarine-viewer/viewer/lib/viewer.ts +++ b/prismarine-viewer/viewer/lib/viewer.ts @@ -32,7 +32,7 @@ export class Viewer { this.world.camera = camera } - constructor(public renderer: THREE.WebGLRenderer, worldConfig = defaultWorldRendererConfig) { + constructor (public renderer: THREE.WebGLRenderer, worldConfig = defaultWorldRendererConfig) { // https://discourse.threejs.org/t/updates-to-color-management-in-three-js-r152/50791 THREE.ColorManagement.enabled = false renderer.outputColorSpace = THREE.LinearSRGBColorSpace @@ -118,7 +118,7 @@ export class Viewer { this.world.updateCamera(pos?.offset(0, yOffset, 0) ?? null, yaw, pitch) } - playSound (position: Vec3, path: string, volume = 1) { + playSound (position: Vec3, path: string, volume = 1, pitch = 1) { if (!this.audioListener) { this.audioListener = new THREE.AudioListener() this.camera.add(this.audioListener) @@ -134,6 +134,7 @@ export class Viewer { sound.setBuffer(buffer) sound.setRefDistance(20) sound.setVolume(volume) + sound.setPlaybackRate(pitch) // set the pitch this.scene.add(sound) // set sound position sound.position.set(position.x, position.y, position.z) diff --git a/src/soundSystem.ts b/src/soundSystem.ts index e7fdaee7..d49b6a8c 100644 --- a/src/soundSystem.ts +++ b/src/soundSystem.ts @@ -50,7 +50,7 @@ subscribeKey(miscUiState, 'gameLoaded', async () => { const isMuted = options.mutedSounds.includes(soundKey) || options.volume === 0 if (position) { if (!isMuted) { - viewer.playSound(position, url, soundVolume * Math.max(Math.min(volume, 1), 0) * (options.volume / 100)) + viewer.playSound(position, url, soundVolume * Math.max(Math.min(volume, 1), 0) * (options.volume / 100), Math.max(Math.min(pitch ?? 1, 2), 0.5)) } if (getDistance(bot.entity.position, position) < 4 * 16) { lastPlayedSounds.lastServerPlayed[soundKey] ??= { count: 0, last: 0 } From b13ef443bb84d4f2f84a4d11bc0f25ffc8d4840c Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 13 Jul 2024 21:30:44 +0300 Subject: [PATCH 092/985] feat: rework sound system. Now sounds are 100% implemented for all current & future supported versions --- prismarine-viewer/viewer/prepare/utils.ts | 14 ++++++ src/globals.d.ts | 2 +- src/soundSystem.ts | 53 ++++++++++++----------- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/prismarine-viewer/viewer/prepare/utils.ts b/prismarine-viewer/viewer/prepare/utils.ts index a33909a9..958273f3 100644 --- a/prismarine-viewer/viewer/prepare/utils.ts +++ b/prismarine-viewer/viewer/prepare/utils.ts @@ -2,3 +2,17 @@ export const versionToNumber = (ver: string) => { const [x, y = '0', z = '0'] = ver.split('.') return +`${x.padStart(2, '0')}${y.padStart(2, '0')}${z.padStart(2, '0')}` } + +export const versionToMajor = (version: string) => { + const [x, y = '0'] = version.split('.') + return `${x.padStart(2, '0')}.${y.padStart(2, '0')}` +} + +export const versionsMapToMajor = (versionsMap: Record) => { + const majorVersions = {} as Record + for (const [ver, data] of Object.entries(versionsMap)) { + const major = versionToMajor(ver) + majorVersions[major] = data + } + return majorVersions +} diff --git a/src/globals.d.ts b/src/globals.d.ts index 05b29a14..f8699f21 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -17,7 +17,7 @@ declare const worldView: import('prismarine-viewer/viewer/lib/worldDataEmitter') declare const localServer: import('flying-squid/dist/index').FullServer & { options } | undefined /** all currently loaded mc data */ declare const mcData: Record -declare const loadedData: import('minecraft-data').IndexedData +declare const loadedData: import('minecraft-data').IndexedData & { sounds: Record } declare const customEvents: import('typed-emitter').default<{ /** Singleplayer load requested */ singleplayer (): void diff --git a/src/soundSystem.ts b/src/soundSystem.ts index d49b6a8c..0187a9b0 100644 --- a/src/soundSystem.ts +++ b/src/soundSystem.ts @@ -1,6 +1,6 @@ import { subscribeKey } from 'valtio/utils' import { Vec3 } from 'vec3' -import { versionToNumber } from 'prismarine-viewer/viewer/prepare/utils' +import { versionToMajor, versionToNumber, versionsMapToMajor } from 'prismarine-viewer/viewer/prepare/utils' import { loadScript } from 'prismarine-viewer/viewer/lib/utils' import type { Block } from 'prismarine-block' import { miscUiState } from './globalState' @@ -22,32 +22,26 @@ subscribeKey(miscUiState, 'gameLoaded', async () => { return } - // todo also use major versioned hardcoded sounds - const soundsMap = allSoundsMap[bot.version] + const allSoundsMajor = versionsMapToMajor(allSoundsMap) + const soundsMap = allSoundsMajor[versionToMajor(bot.version)] ?? Object.values(allSoundsMajor)[0] - if (!soundsMap || !miscUiState.gameLoaded || !soundsMap) { + if (!soundsMap || !miscUiState.gameLoaded || !loadedData.sounds) { return } - const soundsPerId = Object.fromEntries(Object.entries(soundsMap).map(([id, sound]) => [+id.split(';')[0], sound])) + // const soundsPerId = Object.fromEntries(Object.entries(soundsMap).map(([id, sound]) => [+id.split(';')[0], sound])) const soundsPerName = Object.fromEntries(Object.entries(soundsMap).map(([id, sound]) => [id.split(';')[1], sound])) - const soundIdToName = Object.fromEntries(Object.entries(soundsMap).map(([id, sound]) => [+id.split(';')[0], id.split(';')[1]])) - const playGeneralSound = async (soundId: string, soundString: string | undefined, position?: Vec3, volume = 1, pitch?: number) => { - if (!soundString) { - console.warn('Unknown sound received from server to play', soundId) - return - } + const playGeneralSound = async (soundKey: string, position?: Vec3, volume = 1, pitch?: number) => { if (!options.volume) return - const parts = soundString.split(';') - const soundVolume = +parts[0]! - const soundName = parts[1]! - // console.log('pitch', pitch) - const versionedSound = getVersionedSound(bot.version, soundName, Object.entries(soundsLegacyMap)) + const soundStaticData = soundsPerName[soundKey]?.split(';') + if (!soundStaticData) return + const soundVolume = +soundStaticData[0]! + const soundPath = soundStaticData[1]! + const versionedSound = getVersionedSound(bot.version, soundPath, Object.entries(soundsLegacyMap)) // todo test versionedSound - const url = allSoundsMeta.baseUrl.replace(/\/$/, '') + (versionedSound ? `/${versionedSound}` : '') + '/minecraft/sounds/' + soundName + '.' + allSoundsMeta.format - const soundKey = soundIdToName[+soundId] ?? soundId - const isMuted = options.mutedSounds.includes(soundKey) || options.volume === 0 + const url = allSoundsMeta.baseUrl.replace(/\/$/, '') + (versionedSound ? `/${versionedSound}` : '') + '/minecraft/sounds/' + soundPath + '.' + allSoundsMeta.format + const isMuted = options.mutedSounds.includes(soundKey) || options.mutedSounds.includes(soundPath) || options.volume === 0 if (position) { if (!isMuted) { viewer.playSound(position, url, soundVolume * Math.max(Math.min(volume, 1), 0) * (options.volume / 100), Math.max(Math.min(pitch ?? 1, 2), 0.5)) @@ -67,17 +61,24 @@ subscribeKey(miscUiState, 'gameLoaded', async () => { } } } - const playHardcodedSound = async (soundId: string, position?: Vec3, volume = 1, pitch?: number) => { - const sound = soundsPerName[soundId] - await playGeneralSound(soundId, sound, position, volume, pitch) + const playHardcodedSound = async (soundKey: string, position?: Vec3, volume = 1, pitch?: number) => { + await playGeneralSound(soundKey, position, volume, pitch) } bot.on('soundEffectHeard', async (soundId, position, volume, pitch) => { - console.debug('soundEffectHeard', soundId, volume) await playHardcodedSound(soundId, position, volume, pitch) }) - bot.on('hardcodedSoundEffectHeard', async (soundId, soundCategory, position, volume, pitch) => { - const sound = soundsPerId[soundId] - await playGeneralSound(soundId.toString(), sound, position, volume, pitch) + bot.on('hardcodedSoundEffectHeard', async (soundIdNum, soundCategory, position, volume, pitch) => { + const fixOffset = versionToNumber('1.20.4') === versionToNumber(bot.version) ? -1 : 0 + const soundKey = loadedData.sounds[soundIdNum + fixOffset]?.name + if (soundKey === undefined) return + await playGeneralSound(soundKey, position, volume, pitch) + }) + // workaround as mineflayer doesn't support soundEvent + bot._client.on('sound_effect', async (packet) => { + const soundResource = packet['soundEvent']?.resource as string | undefined + if (packet.soundId !== 0 || !soundResource) return + const pos = new Vec3(packet.x / 8, packet.y / 8, packet.z / 8) + await playHardcodedSound(soundResource.replace('minecraft:', ''), pos, packet.volume, packet.pitch) }) bot.on('entityHurt', async (entity) => { if (entity.id === bot.entity.id) { From 698779f6b5302165dd3dff731de0b223ac837513 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 13 Jul 2024 21:31:29 +0300 Subject: [PATCH 093/985] fix: toggle entity visiiblity even after it's creation --- prismarine-viewer/viewer/lib/entities.js | 10 +++++----- prismarine-viewer/viewer/lib/worldDataEmitter.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/prismarine-viewer/viewer/lib/entities.js b/prismarine-viewer/viewer/lib/entities.js index 94f06e0c..d36b6936 100644 --- a/prismarine-viewer/viewer/lib/entities.js +++ b/prismarine-viewer/viewer/lib/entities.js @@ -405,14 +405,14 @@ export class Entities extends EventEmitter { } //@ts-ignore + // set visibility const isInvisible = entity.metadata?.[0] & 0x20 - if (isInvisible) { - for (const child of this.entities[entity.id].children.find(c => c.name === 'mesh').children) { - if (child.name !== 'nametag') { - child.visible = false - } + for (const child of this.entities[entity.id].children.find(c => c.name === 'mesh').children) { + if (child.name !== 'nametag') { + child.visible = !isInvisible } } + // --- // not player const displayText = entity.metadata?.[3] && this.parseEntityLabel(entity.metadata[2]) if (entity.name !== 'player' && displayText) { diff --git a/prismarine-viewer/viewer/lib/worldDataEmitter.ts b/prismarine-viewer/viewer/lib/worldDataEmitter.ts index 5df5cc73..761509c2 100644 --- a/prismarine-viewer/viewer/lib/worldDataEmitter.ts +++ b/prismarine-viewer/viewer/lib/worldDataEmitter.ts @@ -44,7 +44,14 @@ export class WorldDataEmitter extends EventEmitter { listenToBot (bot: typeof __type_bot) { const emitEntity = (e) => { if (!e || e === bot.entity) return - this.emitter.emit('entity', { ...e, pos: e.position, username: e.username }) + this.emitter.emit('entity', { + ...e, + pos: e.position, + username: e.username, + // set debugTree (obj) { + // e.debugTree = obj + // } + }) } this.eventListeners[bot.username] = { From 512bc09477aa96352f4d19a165a7e110d5c76f81 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 14 Jul 2024 01:55:41 +0300 Subject: [PATCH 094/985] make main docker build 5x smaller, add only proxy dockerfile --- Dockerfile | 32 +++++++++++++++++++++----------- Dockerfile.proxy | 11 +++++++++++ README.MD | 15 +++++++++++---- 3 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 Dockerfile.proxy diff --git a/Dockerfile b/Dockerfile index 086240b5..0ae1c6e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,32 @@ -FROM node:18-alpine +# ---- Build Stage ---- +FROM node:18-alpine AS build # Without git installing the npm packages fails -RUN apk add git -RUN mkdir /app +RUN apk add --no-cache git python3 make g++ cairo-dev pango-dev jpeg-dev giflib-dev librsvg-dev WORKDIR /app COPY . /app -# install python and other dependencies -RUN apk add python3 make g++ cairo-dev pango-dev jpeg-dev giflib-dev librsvg-dev # install pnpm RUN npm i -g pnpm@9.0.4 RUN pnpm install -# only for prod -RUN pnpm run build -# --- -EXPOSE 8080 -# uncomment for development + +# TODO for development # EXPOSE 9090 # VOLUME /app/src # VOLUME /app/prismarine-viewer # ENTRYPOINT ["pnpm", "run", "run-all"] + # only for prod -ENTRYPOINT ["npm", "run", "prod-start"] +RUN pnpm run build + +# ---- Run Stage ---- +FROM node:18-alpine +RUN apk add git +WORKDIR /app +# Copy build artifacts from the build stage +COPY --from=build /app/dist /app/dist +COPY server.js /app/server.js +# Install express +RUN npm i -g pnpm@9.0.4 +RUN npm init -yp +RUN pnpm i express github:zardoy/prismarinejs-net-browserify compression cors +EXPOSE 8080 +ENTRYPOINT ["node", "server.js"] diff --git a/Dockerfile.proxy b/Dockerfile.proxy new file mode 100644 index 00000000..746eef72 --- /dev/null +++ b/Dockerfile.proxy @@ -0,0 +1,11 @@ +# ---- Run Stage ---- +FROM node:18-alpine +RUN apk add git +WORKDIR /app +COPY server.js /app/server.js +# Install server dependencies +RUN npm i -g pnpm@9.0.4 +RUN npm init -yp +RUN pnpm i express github:zardoy/prismarinejs-net-browserify compression cors +EXPOSE 8080 +ENTRYPOINT ["node", "server.js"] diff --git a/README.MD b/README.MD index 9a4ba24a..7576f6ba 100644 --- a/README.MD +++ b/README.MD @@ -44,6 +44,13 @@ See the [Mineflayer](https://github.com/PrismarineJS/mineflayer) repo for the li There is a builtin proxy, but you can also host your one! Just clone the repo, run `pnpm i` (following CONTRIBUTING.MD) and run `pnpm prod-start`, then you can specify `http://localhost:8080` in the proxy field. MS account authentication will be supported soon. +### Docker Files + +- [Main Dockerfile](./Dockerfile) - for production build & offline/private usage. Includes full web-app + proxy server for connecting to Minecraft servers. +- [Proxy Dockerfile](./Dockerfile.proxy) - for proxy server only - that one you would be able to specify in the proxy field on the client (`docker build . -f Dockerfile.proxy -t minecraft-web-proxy`) + +In case of using docker, you don't have to follow preparation steps from CONTRIBUTING.MD, like installing Node.js, pnpm, etc. + ### Rendering #### Three.js Renderer @@ -55,10 +62,6 @@ MS account authentication will be supported soon. -### Things that are not planned yet - -- Mods, plugins (basically JARs) support, shaders - since they all are related to specific game pipelines - ### Advanced Settings There are many many settings, that are not exposed in the UI yet. You can find or change them by opening the browser console and typing `options`. You can also change them by typing `options. = `. @@ -131,6 +134,10 @@ Press `Y` to set query parameters to url of your current game state. - [Peer.js](https://peerjs.com/) - P2P networking (when you open to wan) - [Three.js](https://threejs.org/) - Helping in 3D rendering +### Things that are not planned yet + +- Mods, plugins (basically JARs) support, shaders - since they all are related to specific game pipelines + ### Alternatives - [https://github.com/ClassiCube/ClassiCube](ClassiCube - Better C# Rewrite) [DEMO](https://www.classicube.net/server/play/?warned=true) From b49e9880906f269b1be6456abcdb24f78e45f21e Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 16 Jul 2024 10:35:01 +0300 Subject: [PATCH 095/985] fix: inventory didn't update after dropping an item --- src/controls.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controls.ts b/src/controls.ts index a3a22029..98cc6afb 100644 --- a/src/controls.ts +++ b/src/controls.ts @@ -353,7 +353,7 @@ contro.on('trigger', ({ command }) => { document.exitPointerLock?.() openPlayerInventory() break - case 'general.drop': + case 'general.drop': { // if (bot.heldItem/* && ctrl */) bot.tossStack(bot.heldItem) bot._client.write('block_dig', { 'status': 4, @@ -365,7 +365,14 @@ contro.on('trigger', ({ command }) => { 'face': 0, sequence: 0 }) + const slot = bot.inventory.hotbarStart + bot.quickBarSlot + const item = bot.inventory.slots[slot] + if (item) { + item.count-- + bot.inventory.updateSlot(slot, item.count > 0 ? item : null!) + } break + } case 'general.chat': showModal({ reactType: 'chat' }) break From 9ee67cc8270e79e5b2d9025a30148bb083e8c36d Mon Sep 17 00:00:00 2001 From: Wolf2323 Date: Tue, 16 Jul 2024 10:37:01 +0200 Subject: [PATCH 096/985] fix: ignoring exception ResizeObserver loop exceptions (#161) --- src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.ts b/src/index.ts index e34e81ab..2a190785 100644 --- a/src/index.ts +++ b/src/index.ts @@ -330,6 +330,9 @@ async function connect (connectOptions: ConnectOptions) { } const handleError = (err) => { console.error(err) + if (err === 'ResizeObserver loop completed with undelivered notifications.') { + return + } errorAbortController.abort() if (isCypress()) throw err miscUiState.hasErrors = true From cda1d59d3bd59580d91f4107a8b4a8bfae57c976 Mon Sep 17 00:00:00 2001 From: Wolf2323 Date: Tue, 16 Jul 2024 11:05:57 +0200 Subject: [PATCH 097/985] improved query parameters handling (#162) Co-authored-by: Vitaly --- README.MD | 25 ++++++++++------- src/react/AddServerOrConnect.tsx | 46 +++++++++++++++++++------------- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/README.MD b/README.MD index 7576f6ba..cafa3ac9 100644 --- a/README.MD +++ b/README.MD @@ -110,19 +110,26 @@ world chunks have a *yellow* border, hostile mobs have a *red* outline, passive Press `Y` to set query parameters to url of your current game state. -- `?ip=` - Display connect screen to the server on load -- `?username=` - Set the username for server -- `?proxy=` - Set the proxy server address to use for server -- `?version=` - Set the version for server -- `?lockConnect=true` - Disable cancel / save buttons, useful for integrates iframes +There are some parameters you can set in the url to archive some specific behaviors: + +Server specific: +- `?ip=` - Display connect screen to the server on load with predefined server ip. `:` is optional and can be added to the ip. +- `?name=` - Set the server name for saving to the server list +- `?version=` - Set the version for the server +- `?proxy=` - Set the proxy server address to use for the server +- `?username=` - Set the username for the server +- `?lockConnect=true` - Only works then `ip` parameter is set. Disables cancel/save buttons and all inputs in the connect screen already set as parameters. Useful for integrates iframes. - `?reconnect=true` - Reconnect to the server on page reloads. Available in **dev mode only** and very useful on server testing. + +Single player specific: - `?loadSave=` - Load the save on load with the specified folder name (not title) - `?singleplayer=1` - Create empty world on load. Nothing will be saved -- `?noSave=true` - Disable auto save on unload / disconnect / export. Only manual save with `/save` command will work - - +- `?version=` - Set the version for the singleplayer world (when used with `?singleplayer=1`) +- `?noSave=true` - Disable auto save on unload / disconnect / export whenever a world is loaded. Only manual save with `/save` command will work. - `?map=` - Load the map from ZIP. You can use any url, but it must be CORS enabled. -- `?setting=:` - Set the and lock the setting on load. You can set multiple settings by separating them with `&` e.g. `?setting=autoParkour:true&setting=renderDistance:4` + +General: +- `?setting=:` - Set and lock the setting on load. You can set multiple settings by separating them with `&` e.g. `?setting=autoParkour:true&setting=renderDistance:4` ### Notable Things that Power this Project diff --git a/src/react/AddServerOrConnect.tsx b/src/react/AddServerOrConnect.tsx index 729f1ec2..535e3ee9 100644 --- a/src/react/AddServerOrConnect.tsx +++ b/src/react/AddServerOrConnect.tsx @@ -30,19 +30,25 @@ const ELEMENTS_WIDTH = 190 export default ({ onBack, onConfirm, title = 'Add a Server', initialData, parseQs, onQsConnect, defaults, accounts, authenticatedAccounts }: Props) => { const qsParams = parseQs ? new URLSearchParams(window.location.search) : undefined + const qsParamName = qsParams?.get('name') + const qsParamIp = qsParams?.get('ip') + const qsParamVersion = qsParams?.get('version') + const qsParamProxy = qsParams?.get('proxy') + const qsParamUsername = qsParams?.get('username') + const qsParamLockConnect = qsParams?.get('lockConnect') - const [serverName, setServerName] = React.useState(initialData?.name ?? qsParams?.get('name') ?? '') + const qsIpParts = qsParamIp?.split(':') + const ipParts = initialData?.ip.split(':') - const ipWithoutPort = initialData?.ip.split(':')[0] - const port = initialData?.ip.split(':')[1] + const [serverName, setServerName] = React.useState(initialData?.name ?? qsParamName ?? '') + const [serverIp, setServerIp] = React.useState(ipParts?.[0] ?? qsIpParts?.[0] ?? '') + const [serverPort, setServerPort] = React.useState(ipParts?.[1] ?? qsIpParts?.[1] ?? '') + const [versionOverride, setVersionOverride] = React.useState(initialData?.versionOverride ?? /* legacy */ initialData?.['version'] ?? qsParamVersion ?? '') + const [proxyOverride, setProxyOverride] = React.useState(initialData?.proxyOverride ?? qsParamProxy ?? '') + const [usernameOverride, setUsernameOverride] = React.useState(initialData?.usernameOverride ?? qsParamUsername ?? '') + const lockConnect = qsParamLockConnect === 'true' - const [serverIp, setServerIp] = React.useState(ipWithoutPort ?? qsParams?.get('ip') ?? '') - const [serverPort, setServerPort] = React.useState(port ?? '') - const [versionOverride, setVersionOverride] = React.useState(initialData?.versionOverride ?? /* legacy */ initialData?.['version'] ?? qsParams?.get('version') ?? '') - const [proxyOverride, setProxyOverride] = React.useState(initialData?.proxyOverride ?? qsParams?.get('proxy') ?? '') - const [usernameOverride, setUsernameOverride] = React.useState(initialData?.usernameOverride ?? qsParams?.get('username') ?? '') const smallWidth = useIsSmallWidth() - const lockConnect = qsParams?.get('lockConnect') === 'true' const initialAccount = initialData?.authenticatedAccountOverride const [accountIndex, setAccountIndex] = React.useState(initialAccount === true ? -2 : initialAccount ? (accounts?.includes(initialAccount) ? accounts.indexOf(initialAccount) : -2) : -1) @@ -61,7 +67,7 @@ export default ({ onBack, onConfirm, title = 'Add a Server', initialData, parseQ authenticatedAccountOverride, } - return + return
-
- setServerName(value)} placeholder='Defaults to IP' /> -
- setServerIp(value)} /> - setServerPort(value)} placeholder='25565' /> + {!lockConnect && <> +
+ setServerName(value)} placeholder='Defaults to IP' /> +
+ } + setServerIp(value)} /> + setServerPort(value)} placeholder='25565' />
Overrides:
- setVersionOverride(value)} placeholder='Optional, but recommended to specify' /> - setProxyOverride(value)} placeholder={defaults?.proxyOverride} /> - setUsernameOverride(value)} placeholder={defaults?.usernameOverride} disabled={!noAccountSelected} /> + setVersionOverride(value)} placeholder='Optional, but recommended to specify' /> + setProxyOverride(value)} placeholder={defaults?.proxyOverride} /> + setUsernameOverride(value)} placeholder={defaults?.usernameOverride} />
+
{code}
+
+ Waiting... {timeLeft} +
+
+ {warningText &&
+ Join only vanilla servers! This client is detectable and may result in a ban by anti-cheat plugins. +
} + {setSaveToken && } +