build bed

This commit is contained in:
Kolby Nottingham 2024-03-06 15:53:22 -08:00
parent 4eda43b6cb
commit cc48a38ade
4 changed files with 66 additions and 5 deletions

View file

@ -20,8 +20,8 @@
],
[
["dirt", "dirt", "dirt", "dirt", "dirt"],
["dirt", "chest", "air", "air", "dirt"],
["dirt", "air", "air", "air", "dirt"],
["dirt", "chest", "air", "bed", "dirt"],
["dirt", "air", "air", "bed", "dirt"],
["dirt", "air", "air", "air", "dirt"],
["dirt", "dirt", "door", "dirt", "dirt"]
],
@ -30,7 +30,7 @@
["dirt", "air", "air", "air", "dirt"],
["dirt", "air", "air", "air", "dirt"],
["dirt", "air", "air", "air", "dirt"],
["dirt", "dirt", "", "dirt", "dirt"]
["dirt", "dirt", "door", "dirt", "dirt"]
],
[
["air", "air", "air", "air", "air"],

View file

@ -15,7 +15,8 @@ const blacklist = [
'_wood',
'stripped_',
'crimson',
'warped'
'warped',
'dye'
]
@ -206,12 +207,23 @@ class ItemWrapper {
let recipes = mc.getItemCraftingRecipes(this.name);
if (recipes) {
for (let recipe of recipes) {
let includes_blacklisted = false;
for (let ingredient in recipe) {
for (let match of blacklist) {
if (ingredient.includes(match)) {
includes_blacklisted = true;
break;
}
}
if (includes_blacklisted) break;
}
if (includes_blacklisted) continue;
this.add_method(new ItemNode(this.manager, this, this.name).setRecipe(recipe))
}
}
let block_sources = mc.getItemBlockSources(this.name);
if (block_sources.length > 0 && this.name !== 'torch') { // Do not collect placed torches
if (block_sources.length > 0 && this.name !== 'torch' && !this.name.includes('bed')) { // Do not collect placed torches or beds
for (let block_source of block_sources) {
if (block_source === 'grass_block') continue; // Dirt nodes will collect grass blocks
let tool = mc.getBlockTool(block_source);

View file

@ -3,6 +3,7 @@ import * as mc from '../../utils/mcdata.js';
export function getTypeOfGeneric(bot, block_name) {
// Get type of wooden block
if (mc.MATCHING_WOOD_BLOCKS.includes(block_name)) {
// Return most common wood type in inventory
@ -37,6 +38,34 @@ export function getTypeOfGeneric(bot, block_name) {
// Return oak
return 'oak_' + block_name;
}
// Get type of bed
if (block_name === 'bed') {
// Return most common wool type in inventory
let type_count = {};
let max_count = 0;
let max_type = null;
let inventory = world.getInventoryCounts(bot);
for (const item in inventory) {
for (const color of mc.WOOL_COLORS) {
if (item === color + '_wool') {
if (type_count[color] === undefined)
type_count[color] = 0;
type_count[color] += inventory[item];
if (type_count[color] > max_count) {
max_count = type_count[color];
max_type = color;
}
}
}
}
if (max_type !== null)
return max_type + '_' + block_name;
// Return white
return 'white_' + block_name;
}
return block_name;
}
@ -46,6 +75,8 @@ export function blockSatisfied(target_name, block) {
return block.name == 'dirt' || block.name == 'grass_block';
} else if (mc.MATCHING_WOOD_BLOCKS.includes(target_name)) {
return block.name.endsWith(target_name);
} else if (target_name == 'bed') {
return block.name.endsWith('bed');
}
return block.name == target_name;
}

View file

@ -27,6 +27,24 @@ export const MATCHING_WOOD_BLOCKS = [
'pressure_plate',
'trapdoor'
]
export const WOOL_COLORS = [
'white',
'orange',
'magenta',
'light_blue',
'yellow',
'lime',
'pink',
'gray',
'light_gray',
'cyan',
'purple',
'blue',
'brown',
'green',
'red',
'black'
]
export function initBot(username) {