window.title type changed in 1.21.8
- [x] The FAQ doesn't contain a resolution to my issue
Versions
- mineflayer: 4.33.0
- server: vanilla/spigot/paper #.#.#
- node: v25.0.0
I open a chest GUI on a server (/afk menu on DonutSMP). When I have my bot version set to z1.20, the window.title is a string and I can check the name, call .includes on it, etc. Now when I change the bot version to 1.21.8, it's no longer a string but an object with a type and value:
const bot = mineflayer.createBot({
...
version: "1.20",
})
if (window.title.includes("ᴀꜰᴋ ᴀʀᴇᴀѕ")) {
console.log("Works!")
}
// Now
const bot = mineflayer.createBot({
...
version: "1.21.8",
})
console.log(JSON.stringify(window.title)) // {"type":"string","value":"ᴀꜰᴋ ᴀʀᴇᴀѕ"}
if (window.title.includes("ᴀꜰᴋ ᴀʀᴇᴀѕ")) {
// ERROR: window.title.includes is not a function
}
Seems like it should be a string?
I am willing to contribute a fix if someone can confirm that this is a bug and the type and behavior should remain consistent between these versions.
yes agreed it should be consistent
if you could add a test checking that and a fix it'd be great
Ok, I will look at it tomorrow. The fix should be in this repo right? Or could it be a problem with the prismarine window package?
Ok I thought it wouldn't take too long to try and fix this. I wanted to add a test for it and fix the issue but for me the useChests test does not pass currently on 1.21.8.
npm run mocha_test -- -g "1.21.8.*useChests"
0 passing (14s)
1 failing
1) mineflayer_external 1.21.8v
useChests:
Error: Event blockUpdate:(0, -60, 1) did not fire within timeout of 5000ms
at onceWithCleanup (lib/promise_utils.js:62:26)
at placeBlockWithOptions (lib/plugins/place_block.js:13:36)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async EventEmitter.placeBlock (lib/plugins/place_block.js:33:5)
at async test/externalTests/useChests.js:75:3
Though it seems by looking at the pipeline on the latest commit, the pipeline does pass for 1.21.8?
For some extra context to fix the original issue, in case someone else wants to pick this up. Doing this on 1.20 gives:
console.log(window.title, typeof window.title)
// {"text":"ᴀꜰᴋ ᴀʀᴇᴀѕ"} string
On 1.21.8 this gives:
console.log(window.title, typeof window.title)
// { type: 'string', value: 'ᴀꜰᴋ ᴀʀᴇᴀѕ' } object
As you can see on 1.20 it is giving you a stringified object wile on 1.21.8 it is an actual object. I don't know what is the behavior that the project would like to have.
Also, if you do this on 1.19.2 for a normal chest (for example during the useChests test) you will get:
console.log(window.title, typeof window.title)
// {"translate":"container.chestDouble"} string