From ccbaca6ecb6d73b2960ce76e98e366b1aae25728 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Fri, 15 Aug 2025 11:21:11 -0500 Subject: [PATCH] fixed issue with door opening interval --- src/agent/library/skills.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/agent/library/skills.js b/src/agent/library/skills.js index 9d62ef1..8fd5086 100644 --- a/src/agent/library/skills.js +++ b/src/agent/library/skills.js @@ -1071,17 +1071,7 @@ function startDoorInterval(bot) { let prev_check = Date.now(); let stuck_time = 0; - // adjacent positions to check for doors - const positions = [ - bot.entity.position.clone(), - bot.entity.position.offset(0, 0, 1), - bot.entity.position.offset(0, 0, -1), - bot.entity.position.offset(1, 0, 0), - bot.entity.position.offset(-1, 0, 0), - ] - let elevated_positions = positions.map(position => position.offset(0, 1, 0)); - positions.push(...elevated_positions); - + const doorCheckInterval = setInterval(() => { const now = Date.now(); if (bot.entity.position.distanceTo(prev_pos) >= 0.1) { @@ -1092,6 +1082,16 @@ function startDoorInterval(bot) { if (stuck_time > 1200) { // shuffle positions so we're not always opening the same door + const positions = [ + bot.entity.position.clone(), + bot.entity.position.offset(0, 0, 1), // north + bot.entity.position.offset(0, 0, -1), + bot.entity.position.offset(1, 0, 0), + bot.entity.position.offset(-1, 0, 0), + ] + let elevated_positions = positions.map(position => position.offset(0, 1, 0)); + positions.push(...elevated_positions); + let currentIndex = positions.length; while (currentIndex != 0) { let randomIndex = Math.floor(Math.random() * currentIndex); @@ -1099,7 +1099,7 @@ function startDoorInterval(bot) { [positions[currentIndex], positions[randomIndex]] = [ positions[randomIndex], positions[currentIndex]]; } - + for (let position of positions) { let block = bot.blockAt(position); if (block && block.name &&