7d1ffea1b5
Now anvils can be created using copper, bismuth bronze, black bronze, bronze, rose gold, wrought iron, steel, black steel.
77 lines
2.1 KiB
Lua
77 lines
2.1 KiB
Lua
buckets = {}
|
|
buckets.liquids = {}
|
|
|
|
function buckets.register_liquid(source, flowing, itemname, inventory_image)
|
|
|
|
buckets.liquids[source] = {
|
|
source = source,
|
|
flowing = flowing,
|
|
itemname = itemname,
|
|
}
|
|
buckets.liquids[flowing] = buckets.liquids[source]
|
|
|
|
if itemname ~= nil then
|
|
for i = 1,#metals.list do
|
|
minetest.register_craftitem(itemname.."_"..metals.list[i], {
|
|
inventory_image = "metals_"..metals.list[i].."_bucket.png^"..inventory_image,
|
|
stack_max = 1,
|
|
liquids_pointable = true,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
-- Must be pointing to node
|
|
if pointed_thing.type ~= "node" then
|
|
return
|
|
end
|
|
-- Check if pointing to a liquid
|
|
n = minetest.env:get_node(pointed_thing.under)
|
|
if buckets.liquids[n.name] == nil then
|
|
-- Not a liquid
|
|
--if minetest.env:get_node(pointed_thing.above) == "air" then
|
|
minetest.env:add_node(pointed_thing.above, {name=source})
|
|
-- end
|
|
elseif n.name ~= source then
|
|
-- It's a liquid
|
|
minetest.env:add_node(pointed_thing.under, {name=source})
|
|
end
|
|
return {name="metals:bucket_empty_"..metals.list[i]}
|
|
end
|
|
})
|
|
end
|
|
end
|
|
end
|
|
|
|
for i = 1,#metals.list do
|
|
minetest.register_craftitem("metals:bucket_empty_"..metals.list[i], {
|
|
description = "Emtpy " .. metals.desc_list[i] .. " Bucket",
|
|
inventory_image = "metals_"..metals.list[i].."_bucket.png",
|
|
stack_max = 1,
|
|
liquids_pointable = true,
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
-- Must be pointing to node
|
|
if pointed_thing.type ~= "node" then
|
|
return
|
|
end
|
|
-- Check if pointing to a liquid source
|
|
n = minetest.env:get_node(pointed_thing.under)
|
|
liquiddef = buckets.liquids[n.name]
|
|
if liquiddef ~= nil and liquiddef.source == n.name and liquiddef.itemname ~= nil then
|
|
minetest.env:add_node(pointed_thing.under, {name="air"})
|
|
return {name=liquiddef.itemname.."_"..metals.list[i]}
|
|
end
|
|
end,
|
|
})
|
|
end
|
|
|
|
buckets.register_liquid(
|
|
"default:water_source",
|
|
"default:water_flowing",
|
|
"metals:bucket_water",
|
|
"metals_water.png"
|
|
)
|
|
|
|
buckets.register_liquid(
|
|
"default:lava_source",
|
|
"default:lava_flowing",
|
|
"metals:bucket_lava",
|
|
"metals_lava.png"
|
|
)
|