summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2017-01-21 10:38:43 +0000
committerTenPlus1 <kinsellaja@yahoo.com>2017-01-21 10:38:43 +0000
commit4e231429d9c5e37441a53c429a058708ac6f6957 (patch)
tree80bb64f1a85ff3b1dd0bb64e4d6dc6ff21473707
parent52a23559546deb9a1ed4a8aa9b5cdded1e3c1ceb (diff)
spawn egg checks for existing right_click functions
-rw-r--r--api.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/api.lua b/api.lua
index a9c68ff..57d4f26 100644
--- a/api.lua
+++ b/api.lua
@@ -1893,8 +1893,9 @@ local do_states = function(self, dtime)
p.y = p.y + (self.collisionbox[2] + self.collisionbox[5]) / 2
local obj = minetest.add_entity(p, self.arrow)
- if obj then
- local ent = obj:get_luaentity()
+ local ent = obj:get_luaentity()
+
+ if ent then
local amount = (vec.x * vec.x + vec.y * vec.y + vec.z * vec.z) ^ 0.5
local v = ent.velocity or 1 -- or set to default
ent.switch = 1
@@ -2990,6 +2991,13 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
local pos = pointed_thing.above
+ -- am I clicking on something with existing on_rightclick function?
+ local under = minetest.get_node(pointed_thing.under)
+ local def = minetest.registered_nodes[under.name]
+ if def and def.on_rightclick then
+ return def.on_rightclick(pointed_thing.under, under, placer, itemstack)
+ end
+
if pos
and within_limits(pos, 0)
and not minetest.is_protected(pos, placer:get_player_name()) then