fix collect simple crops/weird blocks

This commit is contained in:
MaxRobinsonTheGreat 2025-03-15 16:56:36 -05:00
parent 4ccbbe0f6c
commit 40f294d174
3 changed files with 19 additions and 2 deletions

View file

@ -3,5 +3,5 @@
"model": "gemini-2.0-flash",
"cooldown": 10000
"cooldown": 5000
}

View file

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

View file

@ -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) {