forked from VoxeLibre/VoxeLibre
WIP
This commit is contained in:
parent
14c19c915f
commit
75689afdb4
|
@ -67,15 +67,18 @@ function mcl_sponges.absorb(pos)
|
|||
-- to determine the wet sponge type.
|
||||
local out = {}
|
||||
local p, n
|
||||
local count = 0
|
||||
for i=-3,3 do
|
||||
for j=-3,3 do
|
||||
for k=-3,3 do
|
||||
count = count + 1
|
||||
pos = {x=pos.x+i, y=pos.y+j, z=pos.z+k}
|
||||
node = minetest.get_node(pos)
|
||||
for name,def in pairs(mcl_sponges.registered_sponges) do
|
||||
if minetest.get_item_group(node.name, def.liquidgroup) ~= 0 then
|
||||
minetest.add_node(pos, {name="air"})
|
||||
change = true
|
||||
if not out[name] then out[name] = 0 end
|
||||
out[name] = out[name]+1
|
||||
break
|
||||
end
|
||||
|
@ -83,13 +86,22 @@ function mcl_sponges.absorb(pos)
|
|||
end
|
||||
end
|
||||
end
|
||||
minetest.chat_send_all(count)
|
||||
-- The dominant water type wins. In case of a tie, normal water wins.
|
||||
-- This slight bias is intentional.
|
||||
local sponge_type
|
||||
if river_water > non_river_water then
|
||||
sponge_type = "mcl_sponges:sponge_wet_river_water"
|
||||
local biggest
|
||||
for name, number in pairs(out) do
|
||||
if biggest then
|
||||
if biggest < number then
|
||||
sponge_type = name
|
||||
biggest = number
|
||||
end
|
||||
else
|
||||
sponge_type = "mcl_sponges:sponge_wet"
|
||||
sponge_type = name
|
||||
biggest = number
|
||||
end
|
||||
|
||||
end
|
||||
return change, sponge_type
|
||||
end
|
||||
|
@ -263,7 +275,7 @@ minetest.register_abm({
|
|||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
local absorbed, wet_sponge = absorb(pos)
|
||||
local absorbed, wet_sponge = mcl_sponges.absorb(pos)
|
||||
if absorbed then
|
||||
minetest.add_node(pos, {name = wet_sponge})
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue