From 5296dc151827e01f53972f756011d434d70294e4 Mon Sep 17 00:00:00 2001
From: Perttu Ahola <celeron55@gmail.com>
Date: Sun, 8 Apr 2012 00:09:42 +0300
Subject: [PATCH] Generate dry shrubs on deserts
---
mods/default/init.lua | 17 ++++++++++
mods/default/mapgen.lua | 33 ++++++++++++++++++++
mods/default/textures/default_dry_shrub.png | Bin 0 -> 450 bytes
3 files changed, 50 insertions(+)
create mode 100644 mods/default/textures/default_dry_shrub.png
diff --git a/mods/default/init.lua b/mods/default/init.lua
index 53a365c..01e84fd 100644
--- a/mods/default/init.lua
+++ b/mods/default/init.lua
@@ -1224,6 +1224,23 @@ minetest.register_node("default:apple", {
sounds = default.node_sound_defaults(),
})
+minetest.register_node("default:dry_shrub", {
+ description = "Dry Shrub",
+ drawtype = "plantlike",
+ visual_scale = 1.0,
+ tile_images = {"default_dry_shrub.png"},
+ inventory_image = "default_dry_shrub.png",
+ wield_image = "default_dry_shrub.png",
+ paramtype = "light",
+ walkable = false,
+ groups = {snappy=3},
+ sounds = default.node_sound_leaves_defaults(),
+ selection_box = {
+ type = "fixed",
+ fixed = {-1/3, -1/2, -1/3, 1/3, 1/6, 1/3},
+ },
+})
+
--
-- Crafting items
--
diff --git a/mods/default/mapgen.lua b/mods/default/mapgen.lua
index e7663f2..16150d0 100644
--- a/mods/default/mapgen.lua
+++ b/mods/default/mapgen.lua
@@ -183,6 +183,39 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
end
+ -- Generate dry shrubs
+ local perlin1 = minetest.env:get_perlin(329, 3, 0.6, 100)
+ -- Assume X and Z lengths are equal
+ local divlen = 16
+ local divs = (maxp.x-minp.x)/divlen+1;
+ for divx=0,divs-1 do
+ for divz=0,divs-1 do
+ local x0 = minp.x + math.floor((divx+0)*divlen)
+ local z0 = minp.z + math.floor((divz+0)*divlen)
+ local x1 = minp.x + math.floor((divx+1)*divlen)
+ local z1 = minp.z + math.floor((divz+1)*divlen)
+ -- Determine cactus amount from perlin noise
+ local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 2)
+ -- Find random positions for cactus based on this random
+ local pr = PseudoRandom(seed+1)
+ for i=0,cactus_amount do
+ local x = pr:next(x0, x1)
+ local z = pr:next(z0, z1)
+ -- Find ground level (0...15)
+ local ground_y = nil
+ for y=30,0,-1 do
+ if minetest.env:get_node({x=x,y=y,z=z}).name ~= "air" then
+ ground_y = y
+ break
+ end
+ end
+ -- If desert sand, make cactus
+ if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
+ minetest.env:set_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"})
+ end
+ end
+ end
+ end
end
end)
diff --git a/mods/default/textures/default_dry_shrub.png b/mods/default/textures/default_dry_shrub.png
new file mode 100644
index 0000000000000000000000000000000000000000..450d5d96a52b45dc236520bacaa0fc7abe3ada94
GIT binary patch
literal 450
zcmV;z0X_bSP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00001b5ch_0Itp)
z=>Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RX1P2r{DRq)BJOBUzR7pfZR5;7s
zlA&+HKorJ*M_8H}W?Hk%H38hnWCaR4#Fo@f@HZ@JgIq|L%wq^*jvx?i=1?p{(_{ij
zYG<e!uIgrb%~8VU_sq-P`@Zje@7=-wi_h@sPmJHK9g}q8Zz6Hz;dg8DNYU@sh$D|U
z@(SPy^1)p-&k|rV8j2(}h$D~d+vg%H@?<nrSaE7L={lBl9joZ3JJPKyCskEkEw%t6
z2xqvCrMgH!yguGB2*%hZ+~1s2zd9?N2wkz+=m4<Z%w>`qqVM-uEw;RUyaUMTawlBJ
z!ZtG*gnI!{(I$}V&74-dPP5SwfYiyhnH9La&VfL#C<noqR=bW)==(hpgnQvS761<~
zv!d(KHp}y?JYDW^9ZOD^y8})|{|ByPkppDk?+MMiRNc!V)bjx(sR1BtGm}YblwAN&
sb|6aji-qN40I2h2b|JouZzTl459=|YmDRax;Q#;t07*qoM6N<$f*|d{DF6Tf
literal 0
HcmV?d00001