forked from VoxeLibre/VoxeLibre
Better randomseed
This commit is contained in:
parent
89b025cae8
commit
69ad066e63
|
@ -1,6 +1,17 @@
|
|||
mcl_secret_ores = {}
|
||||
mcl_secret_ores.registered_ores = {}
|
||||
|
||||
local trad_ore = minetest.settings:get_bool("mcl_traditional_ancient_debris_ore",false)
|
||||
local noise_params = {
|
||||
offset = 0.27,
|
||||
scale = 1,
|
||||
spread = {x = 523, y = 123, z = 542 },
|
||||
seed = 252342,
|
||||
octaves = 1,
|
||||
persist = 0,
|
||||
flags = "absvalue",
|
||||
}
|
||||
|
||||
local adjacents = {
|
||||
{ x =-1, y = 0, z = 0},
|
||||
{ x = 1, y = 0, z = 0},
|
||||
|
@ -25,7 +36,11 @@ function mcl_secret_ores.on_dig(pos, oldnode,def)
|
|||
for k,v in pairs(adjacents) do
|
||||
local p=vector.add(pos,v)
|
||||
local n=minetest.get_node_or_nil(p)
|
||||
if n and table.indexof(def.wherein,n.name) and n.param2 == 0 and is_occluded(p,pos) and def.randomfunc(p) then
|
||||
if n and table.indexof(def.wherein,n.name) and n.param2 == 0 and is_occluded(p,pos) and def.randomfunc(p,def) then
|
||||
if def.clust_num_ores then --enforce local limit
|
||||
local oo = minetest.find_nodes_in_area(vector.offset(p,-15,-15,-15),vector.offset(p,15,15,15),{def.ore})
|
||||
if oo and #oo > def.clust_num_ores then return end
|
||||
end
|
||||
minetest.set_node(p,{name=def.ore})
|
||||
return
|
||||
end
|
||||
|
@ -45,7 +60,7 @@ minetest.register_on_mods_loaded(function()
|
|||
local old_on_dig = node.on_dig
|
||||
minetest.override_item(n, {on_dig = function(pos,oldnode,digger)
|
||||
mcl_secret_ores.on_dig(pos, oldnode,def)
|
||||
old_on_dig(pos,oldnode,digger)
|
||||
return old_on_dig(pos,oldnode,digger)
|
||||
end,
|
||||
place_param2 = 1
|
||||
})
|
||||
|
@ -53,14 +68,18 @@ minetest.register_on_mods_loaded(function()
|
|||
end
|
||||
end)
|
||||
|
||||
mcl_secret_ores.register_ore({
|
||||
wherein = {"mcl_nether:netherrack","mcl_blackstone:blackstone","mcl_blackstone:basalt"},
|
||||
ore = "mcl_nether:ancient_debris",
|
||||
y_min = mcl_vars.mg_nether_min,
|
||||
y_max = mcl_vars.mg_nether_lava_max,
|
||||
randomfunc = function(p)
|
||||
p = vector.round(p)
|
||||
local pr = PseudoRandom(p.x*p.y*p.z)
|
||||
if pr:next(1,5000) == 1 then return true end
|
||||
end,
|
||||
})
|
||||
if not trad_ore then
|
||||
mcl_secret_ores.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "mcl_nether:ancient_debris",
|
||||
wherein = {"mcl_nether:netherrack","mcl_nether:soul_sand","mcl_blackstone:blackstone","mcl_blackstone:basalt"},
|
||||
clust_num_ores = 8,
|
||||
y_min = mcl_vars.mg_nether_min,
|
||||
y_max = mcl_vars.mg_lava_nether_max,
|
||||
randomfunc = function(p,def)
|
||||
local noise = minetest.get_perlin(noise_params)
|
||||
local n = noise:get_3d(p)
|
||||
if n > 1 then return true end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue