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 c535831f..3657b10b 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 dd863075..622b08e8 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#y=#+E6vj_Xs%a%1vf0p3{D6vr;z4jwNhQTpN({9_9fX4PAa$wOK~zvgs7e)! z8aUw4!O0ppm0`P#Z4UckOwev8*#utAm9+x5Cb$QaTFYA3~fk5%OkniMvY~v z9znt%+M+U3bL0xUpuncOsUt@ujR3%f;|LmV5hd~fCT=4RFu^b!f*N9g#!X;>1C5~# zX^#=bX>6m$a!d?C!XMhAGWQr@8h=oviN-wBkOC^@9^*|>24hMmrkxB2a`F(vPgvm~ zb%HcL2TTd!!Bc9LzQlk2n!0$opD07KWAzij_%GMrhFW^7(>U8bQ#*N{sCOlv%!6IM zCHy%zQXLvUaQo%zi^B5We6F!)%k$HBXP3GsuHPA2-O*lYPA$Cp+O91%=W;h@4sIXa zwDzoZ8 GYkvT-_G^3q literal 0 HcmV?d00001