summaryrefslogtreecommitdiffstats
path: root/source/cSurvivalInventory.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-12 22:03:46 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-12 22:03:46 +0200
commit5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e (patch)
treedffb59765b1325e416cd79a7d20030b62178e4b7 /source/cSurvivalInventory.cpp
parentFixed an error (diff)
downloadcuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.gz
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.bz2
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.lz
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.xz
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.tar.zst
cuberite-5e6c7368592c0fbaa4d9d4320767d3cdcfd0261e.zip
Diffstat (limited to '')
-rw-r--r--source/cSurvivalInventory.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/source/cSurvivalInventory.cpp b/source/cSurvivalInventory.cpp
index a39cc6b59..cd7b96ad8 100644
--- a/source/cSurvivalInventory.cpp
+++ b/source/cSurvivalInventory.cpp
@@ -6,7 +6,6 @@
#include "cClientHandle.h"
#include "cWindow.h"
#include "cItem.h"
-#include "cRecipeChecker.h"
#include "CraftingRecipes.h"
#include "cRoot.h"
#include "packets/cPacket_WindowClick.h"
@@ -72,30 +71,24 @@ void cSurvivalInventory::Clicked( cPacket* a_ClickPacket )
if ((Packet->m_SlotNum >= (short)c_CraftOffset) && (Packet->m_SlotNum < (short)(c_CraftOffset + c_CraftSlots + 1)))
{
- cItem CookedItem;
+ cCraftingGrid Grid(m_Slots + c_CraftOffset + 1, 2, 2);
+ cCraftingRecipe Recipe(Grid);
+
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(Grid, Recipe);
+
if ((Packet->m_SlotNum == 0) && !bDontCook)
{
// Consume the items from the crafting grid:
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Craft(m_Slots + c_CraftOffset + 1, 2, 2);
- // Upgrade the crafting result from the new crafting grid contents:
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Offer(m_Slots + c_CraftOffset + 1, 2, 2);
- if (CookedItem.IsEmpty())
- {
- // Fallback to the old recipes:
- CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( m_Slots+c_CraftOffset+1, 2, 2, true );
- }
- }
- else
- {
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Offer(m_Slots + c_CraftOffset + 1, 2, 2);
- if (CookedItem.IsEmpty())
- {
- // Fallback to the old recipes:
- CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( m_Slots+c_CraftOffset+1, 2, 2 );
- }
+ Recipe.ConsumeIngredients(Grid);
+
+ // Propagate grid back to m_Slots:
+ Grid.CopyToItems(m_Slots + c_CraftOffset + 1);
+
+ // Get the recipe for the new grid contents:
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(Grid, Recipe);
}
- m_Slots[c_CraftOffset] = CookedItem;
- LOG("You cooked: %i x %i !!", m_Slots[c_CraftOffset].m_ItemID, m_Slots[c_CraftOffset].m_ItemCount );
+ m_Slots[c_CraftOffset] = Recipe.GetResult();
+ LOGD("You cooked: %i x %i !!", m_Slots[c_CraftOffset].m_ItemID, m_Slots[c_CraftOffset].m_ItemCount );
SendWholeInventory( m_Owner->GetClientHandle() );
}
SendSlot( 0 );