From 26315d44cf0721e5ca0d64f08c9ae92fa4648cb2 Mon Sep 17 00:00:00 2001 From: Brandon Date: Sun, 19 Jul 2020 21:08:50 -0400 Subject: [PATCH] Add the ability to give use lingering potions to tip arrows. Corrected issue with bow not finding potion arrows in inventory. --- mods/ITEMS/mcl_bows/bow.lua | 2 +- mods/ITEMS/mcl_potions/potions.lua | 21 ++++++++++++++++----- mods/ITEMS/mcl_potions/tipped_arrow.lua | 10 ++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index 0d48443e0..eb8fbfcf8 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -226,7 +226,7 @@ controls.register_on_hold(function(player, key, time) local inv = minetest.get_inventory({type="player", name=name}) local wielditem = player:get_wielded_item() local creative = minetest.is_creative_enabled(name) - if bow_load[name] == nil and wielditem:get_name()=="mcl_bows:bow" and (creative or inv:contains_item("main", "mcl_bows:arrow")) then + if bow_load[name] == nil and wielditem:get_name()=="mcl_bows:bow" and (creative or #get_arrow(player)) then --inv:contains_item("main", "mcl_bows:arrow")) then wielditem:set_name("mcl_bows:bow_0") player:set_wielded_item(wielditem) if minetest.get_modpath("playerphysics") then diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index c618a26b9..3f197660d 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -79,11 +79,11 @@ local function register_potion(def) return function() end end - local function get_arrow_fun(effect, sp_dur) + local function get_arrow_fun(effect, dur) if def.is_dur then - return function(player) def.on_use(player, effect, sp_dur) end + return function(player) def.on_use(player, effect, dur) end elseif def.effect then - return function(player) def.on_use(player, effect, sp_dur) end + return function(player) def.on_use(player, effect, dur) end end -- covers case of no effect (water, awkward, mundane) return function() end @@ -125,8 +125,8 @@ local function register_potion(def) end local arrow_def = { - tt = get_tt(def._tt, def.effect, splash_dur), - potion_fun = get_arrow_fun(def.effect, splash_dur), + tt = get_tt(def._tt, def.effect, dur/8.), + potion_fun = get_arrow_fun(def.effect, dur/8.), } if def.color then @@ -208,9 +208,15 @@ local function register_potion(def) } end + local arrow_def_2 = { + tt = get_tt(def._tt_2, effect_II, dur_2/8.), + potion_fun = get_arrow_fun(effect_II, dur_2/8.), + } + if def.color then mcl_potions.register_splash(def.name.."_2", S("Splash "..def.description..desc_mod), def.color, splash_def_2) mcl_potions.register_lingering(def.name.."_2", S("Lingering "..def.description..desc_mod), def.color, ling_def_2) + mcl_potions.register_arrow(def.name.."_2", S(def.description.." Arrow "..desc_mod), def.color, arrow_def_2) end end @@ -254,9 +260,14 @@ local function register_potion(def) tt = get_tt(def._tt_plus, def.effect, ling_dur_pl), potion_fun = get_lingering_fun(def.effect, ling_dur_pl), } + local arrow_def_pl = { + tt = get_tt(def._tt_pl, def.effect, dur_pl/8.), + potion_fun = get_arrow_fun(def.effect, dur_pl/8.), + } if def.color then mcl_potions.register_splash(def.name.."_plus", S("Splash "..def.description.." +"), def.color, splash_def_pl) mcl_potions.register_lingering(def.name.."_plus", S("Lingering "..def.description.." +"), def.color, ling_def_pl) + mcl_potions.register_arrow(def.name.."_plus", S(def.description.." Arrow ".." +"), def.color, arrow_def_pl) end end diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index 081b2bcf4..d89024f04 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -435,6 +435,16 @@ function mcl_potions.register_arrow(name, desc, color, def) {'mcl_bows:arrow','mcl_bows:arrow','mcl_bows:arrow'} } }) + + minetest.register_craft({ + output = 'mcl_potions:'..name..'_arrow 8', + recipe = { + {'mcl_bows:arrow','mcl_bows:arrow','mcl_bows:arrow'}, + {'mcl_bows:arrow','mcl_potions:'..name..'_lingering','mcl_bows:arrow'}, + {'mcl_bows:arrow','mcl_bows:arrow','mcl_bows:arrow'} + } + }) + end if minetest.get_modpath("doc_identifier") ~= nil then