From b5b00209976e34bedf47213a63aa6472bf4e153c Mon Sep 17 00:00:00 2001 From: bzoss Date: Mon, 25 May 2020 15:31:35 -0400 Subject: [PATCH] Laid the framework to brew potions...TODO make it actually swap for the potion. --- mods/ITEMS/mcl_brewing/init.lua | 46 +++++++++++++++--- mods/ITEMS/mcl_potions/init.lua | 16 +++--- .../textures/mcl_potions_healing.png | Bin 0 -> 1261 bytes 3 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 mods/ITEMS/mcl_potions/textures/mcl_potions_healing.png diff --git a/mods/ITEMS/mcl_brewing/init.lua b/mods/ITEMS/mcl_brewing/init.lua index c535831f9..3657b10b5 100755 --- a/mods/ITEMS/mcl_brewing/init.lua +++ b/mods/ITEMS/mcl_brewing/init.lua @@ -71,12 +71,37 @@ local function swap_node(pos, name) end +local function brewable(inv) + + local ingredient = inv:get_stack("input",1):get_name() + local stands = {"","",""} + + for i=1,3 do + + local bottle = inv:get_stack("stand", i):get_name() + + if ingredient == "mcl_nether:nether_wart_item" and bottle == "mcl_potions:potion_river_water" or "mcl_potions:potion_water" then + stands[i] = "mcl_potions:potion_awkward" + end + + end + + for i=1,3 do + if stands[i] then return stands end + end + + return false + +end + + local function brewing_stand_timer(pos, elapsed) -- Inizialize metadata local meta = minetest.get_meta(pos) local fuel_time = meta:get_float("fuel_time") or 0 local fuel_totaltime = meta:get_float("fuel_totaltime") or 0 + local BREW_TIME = 10 local input_item = meta:get_string("input_item") or "" @@ -87,7 +112,6 @@ local function brewing_stand_timer(pos, elapsed) local input_list, stand_list, fuel_list - local brewable, brewed local fuel local update = true @@ -109,11 +133,21 @@ local function brewing_stand_timer(pos, elapsed) -- end -- end + local brew_output = brewable(inv) + if fuel_time < fuel_totaltime then fuel_time = fuel_time + elapsed - --TODO check to see if we can brew + -- Replace the stand item with the brew result + if brew_output and (stand_timer >= BREW_TIME) then + for i=1, inv:get_size("stand", i) do + if brew_output[i] then + inv:set_stack("stand", i, brew_output[i]) + end + end + end + else --get more fuel from fuel_list @@ -139,7 +173,6 @@ local function brewing_stand_timer(pos, elapsed) end end - elapsed = 0 end @@ -160,11 +193,12 @@ local function brewing_stand_timer(pos, elapsed) if fuel_totaltime ~= 0 then local fuel_percent = math.floor(fuel_time/fuel_totaltime*100) - formspec = active_brewing_formspec(fuel_percent, 60) - swap_node(pos, "mcl_brewing:stand_active") + local brew_percent = math.floor(stand_timer/BREW_TIME*100) % 100 + formspec = active_brewing_formspec(fuel_percent, stand_timer) + -- swap_node(pos, "mcl_brewing:stand_active") result = true else - swap_node(pos, "mcl_brewing:stand") + -- swap_node(pos, "mcl_brewing:stand") minetest.get_node_timer(pos):stop() end diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index dd863075e..622b08e82 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -280,12 +280,6 @@ minetest.register_craftitem("mcl_potions:potion_mundane", { on_secondary_use = minetest.item_eat(0, "mcl_potions:glass_bottle"), }) -minetest.register_craft({ - type = "cooking", - output = "mcl_potions:potion_awkward", -recipe = "mcl_nether:nether_wart_item", --"mcl_potions:potion_river_water"}, - cooktime = 10, -}) minetest.register_craftitem("mcl_potions:potion_thick", { description = S("Thick Potion"), @@ -328,3 +322,13 @@ minetest.register_craftitem("mcl_potions:dragon_breath", { groups = { brewitem = 1, not_in_creative_inventory = 1 }, stack_max = 64, }) + +minetest.register_craftitem("mcl_potions:healing", { + description = S("Healing Potion"), + _doc_items_longdesc = brewhelp, + wield_image = "mcl_potions_healing.png", + inventory_image = "mcl_potions_healing.png", + -- TODO: Reveal item when it's actually useful + groups = { brewitem = 1, food=5}, + stack_max = 64, +}) diff --git a/mods/ITEMS/mcl_potions/textures/mcl_potions_healing.png b/mods/ITEMS/mcl_potions/textures/mcl_potions_healing.png new file mode 100644 index 0000000000000000000000000000000000000000..66bdbe0065be22e8cb94da875e61db61ee8da2bc GIT binary patch literal 1261 zcmds#zf0Cp6vm%7wbanTEngJr2N(rKhoGTCW4$a6VJDQpe^XY9WM9YbDrn(-0Oq2!!6D2%>Y{Z ztCb-DU0RKG04fh|yaehnI56A?l>rU}kN~wagE=f<38N0(;0_OX!l}Dq2uB1W5!BN( zq$2~FNP++jbTGgKsm5yUrpIZZ=BV5(%+ib+>t^oeVV>rciZBbe2#d6!M5S4}Wmu*q zjWC+gjbTh9C0QQar7|6q15I*QuXLjfY47ggp6-;tFzq5d(u1;_ro#-+^rRC`bGkE} z>7-x?mWOa;fMO#{9ul2l6ey%O%t!_iw4etgm_Z7&QgPiC zXo|YnxtG z7AU2$prf=4!;)NhQ22!`IVdKP`VOSvk$*=0n;JWRu>&Y!a;SEU|7ra#+4Acc2hcQ8 zJ$@EwUD7Ju+tFGEFx6k_9o~2I`SP=t#odkdgS$38J$ZX_p=spmt={ErD@(IuGcUfZ zR2OEa>aR`g-#W12=n^zFKAe(CC%lvG!|x literal 0 HcmV?d00001