mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-06 23:35:39 +02:00
add manual collection for crops/other weird blocks
This commit is contained in:
parent
c5b834597a
commit
4b1e02fc95
2 changed files with 18 additions and 1 deletions
|
@ -460,7 +460,14 @@ export async function collectBlock(bot, blockType, num=1, exclude=null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
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++;
|
collected++;
|
||||||
await autoLight(bot);
|
await autoLight(bot);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,16 @@ export function isHostile(mob) {
|
||||||
return (mob.type === 'mob' || mob.type === 'hostile') && mob.name !== 'iron_golem' && mob.name !== 'snow_golem';
|
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) {
|
export function getItemId(itemName) {
|
||||||
let item = mcdata.itemsByName[itemName];
|
let item = mcdata.itemsByName[itemName];
|
||||||
if (item) {
|
if (item) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue