forked from Mineclonia/Mineclonia
Sponges now regularily absorb water
This commit is contained in:
parent
6620ee91ae
commit
9a9fab87f7
|
@ -1,3 +1,21 @@
|
||||||
|
local absorb = function(pos)
|
||||||
|
local change = false
|
||||||
|
local p, n
|
||||||
|
for i=-3,3 do
|
||||||
|
for j=-3,3 do
|
||||||
|
for k=-3,3 do
|
||||||
|
p = {x=pos.x+i, y=pos.y+j, z=pos.z+k}
|
||||||
|
n = minetest.get_node(p)
|
||||||
|
if minetest.get_item_group(n.name, "water") ~= 0 then
|
||||||
|
minetest.add_node(p, {name="air"})
|
||||||
|
change = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return change
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("mcl_sponges:sponge", {
|
minetest.register_node("mcl_sponges:sponge", {
|
||||||
description = "Sponge",
|
description = "Sponge",
|
||||||
drawtype = "normal",
|
drawtype = "normal",
|
||||||
|
@ -28,57 +46,27 @@ minetest.register_node("mcl_sponges:sponge", {
|
||||||
if minetest.is_protected(pointed_thing.above, pn) then
|
if minetest.is_protected(pointed_thing.above, pn) then
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
local change = false
|
|
||||||
local on_water = false
|
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
local nn = minetest.get_node(pointed_thing.above).name
|
local on_water = false
|
||||||
if minetest.get_item_group(nn, "water") ~= 0 then
|
if minetest.get_item_group(minetest.get_node(pos).name, "water") ~= 0 then
|
||||||
on_water = true
|
on_water = true
|
||||||
end
|
end
|
||||||
for i=-1,1 do
|
local water_found = minetest.find_node_near(pos, 1, "group:water")
|
||||||
local p = {x=pos.x+i, y=pos.y, z=pos.z}
|
if water_found ~= nil then
|
||||||
local n = minetest.get_node(p)
|
on_water = true
|
||||||
if minetest.get_item_group(n.name, "water") ~= 0 then
|
|
||||||
on_water = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
for i=-1,1 do
|
if on_water then
|
||||||
local p = {x=pos.x, y=pos.y+i, z=pos.z}
|
-- Absorb water
|
||||||
local n = minetest.get_node(p)
|
if absorb(pos) then
|
||||||
if minetest.get_item_group(n.name, "water") ~= 0 then
|
minetest.item_place_node(ItemStack("mcl_sponges:sponge_wet"), placer, pointed_thing)
|
||||||
on_water = true
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
end
|
itemstack:take_item()
|
||||||
end
|
|
||||||
for i=-1,1 do
|
|
||||||
local p = {x=pos.x, y=pos.y, z=pos.z+i}
|
|
||||||
local n = minetest.get_node(p)
|
|
||||||
if minetest.get_item_group(n.name, "water") ~= 0 then
|
|
||||||
on_water = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local p, n
|
|
||||||
if on_water == true then
|
|
||||||
for i=-3,3 do
|
|
||||||
for j=-3,3 do
|
|
||||||
for k=-3,3 do
|
|
||||||
p = {x=pos.x+i, y=pos.y+j, z=pos.z+k}
|
|
||||||
n = minetest.get_node(p)
|
|
||||||
if minetest.get_item_group(n.name, "water") ~= 0 then
|
|
||||||
minetest.add_node(p, {name="air"})
|
|
||||||
change = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
p = {x=pos.x, y=pos.y, z=pos.z}
|
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
n = minetest.get_node(p)
|
|
||||||
if change == true then
|
|
||||||
minetest.add_node(pointed_thing.above, {name = "mcl_sponges:sponge_wet"})
|
|
||||||
else
|
|
||||||
minetest.add_node(pointed_thing.above, {name = "mcl_sponges:sponge"})
|
|
||||||
end
|
|
||||||
return itemstack
|
|
||||||
end,
|
end,
|
||||||
_mcl_blast_resistance = 3,
|
_mcl_blast_resistance = 3,
|
||||||
_mcl_hardness = 0.6,
|
_mcl_hardness = 0.6,
|
||||||
|
@ -108,3 +96,15 @@ minetest.register_craft({
|
||||||
cooktime = 10,
|
cooktime = 10,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
label = "Sponge water absorbtion",
|
||||||
|
nodenames = { "mcl_sponges:sponge" },
|
||||||
|
neighbors = { "group:water" },
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos)
|
||||||
|
if absorb(pos) then
|
||||||
|
minetest.add_node(pos, {name = "mcl_sponges:sponge_wet"})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
|
@ -26,7 +26,6 @@ local wip_items = {
|
||||||
"mcl_mobitems:rotten_flesh",
|
"mcl_mobitems:rotten_flesh",
|
||||||
"mcl_mobitems:spider_eye",
|
"mcl_mobitems:spider_eye",
|
||||||
"mcl_minecarts:golden_rail",
|
"mcl_minecarts:golden_rail",
|
||||||
"mcl_sponges:sponge",
|
|
||||||
"mcl_mushrooms:mushroom_red",
|
"mcl_mushrooms:mushroom_red",
|
||||||
"mcl_mushrooms:mushroom_brown",
|
"mcl_mushrooms:mushroom_brown",
|
||||||
"gemalde:node_1",
|
"gemalde:node_1",
|
||||||
|
|
Loading…
Reference in New Issue