Last active
March 26, 2021 17:07
-
-
Save d-513/3d88f772be4224b40f9e5d1787bd63e9 to your computer and use it in GitHub Desktop.
mineflayer - drop every item in bot's inventory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JS Standard Code Style | |
/* | |
Simple | |
*/ | |
const items = bot.inventory.items() // get the items | |
// dropper is a recursive function | |
const dropper = (i) => { | |
if (!items[i]) return // if we dropped all items, stop. | |
bot.tossStack(items[i], () => dropper(i + 1)) // drop the item, then wait for a response from the server and drop another one. | |
} | |
dropper(0) | |
/* | |
With a delay between each drop | |
*/ | |
const items = bot.inventory.items() // get the items | |
const timeout = 1000 // timeout in milliseconds before dropping another item. 1 second = 1000ms | |
// dropper is a recursive function | |
const dropper = (i) => { | |
if (!items[i]) return // if we dropped all items, stop. | |
bot.tossStack(items[i], () => { | |
setTimeout(() => dropper(i + 1), timeout) // wait for `timeout` ms, then drop another item | |
}) | |
} | |
dropper(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
something along the lines of if(item.name !== "dirt") return