fixed issue with door opening interval

This commit is contained in:
MaxRobinsonTheGreat 2025-08-15 11:21:11 -05:00
parent 4eb98b467f
commit ccbaca6ecb

View file

@ -1071,16 +1071,6 @@ 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();
@ -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);