1
0
Fork 0

Move mob spawner change code to mobs mod

objects
Wuzzy 2018-01-07 16:53:25 +01:00
parent 1a96ef137a
commit cc411efe4c
2 changed files with 17 additions and 18 deletions

View File

@ -3152,6 +3152,9 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
inventory_image = invimg,
groups = grp,
_doc_items_longdesc = "This allows you to place a single mob.",
_doc_items_usagehelp = "Just place it where you want the mob to appear. Animals will spawn tamed, unless you hold down the sneak key while placing. If you place this on a monster spawner, you change the monster it spawns.",
on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
@ -3171,6 +3174,20 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
return
end
local name = placer:get_player_name()
local privs = minetest.get_player_privs(name)
if not privs.maphack then
minetest.chat_send_player(name, "You need the “maphack” privilege to change the mob spawner.")
return itemstack
end
if minetest.get_modpath("mcl_mobspawners") and under.name == "mcl_mobspawners:spawner" then
mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name())
if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item()
end
return itemstack
end
pos.y = pos.y + 1
local mob = minetest.add_entity(pos, mob)

View File

@ -304,24 +304,6 @@ minetest.register_node("mcl_mobspawners:spawner", {
end,
sounds = mcl_sounds.node_sound_metal_defaults(),
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
-- Change mob type if placing spawn egg into monster spawner.
-- Shift-click to ignore.
if minetest.get_item_group(itemstack:get_name(), "spawn_egg") == 1 then
local name = clicker:get_player_name()
local privs = minetest.get_player_privs(name)
if not privs.maphack then
minetest.chat_send_player(name, "You need the “maphack” privilege to change the spawned monster.")
return itemstack
end
mcl_mobspawners.setup_spawner(pos, itemstack:get_name())
if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item()
end
return itemstack
end
end,
_mcl_blast_resistance = 25,
_mcl_hardness = 5,
})