Skip to content

Instantly share code, notes, and snippets.

@d-513
Last active March 26, 2021 17:07
Show Gist options
  • Save d-513/3d88f772be4224b40f9e5d1787bd63e9 to your computer and use it in GitHub Desktop.
Save d-513/3d88f772be4224b40f9e5d1787bd63e9 to your computer and use it in GitHub Desktop.
mineflayer - drop every item in bot's inventory
// 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)
@NoRegret-fake-malware
Copy link

how do i make this drop all of a specific item

@d-513
Copy link
Author

d-513 commented Mar 26, 2021

how do i make this drop all of a specific item

something along the lines of if(item.name !== "dirt") return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment