Skip to content

Instantly share code, notes, and snippets.

@rom1504
Last active March 13, 2021 02:42
Show Gist options
  • Save rom1504/b8530371c7407f790ca63717ee0f8932 to your computer and use it in GitHub Desktop.
Save rom1504/b8530371c7407f790ca63717ee0f8932 to your computer and use it in GitHub Desktop.
mineflayer helpers
chat = (o) => bot.chat(JSON.stringify(o))
craft = (name, count=1) => {
let crafting_table = bot.findBlock({matching:mcData.blocksByName.crafting_table.id, maxDistance:5})
console.log(crafting_table)
let item = mcData.itemsByName[name]
console.log(item)
let recipes = bot.recipesFor(item.id, item.metadata, count, crafting_table)
console.log(recipes)
bot.craft(recipes[0], count, crafting_table)
}
putInHotbar = async () => {
for (let i of bot.inventory.items()) {
if (i.slot < bot.inventory.hotbarStart) {
await bot.equip(i, 'hand')
}
}
}
bot.loadPlugin(pathfinder.pathfinder)
stop = () => {
bot.pathfinder.setGoal(null)
}
mineBlock = (name) => {
let block = bot.findBlock({matching:mcData.blocksByName[name].id, maxDistance:256})
let p = block.position
bot.pathfinder.goto(new pathfinder.goals.GoalBlock(p.x, p.y, p.z))
}
@Karang
Copy link

Karang commented Mar 13, 2021

invSee = () => {
  for (let i of bot.inventory.items()) {
    console.log(i.displayName, i.count)
  }
  bot.chat(bot.inventory.items().map(i => i.displayName+' '+i.count).join(", "))
}

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