Add setting to customize spawning nodes

This commit is contained in:
Jordan Irwin 2021-07-20 11:05:24 -07:00
parent 00dcdda702
commit fa8363fef6
4 changed files with 26 additions and 13 deletions

@ -3,6 +3,7 @@ v1.1
----
- added sound when hit
- fixed entity vertical positioning
- added setting to customize spawn nodes
v1.0
----

@ -75,21 +75,22 @@ local def = {
}
]]
local spawn_nodes = {
"default:dirt_with_dry_grass",
"default:dry_dirt",
"default:dry_dirt_with_dry_grass",
"default:desert_sand",
}
if core.global_exists("nether") then
table.insert(spawn_nodes, "nether:rack")
local spawn_nodes = {}
if sneeker.spawn_nodes ~= "" then
if not sneeker.spawn_nodes:find(",") then
table.insert(spawn_nodes, sneeker.spawn_nodes)
else
for _, node in ipairs(sneeker.spawn_nodes:split(",")) do
local node = node:trim()
if node ~= "" then
table.insert(spawn_nodes, node)
end
end
end
end
for _, node_name in ipairs(spawn_nodes) do
if not core.registered_nodes[node_name] then
sneeker.log("warning", "Invalid node for spawn: " .. node_name)
end
if #spawn_nodes == 0 then
sneeker.log("warning", "no spawning nodes set, cannot spawn")
end
local item_drops = {}

@ -106,3 +106,11 @@ sneeker.spawn_maxheight = tonumber(core.settings:get("sneeker.spawn_maxheight")
-- @settype int
-- @default 1
sneeker.spawn_mapblock_limit = tonumber(core.settings:get("sneeker.spawn_mapblock_limit") or 1)
--- Comma-separated list of nodes on which sneeker can spawn.
--
-- @setting sneeker.spawn_nodes
-- @settype string
-- @default default:dirt_with_dry_grass,default:dry_dirt,default:dry_dirt_with_dry_grass,default:desert_sand,nether:rack
sneeker.spawn_nodes = core.settings:get("sneeker.spawn_nodes") or "default:dirt_with_dry_grass,default:dry_dirt,default:dry_dirt_with_dry_grass,default:desert_sand,nether:rack"
sneeker.spawn_nodes = sneeker.spawn_nodes:trim()

@ -50,3 +50,6 @@ sneeker.spawn_maxheight (Sneeker max spawn height) int 31000
# Limits the number of entities that can spawn per mapblock (16x16x16).
sneeker.spawn_mapblock_limit (Sneeker spawn limit) int 1
# Comma-separated list of nodes on which sneeker can spawn.
sneeker.spawn_nodes (Sneeker spawn nodes) string default:dirt_with_dry_grass,default:dry_dirt,default:dry_dirt_with_dry_grass,default:desert_sand,nether:rack