From 94f52e9fd7cd138938c1e7d742f523ed3c7abc50 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 28 Feb 2020 19:42:00 +0000 Subject: [PATCH] added sponges to coral reefs --- README.md | 1 + sealife.lua | 97 +++++++++++++++++++++++++++++-- textures/ethereal_sponge.png | Bin 0 -> 272 bytes textures/ethereal_sponge_wet.png | Bin 0 -> 272 bytes 4 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 textures/ethereal_sponge.png create mode 100644 textures/ethereal_sponge_wet.png diff --git a/README.md b/README.md index 4699b78..7f179a4 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Ethereal Mapgen mod for Minetest (works on all except v6) - Added Etherium ore and dust - Added sparse decoration of dry grass and shrub to caves biome + - Added sponges that spawn near coral, dry sponge in furnace to soak up water ### 1.26 diff --git a/sealife.lua b/sealife.lua index aa1a31e..50866de 100644 --- a/sealife.lua +++ b/sealife.lua @@ -165,19 +165,24 @@ minetest.register_abm({ catch_up = false, action = function(pos, node) - local sel = math.random(1, 5) + local sel = math.random(1, 6) pos.y = pos.y + 1 local nod = minetest.get_node(pos).name + if nod == "default:water_source" + and sel == 6 then + + minetest.swap_node(pos, {name = "ethereal:sponge_wet"}) + + return + end + if nod == "default:water_source" and sel > 1 then - if minetest.get_node(pos).name == "default:water_source" then - - minetest.swap_node(pos, {name = "ethereal:coral" .. sel}) - end + minetest.swap_node(pos, {name = "ethereal:coral" .. sel}) return end @@ -206,3 +211,85 @@ minetest.register_abm({ end, }) end + +-- sponges + +minetest.register_node("ethereal:sponge_air", { + drawtype = "airlike", + paramtype = "light", + walkable = false, + buildable_to = true, + sunlight_propagates = true, + pointable = false, + drop = "", + groups = {not_in_creative_inventory = 1}, +}) + + +minetest.register_node("ethereal:sponge", { + description = S("Sponge"), + tiles = {"ethereal_sponge.png"}, + groups = {crumbly = 3}, + sounds = default.node_sound_sand_defaults(), + + after_place_node = function(pos, placer, itemstack, pointed_thing) + + -- get player name + local name = placer:get_player_name() + + -- is area protected + if minetest.is_protected(pos, name) then + return + end + + -- get water nodes within range + local num = minetest.find_nodes_in_area( + {x = pos.x - 3, y = pos.y - 3, z = pos.z - 3}, + {x = pos.x + 3, y = pos.y + 3, z = pos.z + 3}, + {"group:water"}) + + -- no water + if #num == 0 then return end + + -- replace water nodes with sponge air + for _, w in pairs(num) do + + if not minetest.is_protected(pos, name) then + minetest.swap_node(w, {name = "ethereal:sponge_air"}) + end + end + + -- replace dry sponge with wet sponge + minetest.swap_node(pos, {name="ethereal:sponge_wet"}) + end +}) + + +minetest.register_node("ethereal:sponge_wet", { + description = S("Wet sponge"), + tiles = {"ethereal_sponge_wet.png"}, + groups = {crumbly = 3}, + sounds = default.node_sound_sand_defaults(), +}) + +-- cook wet sponge into dry sponge +minetest.register_craft({ + type = "cooking", + recipe = "ethereal:sponge_wet", + output = "ethereal:sponge", + cooktime = 3, +}) + +-- use leaf decay to remove sponge air nodes +default.register_leafdecay({ + trunks = {"ethereal:sponge_wet"}, + leaves = {"ethereal:sponge_air"}, + radius = 3 +}) + +-- dry sponges can be used as fuel +minetest.register_craft({ + type = "fuel", + recipe = "ethereal:sponge", + burntime = 5, +}) diff --git a/textures/ethereal_sponge.png b/textures/ethereal_sponge.png new file mode 100644 index 0000000000000000000000000000000000000000..e739ec4c80fbf710b4e112a85f36e253435b722f GIT binary patch literal 272 zcmV+r0q_2aP)Q>zJl})J^X10PWkftwu!M;sDysySs%;u_6GV8w$JJ-O@e)6RQD8 ztK8l00IItbc$=^hEdYTU$BVVuV@?1Uceb=?%xB&JCwtx4yS=>K05yu;ip$;IeE>V$t={ed088E7Xx;AK69C(*-JRa;?)Cuax!c|D?*ISt WuTuxrm$BRc0000bZsHyoTw(knYK$n@h2S0001+ zNklQ_%yU!;x6z10RFnNj3Xk)VF1~?tEy8vaS{NK8wk7H%;GKp0g4hO zi`>rc0GYcZGd#j09sqF~vpd7pLM{Li60@>4%vJ6H5*p3KWv+If01+s>HE7Q5UH~Y& z%x9d&+{^&Hm&}~*hHlLO6eg|Be((MO02a>8W|{w=MF8A+?0Jp$fAs+NWy{L$|NsBI WAV)CsdvE6e0000