Skip to content

Commit

Permalink
Update digging.js
Browse files Browse the repository at this point in the history
fixed lint
  • Loading branch information
Vakore committed Aug 5, 2023
1 parent f5da310 commit 4471376
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions lib/plugins/digging.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ function inject (bot) {
bot.lastHeldItemName = ''
if (bot.heldItem) { bot.lastHeldItemName = bot.heldItem.name }
bot.on('heldItemChanged', () => {
// if (bot.heldItem) {console.log("this why " + bot.heldItem.name);}
// if (!bot.heldItem) {console.log("this why " + bot.heldItem);}
let nameToCompare = ''
if (bot.heldItem) { nameToCompare = bot.heldItem.name }
if (bot.lastHeldItemName != nameToCompare) {
if (bot.lastHeldItemName !== nameToCompare) {
bot.lastHeldItemName = nameToCompare
bot.digPercentage = 0
}
Expand Down Expand Up @@ -111,18 +109,10 @@ function inject (bot) {
location: block.position,
face: diggingFace // default face is 1 (top)
})
const waitTime = bot.digTime(block)
// waitInterval = setTimeout(finishDigging, waitTime)
if (waitInterval) { clearInterval(waitInterval) }
// bot.digPercentage = (50 / bot.digTime(block));
// bot.referenceTime = window.performance.now();
waitInterval = setInterval(() => { //! !!!
waitInterval = setInterval(() => {
bot.digPercentage += (50 / bot.digTime(block))
// bot.digPercentage += (Math.abs(bot.referenceTime - window.performance.now()) / bot.digTime(block));
// console.log(Math.abs(bot.referenceTime - window.performance.now()) + ", " + bot.digPercentage);
// bot.referenceTime = window.performance.now();
if (bot.digPercentage >= 1.0) {
// console.log("broke it");
finishDigging()
}
}, 50)
Expand Down Expand Up @@ -156,7 +146,6 @@ function inject (bot) {
}

const eventName = `blockUpdate:${block.position}`
// console.log(bot.digPercentage + "% " + eventName);
bot.on(eventName, onBlockUpdate)

bot.stopDigging = () => {
Expand Down

0 comments on commit 4471376

Please sign in to comment.