This commit is contained in:
HybridDog 2014-04-18 22:02:24 +02:00
parent 48d6f4aa64
commit 4dba4e8cb1
2 changed files with 126 additions and 9 deletions

View File

@ -98,6 +98,21 @@ NETHER_PORTAL = {
--== END OF EDITABLE OPTIONS ==--
local path = minetest.get_modpath("nether")
dofile(path.."/weird_mapgen_noise.lua")
local function dif(z1, z2)
if z1 < 0
and z2 < 0 then
z1,z2 = -z1,-z2
end
return math.abs(z1-z2)
end
local function pymg(x1, x2, z1, z2)
return math.max(dif(x1, x2), dif(z1, z2))
end
local function r_area(manip, width, height, pos)
local emerged_pos1, emerged_pos2 = manip:read_from_map(
{x=pos.x-width, y=pos.y, z=pos.z-width},
@ -278,7 +293,7 @@ minetest.register_node("nether:blood_stem", {
sounds = default.node_sound_wood_defaults(),
})
-- Nether leaves
--[[ Nether leaves
minetest.register_node("nether:leaves", {
description = "Nether Leaves",
drawtype = "allfaces_optional",
@ -287,7 +302,7 @@ minetest.register_node("nether:leaves", {
paramtype = "light",
groups = {snappy=3, leafdecay=2},
sounds = default.node_sound_leaves_defaults(),
})
})]]
-- Nether apple
minetest.register_node("nether:apple", {
@ -360,6 +375,7 @@ minetest.register_craftitem("nether:pearl", {
local c_air = minetest.get_content_id("air")
local c_netherrack = minetest.get_content_id("nether:netherrack")
local c_netherrack_brick = minetest.get_content_id("nether:netherrack_brick")
local c_glowstone = minetest.get_content_id("glow:stone") --https://github.com/Zeg9/minetest-glow
local c_lava = minetest.get_content_id("default:lava_source")
local c_nether_shroom = minetest.get_content_id("riesenpilz:nether_shroom")
@ -395,15 +411,16 @@ minetest.register_on_generated(function(minp, maxp, seed)
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
pr = PseudoRandom(seed+33)
local num = 1
local tab = {}
local tab,num = {},1
local num2 = 1
local perlin1 = minetest.get_perlin(13,3, 0.5, 50) --Get map specific perlin
local perlin2 = minetest.get_perlin(133,3, 0.5, 10)
local perlin3 = minetest.get_perlin(112,3, 0.5, 5)
local tab2 = nether_weird_noise(minp, pymg, 20, 8)
for x=minp.x, maxp.x, 1 do
for z=minp.z, maxp.z, 1 do
for z=minp.z, maxp.z do
for x=minp.x, maxp.x do
local r_tree = pr:next(1,NETHER_TREE_FREQ)
local r_shroom = pr:next(1,NETHER_SHROOM_FREQ)
@ -431,10 +448,18 @@ minetest.register_on_generated(function(minp, maxp, seed)
local bottom = NETHER_BOTTOM+h
local top = NETHER_DEPTH-pr:next(0,NETHER_RANDOM)+t
local py_h = tab2[num2].y
num2 = num2+1
for y=minp.y, maxp.y, 1 do
local p_addpos = area:index(x, y, z)
if data[p_addpos] ~= c_air then
local addpos = {x=x, y=y-1, z=z}
--if py_h >= maxp.y-4 then
if y == py_h then
data[p_addpos] = c_netherrack_brick
--[[else
data[p_addpos] = c_air
end]]
elseif data[p_addpos] ~= c_air then
if y <= NETHER_BOTTOM then
if y <= bottom then
data[p_addpos] = return_nether_ore(1)
@ -443,7 +468,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
elseif r_tree == 1
and y == bottom then
tab[num] = addpos
tab[num] = {x=x, y=y-1, z=z}
num = num+1
elseif y <= bottom then
if pr:next(1,LAVA_FREQ) == 1 then

View File

@ -0,0 +1,92 @@
--V2
local function get_random(a, b, seed)
return PseudoRandom(math.abs(a+b*5)+seed)
end
local r_chs = {}
function nether_weird_noise(minp, fct, s, seed, range)
if not r_chs[s] then
r_chs[s] = math.floor(s/3+0.5)
end
local r_ch = r_chs[s]
local maxp = vector.add(minp, 16)
local tab,n = {},1
local sm = range or (s+r_ch)*2
for z = -sm, 16+sm do
local pz = z+minp.z
if pz%s == 0 then
for x = -sm, 16+sm do
local px = x+minp.x
if px%s == 0 then
local pr = get_random(px, pz, seed)
tab[n] = {x=px+pr:next(-r_ch, r_ch), y=0, z=pz+pr:next(-r_ch, r_ch)}
n = n+1
end
end
end
end
local tab2,n = {},1
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
local h = sm
for _,i in ipairs(tab) do
--local dist = vector.distance(i, {x=x, y=0, z=z})
h = math.min(h, fct(x, i.x, z, i.z))
end
tab2[n] = {x=x, y=maxp.y-h, z=z}
n = n+1
end
end
return tab2
end
--[[
local function dif(z1, z2)
if z1 < 0
and z2 < 0 then
z1,z2 = -z1,-z2
end
return math.abs(z1-z2)
end
local function pymg(x1, x2, z1, z2)
return math.max(dif(x1, x2), dif(z1, z2))
end
local function romg(x1, x2, z1, z2)
return math.hypot(dif(x1, x2), dif(z1, z2))
end
local function py2mg(x1, x2, z1, z2)
return dif(x1, x2) + dif(z1, z2)
end
minetest.register_node("ac:wmg", {
description = "wmg",
tiles = {"ac_block.png"},
groups = {snappy=1,bendy=2,cracky=1},
sounds = default_stone_sounds,
on_construct = function(pos)
local minp = vector.chunkcorner(pos)
for _,p in ipairs(weird_noise(minp, pymg, 20, 8, 4)) do
local p2 = {x=p.x, y=p.y+1, z=p.z}
if p.y <= minp.y+7 then
local p2 = {x=p.x, y=minp.y+6, z=p.z}
local p3 = {x=p.x, y=p2.y+1, z=p.z}
if minetest.get_node(p2).name ~= "default:desert_stone" then
minetest.set_node(p2, {name="default:desert_stone"})
end
if minetest.get_node(p3).name ~= "default:desert_sand" then
minetest.set_node(p3, {name="default:desert_sand"})
end
else
if minetest.get_node(p).name ~= "default:desert_stone" then
minetest.set_node(p, {name="default:desert_stone"})
end
end
end
end,
})]]