Skip to content

Commit

Permalink
fix internalTest and check
Browse files Browse the repository at this point in the history
  • Loading branch information
extremeheat committed Jan 7, 2025
1 parent 7763ccd commit be14be2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/plugins/creative.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ function inject (bot) {
return new Promise((resolve, reject) => {
function updateSlot (oldItem, newItem) {
console.log('[creative] Slot update', arguments)
if (newItem.itemId !== item.itemId) reject(Error('Server rejected'))
if (newItem.itemId !== item.itemId) {
creativeSlotsUpdates[slot] = false
reject(Error('Server rejected'))
}
}
bot.inventory.once(`updateSlot:${slot}`, updateSlot)
setTimeout(() => {
bot.inventory.off(`updateSlot:${slot}`, updateSlot)
console.log('[creative] setSlot OK')
creativeSlotsUpdates[slot] = false
resolve()
}, waitTimeout)
})
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,10 @@ function inject (bot) {
})

bot._client.on('player_info', (packet) => {
console.log('Player Info', packet)
console.dir(packet, { depth: null })
// player list item(s)

if (typeof packet.action === 'string') {
if (typeof packet.action !== 'number') {
// the features checks below this will be un-needed with https://github.com/PrismarineJS/minecraft-data/pull/948
for (const update of packet.data) {
let player = bot.uuidToUsername[update.uuid] ? bot.players[bot.uuidToUsername[update.uuid]] : null
Expand Down
13 changes: 12 additions & 1 deletion test/internalTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ for (const supportedVersion of mineflayer.testedVersions) {
const Chunk = require('prismarine-chunk')(supportedVersion)
const isNewPlayerInfoFormat = registry.version['>=']('1.21.3')
function wrapPlayerInfo (n) {
if (isNewPlayerInfoFormat) return { _value: n }
if (isNewPlayerInfoFormat) {
return {
_value: n,
add_player: (n & 1) !== 0,
initialize_chat: (n & 2) !== 0,
update_game_mode: (n & 4) !== 0,
update_listed: (n & 8) !== 0,
update_latency: (n & 16) !== 0,
update_display_name: (n & 32) !== 0,
update_priority: (n & 64) !== 0
}
}
return n
}

Expand Down

0 comments on commit be14be2

Please sign in to comment.