From 40f294d1742b871d6ecc1cbdb6b6999014bd314b Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sat, 15 Mar 2025 16:56:36 -0500 Subject: [PATCH] fix collect simple crops/weird blocks --- profiles/gemini.json | 2 +- src/agent/library/skills.js | 9 ++++++++- src/utils/mcdata.js | 10 ++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/profiles/gemini.json b/profiles/gemini.json index db7243e..8a91387 100644 --- a/profiles/gemini.json +++ b/profiles/gemini.json @@ -3,5 +3,5 @@ "model": "gemini-2.0-flash", - "cooldown": 10000 + "cooldown": 5000 } diff --git a/src/agent/library/skills.js b/src/agent/library/skills.js index 36355e2..ca3718d 100644 --- a/src/agent/library/skills.js +++ b/src/agent/library/skills.js @@ -460,7 +460,14 @@ export async function collectBlock(bot, blockType, num=1, exclude=null) { return false; } try { - await bot.collectBlock.collect(block); + if (mc.mustCollectManually(blockType)) { + await goToPosition(bot, block.position.x, block.position.y, block.position.z, 2); + await bot.dig(block); + await pickupNearbyItems(bot); + } + else { + await bot.collectBlock.collect(block); + } collected++; await autoLight(bot); } diff --git a/src/utils/mcdata.js b/src/utils/mcdata.js index 2a3a27c..33b0142 100644 --- a/src/utils/mcdata.js +++ b/src/utils/mcdata.js @@ -86,6 +86,16 @@ export function isHostile(mob) { return (mob.type === 'mob' || mob.type === 'hostile') && mob.name !== 'iron_golem' && mob.name !== 'snow_golem'; } +// blocks that don't work with collectBlock, need to be manually collected +export function mustCollectManually(blockName) { + // all crops (that aren't normal blocks), torches, buttons, levers, redstone, + const full_names = ['wheat', 'carrots', 'potatoes', 'beetroots', 'nether_wart', 'cocoa', 'sugar_cane', 'kelp', 'short_grass', 'fern', 'tall_grass', 'bamboo', + 'poppy', 'dandelion', 'blue_orchid', 'allium', 'azure_bluet', 'oxeye_daisy', 'cornflower', 'lilac', 'wither_rose', 'lily_of_the_valley', 'wither_rose', + 'lever', 'redstone_wire', 'lantern'] + const partial_names = ['sapling', 'torch', 'button', 'carpet', 'pressure_plate', 'mushroom', 'tulip', 'bush', 'vines', 'fern'] + return full_names.includes(blockName.toLowerCase()) || partial_names.some(partial => blockName.toLowerCase().includes(partial)); +} + export function getItemId(itemName) { let item = mcdata.itemsByName[itemName]; if (item) {