From 4feb6c29ef4de8104a356653e31588f32f482d62 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Tue, 5 May 2015 14:11:48 +0200 Subject: [PATCH] Added check for access right when using teleport arrow - Players can't teleport themselves into an area they can't interact in (ie. enter a house by throwing an arrow through the door or on the roof) --- mods/throwing/teleport_arrow.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mods/throwing/teleport_arrow.lua b/mods/throwing/teleport_arrow.lua index c7e44a28..0564a20b 100755 --- a/mods/throwing/teleport_arrow.lua +++ b/mods/throwing/teleport_arrow.lua @@ -51,7 +51,9 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) if obj:get_luaentity() ~= nil then if obj:get_luaentity().name ~= "throwing:arrow_teleport_entity" and obj:get_luaentity().name ~= "__builtin:item" then if self.player ~= "" then - self.player:setpos(pos) + if not minetest.is_protected(pos, self.player:get_player_name()) then + self.player:setpos(pos) + end self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport")) minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos}) end @@ -59,7 +61,9 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) end else if self.player ~= "" then - self.player:setpos(pos) + if not minetest.is_protected(pos, self.player:get_player_name()) then + self.player:setpos(pos) + end self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport")) minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos}) end @@ -71,7 +75,9 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime) if self.lastpos.x ~= nil then if minetest.registered_nodes[node.name].walkable then if self.player ~= "" then - self.player:setpos(self.lastpos) + if not minetest.is_protected(self.lastpos, self.player:get_player_name()) then + self.player:setpos(self.lastpos) + end self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport")) minetest.sound_play("throwing_teleport_arrow", {pos = self.lastpos}) end