diff --git a/mods/default/init.lua b/mods/default/init.lua index 53a365c8..01e84fd3 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 e7663f2a..16150d0f 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 00000000..450d5d96 Binary files /dev/null and b/mods/default/textures/default_dry_shrub.png differ