X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finventorymanager.cpp;h=1c511e9cbe69f7659e70e8a7a1d5e172285af73b;hb=58e6d25e033c76dc91aaac18fdeda92ac23fe0e1;hp=6187675d47e2c22002acfb3f2e8bc6166e23c1fc;hpb=ab433775777c4f5055bcf4d2a1cffc506c4f9961;p=oweals%2Fminetest.git diff --git a/src/inventorymanager.cpp b/src/inventorymanager.cpp index 6187675d4..1c511e9cb 100644 --- a/src/inventorymanager.cpp +++ b/src/inventorymanager.cpp @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "inventorymanager.h" #include "log.h" #include "environment.h" -#include "cpp_api/scriptapi.h" +#include "scripting_game.h" #include "serverobject.h" #include "main.h" // for g_settings #include "settings.h" @@ -29,6 +29,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" +#define PLAYER_TO_SA(p) p->getEnv()->getScriptIface() + /* InventoryLocation */ @@ -722,13 +724,19 @@ void ICraftAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGam } ItemStack crafted; + ItemStack craftresultitem; int count_remaining = count; bool found = getCraftingResult(inv_craft, crafted, false, gamedef); + PLAYER_TO_SA(player)->item_CraftPredict(crafted, player, list_craft, craft_inv); + found = !crafted.empty(); while(found && list_craftresult->itemFits(0, crafted)) { + InventoryList saved_craft_list = *list_craft; + // Decrement input and add crafting output getCraftingResult(inv_craft, crafted, true, gamedef); + PLAYER_TO_SA(player)->item_OnCraft(crafted, player, &saved_craft_list, craft_inv); list_craftresult->addItem(0, crafted); mgr->setInventoryModified(craft_inv); @@ -745,6 +753,8 @@ void ICraftAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGam // Get next crafting result found = getCraftingResult(inv_craft, crafted, false, gamedef); + PLAYER_TO_SA(player)->item_CraftPredict(crafted, player, list_craft, craft_inv); + found = !crafted.empty(); } infostream<<"ICraftAction::apply(): crafted "