From b4a60cb11a83772eeaaffa54c8f913f24b3dfe03 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Tue, 14 May 2024 21:05:21 -0500 Subject: [PATCH] fix unloaded blocks crash --- src/agent/modes.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/agent/modes.js b/src/agent/modes.js index ba170fa..aed2fc4 100644 --- a/src/agent/modes.js +++ b/src/agent/modes.js @@ -26,13 +26,15 @@ const modes = [ const bot = agent.bot; const block = bot.blockAt(bot.entity.position); const blockAbove = bot.blockAt(bot.entity.position.offset(0, 1, 0)); - if (blockAbove && (blockAbove.name === 'water' || blockAbove.name === 'flowing_water')) { + if (!block) block = {name: 'air'}; // hacky fix when blocks are not loaded + if (!blockAbove) blockAbove = {name: 'air'}; + if (blockAbove.name === 'water' || blockAbove.name === 'flowing_water') { // does not call execute so does not interrupt other actions if (!bot.pathfinder.goal) { bot.setControlState('jump', true); } } - else if (blockAbove && this.fall_blocks.some(name => blockAbove.name.includes(name))) { + else if (this.fall_blocks.some(name => blockAbove.name.includes(name))) { execute(this, agent, async () => { await skills.moveAway(bot, 2); });