Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- breakBlock = (block) => {
- return new Promise((resolve, reject) => {
- // @TODO: Equip the right tool
- this.bot.dig(block, (err) => {
- if (err) {
- return reject(err);
- }
- return resolve();
- });
- });
- };
- mine = (position, direction) => {
- const target = position.floor().plus(direction);
- const lower = this.bot.blockAt(target);
- const upper = this.bot.blockAt(target.offset(0, 1, 0));
- if (lower && lower.boundingBox !== 'empty') {
- this.breakBlock(lower).then(() => {
- setTimeout(() => this.mine(position, direction), 500);
- });
- return;
- }
- if (upper && upper.boundingBox !== 'empty') {
- this.breakBlock(upper).then(() => {
- setTimeout(() => this.mine(position, direction), 500);
- });
- return;
- }
- this.bot.navigate.walk([target.offset(0.5, 0, 0.5)], (err) => {
- if (err) {
- console.error('err>', err);
- // return;
- }
- setTimeout(() => {
- this.mine(this.bot.entity.position, vec3(0, 0, 1));
- }, 250);
- });
- };
Add Comment
Please, Sign In to add comment