diff --git a/mods/throwing/dig_arrow.lua b/mods/throwing/dig_arrow.lua index adb4e6b2..af914501 100755 --- a/mods/throwing/dig_arrow.lua +++ b/mods/throwing/dig_arrow.lua @@ -55,12 +55,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) damage_groups={fleshy=damage}, }, nil) self.object:remove() - local toughness = 0.9 - if math.random() < toughness then - minetest.add_item(self.lastpos, 'throwing:arrow_dig') - else - minetest.add_item(self.lastpos, 'default:stick') - end + minetest.add_item(self.lastpos, "throwing:arrow_dig") end end end @@ -68,18 +63,15 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) if self.lastpos.x~=nil then if node.name ~= "air" then - self.object:remove() + if minetest.get_item_group(node.name, "unbreakable") == 0 and areas:canInteract(self.lastpos, self.player:get_player_name()) and node.diggable ~= false then minetest.set_node(pos, {name = "air"}) end - local toughness = 0.65 - if math.random() < toughness then - minetest.add_item(self.lastpos, 'default:pick_steel') - else - minetest.add_item(self.lastpos, 'default:stick') - end + minetest.add_item(self.lastpos, node.name) + minetest.add_item(self.lastpos, "throwing:arrow_dig") + self.object:remove() end end self.lastpos={x=pos.x, y=pos.y, z=pos.z} diff --git a/mods/throwing/functions.lua b/mods/throwing/functions.lua index e6d1c518..2fefc7ca 100755 --- a/mods/throwing/functions.lua +++ b/mods/throwing/functions.lua @@ -17,11 +17,13 @@ minetest.register_on_leaveplayer(function(player) end) function throwing_shoot_arrow (itemstack, player, stiffness, is_cross) + if not player then return end local arrow = itemstack:get_metadata() itemstack:set_metadata("") player:set_wielded_item(itemstack) local playerpos = player:getpos() local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow) + if not obj then return end local dir = player:get_look_dir() obj:setvelocity({x=dir.x*stiffness, y=dir.y*stiffness, z=dir.z*stiffness}) obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3}) @@ -44,6 +46,7 @@ function throwing_unload (itemstack, player, unloaded, wear) if not minetest.setting_getbool("creative_mode") then player:get_inventory():add_item("main", arrow[1]) end + break end end end