This commit is contained in:
Elias Fleckenstein 2021-01-06 12:43:09 +01:00
parent 3a02e90c3a
commit 08a8b155d7

View File

@ -131,6 +131,24 @@ S("The speed and damage of the arrow increases the longer you charge. The regula
range = 4,
-- Trick to disable digging as well
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},
_mcl_uses = 385,
})
@ -140,11 +158,15 @@ local reset_bows = function(player)
local inv = player:get_inventory()
local list = inv:get_list("main")
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:get_meta():set_string("active", "")
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
stack:set_name("mcl_bows:bow_enchanted")
stack:get_meta():set_string("active", "")
list[place] = stack
end
end
@ -177,6 +199,7 @@ for level=0, 2 do
on_use = function() return end,
on_drop = function(itemstack, dropper, pos)
reset_bow_state(dropper)
itemstack:get_meta():set_string("active", "")
if mcl_enchanting.is_enchanted(itemstack:get_name()) then
itemstack:set_name("mcl_bows:bow_enchanted")
else
@ -270,7 +293,7 @@ controls.register_on_hold(function(player, key, time)
end
local inv = minetest.get_inventory({type="player", name=name})
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())
if enchanted then
wielditem:set_name("mcl_bows:bow_0_enchanted")