From 82991c27d89da80ac46c2d9b736959d7f48988e6 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Fri, 22 May 2015 23:42:25 +0200 Subject: [PATCH] Completed update of nether mod (mapgen fixes) --- mods/nether/README.txt | 3 ++- mods/nether/nether/init.lua | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/mods/nether/README.txt b/mods/nether/README.txt index 570b021b..10985249 100644 --- a/mods/nether/README.txt +++ b/mods/nether/README.txt @@ -7,4 +7,5 @@ http://i.imgur.com/pMZYqt9.png TODO: -— finish nether forest +— care about nether torches +— find a way to get the perlin noise inside [-1; 1] or use another noise diff --git a/mods/nether/nether/init.lua b/mods/nether/nether/init.lua index afc92cc7..6e4e752e 100644 --- a/mods/nether/nether/init.lua +++ b/mods/nether/nether/init.lua @@ -125,6 +125,36 @@ local function table_contains(t, v) return false end +-- Weierstrass function stuff from https://github.com/slemonide/gen +local SIZE = 1000 +local ssize = math.ceil(math.abs(SIZE)) +local function do_ws_func(depth, a, x) + local n = x/(16*SIZE) + local y = 0 + for k=1,depth do + y = y + SIZE*(math.sin(math.pi * k^a * n)/(math.pi * k^a)) + end + return y +end + +local chunksize = minetest.setting_get("chunksize") or 5 +local ws_lists = {} +local function get_ws_list(a,x) + ws_lists[a] = ws_lists[a] or {} + local v = ws_lists[a][x] + if v then + return v + end + v = {} + for x=x,x + (chunksize*16 - 1) do + local y = do_ws_func(ssize, a, x) + v[x] = y + end + ws_lists[a][x] = v + return v +end + + local function dif(z1, z2) if z1 < 0 and z2 < 0 then