mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-09-01 11:53:03 +02:00
set interruptible
This commit is contained in:
parent
d5e118fa3a
commit
5a1e57bd42
1 changed files with 8 additions and 0 deletions
|
@ -301,10 +301,18 @@ export class ItemGoal {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait for the bot to be idle before attempting to execute the next goal
|
||||||
|
if (!this.agent.isIdle()) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let init_quantity = world.getInventoryCounts(this.agent.bot)[next.name] || 0;
|
let init_quantity = world.getInventoryCounts(this.agent.bot)[next.name] || 0;
|
||||||
|
this.agent.coder.interruptible = true;
|
||||||
await this.agent.coder.execute(async () => {
|
await this.agent.coder.execute(async () => {
|
||||||
await next.execute();
|
await next.execute();
|
||||||
}, this.timeout);
|
}, this.timeout);
|
||||||
|
this.agent.coder.interruptible = false;
|
||||||
let final_quantity = world.getInventoryCounts(this.agent.bot)[next.name] || 0;
|
let final_quantity = world.getInventoryCounts(this.agent.bot)[next.name] || 0;
|
||||||
|
|
||||||
if (final_quantity > init_quantity) {
|
if (final_quantity > init_quantity) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue