Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BehaviorFindBlock doesn't work for preventxray = true #127

Open
Epirito opened this issue Dec 29, 2021 · 0 comments
Open

BehaviorFindBlock doesn't work for preventxray = true #127

Epirito opened this issue Dec 29, 2021 · 0 comments

Comments

@Epirito
Copy link

Epirito commented Dec 29, 2021

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
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant