Commit de707d0c authored by Milan's avatar Milan
Browse files

[PATCH (from upstream)] added sponges to coral reefs

parent 60f97d46
......@@ -146,19 +146,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 > 1 then
and sel == 6 then
if minetest.get_node(pos).name == "default:water_source" then
minetest.swap_node(pos, {name = "ethereal:sponge_wet"})
minetest.swap_node(pos, {name = "ethereal:coral" .. sel})
end
return
end
if nod == "default:water_source"
and sel > 1 then
minetest.swap_node(pos, {name = "ethereal:coral" .. sel})
return
end
......@@ -187,3 +192,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,
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment