2021-05-29 16:12:33 +02:00
local S = minetest.get_translator ( minetest.get_current_modname ( ) )
2019-03-07 23:40:43 +01:00
2017-03-01 17:48:01 +01:00
-- Cauldron mod, adds cauldrons.
-- TODO: Extinguish fire of burning entities
-- Convenience function because the cauldron nodeboxes are very similar
2022-06-21 12:52:54 +02:00
local function create_cauldron_nodebox ( water_level )
2017-03-01 17:48:01 +01:00
local floor_y
if water_level == 0 then -- empty
floor_y = - 0.1875
elseif water_level == 1 then -- 1/3 filled
floor_y = 1 / 16
elseif water_level == 2 then -- 2/3 filled
floor_y = 4 / 16
elseif water_level == 3 then -- full
floor_y = 7 / 16
end
return {
2017-03-01 17:26:33 +01:00
type = " fixed " ,
fixed = {
{ - 0.5 , - 0.1875 , - 0.5 , - 0.375 , 0.5 , 0.5 } , -- Left wall
{ 0.375 , - 0.1875 , - 0.5 , 0.5 , 0.5 , 0.5 } , -- Right wall
{ - 0.375 , - 0.1875 , 0.375 , 0.375 , 0.5 , 0.5 } , -- Back wall
{ - 0.375 , - 0.1875 , - 0.5 , 0.375 , 0.5 , - 0.375 } , -- Front wall
2017-03-01 17:48:01 +01:00
{ - 0.5 , - 0.3125 , - 0.5 , 0.5 , floor_y , 0.5 } , -- Floor
2017-03-01 17:26:33 +01:00
{ - 0.5 , - 0.5 , - 0.5 , - 0.375 , - 0.3125 , - 0.25 } , -- Left front foot, part 1
{ - 0.375 , - 0.5 , - 0.5 , - 0.25 , - 0.3125 , - 0.375 } , -- Left front foot, part 2
{ - 0.5 , - 0.5 , 0.25 , - 0.375 , - 0.3125 , 0.5 } , -- Left back foot, part 1
{ - 0.375 , - 0.5 , 0.375 , - 0.25 , - 0.3125 , 0.5 } , -- Left back foot, part 2
{ 0.375 , - 0.5 , 0.25 , 0.5 , - 0.3125 , 0.5 } , -- Right back foot, part 1
{ 0.25 , - 0.5 , 0.375 , 0.375 , - 0.3125 , 0.5 } , -- Right back foot, part 2
{ 0.375 , - 0.5 , - 0.5 , 0.5 , - 0.3125 , - 0.25 } , -- Right front foot, part 1
{ 0.25 , - 0.5 , - 0.5 , 0.375 , - 0.3125 , - 0.375 } , -- Right front foot, part 2
}
2017-03-01 17:48:01 +01:00
}
end
-- Empty cauldron
minetest.register_node ( " mcl_cauldrons:cauldron " , {
2019-03-07 23:40:43 +01:00
description = S ( " Cauldron " ) ,
2020-02-19 04:54:17 +01:00
_tt_help = S ( " Stores water " ) ,
2023-05-12 00:39:49 +02:00
_doc_items_longdesc = S ( " Cauldrons are used to store water and slowly fill up under rain. They can also be used to wash off banners. " ) ,
_doc_items_usagehelp = S ( " Place a water bucket into the cauldron to fill it with water. Place an empty bucket on a full cauldron to retrieve the water. Place a water bottle into the cauldron to fill the cauldron to one third with water. Place a glass bottle in a cauldron with water to retrieve one third of the water. Use an emblazoned banner on a cauldron with water to wash off its top layer. " ) ,
2017-03-01 17:48:01 +01:00
wield_image = " mcl_cauldrons_cauldron.png " ,
inventory_image = " mcl_cauldrons_cauldron.png " ,
2021-02-18 14:00:17 +01:00
use_texture_alpha = minetest.features . use_texture_alpha_string_modes and " opaque " or false ,
2017-03-01 17:48:01 +01:00
drawtype = " nodebox " ,
paramtype = " light " ,
2017-03-11 16:36:05 +01:00
is_ground_content = false ,
2017-11-30 19:27:57 +01:00
groups = { pickaxey = 1 , deco_block = 1 , cauldron = 1 } ,
2022-06-21 12:52:54 +02:00
node_box = create_cauldron_nodebox ( 0 ) ,
2017-03-01 17:26:33 +01:00
selection_box = { type = " regular " } ,
tiles = {
" mcl_cauldrons_cauldron_inner.png^mcl_cauldrons_cauldron_top.png " ,
" mcl_cauldrons_cauldron_inner.png^mcl_cauldrons_cauldron_bottom.png " ,
" mcl_cauldrons_cauldron_side.png "
} ,
sounds = mcl_sounds.node_sound_metal_defaults ( ) ,
_mcl_hardness = 2 ,
2020-04-17 21:40:13 +02:00
_mcl_blast_resistance = 2 ,
2017-03-01 17:26:33 +01:00
} )
2017-03-01 17:48:01 +01:00
-- Template function for cauldrons with water
2022-06-21 12:58:19 +02:00
local function register_filled_cauldron ( water_level , description , liquid )
2017-11-30 19:27:57 +01:00
local id = " mcl_cauldrons:cauldron_ " .. water_level
local water_tex
2022-06-21 12:58:19 +02:00
if liquid == " river_water " then
2017-11-30 19:27:57 +01:00
id = id .. " r "
2023-11-03 00:47:26 +01:00
water_tex = " mcl_core_water_source_animation.png^[verticalframe:16:0^[multiply:#0084FF "
2022-06-21 12:58:19 +02:00
elseif liquid == " lava " then
id = id .. " _lava "
2023-11-03 00:47:26 +01:00
water_tex = " mcl_core_lava_source_animation.png^[verticalframe:16:0 "
2017-11-30 19:27:57 +01:00
else
2023-11-03 00:47:26 +01:00
water_tex = " mcl_core_water_source_animation.png^[verticalframe:16:0^[multiply:#3F76E4 "
2017-11-30 19:27:57 +01:00
end
minetest.register_node ( id , {
2017-03-01 17:48:01 +01:00
description = description ,
2017-03-02 19:53:53 +01:00
_doc_items_create_entry = false ,
2021-02-18 14:00:17 +01:00
use_texture_alpha = minetest.features . use_texture_alpha_string_modes and " opaque " or false ,
2017-03-01 17:48:01 +01:00
drawtype = " nodebox " ,
paramtype = " light " ,
2017-03-11 16:36:05 +01:00
is_ground_content = false ,
2021-01-17 12:29:25 +01:00
groups = { pickaxey = 1 , not_in_creative_inventory = 1 , cauldron = ( 1 + water_level ) , cauldron_filled = water_level , comparator_signal = water_level } ,
2022-06-21 12:52:54 +02:00
node_box = create_cauldron_nodebox ( water_level ) ,
collision_box = create_cauldron_nodebox ( 0 ) ,
2017-03-01 17:48:01 +01:00
selection_box = { type = " regular " } ,
tiles = {
2017-11-30 19:27:57 +01:00
" ( " .. water_tex .. " )^mcl_cauldrons_cauldron_top.png " ,
2017-03-01 17:48:01 +01:00
" mcl_cauldrons_cauldron_inner.png^mcl_cauldrons_cauldron_bottom.png " ,
" mcl_cauldrons_cauldron_side.png "
} ,
sounds = mcl_sounds.node_sound_metal_defaults ( ) ,
2017-03-01 19:07:50 +01:00
drop = " mcl_cauldrons:cauldron " ,
2017-03-01 17:48:01 +01:00
_mcl_hardness = 2 ,
2020-04-17 21:40:13 +02:00
_mcl_blast_resistance = 2 ,
2017-03-01 17:48:01 +01:00
} )
2017-03-20 18:12:05 +01:00
-- Add entry aliases for the Help
if minetest.get_modpath ( " doc " ) then
2017-11-30 19:27:57 +01:00
doc.add_entry_alias ( " nodes " , " mcl_cauldrons:cauldron " , " nodes " , id )
2017-03-20 18:12:05 +01:00
end
2017-03-01 17:48:01 +01:00
end
2017-11-30 19:27:57 +01:00
-- Filled cauldrons (3 levels)
2022-06-21 13:51:06 +02:00
for i = 1 , 3 do
register_filled_cauldron ( i , S ( " Cauldron ( " .. i .. " /3 Water) " ) )
register_filled_cauldron ( i , S ( " Cauldron ( " .. i .. " /3 Water) " ) , " lava " )
if minetest.get_modpath ( " mclx_core " ) then
register_filled_cauldron ( i , S ( " Cauldron ( " .. i .. " /3 Water) " ) , " river_water " )
end
2017-11-30 19:27:57 +01:00
end
2017-03-01 17:48:01 +01:00
2017-03-01 17:26:33 +01:00
minetest.register_craft ( {
output = " mcl_cauldrons:cauldron " ,
recipe = {
{ " mcl_core:iron_ingot " , " " , " mcl_core:iron_ingot " } ,
{ " mcl_core:iron_ingot " , " " , " mcl_core:iron_ingot " } ,
{ " mcl_core:iron_ingot " , " mcl_core:iron_ingot " , " mcl_core:iron_ingot " } ,
}
} )
2021-01-17 12:29:25 +01:00
2022-06-21 14:24:15 +02:00
local function cauldron_extinguish ( obj , pos )
local node = minetest.get_node ( pos )
if mcl_burning.is_burning ( obj ) then
mcl_burning.extinguish ( obj )
local new_group = minetest.get_item_group ( node.name , " cauldron_filled " ) - 1
minetest.swap_node ( pos , { name = " mcl_cauldrons:cauldron " .. ( new_group == 0 and " " or " _ " .. new_group ) } )
end
end
2022-06-22 11:56:25 +02:00
local etime = 0
2022-06-21 14:24:15 +02:00
minetest.register_globalstep ( function ( dtime )
2022-06-22 11:56:25 +02:00
etime = dtime + etime
if etime < 0.5 then return end
etime = 0
2022-06-21 14:24:15 +02:00
for _ , pl in pairs ( minetest.get_connected_players ( ) ) do
local n = minetest.find_node_near ( pl : get_pos ( ) , 0.4 , { " group:cauldron_filled " } , true )
if n and not minetest.get_node ( n ) . name : find ( " lava " ) then
cauldron_extinguish ( pl , n )
2022-06-22 11:56:25 +02:00
elseif n and minetest.get_node ( n ) . name : find ( " lava " ) then
mcl_burning.set_on_fire ( pl , 5 )
2022-06-21 14:24:15 +02:00
end
end
for _ , ent in pairs ( minetest.luaentities ) do
2022-06-22 11:56:25 +02:00
if ent.object : get_pos ( ) and ent.is_mob then
2022-06-21 14:24:15 +02:00
local n = minetest.find_node_near ( ent.object : get_pos ( ) , 0.4 , { " group:cauldron_filled " } , true )
if n and not minetest.get_node ( n ) . name : find ( " lava " ) then
cauldron_extinguish ( ent.object , n )
2022-06-22 11:56:25 +02:00
elseif n and minetest.get_node ( n ) . name : find ( " lava " ) then
mcl_burning.set_on_fire ( ent.object , 5 )
2021-01-17 12:29:25 +01:00
end
end
end
2022-06-21 14:24:15 +02:00
end )