Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/plugins/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,16 @@ function inject (bot, { hideErrors }) {
await withTimeout(eatingTask.promise, CONSUME_TIMEOUT)
}

function activateItem (offHand = false) {
function activateItem (offHand = false, directionVec = new Vec3(0, 0, 0)) {
bot.usingHeldItem = true
sequence++
const dir = directionVec.normalize()
const yaw = Math.atan2(-dir.x, -dir.z) * (180 / Math.PI)
const pitch = -Math.asin(dir.y) * (180 / Math.PI)
const rotation = {
x: yaw,
y: pitch
}

if (bot.supportFeature('useItemWithBlockPlace')) {
bot._client.write('block_place', {
Expand All @@ -128,7 +135,7 @@ function inject (bot, { hideErrors }) {
bot._client.write('use_item', {
hand: offHand ? 1 : 0,
sequence,
rotation: { x: 0, y: 0 }
rotation
})
}
}
Expand Down
Loading