From eb5a5b56e194bbaa432edea9697f1adb1d2398d9 Mon Sep 17 00:00:00 2001
From: paramat <paramat@users.noreply.github.com>
Date: Wed, 4 Oct 2017 23:46:32 +0100
Subject: [PATCH] Decorations: Add kelp to cool and temperate shallow ocean

Original texture by tobyplowy, colourised by paramat.
---
 mods/default/README.txt                |   3 ++
 mods/default/license.txt               |   1 +
 mods/default/mapgen.lua                |  31 +++++++++++++++
 mods/default/nodes.lua                 |  51 +++++++++++++++++++++++++
 mods/default/textures/default_kelp.png | Bin 0 -> 312 bytes
 5 files changed, 86 insertions(+)
 create mode 100644 mods/default/textures/default_kelp.png

diff --git a/mods/default/README.txt b/mods/default/README.txt
index dd6c44fd..0a9f8ff7 100644
--- a/mods/default/README.txt
+++ b/mods/default/README.txt
@@ -215,6 +215,9 @@ kilbith (CC BY-SA 3.0):
   default_tin_ingot.png
   default_tin_lump.png
 
+tobyplowy (CC BY-SA 3.0):
+  default_kelp.png
+
 Glass breaking sounds (CC BY 3.0):
   1: http://www.freesound.org/people/cmusounddesign/sounds/71947/
   2: http://www.freesound.org/people/Tomlija/sounds/97669/
diff --git a/mods/default/license.txt b/mods/default/license.txt
index 0bfba618..034151f2 100644
--- a/mods/default/license.txt
+++ b/mods/default/license.txt
@@ -44,6 +44,7 @@ Copyright (C) 2010-2016:
   GreenXenith
   kaeza
   kilbith
+  tobyplowy
 
 You are free to:
 Share — copy and redistribute the material in any medium or format.
diff --git a/mods/default/mapgen.lua b/mods/default/mapgen.lua
index 4503d530..7cd60666 100644
--- a/mods/default/mapgen.lua
+++ b/mods/default/mapgen.lua
@@ -2019,6 +2019,37 @@ function default.register_decorations()
 		flags = "place_center_x, place_center_z",
 		rotation = "random",
 	})
+
+	-- Kelp
+
+	minetest.register_decoration({
+		deco_type = "simple",
+		place_on = {"default:sand"},
+		place_offset_y = -1,
+		sidelen = 16,
+		noise_params = {
+			offset = -0.04,
+			scale = 0.1,
+			spread = {x = 200, y = 200, z = 200},
+			seed = 87112,
+			octaves = 3,
+			persist = 0.7
+		},
+		biomes = {
+			"taiga_ocean",
+			"snowy_grassland_ocean",
+			"grassland_ocean",
+			"coniferous_forest_ocean",
+			"deciduous_forest_ocean",
+			"sandstone_desert_ocean",
+			"cold_desert_ocean"},
+		y_min = -10,
+		y_max = -5,
+		flags = "force_placement",
+		decoration = "default:sand_with_kelp",
+		param2 = 48,
+		param2_max = 96,
+	})
 end
 
 
diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua
index bab1a27e..e0e75cdf 100644
--- a/mods/default/nodes.lua
+++ b/mods/default/nodes.lua
@@ -149,6 +149,8 @@ default:acacia_bush_stem
 default:acacia_bush_leaves
 default:acacia_bush_sapling
 
+default:sand_with_kelp
+
 Corals
 ------
 
@@ -1449,6 +1451,55 @@ minetest.register_node("default:acacia_bush_sapling", {
 	end,
 })
 
+minetest.register_node("default:sand_with_kelp", {
+	description = "Kelp On Sand",
+	drawtype = "plantlike_rooted",
+	tiles = {"default_sand.png"},
+	special_tiles = {{name = "default_kelp.png", tileable_vertical = true}},
+	inventory_image = "default_kelp.png",
+	paramtype2 = "leveled",
+	groups = {snappy = 3},
+	node_placement_prediction = "",
+
+	on_place = function(itemstack, placer, pointed_thing)
+		-- Call on_rightclick if the pointed node defines it
+		if pointed_thing.type == "node" and placer and
+				not placer:get_player_control().sneak then
+			local node_ptu = minetest.get_node(pointed_thing.under)
+			local def_ptu = minetest.registered_nodes[node_ptu.name]
+			if def_ptu and def_ptu.on_rightclick then
+				return def_ptu.on_rightclick(pointed_thing.under, node_ptu, placer,
+					itemstack, pointed_thing)
+			end
+		end
+
+		local pos = pointed_thing.above
+		local height = math.random(4, 6)
+		local pos_top = {x = pos.x, y = pos.y + height, z = pos.z}
+		local node_top = minetest.get_node(pos_top)
+		local def_top = minetest.registered_nodes[node_top.name]
+		local player_name = placer:get_player_name()
+
+		if def_top and def_top.liquidtype == "source" and
+				minetest.get_item_group(node_top.name, "water") > 0 then
+			if not minetest.is_protected(pos, player_name) and
+					not minetest.is_protected(pos_top, player_name) then
+				minetest.set_node(pos, {name = "default:sand_with_kelp",
+					param2 = height * 16})
+				if not (creative and creative.is_enabled_for
+						and creative.is_enabled_for(player_name)) then
+					itemstack:take_item()
+				end
+			else
+				minetest.chat_send_player(player_name, "Node is protected")
+				minetest.record_protection_violation(pos, player_name)
+			end
+		end
+
+		return itemstack
+	end
+})
+
 
 --
 -- Corals
diff --git a/mods/default/textures/default_kelp.png b/mods/default/textures/default_kelp.png
new file mode 100644
index 0000000000000000000000000000000000000000..70b743d594f2674fb2eb67976a5589ce2aeffab2
GIT binary patch
literal 312
zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbK}LV!<*E09i0Rm{v#&dOBI$yO=I
zS1l}5D=tziEm1EkRj(-5sI1VauF|Nf)@*FhZfewSZq{jS(dq5hpE$u_`ZS|iGmYoY
zF<CI*bnzmy70WDEuCQ3W(qheO%XMokH?FtdyvgPbn|U?R4#tuozhDN3XE)M-oHkDv
z#}J9jq5ThqniK?D%moEqySOa5zWlv!^kmkOzr~-=zO6Clo^nLC;3?m#AU-!Mjz38%
zS&6+FN(<N41|@XOlRXupl&`<^f`y5-Q<kjk90QTgOzt-`-a01VdsozCdHe8>(mm0~
zd2;0pE0*oq<Q&4j_fl@;h55OqIhywWw=Z=!kInS|!C>~5P5BsuZX(b{44$rjF6*2U
FngC5QbLap7

literal 0
HcmV?d00001

-- 
GitLab