2021-05-08 20:42:35 +02:00
|
|
|
|
2021-05-08 20:53:32 +02:00
|
|
|
local spawn_nodes = {
|
|
|
|
"default:dirt_with_grass",
|
|
|
|
"default:stone",
|
|
|
|
}
|
|
|
|
|
|
|
|
if core.global_exists("nether") then
|
|
|
|
table.insert(spawn_nodes, "nether:rack")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2021-05-08 20:42:35 +02:00
|
|
|
core.register_abm({
|
2021-05-08 20:53:32 +02:00
|
|
|
nodenames = spawn_nodes,
|
2017-05-13 12:35:54 +02:00
|
|
|
neighbors = {"air"},
|
2021-05-08 21:23:00 +02:00
|
|
|
interval = sneeker.spawn_interval,
|
|
|
|
chance = sneeker.spawn_chance,
|
2017-05-13 12:35:54 +02:00
|
|
|
action = function(pos, node, _, active_object_count_wider)
|
|
|
|
if active_object_count_wider > 5 then
|
|
|
|
return
|
|
|
|
end
|
2021-05-08 21:23:00 +02:00
|
|
|
|
|
|
|
if pos.y > sneeker.spawn_maxheight then
|
2017-05-13 12:35:54 +02:00
|
|
|
return
|
|
|
|
end
|
2021-05-08 21:23:00 +02:00
|
|
|
if pos.y < sneeker.spawn_minheight then
|
2017-05-13 12:35:54 +02:00
|
|
|
return
|
|
|
|
end
|
2021-05-08 21:23:00 +02:00
|
|
|
|
|
|
|
-- needs two vertical air nodes to spawn
|
|
|
|
for _, node_pos in ipairs({pos, {x=pos.x, y=pos.y+1, z=pos.z}}) do
|
|
|
|
if core.get_node(node_pos).name ~= "air" then
|
|
|
|
return
|
|
|
|
end
|
2017-05-13 12:35:54 +02:00
|
|
|
end
|
2021-05-08 21:23:00 +02:00
|
|
|
|
|
|
|
local llevel = core.get_node_light(pos)
|
|
|
|
if not llevel or llevel > sneeker.spawn_maxlight or llevel < sneeker.spawn_minlight then
|
2017-05-13 12:35:54 +02:00
|
|
|
return
|
|
|
|
end
|
2021-05-08 21:23:00 +02:00
|
|
|
|
2021-05-08 20:42:35 +02:00
|
|
|
core.add_entity(pos, "sneeker:sneeker")
|
2017-05-13 12:35:54 +02:00
|
|
|
end
|
|
|
|
})
|