forked from VoxeLibre/VoxeLibre
parent
3a02e90c3a
commit
08a8b155d7
|
@ -131,6 +131,24 @@ S("The speed and damage of the arrow increases the longer you charge. The regula
|
||||||
range = 4,
|
range = 4,
|
||||||
-- Trick to disable digging as well
|
-- Trick to disable digging as well
|
||||||
on_use = function() return end,
|
on_use = function() return end,
|
||||||
|
on_place = function(itemstack, player, pointed_thing)
|
||||||
|
if pointed_thing and pointed_thing.type == "node" then
|
||||||
|
-- Call on_rightclick if the pointed node defines it
|
||||||
|
local node = minetest.get_node(pointed_thing.under)
|
||||||
|
if player and not player:get_player_control().sneak then
|
||||||
|
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
|
||||||
|
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, player, itemstack) or itemstack
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
itemstack:get_meta():set_string("active", "true")
|
||||||
|
return itemstack
|
||||||
|
end,
|
||||||
|
on_secondary_use = function(itemstack)
|
||||||
|
itemstack:get_meta():set_string("active", "true")
|
||||||
|
return itemstack
|
||||||
|
end,
|
||||||
groups = {weapon=1,weapon_ranged=1,bow=1,enchantability=1},
|
groups = {weapon=1,weapon_ranged=1,bow=1,enchantability=1},
|
||||||
_mcl_uses = 385,
|
_mcl_uses = 385,
|
||||||
})
|
})
|
||||||
|
@ -140,11 +158,15 @@ local reset_bows = function(player)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
local list = inv:get_list("main")
|
local list = inv:get_list("main")
|
||||||
for place, stack in pairs(list) do
|
for place, stack in pairs(list) do
|
||||||
if stack:get_name()=="mcl_bows:bow_0" or stack:get_name()=="mcl_bows:bow_1" or stack:get_name()=="mcl_bows:bow_2" then
|
if stack:get_name() == "mcl_bows:bow" or stack:get_name() == "mcl_bows:bow_enchanted" then
|
||||||
|
stack:get_meta():set_string("active", "")
|
||||||
|
elseif stack:get_name()=="mcl_bows:bow_0" or stack:get_name()=="mcl_bows:bow_1" or stack:get_name()=="mcl_bows:bow_2" then
|
||||||
stack:set_name("mcl_bows:bow")
|
stack:set_name("mcl_bows:bow")
|
||||||
|
stack:get_meta():set_string("active", "")
|
||||||
list[place] = stack
|
list[place] = stack
|
||||||
elseif stack:get_name()=="mcl_bows:bow_0_enchanted" or stack:get_name()=="mcl_bows:bow_1_enchanted" or stack:get_name()=="mcl_bows:bow_2_enchanted" then
|
elseif stack:get_name()=="mcl_bows:bow_0_enchanted" or stack:get_name()=="mcl_bows:bow_1_enchanted" or stack:get_name()=="mcl_bows:bow_2_enchanted" then
|
||||||
stack:set_name("mcl_bows:bow_enchanted")
|
stack:set_name("mcl_bows:bow_enchanted")
|
||||||
|
stack:get_meta():set_string("active", "")
|
||||||
list[place] = stack
|
list[place] = stack
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -177,6 +199,7 @@ for level=0, 2 do
|
||||||
on_use = function() return end,
|
on_use = function() return end,
|
||||||
on_drop = function(itemstack, dropper, pos)
|
on_drop = function(itemstack, dropper, pos)
|
||||||
reset_bow_state(dropper)
|
reset_bow_state(dropper)
|
||||||
|
itemstack:get_meta():set_string("active", "")
|
||||||
if mcl_enchanting.is_enchanted(itemstack:get_name()) then
|
if mcl_enchanting.is_enchanted(itemstack:get_name()) then
|
||||||
itemstack:set_name("mcl_bows:bow_enchanted")
|
itemstack:set_name("mcl_bows:bow_enchanted")
|
||||||
else
|
else
|
||||||
|
@ -202,7 +225,7 @@ controls.register_on_release(function(player, key, time)
|
||||||
if (wielditem:get_name()=="mcl_bows:bow_0" or wielditem:get_name()=="mcl_bows:bow_1" or wielditem:get_name()=="mcl_bows:bow_2" or
|
if (wielditem:get_name()=="mcl_bows:bow_0" or wielditem:get_name()=="mcl_bows:bow_1" or wielditem:get_name()=="mcl_bows:bow_2" or
|
||||||
wielditem:get_name()=="mcl_bows:bow_0_enchanted" or wielditem:get_name()=="mcl_bows:bow_1_enchanted" or wielditem:get_name()=="mcl_bows:bow_2_enchanted") then
|
wielditem:get_name()=="mcl_bows:bow_0_enchanted" or wielditem:get_name()=="mcl_bows:bow_1_enchanted" or wielditem:get_name()=="mcl_bows:bow_2_enchanted") then
|
||||||
local has_shot = false
|
local has_shot = false
|
||||||
|
|
||||||
local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name())
|
local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name())
|
||||||
local speed, damage
|
local speed, damage
|
||||||
local p_load = bow_load[player:get_player_name()]
|
local p_load = bow_load[player:get_player_name()]
|
||||||
|
@ -242,13 +265,13 @@ controls.register_on_release(function(player, key, time)
|
||||||
end
|
end
|
||||||
|
|
||||||
has_shot = player_shoot_arrow(wielditem, player, speed, damage, is_critical)
|
has_shot = player_shoot_arrow(wielditem, player, speed, damage, is_critical)
|
||||||
|
|
||||||
if enchanted then
|
if enchanted then
|
||||||
wielditem:set_name("mcl_bows:bow_enchanted")
|
wielditem:set_name("mcl_bows:bow_enchanted")
|
||||||
else
|
else
|
||||||
wielditem:set_name("mcl_bows:bow")
|
wielditem:set_name("mcl_bows:bow")
|
||||||
end
|
end
|
||||||
|
|
||||||
if has_shot and not minetest.is_creative_enabled(player:get_player_name()) then
|
if has_shot and not minetest.is_creative_enabled(player:get_player_name()) then
|
||||||
local durability = BOW_DURABILITY
|
local durability = BOW_DURABILITY
|
||||||
local unbreaking = mcl_enchanting.get_enchantment(wielditem, "unbreaking")
|
local unbreaking = mcl_enchanting.get_enchantment(wielditem, "unbreaking")
|
||||||
|
@ -270,7 +293,7 @@ controls.register_on_hold(function(player, key, time)
|
||||||
end
|
end
|
||||||
local inv = minetest.get_inventory({type="player", name=name})
|
local inv = minetest.get_inventory({type="player", name=name})
|
||||||
local wielditem = player:get_wielded_item()
|
local wielditem = player:get_wielded_item()
|
||||||
if bow_load[name] == nil and (wielditem:get_name()=="mcl_bows:bow" or wielditem:get_name()=="mcl_bows:bow_enchanted") and (creative or get_arrow(player)) then
|
if bow_load[name] == nil and (wielditem:get_name()=="mcl_bows:bow" or wielditem:get_name()=="mcl_bows:bow_enchanted") and wielditem:get_meta():get("active") and (creative or get_arrow(player)) then
|
||||||
local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name())
|
local enchanted = mcl_enchanting.is_enchanted(wielditem:get_name())
|
||||||
if enchanted then
|
if enchanted then
|
||||||
wielditem:set_name("mcl_bows:bow_0_enchanted")
|
wielditem:set_name("mcl_bows:bow_0_enchanted")
|
||||||
|
|
Loading…
Reference in New Issue