From 7e7d3acb085dc2bf0f2e9ca224a67c9977f26ec1 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 26 Jan 2017 19:05:25 +0100 Subject: [PATCH] Make throwables only collide on solid nodes --- mods/mcl_throwing/arrow.lua | 3 ++- mods/mcl_throwing/throwable.lua | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mods/mcl_throwing/arrow.lua b/mods/mcl_throwing/arrow.lua index d27ce5bcc..1aa86b617 100644 --- a/mods/mcl_throwing/arrow.lua +++ b/mods/mcl_throwing/arrow.lua @@ -70,7 +70,8 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) end if self.lastpos.x~=nil then - if node.name ~= "air" then + local def = minetest.registered_nodes[node.name] + if (def and def.walkable) or not def then minetest.add_item(self.lastpos, 'mcl_throwing:arrow') self.object:remove() end diff --git a/mods/mcl_throwing/throwable.lua b/mods/mcl_throwing/throwable.lua index 9974e3599..dce1c3936 100644 --- a/mods/mcl_throwing/throwable.lua +++ b/mods/mcl_throwing/throwable.lua @@ -83,10 +83,11 @@ local on_step = function(self, dtime) self.timer=self.timer+dtime local pos = self.object:getpos() local node = minetest.get_node(pos) + local def = minetest.registered_nodes[node.name] - -- Remove when hitting a node. + -- Destroy when hitting a solid node if self._lastpos.x~=nil then - if node.name ~= "air" then + if (def and def.walkable) or not def then self.object:remove() return end @@ -99,10 +100,11 @@ local pearl_on_step = function(self, dtime) self.timer=self.timer+dtime local pos = self.object:getpos() local node = minetest.get_node(pos) + local def = minetest.registered_nodes[node.name] - --Become item when hitting a node. + -- Destroy when hitting a solid node if self._lastpos.x~=nil then - if node.name ~= "air" then + if (def and def.walkable) or not def then local player = minetest.get_player_by_name(self._thrower) if player then -- Teleport and hurt player