Skip to content

Commit

Permalink
fix bot.entity.equipment
Browse files Browse the repository at this point in the history
  • Loading branch information
szdytom committed Nov 2, 2023
1 parent 0594bce commit c6830b7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/plugins/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,24 @@ function inject (bot, { hideErrors }) {
bot.inventory = windows.createWindow(0, 'minecraft:inventory', 'Inventory')
bot.currentWindow = null
bot.usingHeldItem = false
Object.defineProperty(o, 'heldItem', {
Object.defineProperty(bot, 'heldItem', {
get: function () {
return bot.inventory.slots[bot.QUICK_BAR_START + bot.quickBarSlot]
},
}
})

bot.on('spawn', () => {
Object.defineProperty(bot.entity, 'equipment', {
get: bot.supportFeature('doesntHaveOffHandSlot')
? function () {
return [bot.heldItem, bot.inventory.slots[8], bot.inventory.slots[7],
bot.inventory.slots[6], bot.inventory.slots[5]]
}
: function () {
return [bot.heldItem, bot.inventory.slots[45], bot.inventory.slots[8],
bot.inventory.slots[7], bot.inventory.slots[6], bot.inventory.slots[5]]
}
})
})

bot._client.on('entity_status', (packet) => {
Expand Down

0 comments on commit c6830b7

Please sign in to comment.