fix unloaded blocks crash

This commit is contained in:
MaxRobinsonTheGreat 2024-05-14 21:05:21 -05:00
parent 5c6de46882
commit b4a60cb11a

View file

@ -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);
});