mineflayer-statemachine icon indicating copy to clipboard operation
mineflayer-statemachine copied to clipboard

BehaviorFindBlock doesn't work for preventxray = true

Open Epirito opened this issue 2 years ago • 0 comments

In order to check line of sight to a block with mineflayer's bot.findBlock, you have to set checkExtraInfo in the matching options to true, but BehaviorFindBlock doesn't do that and thus it doesn't work. Here is a proof of concept fix: class BehaviorCustomFindBlock implements sm.StateBehavior { active = false; stateName = 'customFindBlock'; blocks:any[] bot:mf.Bot; isFinished = false targets:any = {} constructor(bot:mf.Bot,targets) { this.bot = bot this.targets = targets } onStateEntered(): void { this.targets.position = this.targets.position = this.bot.findBlock({ matching:(block)=>this.blocks.indexOf(block.stateId)!==-1 && bot.canSeeBlock(block), useExtraInfo:true, maxDistance:32, }).position } }

Epirito avatar Dec 29 '21 13:12 Epirito