summaryrefslogtreecommitdiffstats
path: root/source/cCraftingWindow.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/cCraftingWindow.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 'source/cCraftingWindow.cpp')
-rw-r--r--source/cCraftingWindow.cpp41
1 files changed, 15 insertions, 26 deletions
diff --git a/source/cCraftingWindow.cpp b/source/cCraftingWindow.cpp
index 8d499c514..c84121a06 100644
--- a/source/cCraftingWindow.cpp
+++ b/source/cCraftingWindow.cpp
@@ -3,7 +3,6 @@
#include "cCraftingWindow.h"
#include "cItem.h"
-#include "cRecipeChecker.h"
#include "CraftingRecipes.h"
#include "cPlayer.h"
#include "cClientHandle.h"
@@ -71,34 +70,24 @@ void cCraftingWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_P
if ((a_ClickPacket->m_SlotNum >= 0) && (a_ClickPacket->m_SlotNum < 10))
{
- cItem CookedItem;
+ cCraftingGrid Grid(GetSlots() + 1, 3, 3);
+ cCraftingRecipe Recipe(Grid);
+
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(Grid, Recipe);
+
if ((a_ClickPacket->m_SlotNum == 0) && !bDontCook)
{
- // Consume the ingredients from the crafting grid:
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Craft(GetSlots() + 1, 3, 3);
- LOGD("New recipes crafted: %i x %i", CookedItem.m_ItemID, CookedItem.m_ItemCount);
- // Upgrade the crafting result from the new crafting grid contents:
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Offer(GetSlots() + 1, 3, 3);
- if (CookedItem.IsEmpty())
- {
- // Fallback to the old recipes:
- CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( GetSlots()+1, 3, 3, true );
- LOGD("Old recipes crafted: %i x %i", CookedItem.m_ItemID, CookedItem.m_ItemCount );
- }
- }
- else
- {
- CookedItem = cRoot::Get()->GetCraftingRecipes()->Offer(GetSlots() + 1, 3, 3);
- LOGD("New recipes offer: %i x %i", CookedItem.m_ItemID, CookedItem.m_ItemCount );
- if (CookedItem.IsEmpty())
- {
- // Fallback to the old recipes
- CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( GetSlots()+1, 3, 3 );
- LOGD("Old recipes offer: %i x %i", CookedItem.m_ItemID, CookedItem.m_ItemCount );
- }
+ // Consume the items from the crafting grid:
+ Recipe.ConsumeIngredients(Grid);
+
+ // Propagate grid back to m_Slots:
+ Grid.CopyToItems(GetSlots() + 1);
+
+ // Get the recipe for the new grid contents:
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(Grid, Recipe);
}
- *GetSlot(0) = CookedItem;
- LOG("You cooked: %i x %i !!", GetSlot(0)->m_ItemID, GetSlot(0)->m_ItemCount );
+ *GetSlot(0) = Recipe.GetResult();
+ LOGD("You cooked: %i x %i !!", GetSlot(0)->m_ItemID, GetSlot(0)->m_ItemCount );
}
SendWholeWindow( a_Player.GetClientHandle() );
a_Player.GetInventory().SendWholeInventory( a_Player.GetClientHandle() );