Skip to content

Commit 78bcc71

Browse files
authored
Release (#449)
2 parents 0a9b94b + 662b0ae commit 78bcc71

4 files changed

Lines changed: 60 additions & 26 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
"mc-assets": "^0.2.62",
158158
"minecraft-inventory-gui": "github:zardoy/minecraft-inventory-gui#next",
159159
"mineflayer": "github:zardoy/mineflayer#gen-the-master",
160-
"mineflayer-mouse": "^0.1.21",
160+
"mineflayer-mouse": "^0.1.23",
161161
"npm-run-all": "^4.1.5",
162162
"os-browserify": "^0.3.0",
163163
"path-browserify": "^1.0.1",

pnpm-lock.yaml

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/inventoryWindows.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,16 @@ const implementedContainersGuiMap = {
331331
'minecraft:generic_9x4': 'Generic95Win',
332332
'minecraft:generic_9x5': 'Generic95Win',
333333
// hopper
334+
'minecraft:hopper': 'HopperWin',
334335
'minecraft:generic_5x1': 'HopperWin',
335336
'minecraft:generic_9x6': 'LargeChestWin',
336337
'minecraft:generic_3x3': 'DropDispenseWin',
337338
'minecraft:furnace': 'FurnaceWin',
338339
'minecraft:smoker': 'FurnaceWin',
339-
'minecraft:shulker_box': 'ChestWin',
340340
'minecraft:blast_furnace': 'FurnaceWin',
341+
'minecraft:shulker_box': 'ChestWin',
341342
'minecraft:crafting': 'CraftingWin',
343+
'minecraft:smithing': 'will_be_patched_in_openWindow',
342344
'minecraft:crafting3x3': 'CraftingWin', // todo different result slot
343345
'minecraft:anvil': 'AnvilWin',
344346
// enchant
@@ -407,6 +409,9 @@ const upWindowItemsLocal = () => {
407409

408410
let skipClosePacketSending = false
409411
const openWindow = (type: string | undefined, title: string | any = undefined) => {
412+
// patch implementedContainersGuiMap
413+
implementedContainersGuiMap['minecraft:smithing'] = versionToNumber(bot.version) < versionToNumber('1.20') ? 'SmithingTableLegacyWin' : 'SmithingTableWin'
414+
410415
// if (activeModalStack.some(x => x.reactType?.includes?.('player_win:'))) {
411416
if (activeModalStack.length && !miscUiState.disconnectedCleanup) { // game is not in foreground, don't close current modal
412417
if (type) {
@@ -421,19 +426,6 @@ const openWindow = (type: string | undefined, title: string | any = undefined) =
421426
showModal({
422427
reactType: `player_win:${type}`,
423428
})
424-
onModalClose(() => {
425-
// might be already closed (event fired)
426-
if (type !== undefined && bot.currentWindow && !skipClosePacketSending) bot.currentWindow['close']()
427-
lastWindow.destroy()
428-
lastWindow = null as any
429-
lastWindowType = undefined
430-
window.inventory = null
431-
miscUiState.displaySearchInput = false
432-
destroyFn()
433-
skipClosePacketSending = false
434-
435-
modelViewerState.model = undefined
436-
})
437429
if (type === undefined) {
438430
showInventoryPlayer()
439431
}
@@ -470,6 +462,20 @@ const openWindow = (type: string | undefined, title: string | any = undefined) =
470462

471463
lastWindow = inv
472464

465+
onModalClose(() => {
466+
// might be already closed (event fired)
467+
if (type !== undefined && bot.currentWindow && !skipClosePacketSending) bot.currentWindow['close']()
468+
lastWindow.destroy()
469+
lastWindow = null as any
470+
lastWindowType = undefined
471+
window.inventory = null
472+
miscUiState.displaySearchInput = false
473+
destroyFn()
474+
skipClosePacketSending = false
475+
476+
modelViewerState.model = undefined
477+
})
478+
473479
upWindowItemsLocal()
474480

475481
lastWindow.pwindow.touch = miscUiState.currentTouch ?? false

src/react/DebugOverlay.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEffect, useRef, useState } from 'react'
2+
import type { Entity } from 'prismarine-entity'
23
import { useSnapshot } from 'valtio'
34
import type { Block } from 'prismarine-block'
45
import { getThreeJsRendererMethods } from 'renderer/viewer/three/threeJsMethods'
@@ -39,6 +40,7 @@ export default () => {
3940
const [timeOfDay, setTimeOfDay] = useState(0)
4041
const [dimension, setDimension] = useState('')
4142
const [cursorBlock, setCursorBlock] = useState<Block | null>(null)
43+
const [cursorEntity, setCursorEntity] = useState<Entity | null>(null)
4244
const [blockInfo, setBlockInfo] = useState<{ customBlockName?: string, modelInfo?: BlockStateModelInfo } | null>(null)
4345
const [clientTps, setClientTps] = useState(0)
4446
const [serverTps, setServerTps] = useState(null as null | { value: number, frozen: boolean })
@@ -55,6 +57,14 @@ export default () => {
5557

5658
const viewDegToMinecraft = (yaw) => yaw % 360 - 180 * (yaw < 0 ? -1 : 1)
5759

60+
const shortenUuid = (uuid: string | undefined): string | undefined => {
61+
if (!uuid) return undefined
62+
// Format: 2383-*-3243 (first 4 chars, *, last 4 chars)
63+
const cleaned = uuid.replaceAll('-', '')
64+
if (cleaned.length < 8) return uuid
65+
return `${cleaned.slice(0, 4)}-*-${cleaned.slice(-4)}`
66+
}
67+
5868
const readPacket = (data, { name }, _buf, fullBuffer) => {
5969
if (fullBuffer) {
6070
const size = fullBuffer.byteLength
@@ -129,7 +139,9 @@ export default () => {
129139
setDimension(bot.game.dimension)
130140
setDay(bot.time.day)
131141
setTimeOfDay(bot.time.timeOfDay)
132-
setCursorBlock(bot.mouse.getCursorState().cursorBlock)
142+
const cursorState = bot.mouse.getCursorState()
143+
setCursorBlock(cursorState.cursorBlock)
144+
setCursorEntity(cursorState.entity)
133145
}, 100)
134146

135147
const notFrequentUpdateInterval = setInterval(async () => {
@@ -212,6 +224,22 @@ export default () => {
212224
{cursorBlock ? (
213225
<p>Looking at: {cursorBlock.position.x} {cursorBlock.position.y} {cursorBlock.position.z}</p>
214226
) : ''}
227+
{cursorEntity ? (<>
228+
<div className={styles.empty} />
229+
<p>E: {cursorEntity.name}</p>
230+
{cursorEntity.displayName && <p>{cursorEntity.displayName}</p>}
231+
{cursorEntity.id !== undefined && <p>ID: {cursorEntity.id}</p>}
232+
{shortenUuid(cursorEntity.uuid) && <p>UUID: {shortenUuid(cursorEntity.uuid)}</p>}
233+
{cursorEntity.username && <p>Username: {cursorEntity.username}</p>}
234+
{cursorEntity.position && (
235+
<p>{cursorEntity.position.x.toFixed(2)} {cursorEntity.position.y.toFixed(2)} {cursorEntity.position.z.toFixed(2)}</p>
236+
)}
237+
{cursorEntity.yaw !== undefined && <p>Yaw: {cursorEntity.yaw.toFixed(1)}</p>}
238+
{cursorEntity.pitch !== undefined && <p>Pitch: {cursorEntity.pitch.toFixed(1)}</p>}
239+
{cursorEntity.type && <p>Type: {cursorEntity.type}</p>}
240+
{cursorEntity.health !== undefined && <p>Health: {cursorEntity.health.toFixed(1)}</p>}
241+
</>)
242+
: ''}
215243
<div className={styles.empty} />
216244
{blockInfo && (() => {
217245
const { customBlockName, modelInfo } = blockInfo

0 commit comments

Comments
 (0)