This commit is contained in:
Evert Prants 2018-06-20 17:05:41 +03:00
parent 03ff573adb
commit 12867e4e5e
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 33 additions and 28 deletions

View File

@ -111,15 +111,18 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
-- Fill any fluid buffers if present
local place = true
if ndef.fluid_buffers then
local buffers = fluid_lib.get_node_buffers(lpos)
local ppos = pointed_thing.under
local buffers = fluid_lib.get_node_buffers(ppos)
if buffers then
for buffer in pairs(buffers) do
if fluid_lib.can_insert_into_buffer(lpos, buffer, source, 1000) == 1000 then
fluid_lib.insert_into_buffer(lpos, buffer, source, 1000)
if fluid_lib.can_insert_into_buffer(ppos, buffer, source, 1000) == 1000 then
fluid_lib.insert_into_buffer(ppos, buffer, source, 1000)
place = false
break
end
end
end
end
if place then
minetest.set_node(lpos, {name = source})
@ -222,7 +225,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
if check_protection(lpos, user
and user:get_player_name()
or "", "take "..source) then
or "", "take "..node.name) then
return
end
@ -231,6 +234,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
-- Remove fluid from buffers if present
if ndef.fluid_buffers then
local buffers = fluid_lib.get_node_buffers(lpos)
if buffers then
for buffer in pairs(buffers) do
if fluid_lib.can_take_from_buffer(lpos, buffer, 1000) == 1000 then
local fluid = fluid_lib.take_from_buffer(lpos, buffer, 1000)
@ -241,6 +245,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
end
end
end
end
return itemstack
end

View File

@ -69,7 +69,7 @@ end
function fluid_lib.can_insert_into_buffer(pos, buffer, fluid, count)
local bfdata = fluid_lib.get_buffer_data(pos, buffer)
if not bfdata then return 0 end
if bfdata.fluid ~= fluid and bfdata.fluid ~= "" then return 0 end
if not fluid_lib.buffer_accepts_fluid(pos, buffer, fluid) then return 0 end
local can_put = 0
if bfdata.amount + count > bfdata.capacity then