Skip to content

Instantly share code, notes, and snippets.

@ArcticZeroo
Created April 10, 2019 19:02
Show Gist options
  • Save ArcticZeroo/94065b15240a9594245f59c01d7dbed9 to your computer and use it in GitHub Desktop.
Save ArcticZeroo/94065b15240a9594245f59c01d7dbed9 to your computer and use it in GitHub Desktop.
const bot = mineflayer.createBot({ /* ... */ });
// ... do some action that would get you within range of a piston ...
// This .findBlock method will find the nearest block to the point, which is the position of the bot's entity. The block it finds must match the piston block ID, and will be returned.
const piston = bot.findBlock({ point: bot.entity.position, matching: pistonBlockId });
if (piston == null) {
return;
}
// the null is required for some reason, but doesn't do anything
const sand = bot.inventory.findInventoryItem(sandBlockId, null);
if (sand == null) {
return;
}
const onSandPlace = (error) => // ...
const onSandEquip = (error) => {
if (error) {
return;
}
// this vec should probably be different based on the face you want to place it on
bot.placeBlock(piston, new Vec3(0, 1, 0), onSandPlace);
}
bot.equip(sand, 'hand', onSandEquip);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment