mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 04:21:07 +01:00
Sponges now regularily absorb water
This commit is contained in:
parent
6620ee91ae
commit
9a9fab87f7
2 changed files with 44 additions and 45 deletions
|
@ -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)
|
|
||||||
if minetest.get_item_group(n.name, "water") ~= 0 then
|
|
||||||
on_water = true
|
on_water = true
|
||||||
end
|
end
|
||||||
end
|
if on_water then
|
||||||
for i=-1,1 do
|
-- Absorb water
|
||||||
local p = {x=pos.x, y=pos.y+i, z=pos.z}
|
if absorb(pos) then
|
||||||
local n = minetest.get_node(p)
|
minetest.item_place_node(ItemStack("mcl_sponges:sponge_wet"), placer, pointed_thing)
|
||||||
if minetest.get_item_group(n.name, "water") ~= 0 then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
on_water = true
|
itemstack:take_item()
|
||||||
end
|
|
||||||
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
|
|
||||||
end
|
|
||||||
p = {x=pos.x, y=pos.y, z=pos.z}
|
|
||||||
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
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
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 a new issue