Check node handler for mobspawn/village node
This commit is contained in:
parent
604141ea01
commit
23a8258a35
@ -1630,13 +1630,17 @@ function mobs:register_egg(mobname, desc, background)
|
||||
inventory_image = invimg,
|
||||
groups = { spawn_egg = 1 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local handled, handled_itemstack = util.on_place_pointed_node_handler(itemstack, placer, pointed_thing)
|
||||
if handled then
|
||||
return handled_itemstack
|
||||
end
|
||||
local pname = placer:get_player_name()
|
||||
if peaceful_only and minetest.registered_entities[mobname].type == "monster" then
|
||||
minetest.chat_send_player(pname, minetest.colorize("#FFFF00", S("Hostile mobs are disabled!")))
|
||||
return itemstack
|
||||
end
|
||||
local pos = pointed_thing.above
|
||||
if pointed_thing.above then
|
||||
if pointed_thing.type == "node" then
|
||||
local pos = pointed_thing.above
|
||||
if minetest.is_protected(pos, pname) and
|
||||
not minetest.check_player_privs(placer, "protection_bypass") then
|
||||
minetest.record_protection_violation(pos, pname)
|
||||
|
@ -30,15 +30,20 @@ local check_priv = function(player)
|
||||
end
|
||||
|
||||
local place_entity_spawner = function(itemstack, placer, pointed_thing)
|
||||
if not check_priv(placer) then
|
||||
return itemstack
|
||||
end
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
if util.handle_node_protection(placer, pointed_thing) then
|
||||
return itemstack
|
||||
end
|
||||
local handled, handled_itemstack = util.on_place_pointed_node_handler(itemstack, placer, pointed_thing)
|
||||
if handled then
|
||||
return handled_itemstack
|
||||
end
|
||||
if not check_priv(placer) then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local place_pos
|
||||
itemstack, place_pos = minetest.item_place(itemstack, placer, pointed_thing)
|
||||
if placer and placer:is_player() then
|
||||
@ -124,15 +129,19 @@ local village_info = {
|
||||
}
|
||||
|
||||
local use_village_spawner = function(itemstack, placer, pointed_thing)
|
||||
if not check_priv(placer) then
|
||||
return itemstack
|
||||
end
|
||||
if not pointed_thing.type == "node" then
|
||||
return itemstack
|
||||
end
|
||||
if util.handle_node_protection(placer, pointed_thing) then
|
||||
return itemstack
|
||||
end
|
||||
local handled, handled_itemstack = util.on_place_pointed_node_handler(itemstack, placer, pointed_thing)
|
||||
if handled then
|
||||
return handled_itemstack
|
||||
end
|
||||
if not check_priv(placer) then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local pos = pointed_thing.above
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user