1
0
Fork 0

Make throwables only collide on solid nodes

This commit is contained in:
Wuzzy 2017-01-26 19:05:25 +01:00
parent 460f7a1962
commit 7e7d3acb08
2 changed files with 8 additions and 5 deletions

View File

@ -70,7 +70,8 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
end end
if self.lastpos.x~=nil then 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') minetest.add_item(self.lastpos, 'mcl_throwing:arrow')
self.object:remove() self.object:remove()
end end

View File

@ -83,10 +83,11 @@ local on_step = function(self, dtime)
self.timer=self.timer+dtime self.timer=self.timer+dtime
local pos = self.object:getpos() local pos = self.object:getpos()
local node = minetest.get_node(pos) 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 self._lastpos.x~=nil then
if node.name ~= "air" then if (def and def.walkable) or not def then
self.object:remove() self.object:remove()
return return
end end
@ -99,10 +100,11 @@ local pearl_on_step = function(self, dtime)
self.timer=self.timer+dtime self.timer=self.timer+dtime
local pos = self.object:getpos() local pos = self.object:getpos()
local node = minetest.get_node(pos) 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 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) local player = minetest.get_player_by_name(self._thrower)
if player then if player then
-- Teleport and hurt player -- Teleport and hurt player