forked from MineClone5/MineClone5
Add water breathing.
This commit is contained in:
parent
58cde1c9e9
commit
d9e78e8ad9
|
@ -81,3 +81,13 @@ function mcl_potions.invisiblility_func(player, duration)
|
|||
mcl_potions.invisible(player, true)
|
||||
minetest.after(duration, function() mcl_potions.invisible(player, false) end )
|
||||
end
|
||||
|
||||
function mcl_potions.water_breathing_func(player, duration)
|
||||
if minetest.is_player(player) then
|
||||
|
||||
for i=1,math.floor(duration) do
|
||||
minetest.after(i, function() player:set_breath(10) end )
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -303,7 +303,7 @@ local awkward_table = {
|
|||
["mcl_fishing:pufferfish_raw"] = "mcl_potions:water_breathing", --add craft
|
||||
["mcl_mobitems:ghast_tear"] = "mcl_potions:regeneration", --add craft
|
||||
["mcl_mobitems:spider_eye"] = "mcl_potions:poison", --add craft
|
||||
["mcl_mobitems:rabbit_foot"] = "mcl_potions:leaping", --add craft
|
||||
["mcl_mobitems:rabbit_foot"] = "mcl_potions:leaping",
|
||||
}
|
||||
|
||||
local output_table = {
|
||||
|
@ -316,11 +316,11 @@ local output_table = {
|
|||
local enhancement_table = {}
|
||||
local extension_table = {}
|
||||
local potions = {"awkward", "mundane", "thick"}
|
||||
for i, potion in ipairs({"healing","harming","swiftness","leaping","poison","regeneration","invisibility","weakness"}) do
|
||||
for i, potion in ipairs({"healing","harming","swiftness","leaping","poison","regeneration","invisibility","weakness","water_breathing"}) do
|
||||
|
||||
table.insert(potions, potion)
|
||||
|
||||
if potion ~= "invisibility" and potion ~= "night_vision" and potion ~= "weakness" then
|
||||
if potion ~= "invisibility" and potion ~= "night_vision" and potion ~= "weakness" and potion ~= "water_breathing" then
|
||||
enhancement_table["mcl_potions:"..potion] = "mcl_potions:"..potion.."_2"
|
||||
enhancement_table["mcl_potions:"..potion.."_splash"] = "mcl_potions:"..potion.."_2_splash"
|
||||
table.insert(potions, potion.."_2")
|
||||
|
|
|
@ -548,3 +548,46 @@ minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
|
|||
print("Weakness Active")
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
minetest.register_craftitem("mcl_potions:water_breathing", {
|
||||
description = S("Water Breathing Potion"),
|
||||
_doc_items_longdesc = brewhelp,
|
||||
wield_image = potion_image("#0000AA"),
|
||||
inventory_image = potion_image("#0000AA"),
|
||||
groups = { brewitem = 1, food = 0 },
|
||||
stack_max = 1,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.water_breathing_func(user, 180)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.water_breathing_func(user, 180)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mcl_potions:water_breathing_plus", {
|
||||
description = S("Water Breathing Potion +"),
|
||||
_doc_items_longdesc = brewhelp,
|
||||
wield_image = potion_image("#0000CC"),
|
||||
inventory_image = potion_image("#0000CC"),
|
||||
groups = { brewitem = 1, food = 0 },
|
||||
stack_max = 1,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.water_breathing_func(user, 480)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
return itemstack
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||
mcl_potions.water_breathing_func(user, 480)
|
||||
mcl_potions._use_potion(itemstack)
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
|
|
@ -171,7 +171,7 @@ register_splash("invisibility", "Splash Invisibility", "#B0B0B0", {
|
|||
})
|
||||
|
||||
register_splash("invisibility_plus", "Splash Invisibility +", "#A0A0A0", {
|
||||
potion_fun = function(player, redx) mcl_potions.invisiblility_func(player, 300*redx) end
|
||||
potion_fun = function(player, redx) mcl_potions.invisiblility_func(player, 360*redx) end
|
||||
})
|
||||
|
||||
register_splash("weakness", "Splash Weakness", "#6600AA", {
|
||||
|
@ -181,3 +181,11 @@ register_splash("weakness", "Splash Weakness", "#6600AA", {
|
|||
register_splash("weakness_plus", "Splash Weakness +", "#7700BB", {
|
||||
potion_fun = function(player, redx) mcl_potions.weakness_func(player, 1.4, 180*redx) end
|
||||
})
|
||||
|
||||
register_splash("water_breathing", "Splash Water Breathing", "#0000AA", {
|
||||
potion_fun = function(player, redx) mcl_potions.water_breathing_func(player, 135*redx) end
|
||||
})
|
||||
|
||||
register_splash("water_breathing_plus", "Splash Water Breathing +", "#0000CC", {
|
||||
potion_fun = function(player, redx) mcl_potions.water_breathing_func(player, 360*redx) end
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue