From 3eefa2f18134ab59139f73f4bbf918024c494d7f Mon Sep 17 00:00:00 2001
From: Novatux <nathanael.courant@laposte.net>
Date: Sun, 22 Feb 2015 12:42:46 +0100
Subject: [PATCH] Add sulfur and lead, and make them generate

---
 technic_worldgen/nodes.lua                           |   32 +++++++++-
 technic_worldgen/textures/technic_lead_block.png     |    0 
 technic_worldgen/textures/technic_lead_lump.png      |    0 
 technic_worldgen/textures/technic_mineral_sulfur.png |    0 
 technic_worldgen/textures/technic_lead_ingot.png     |    0 
 technic_worldgen/textures/technic_sulfur_dust.png    |    0 
 technic_worldgen/oregen.lua                          |   85 ++++++++++++++++++++++++++++
 technic_worldgen/mg.lua                              |   15 +++++
 technic_worldgen/textures/technic_lead_dust.png      |    0 
 technic_worldgen/textures/technic_sulfur_lump.png    |    0 
 technic_worldgen/crafts.lua                          |   14 +++-
 technic_worldgen/textures/technic_mineral_lead.png   |    0 
 12 files changed, 139 insertions(+), 7 deletions(-)

diff --git a/technic_worldgen/crafts.lua b/technic_worldgen/crafts.lua
index 3965258..ac84652 100644
--- a/technic_worldgen/crafts.lua
+++ b/technic_worldgen/crafts.lua
@@ -4,27 +4,23 @@
 minetest.register_craftitem(":technic:uranium_lump", {
 	description = S("Uranium Lump"),
 	inventory_image = "technic_uranium_lump.png",
-	on_place_on_ground = minetest.craftitem_place_item,
 })
 minetest.register_alias("technic:uranium", "technic:uranium_lump")
 
 minetest.register_craftitem(":technic:uranium_ingot", {
 	description = S("Uranium Ingot"),
 	inventory_image = "technic_uranium_ingot.png",
-	on_place_on_ground = minetest.craftitem_place_item,
 	groups = {uranium_ingot=1},
 })
 
 minetest.register_craftitem(":technic:chromium_lump", {
 	description = S("Chromium Lump"),
 	inventory_image = "technic_chromium_lump.png",
-	on_place_on_ground = minetest.craftitem_place_item,
 })
 
 minetest.register_craftitem(":technic:chromium_ingot", {
 	description = S("Chromium Ingot"),
 	inventory_image = "technic_chromium_ingot.png",
-	on_place_on_ground = minetest.craftitem_place_item,
 })
 
 minetest.register_craftitem(":technic:zinc_lump", {
@@ -37,6 +33,16 @@
 	inventory_image = "technic_zinc_ingot.png",
 })
 
+minetest.register_craftitem(":technic:lead_lump", {
+	description = S("Lead Lump"),
+	inventory_image = "technic_lead_lump.png",
+})
+
+minetest.register_craftitem(":technic:sulfur_lump", {
+	description = S("Sulfur Lump"),
+	inventory_image = "technic_sulfur_lump.png",
+})
+
 minetest.register_craftitem(":technic:brass_ingot", {
 	description = S("Brass Ingot"),
 	inventory_image = "technic_brass_ingot.png",
diff --git a/technic_worldgen/mg.lua b/technic_worldgen/mg.lua
index d511277..4025384 100644
--- a/technic_worldgen/mg.lua
+++ b/technic_worldgen/mg.lua
@@ -48,6 +48,21 @@
 	numperblock = 2
 })
 
+mg.register_ore({
+	name = "technic:mineral_lead",
+	wherein = "default:stone",
+	seeddiff = 13,
+	maxvdistance = 10.5,
+	maxheight = 16,
+	seglenghtn = 15,
+	seglenghtdev = 6,
+	segincln = 0,
+	segincldev = 0.6,
+	turnangle = 57,
+	forkturnangle = 57,
+	numperblock = 3
+})
+
 if technic.config:get_bool("enable_granite_generation") then
 	mg.register_ore_sheet({
 		name = "technic:granite",
diff --git a/technic_worldgen/nodes.lua b/technic_worldgen/nodes.lua
index d38173d..54ddfca 100644
--- a/technic_worldgen/nodes.lua
+++ b/technic_worldgen/nodes.lua
@@ -7,7 +7,7 @@
 	is_ground_content = true,
 	groups = {cracky=3, radioactive=1000},
 	sounds = default.node_sound_stone_defaults(),
-	drop = 'craft "technic:uranium_lump" 1',
+	drop = "technic:uranium_lump",
 }) 
 
 minetest.register_node( ":technic:mineral_chromium", {
@@ -16,7 +16,7 @@
 	is_ground_content = true,
 	groups = {cracky=3},
 	sounds = default.node_sound_stone_defaults(),
-	drop = 'craft "technic:chromium_lump" 1',
+	drop = "technic:chromium_lump",
 }) 
 
 minetest.register_node( ":technic:mineral_zinc", {
@@ -25,7 +25,25 @@
 	is_ground_content = true,
 	groups = {cracky=3},
 	sounds = default.node_sound_stone_defaults(),
-	drop = 'craft "technic:zinc_lump" 1',
+	drop = "technic:zinc_lump",
+})
+
+minetest.register_node( ":technic:mineral_lead", {
+	description = S("Lead Ore"),
+	tile_images = { "default_stone.png^technic_mineral_lead.png" },
+	is_ground_content = true,
+	groups = {cracky=3},
+	sounds = default.node_sound_stone_defaults(),
+	drop = "technic:lead_lump",
+})
+
+minetest.register_node( ":technic:mineral_sulfur", {
+	description = S("Sulfur Ore"),
+	tile_images = { "default_stone.png^technic_mineral_sulfur.png" },
+	is_ground_content = true,
+	groups = {cracky=3},
+	sounds = default.node_sound_stone_defaults(),
+	drop = "technic:sulfur_lump",
 })
 
 minetest.register_node( ":technic:granite", {
@@ -76,6 +94,14 @@
 	sounds = default.node_sound_stone_defaults()
 })
 
+minetest.register_node(":technic:lead_block", {
+	description = S("Lead Block"),
+	tiles = { "technic_lead_block.png" },
+	is_ground_content = true,
+	groups = {cracky=1, level=2},
+	sounds = default.node_sound_stone_defaults()
+})
+
 minetest.register_alias("technic:wrought_iron_block", "default:steelblock")
 
 minetest.override_item("default:steelblock", {
diff --git a/technic_worldgen/oregen.lua b/technic_worldgen/oregen.lua
index ec9386d..4aca7f1 100644
--- a/technic_worldgen/oregen.lua
+++ b/technic_worldgen/oregen.lua
@@ -7,6 +7,9 @@
 local zinc_params = {offset = 0, scale = 1, spread = {x = 100, y = 100, z = 100}, seed = 422, octaves = 3, persist = 0.7}
 local zinc_threshhold = 0.5
 
+local lead_params = {offset = 0, scale = 1, spread = {x = 100, y = 100, z = 100}, seed = 423, octaves = 3, persist = 0.7}
+local lead_threshhold = 0.3
+
 minetest.register_ore({
 	ore_type         = "scatter",
 	ore              = "technic:mineral_uranium",
@@ -74,6 +77,88 @@
 	noise_threshhold = zinc_threshhold,
 })
 
+minetest.register_ore({
+	ore_type         = "scatter",
+	ore              = "technic:mineral_lead",
+	wherein          = "default:stone",
+	clust_scarcity   = 9*9*9,
+	clust_num_ores   = 5,
+	clust_size       = 3,
+	height_min       = -16,
+	height_max       = 16,
+	noise_params     = lead_params,
+	noise_threshhold = lead_threshhold,
+})
+
+minetest.register_ore({
+	ore_type         = "scatter",
+	ore              = "technic:mineral_lead",
+	wherein          = "default:stone",
+	clust_scarcity   = 8*8*8,
+	clust_num_ores   = 5,
+	clust_size       = 3,
+	height_min       = -128,
+	height_max       = -16,
+	noise_params     = lead_params,
+	noise_threshhold = lead_threshhold,
+})
+
+minetest.register_ore({
+	ore_type         = "scatter",
+	ore              = "technic:mineral_lead",
+	wherein          = "default:stone",
+	clust_scarcity   = 6*6*6,
+	clust_num_ores   = 5,
+	clust_size       = 3,
+	height_min       = -31000,
+	height_max       = -128,
+	flags            = "absheight",
+	noise_params     = lead_params,
+	noise_threshhold = lead_threshhold,
+})
+
+-- Sulfur
+minetest.register_on_generated(function(minp, maxp, seed)
+	local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
+	local a = VoxelArea:new{
+		MinEdge = {x = emin.x, y = emin.y, z = emin.z},
+		MaxEdge = {x = emax.x, y = emax.y, z = emax.z},
+	}
+	local data = vm:get_data()
+	local pr = PseudoRandom(17 * minp.x + 42 * minp.y + 101 * minp.z)
+	local noise = minetest.get_perlin(9876, 3, 0.5, 100)
+	
+	local c_lava = minetest.get_content_id("default:lava_source")
+	local c_lava_flowing = minetest.get_content_id("default:lava_flowing")
+	local c_stone = minetest.get_content_id("default:stone")
+	local c_sulfur = minetest.get_content_id("technic:mineral_sulfur")
+	
+	local grid_size = 5
+	for x = minp.x + math.floor(grid_size / 2), maxp.x, grid_size do
+	for y = minp.y + math.floor(grid_size / 2), maxp.y, grid_size do
+	for z = minp.z + math.floor(grid_size / 2), maxp.z, grid_size do
+		local c = data[a:index(x, y, z)]
+		if (c == c_lava or c == c_lava_flowing) and noise:get3d({x = x, y = z, z = z}) >= 0.4 then
+			for xx = math.max(minp.x, x - grid_size), math.min(maxp.x, x + grid_size) do
+			for yy = math.max(minp.y, y - grid_size), math.min(maxp.y, y + grid_size) do
+			for zz = math.max(minp.z, z - grid_size), math.min(maxp.z, z + grid_size) do
+				local i = a:index(xx, yy, zz)
+				if data[i] == c_stone and pr:next(1, 10) <= 7 then
+					data[i] = c_sulfur
+				end
+			end
+			end
+			end
+		end
+	end
+	end
+	end
+	
+	vm:set_data(data)
+	vm:write_to_map(data)
+end)
+
+
 if technic.config:get_bool("enable_marble_generation") then
 minetest.register_ore({
 	ore_type       = "sheet",
diff --git a/technic_worldgen/textures/technic_lead_block.png b/technic_worldgen/textures/technic_lead_block.png
new file mode 100644
index 0000000..11da56a
--- /dev/null
+++ b/technic_worldgen/textures/technic_lead_block.png
Binary files differ
diff --git a/technic_worldgen/textures/technic_lead_dust.png b/technic_worldgen/textures/technic_lead_dust.png
new file mode 100644
index 0000000..af6ee29
--- /dev/null
+++ b/technic_worldgen/textures/technic_lead_dust.png
Binary files differ
diff --git a/technic_worldgen/textures/technic_lead_ingot.png b/technic_worldgen/textures/technic_lead_ingot.png
new file mode 100644
index 0000000..fae0cbf
--- /dev/null
+++ b/technic_worldgen/textures/technic_lead_ingot.png
Binary files differ
diff --git a/technic_worldgen/textures/technic_lead_lump.png b/technic_worldgen/textures/technic_lead_lump.png
new file mode 100644
index 0000000..64584cb
--- /dev/null
+++ b/technic_worldgen/textures/technic_lead_lump.png
Binary files differ
diff --git a/technic_worldgen/textures/technic_mineral_lead.png b/technic_worldgen/textures/technic_mineral_lead.png
new file mode 100644
index 0000000..0309cd3
--- /dev/null
+++ b/technic_worldgen/textures/technic_mineral_lead.png
Binary files differ
diff --git a/technic_worldgen/textures/technic_mineral_sulfur.png b/technic_worldgen/textures/technic_mineral_sulfur.png
new file mode 100644
index 0000000..26cb19d
--- /dev/null
+++ b/technic_worldgen/textures/technic_mineral_sulfur.png
Binary files differ
diff --git a/technic_worldgen/textures/technic_sulfur_dust.png b/technic_worldgen/textures/technic_sulfur_dust.png
new file mode 100644
index 0000000..04ffee0
--- /dev/null
+++ b/technic_worldgen/textures/technic_sulfur_dust.png
Binary files differ
diff --git a/technic_worldgen/textures/technic_sulfur_lump.png b/technic_worldgen/textures/technic_sulfur_lump.png
new file mode 100644
index 0000000..017c8e1
--- /dev/null
+++ b/technic_worldgen/textures/technic_sulfur_lump.png
Binary files differ

--
Gitblit v1.8.0