From 9749c3aac9dbfbc46a919193c97bb9c9e5339e03 Mon Sep 17 00:00:00 2001 From: Lukas Pioch Date: Thu, 24 Sep 2015 10:48:33 +0200 Subject: Implemented brewing --- src/Bindings/ManualBindings.cpp | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/Bindings/ManualBindings.cpp') diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 7e6839fdf..3a595c1d2 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -20,6 +20,7 @@ #include "../ClientHandle.h" #include "../BlockArea.h" #include "../BlockEntities/BeaconEntity.h" +#include "../BlockEntities/BrewingstandEntity.h" #include "../BlockEntities/ChestEntity.h" #include "../BlockEntities/CommandBlockEntity.h" #include "../BlockEntities/DispenserEntity.h" @@ -2516,6 +2517,54 @@ static int tolua_cRoot_GetBuildSeriesName(lua_State * tolua_S) +static int tolua_cRoot_GetBrewingRecipe(lua_State * tolua_S) +{ + cLuaState L(tolua_S); + if ( + !L.CheckParamUserTable(1, "cRoot") || + !L.CheckParamUserType (2, "const cItem") || + !L.CheckParamUserType (3, "const cItem") || + !L.CheckParamEnd (4) + ) + { + return 0; + } + + // Check the bottle param: + cItem * Bottle = nullptr; + L.GetStackValue(2, Bottle); + if (Bottle == nullptr) + { + LOGWARNING("cRoot:GetBrewingRecipe: the Bottle parameter is nil or missing."); + return 0; + } + + cItem * Ingredient = nullptr; + L.GetStackValue(3, Ingredient); + if (Ingredient == nullptr) + { + LOGWARNING("cRoot:GetBrewingRecipe: the Ingredient parameter is nil or missing."); + return 0; + } + + // Get the recipe for the input + cBrewingRecipes * BR = cRoot::Get()->GetBrewingRecipes(); + const cBrewingRecipes::cRecipe * Recipe = BR->GetRecipeFrom(*Bottle, *Ingredient); + if (Recipe == nullptr) + { + // There is no such brewing recipe for this bottle and ingredient, return no value + return 0; + } + + // Push the output item + L.Push(Recipe->Output.get()); + return 1; +} + + + + + static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S) { cLuaState L(tolua_S); @@ -3320,6 +3369,7 @@ void cManualBindings::Bind(lua_State * tolua_S) tolua_function(tolua_S, "DoWithPlayerByUUID", DoWith ); tolua_function(tolua_S, "ForEachPlayer", ForEach); tolua_function(tolua_S, "ForEachWorld", ForEach); + tolua_function(tolua_S, "GetBrewingRecipe", tolua_cRoot_GetBrewingRecipe); tolua_function(tolua_S, "GetBuildCommitID", tolua_cRoot_GetBuildCommitID); tolua_function(tolua_S, "GetBuildDateTime", tolua_cRoot_GetBuildDateTime); tolua_function(tolua_S, "GetBuildID", tolua_cRoot_GetBuildID); -- cgit v1.2.3