2021-03-12 20:05:47 +01:00
local S = minetest.get_translator ( minetest.get_current_modname ( ) )
local mod_mcl_core = minetest.get_modpath ( " mcl_core " )
local mod_mclx_core = minetest.get_modpath ( " mclx_core " )
2021-05-19 11:14:18 +02:00
local has_awards = minetest.get_modpath ( " awards " )
2021-03-12 20:05:47 +01:00
2021-03-17 16:56:46 +01:00
local sound_place = function ( itemname , pos )
local def = minetest.registered_nodes [ itemname ]
if def and def.sounds and def.sounds . place then
minetest.sound_play ( def.sounds . place , { gain = 1.0 , pos = pos , pitch = 1 + math.random ( - 10 , 10 ) * 0.005 } , true )
end
end
2021-05-23 00:32:04 +02:00
--[[local sound_take = function(itemname, pos)
2021-03-17 16:56:46 +01:00
local def = minetest.registered_nodes [ itemname ]
if def and def.sounds and def.sounds . dug then
minetest.sound_play ( def.sounds . dug , { gain = 1.0 , pos = pos , pitch = 1 + math.random ( - 10 , 10 ) * 0.005 } , true )
end
2021-05-23 00:32:04 +02:00
end ] ]
2021-03-17 16:56:46 +01:00
2021-03-12 20:05:47 +01:00
if mod_mcl_core then
-- Lava bucket
mcl_buckets.register_liquid ( {
source_place = function ( pos )
local dim = mcl_worlds.pos_to_dimension ( pos )
if dim == " nether " then
return " mcl_nether:nether_lava_source "
else
return " mcl_core:lava_source "
end
end ,
source_take = { " mcl_core:lava_source " , " mcl_nether:nether_lava_source " } ,
2021-05-19 11:14:18 +02:00
on_take = function ( user )
if has_awards and user and user : is_player ( ) then
awards.unlock ( user : get_player_name ( ) , " mcl:hotStuff " )
end
end ,
2021-03-12 20:05:47 +01:00
itemname = " mcl_buckets:bucket_lava " ,
inventory_image = " bucket_lava.png " ,
name = S ( " Lava Bucket " ) ,
longdesc = S ( " A bucket can be used to collect and release liquids. This one is filled with hot lava, safely contained inside. Use with caution. " ) ,
usagehelp = S ( " Get in a safe distance and place the bucket to empty it and create a lava source at this spot. Don't burn yourself! " ) ,
tt_help = S ( " Places a lava source " )
} )
-- Water bucket
mcl_buckets.register_liquid ( {
source_place = " mcl_core:water_source " ,
source_take = { " mcl_core:water_source " } ,
itemname = " mcl_buckets:bucket_water " ,
inventory_image = " bucket_water.png " ,
name = S ( " Water Bucket " ) ,
longdesc = S ( " A bucket can be used to collect and release liquids. This one is filled with water. " ) ,
usagehelp = S ( " Place it to empty the bucket and create a water source. " ) ,
tt_help = S ( " Places a water source " ) ,
extra_check = function ( pos , placer )
-- Check protection
local placer_name = " "
if placer ~= nil then
placer_name = placer : get_player_name ( )
end
if placer and minetest.is_protected ( pos , placer_name ) then
minetest.record_protection_violation ( pos , placer_name )
return false
end
local nn = minetest.get_node ( pos ) . name
-- Evaporate water if used in Nether (except on cauldron)
2021-10-25 00:37:43 +02:00
local dim = mcl_worlds.pos_to_dimension ( pos )
if dim == " nether " then
minetest.sound_play ( " fire_extinguish_flame " , { pos = pos , gain = 0.25 , max_hear_distance = 16 } , true )
return false
2021-03-12 20:05:47 +01:00
end
end ,
groups = { water_bucket = 1 } ,
2021-10-25 23:31:24 +02:00
-- TODO: this is getting clunkier by the commit, re-do handling of bucket/cauldron interaction (as a node callback, this function contains too many side effects).
2021-10-25 00:37:43 +02:00
_mcl_get_bucket_from_cauldron = function ( pos , placer )
2021-10-22 09:37:40 +02:00
local node = minetest.get_node ( pos )
if not mcl_cauldrons.is_cauldron ( node ) then
return nil
end
local placer_name = " "
if placer ~= nil then
placer_name = placer : get_player_name ( )
end
if placer and minetest.is_protected ( pos , placer_name ) then
minetest.record_protection_violation ( pos , placer_name )
return nil
end
local newnode = mcl_cauldrons.fill_levels ( node , mcl_cauldrons.BUCKETFUL , " cauldron_water " )
if newnode ~= node then
minetest.set_node ( pos , newnode )
sound_place ( " mcl_core:water_source " , pos )
return " mcl_buckets:bucket_water "
end
return nil
end ,
2021-03-12 20:05:47 +01:00
} )
end
if mod_mclx_core then
-- River water bucket
mcl_buckets.register_liquid ( {
source_place = " mclx_core:river_water_source " ,
source_take = { " mclx_core:river_water_source " } ,
itemname = " mcl_buckets:bucket_river_water " ,
inventory_image = " bucket_river_water.png " ,
name = S ( " River Water Bucket " ) ,
longdesc = S ( " A bucket can be used to collect and release liquids. This one is filled with river water. " ) ,
usagehelp = S ( " Place it to empty the bucket and create a river water source. " ) ,
tt_help = S ( " Places a river water source " ) ,
extra_check = function ( pos , placer )
-- Check protection
local placer_name = " "
if placer ~= nil then
placer_name = placer : get_player_name ( )
end
if placer and minetest.is_protected ( pos , placer_name ) then
minetest.record_protection_violation ( pos , placer_name )
return false
end
local nn = minetest.get_node ( pos ) . name
2021-10-25 00:37:43 +02:00
-- Evaporate water if used in Nether (except on cauldron)
local dim = mcl_worlds.pos_to_dimension ( pos )
if dim == " nether " then
minetest.sound_play ( " fire_extinguish_flame " , { pos = pos , gain = 0.25 , max_hear_distance = 16 } , true )
2021-03-12 20:05:47 +01:00
return false
end
end ,
groups = { water_bucket = 1 } ,
2021-10-25 00:37:43 +02:00
_mcl_get_bucket_from_cauldron = function ( pos , placer )
2021-10-22 09:37:40 +02:00
local node = minetest.get_node ( pos )
if not mcl_cauldrons.is_cauldron ( node ) then
return nil
end
local placer_name = " "
if placer ~= nil then
placer_name = placer : get_player_name ( )
end
if placer and minetest.is_protected ( pos , placer_name ) then
minetest.record_protection_violation ( pos , placer_name )
return nil
end
local newnode = mcl_cauldrons.fill_levels ( node , mcl_cauldrons.BUCKETFUL , " cauldron_river_water " )
if newnode ~= node then
minetest.set_node ( pos , newnode )
sound_place ( " mcl_core:water_source " , pos )
return " mcl_buckets:bucket_river_water "
end
return nil
end ,
2021-03-12 20:05:47 +01:00
} )
end
minetest.register_craft ( {
type = " fuel " ,
recipe = " mcl_buckets:bucket_lava " ,
burntime = 1000 ,
replacements = { { " mcl_buckets:bucket_lava " , " mcl_buckets:bucket_empty " } } ,
} )