local node = minetest.get_node(under)
local udef = minetest.registered_nodes[node.name]
if udef and udef.on_rightclick and
- not (placer and placer:get_player_control().sneak) then
+ not (placer and placer:is_player() and
+ placer:get_player_control().sneak) then
return udef.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
pos = pointed_thing.above
end
- if minetest.is_protected(pos, placer:get_player_name()) and
- not minetest.check_player_privs(placer, "protection_bypass") then
- minetest.record_protection_violation(pos, placer:get_player_name())
+ local player_name = placer and placer:get_player_name() or ""
+
+ if minetest.is_protected(pos, player_name) and
+ not minetest.check_player_privs(player_name, "protection_bypass") then
+ minetest.record_protection_violation(pos, player_name)
return itemstack
end
return itemstack
end
- local dir = minetest.dir_to_facedir(placer:get_look_dir())
+ local dir = placer and placer:get_look_dir() and
+ minetest.dir_to_facedir(placer:get_look_dir()) or 0
local botpos = vector.add(pos, minetest.facedir_to_dir(dir))
- if minetest.is_protected(botpos, placer:get_player_name()) and
- not minetest.check_player_privs(placer, "protection_bypass") then
- minetest.record_protection_violation(botpos, placer:get_player_name())
+ if minetest.is_protected(botpos, player_name) and
+ not minetest.check_player_privs(player_name, "protection_bypass") then
+ minetest.record_protection_violation(botpos, player_name)
return itemstack
end
minetest.set_node(botpos, {name = name .. "_top", param2 = dir})
if not (creative and creative.is_enabled_for
- and creative.is_enabled_for(placer:get_player_name())) then
+ and creative.is_enabled_for(player_name)) then
itemstack:take_item()
end
return itemstack
local node = minetest.get_node(under)
local udef = minetest.registered_nodes[node.name]
if udef and udef.on_rightclick and
- not (placer and placer:get_player_control().sneak) then
+ not (placer and placer:is_player() and
+ placer:get_player_control().sneak) then
return udef.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
pointed_thing.under.y = pointed_thing.under.y + 0.5
boat = minetest.add_entity(pointed_thing.under, "boats:boat")
if boat then
- boat:setyaw(placer:get_look_horizontal())
- if not (creative and creative.is_enabled_for
- and creative.is_enabled_for(placer:get_player_name())) then
+ if placer then
+ boat:setyaw(placer:get_look_horizontal())
+ end
+ local player_name = placer and placer:get_player_name() or ""
+ if not (creative and creative.is_enabled_for and
+ creative.is_enabled_for(player_name)) then
itemstack:take_item()
end
end
-- Call on_rightclick if the pointed node defines it
if ndef and ndef.on_rightclick and
- user and not user:get_player_control().sneak then
+ not (user and user:is_player() and
+ user:get_player_control().sneak) then
return ndef.on_rightclick(
pointed_thing.under,
node, user,
local node = minetest.get_node(under)
local udef = minetest.registered_nodes[node.name]
if udef and udef.on_rightclick and
- not (placer and placer:get_player_control().sneak) then
+ not (placer and placer:is_player() and
+ placer:get_player_control().sneak) then
return udef.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
-- Prevent decay of placed leaves
default.after_place_leaves = function(pos, placer, itemstack, pointed_thing)
- if placer and not placer:get_player_control().sneak then
+ if placer and placer:is_player() and not placer:get_player_control().sneak then
local node = minetest.get_node(pos)
node.param2 = 1
minetest.set_node(pos, node)
sounds = default.node_sound_leaves_defaults(),
after_place_node = function(pos, placer, itemstack)
- if placer:is_player() then
- minetest.set_node(pos, {name = "default:apple", param2 = 1})
- end
+ minetest.set_node(pos, {name = "default:apple", param2 = 1})
end,
})
local node = minetest.get_node(under)
local def = minetest.registered_nodes[node.name]
if def and def.on_rightclick and
- not (placer and placer:get_player_control().sneak) then
+ not (placer and placer:is_player() and
+ placer:get_player_control().sneak) then
return def.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
local node = minetest.get_node(under)
local def = minetest.registered_nodes[node.name]
if def and def.on_rightclick and
- ((not placer) or (placer and not placer:get_player_control().sneak)) then
+ not (placer and placer:is_player() and
+ placer:get_player_control().sneak) then
return def.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
local node = minetest.get_node_or_nil(pos)
local pdef = node and minetest.registered_nodes[node.name]
- if pdef and pdef.on_rightclick and not placer:get_player_control().sneak then
+ if pdef and pdef.on_rightclick and
+ not (placer and placer:is_player() and
+ placer:get_player_control().sneak) then
return pdef.on_rightclick(pos, node, placer, itemstack, pointed_thing)
end
end
end
- local player_name = placer:get_player_name()
+ local player_name = placer and placer:get_player_name() or ""
-- Check sapling position for protection
if minetest.is_protected(pos, player_name) then
minetest.record_protection_violation(pos, player_name)
local node = minetest.get_node(pointed_thing.under)
local pdef = minetest.registered_nodes[node.name]
if pdef and pdef.on_rightclick and
- not placer:get_player_control().sneak then
+ not (placer and placer:is_player() and
+ placer:get_player_control().sneak) then
return pdef.on_rightclick(pointed_thing.under,
node, placer, itemstack, pointed_thing)
end
return itemstack
end
- local pn = placer:get_player_name()
+ local pn = placer and placer:get_player_name() or ""
if minetest.is_protected(pos, pn) or minetest.is_protected(above, pn) then
return itemstack
end
- local dir = minetest.dir_to_facedir(placer:get_look_dir())
+ local dir = placer and minetest.dir_to_facedir(placer:get_look_dir()) or 0
local ref = {
{x = -1, y = 0, z = 0},
local under = minetest.get_node(pt.under)
local above = minetest.get_node(pt.above)
- if minetest.is_protected(pt.under, placer:get_player_name()) then
- minetest.record_protection_violation(pt.under, placer:get_player_name())
+ local player_name = placer and placer:get_player_name() or ""
+
+ if minetest.is_protected(pt.under, player_name) then
+ minetest.record_protection_violation(pt.under, player_name)
return
end
- if minetest.is_protected(pt.above, placer:get_player_name()) then
- minetest.record_protection_violation(pt.above, placer:get_player_name())
+ if minetest.is_protected(pt.above, player_name) then
+ minetest.record_protection_violation(pt.above, player_name)
return
end
minetest.add_node(pt.above, {name = plantname, param2 = 1})
tick(pt.above)
if not (creative and creative.is_enabled_for
- and creative.is_enabled_for(placer:get_player_name())) then
+ and creative.is_enabled_for(player_name)) then
itemstack:take_item()
end
return itemstack
local node = minetest.get_node(under)
local udef = minetest.registered_nodes[node.name]
if udef and udef.on_rightclick and
- not (placer and placer:get_player_control().sneak) then
+ not (placer and placer:is_player() and
+ placer:get_player_control().sneak) then
return udef.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
local pos = pointed_thing.above
local node = minetest.get_node(pointed_thing.under)
local def = minetest.registered_nodes[node.name]
- local player_name = placer:get_player_name()
+ local player_name = placer and placer:get_player_name() or ""
if def and def.on_rightclick then
return def.on_rightclick(pointed_thing.under, node, placer, itemstack,
end
local pos = pointed_thing.under
+ local player_name = user and user:get_player_name() or ""
- if minetest.is_protected(pos, user:get_player_name()) then
- minetest.record_protection_violation(pos, user:get_player_name())
+ if minetest.is_protected(pos, player_name) then
+ minetest.record_protection_violation(pos, player_name)
return
end
minetest.check_for_falling(pos)
end
- if not (creative and creative.is_enabled_for
- and creative.is_enabled_for(user:get_player_name())) then
+ if not (creative and creative.is_enabled_for and
+ creative.is_enabled_for(player_name)) then
itemstack:add_wear(65535 / ((uses or 200) - 1))
end
local p1 = pointed_thing.above
local param2 = 0
- local placer_pos = placer:getpos()
- if placer_pos then
- param2 = minetest.dir_to_facedir(vector.subtract(p1, placer_pos))
- end
+ if placer then
+ local placer_pos = placer:getpos()
+ if placer_pos then
+ param2 = minetest.dir_to_facedir(vector.subtract(p1, placer_pos))
+ end
- local finepos = minetest.pointed_thing_to_face_pos(placer, pointed_thing)
- local fpos = finepos.y % 1
+ local finepos = minetest.pointed_thing_to_face_pos(placer, pointed_thing)
+ local fpos = finepos.y % 1
- if p0.y - 1 == p1.y or (fpos > 0 and fpos < 0.5)
- or (fpos < -0.5 and fpos > -0.999999999) then
- param2 = param2 + 20
- if param2 == 21 then
- param2 = 23
- elseif param2 == 23 then
- param2 = 21
+ if p0.y - 1 == p1.y or (fpos > 0 and fpos < 0.5)
+ or (fpos < -0.5 and fpos > -0.999999999) then
+ param2 = param2 + 20
+ if param2 == 21 then
+ param2 = 23
+ elseif param2 == 23 then
+ param2 = 21
+ end
end
end
return minetest.item_place(itemstack, placer, pointed_thing, param2)
on_place = function(itemstack, placer, pointed_thing)
local under = minetest.get_node(pointed_thing.under)
local wield_item = itemstack:get_name()
+ local player_name = placer and placer:get_player_name() or ""
local creative_enabled = (creative and creative.is_enabled_for
- and creative.is_enabled_for(placer:get_player_name()))
+ and creative.is_enabled_for(player_name))
if under and under.name:find("stairs:slab_") then
-- place slab using under node orientation
if not recipeitem then
return itemstack
end
- local player_name = placer:get_player_name()
if minetest.is_protected(pointed_thing.under, player_name) and not
- minetest.check_player_privs(placer, "protection_bypass") then
+ minetest.check_player_privs(player_name, "protection_bypass") then
minetest.record_protection_violation(pointed_thing.under,
player_name)
return