[CraftingRecipe] Small fix for shapeless recipes.

This commit is contained in:
Quentin Bazin 2018-06-25 18:27:27 +02:00
parent b18333d43c
commit 6fdf1fc81d
2 changed files with 7 additions and 9 deletions

View File

@ -58,14 +58,14 @@ void Registry::registerItems() {
}
void Registry::registerRecipes() {
m_recipes.emplace_back(std::array<u32, 9>{6, 6, 0, 6, 12, 0, 0, 12, 0}, ItemStack{13});
m_recipes.emplace_back(std::array<u32, 9>{6, 6, 0, 0, 12, 0, 0, 12, 0}, ItemStack{14});
m_recipes.emplace_back(std::array<u32, 9>{6, 6, 6, 0, 12, 0, 0, 12, 0}, ItemStack{15});
m_recipes.emplace_back(std::array<u32, 9>{0, 6, 0, 0, 12, 0, 0, 12, 0}, ItemStack{16});
m_recipes.emplace_back(std::array<u32, 9>{0, 6, 0, 0, 6, 0, 0, 12, 0}, ItemStack{17});
m_recipes.emplace_back(std::array<u32, 9>{6, 6, 0, 6, 12, 0, 0, 12, 0}, ItemStack{ItemType::StoneAxe});
m_recipes.emplace_back(std::array<u32, 9>{6, 6, 0, 0, 12, 0, 0, 12, 0}, ItemStack{ItemType::StoneHoe});
m_recipes.emplace_back(std::array<u32, 9>{6, 6, 6, 0, 12, 0, 0, 12, 0}, ItemStack{ItemType::StonePickaxe});
m_recipes.emplace_back(std::array<u32, 9>{0, 6, 0, 0, 12, 0, 0, 12, 0}, ItemStack{ItemType::StoneShovel});
m_recipes.emplace_back(std::array<u32, 9>{0, 6, 0, 0, 6, 0, 0, 12, 0}, ItemStack{ItemType::StoneSword});
m_recipes.emplace_back(std::array<u32, 9>{11, 11, 0, 0, 0, 0, 0, 0, 0}, ItemStack{12, 4}, true);
m_recipes.emplace_back(std::array<u32, 9>{5, 0, 0, 0, 0, 0, 0, 0, 0}, ItemStack{11, 4}, true);
m_recipes.emplace_back(std::array<u32, 9>{5, 0, 0, 0, 0, 0, 0, 0, 0}, ItemStack{ItemType::Wood, 4}, true);
m_recipes.emplace_back(std::array<u32, 9>{11, 11, 0, 0, 0, 0, 0, 0, 0}, ItemStack{ItemType::Stick, 4}, true);
}
const CraftingRecipe *Registry::getRecipe(const Inventory &inventory) const {

View File

@ -33,8 +33,6 @@ bool CraftingRecipe::isMatching(const Inventory &inventory) const {
else {
std::array<bool, 9> match{false, false, false, false, false, false, false, false, false};
for (u32 id : m_recipe) {
if (!id) continue;
bool matched = false;
for (u16 i = 0 ; i < 9 ; ++i) {
if (inventory.getStack(i % 3, i / 3).item().id() == id && !match[i]) {