From 2600ce6a37b2f08079f18ca4414e5b3b059f43c4 Mon Sep 17 00:00:00 2001
From: Chris N <swordsman9613@gmail.com>
Date: Tue, 6 Jan 2015 11:57:15 -1000
Subject: [PATCH] Stability Update, Further Grief Prevention

Made a tweak to the noise that both speeds up mapgen and prevents
crashes with Minetest 0.4.11.  Also made it so that DM realm structure
spawners automatically remove themselves from the surface world,
preventing griefing.
---
 init.lua  |  3 ++-
 nodes.lua | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/init.lua b/init.lua
index 384e1d8..4d62b29 100644
--- a/init.lua
+++ b/init.lua
@@ -163,12 +163,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
 	--mandatory values
 	local sidelen = x1 - x0 + 1 --length of a mapblock
 	local chulens = {x=sidelen, y=sidelen, z=sidelen} --table of chunk edges
+	local chulens2D = {x=sidelen, y=sidelen, z=1}
 	local minposxyz = {x=x0, y=y0, z=z0} --bottom corner
 	local minposxz = {x=x0, y=z0} --2D bottom corner
 	
 	local nvals_cave = minetest.get_perlin_map(np_cave, chulens):get3dMap_flat(minposxyz) --cave noise for structure
 	local nvals_wave = minetest.get_perlin_map(np_wave, chulens):get3dMap_flat(minposxyz) --wavy structure of cavern ceilings and floors
-	local nvals_biome = minetest.get_perlin_map(np_biome, chulens):get2dMap_flat({x=x0+150, y=z0+50}) --2D noise for biomes (will be 3D humidity/temp later)
+	local nvals_biome = minetest.get_perlin_map(np_biome, chulens2D):get2dMap_flat({x=x0+150, y=z0+50}) --2D noise for biomes (will be 3D humidity/temp later)
 	
 	local nixyz = 1 --3D node index
 	local nixz = 1 --2D node index
diff --git a/nodes.lua b/nodes.lua
index a8db708..23f1051 100644
--- a/nodes.lua
+++ b/nodes.lua
@@ -4,6 +4,7 @@
 
 local FALLING_ICICLES = caverealms.config.falling_icicles --true --toggle to turn on or off falling icicles in glaciated biome
 local FALLCHA = caverealms.config.fallcha --0.33 --chance of causing the structure to fall
+local DM_TOP = caverealms.config.dm_top -- -4000 --level at which Dungeon Master Realms start to appear
 
 
 --glowing crystal
@@ -537,6 +538,9 @@ minetest.register_node("caverealms:constant_flame", {
 	
 	after_dig_node = function(pos, oldnode, oldmetadata, digger)
 		fire.on_flame_remove_at(pos)
+		if pos.y > DM_TOP then
+			minetest.remove_node(pos)
+		end
 	end,
 })
 
@@ -546,6 +550,11 @@ minetest.register_node("caverealms:s_chest", {
 	tiles = {"default_chest_front.png"},
 	paramtype2 = "facedir",
 	groups = {choppy=3,oddly_breakable_by_hand=2,cavechest=1, not_in_creative_inventory=1},
+	after_dig_node = function(pos, oldnode, oldmetadata, digger)
+		if pos.y > DM_TOP then
+			minetest.remove_node(pos)
+		end
+	end,
 })
 
 --hacky schematic placers
@@ -554,12 +563,22 @@ minetest.register_node("caverealms:s_fountain", {
 	description = "A Hack like you should know what this does...",
 	tiles = {"caverealms_stone_eyes.png"},
 	groups = {crumbly=3, schema=1, not_in_creative_inventory=1},
+	after_dig_node = function(pos, oldnode, oldmetadata, digger)
+		if pos.y > DM_TOP then
+			minetest.remove_node(pos)
+		end
+	end,
 })
 
 minetest.register_node("caverealms:s_fortress", {
 	description = "A Hack like you should know what this does...",
 	tiles = {"caverealms_stone_eyes.png"},
 	groups = {crumbly=3, schema=1, not_in_creative_inventory=1},
+	after_dig_node = function(pos, oldnode, oldmetadata, digger)
+		if pos.y > DM_TOP then
+			minetest.remove_node(pos)
+		end
+	end,
 })
 
 --dungeon master statue (nodebox)
-- 
GitLab