0
0
Fork 0

Dispensers dispense water buckets into cauldrons

This commit is contained in:
Wuzzy 2017-11-30 21:08:28 +01:00
parent 74d5da78a1
commit 785b4a2ef7
1 changed files with 20 additions and 6 deletions

View File

@ -63,11 +63,7 @@ local dispenserdef = {
droppos = {x=pos.x, y=pos.y-1, z=pos.z} droppos = {x=pos.x, y=pos.y-1, z=pos.z}
end end
local dropnode = minetest.get_node(droppos) local dropnode = minetest.get_node(droppos)
-- Do not dispense into solid nodes
local dropnodedef = minetest.registered_nodes[dropnode.name] local dropnodedef = minetest.registered_nodes[dropnode.name]
if dropnodedef.walkable then
return
end
local stacks = {} local stacks = {}
for i=1,inv:get_size("main") do for i=1,inv:get_size("main") do
local stack = inv:get_stack("main", i) local stack = inv:get_stack("main", i)
@ -83,8 +79,12 @@ local dispenserdef = {
local iname = stack:get_name() local iname = stack:get_name()
local igroups = minetest.registered_items[iname].groups local igroups = minetest.registered_items[iname].groups
-- Do not dispense into solid nodes. Exception: Water bucket into cauldron
if dropnodedef.walkable and not (minetest.get_item_group(dropnode.name, "cauldron") ~= 0 and (iname == "mcl_buckets:bucket_water" or iname == "mcl_buckets:bucket_river_water")) then
-- no-op
--[===[ Dispense item ]===] --[===[ Dispense item ]===]
if iname == "mcl_throwing:arrow" then elseif iname == "mcl_throwing:arrow" then
-- Shoot arrow -- Shoot arrow
local shootpos = vector.add(pos, vector.multiply(dropdir, 0.51)) local shootpos = vector.add(pos, vector.multiply(dropdir, 0.51))
local yaw = math.atan2(dropdir.z, dropdir.x) - math.pi/2 local yaw = math.atan2(dropdir.z, dropdir.x) - math.pi/2
@ -174,8 +174,17 @@ local dispenserdef = {
inv:set_stack("main", stack_id, stack) inv:set_stack("main", stack_id, stack)
end end
elseif iname == "mcl_buckets:bucket_water" or iname == "mcl_buckets:bucket_river_water" or iname == "mcl_buckets:bucket_lava" then elseif iname == "mcl_buckets:bucket_water" or iname == "mcl_buckets:bucket_river_water" or iname == "mcl_buckets:bucket_lava" then
local do_empty = false
-- Place water/lava source -- Place water/lava source
if dropnodedef.buildable_to then if minetest.get_item_group(dropnode.name, "cauldron") ~= 0 then
if iname == "mcl_buckets:bucket_water" then
minetest.set_node(droppos, {name = "mcl_cauldrons:cauldron_3"})
do_empty = true
elseif iname == "mcl_buckets:bucket_river_water" then
minetest.set_node(droppos, {name = "mcl_cauldrons:cauldron_3r"})
do_empty = true
end
elseif dropnodedef.buildable_to then
local dim = mcl_worlds.pos_to_dimension(droppos) local dim = mcl_worlds.pos_to_dimension(droppos)
if iname == "mcl_buckets:bucket_water" then if iname == "mcl_buckets:bucket_water" then
if dim == "nether" then if dim == "nether" then
@ -183,20 +192,25 @@ local dispenserdef = {
else else
minetest.set_node(droppos, {name = "mcl_core:water_source"}) minetest.set_node(droppos, {name = "mcl_core:water_source"})
end end
do_empty = true
elseif iname == "mcl_buckets:bucket_river_water" then elseif iname == "mcl_buckets:bucket_river_water" then
if dim == "nether" then if dim == "nether" then
minetest.sound_play("fire_extinguish_flame", {pos = droppos, gain = 0.25, max_hear_distance = 16}) minetest.sound_play("fire_extinguish_flame", {pos = droppos, gain = 0.25, max_hear_distance = 16})
else else
minetest.set_node(droppos, {name = "mclx_core:river_water_source"}) minetest.set_node(droppos, {name = "mclx_core:river_water_source"})
end end
do_empty = true
elseif iname == "mcl_buckets:bucket_lava" then elseif iname == "mcl_buckets:bucket_lava" then
if dim == "nether" then if dim == "nether" then
minetest.set_node(droppos, {name = "mcl_nether:nether_lava_source"}) minetest.set_node(droppos, {name = "mcl_nether:nether_lava_source"})
else else
minetest.set_node(droppos, {name = "mcl_core:lava_source"}) minetest.set_node(droppos, {name = "mcl_core:lava_source"})
end end
do_empty = true
end
end end
if do_empty then
stack:take_item() stack:take_item()
inv:set_stack("main", stack_id, stack) inv:set_stack("main", stack_id, stack)