2017-07-07 17:52:28 +03:00
-- Liquids: Water and lava
2021-05-29 17:12:33 +03:00
local S = minetest.get_translator ( minetest.get_current_modname ( ) )
2019-03-08 01:40:43 +03:00
2021-05-23 01:09:07 +03:00
local vector = vector
local math = math
--local WATER_ALPHA = 179
2017-07-07 17:52:28 +03:00
local WATER_VISC = 1
local LAVA_VISC = 7
2020-08-19 21:17:04 +03:00
local LIGHT_LAVA = minetest.LIGHT_MAX
2021-04-02 15:12:44 +03:00
local USE_TEXTURE_ALPHA = true
2021-02-18 12:58:50 +03:00
if minetest.features . use_texture_alpha_string_modes then
USE_TEXTURE_ALPHA = " blend "
end
2017-07-07 17:52:28 +03:00
minetest.register_node ( " mcl_core:water_flowing " , {
2019-03-08 01:40:43 +03:00
description = S ( " Flowing Water " ) ,
2017-07-07 17:52:28 +03:00
_doc_items_create_entry = false ,
2017-07-17 13:20:15 +03:00
wield_image = " default_water_flowing_animated.png^[verticalframe:64:0 " ,
2017-07-07 17:52:28 +03:00
drawtype = " flowingliquid " ,
2017-07-17 13:20:15 +03:00
tiles = { " default_water_flowing_animated.png^[verticalframe:64:0 " } ,
2017-07-07 17:52:28 +03:00
special_tiles = {
{
image = " default_water_flowing_animated.png " ,
backface_culling = false ,
2017-07-17 13:20:15 +03:00
animation = { type = " vertical_frames " , aspect_w = 16 , aspect_h = 16 , length = 4.0 }
2017-07-07 17:52:28 +03:00
} ,
{
image = " default_water_flowing_animated.png " ,
2020-01-20 00:56:37 +03:00
backface_culling = false ,
2017-07-17 13:20:15 +03:00
animation = { type = " vertical_frames " , aspect_w = 16 , aspect_h = 16 , length = 4.0 }
2017-07-07 17:52:28 +03:00
} ,
} ,
2018-01-12 04:26:12 +03:00
sounds = mcl_sounds.node_sound_water_defaults ( ) ,
2020-06-07 22:32:55 +03:00
is_ground_content = false ,
2021-02-18 12:58:50 +03:00
use_texture_alpha = USE_TEXTURE_ALPHA ,
2017-07-07 17:52:28 +03:00
paramtype = " light " ,
paramtype2 = " flowingliquid " ,
walkable = false ,
pointable = false ,
diggable = false ,
buildable_to = true ,
drop = " " ,
drowning = 4 ,
liquidtype = " flowing " ,
liquid_alternative_flowing = " mcl_core:water_flowing " ,
liquid_alternative_source = " mcl_core:water_source " ,
liquid_viscosity = WATER_VISC ,
liquid_range = 7 ,
2022-08-12 16:11:17 +03:00
waving = 3 ,
2023-01-27 18:49:58 +03:00
post_effect_color = { a = 60 , r = 0x03 , g = 0x3C , b = 0x5C } ,
2017-07-07 17:52:28 +03:00
groups = { water = 3 , liquid = 3 , puts_out_fire = 1 , not_in_creative_inventory = 1 , freezes = 1 , melt_around = 1 , dig_by_piston = 1 } ,
2020-04-15 14:27:29 +03:00
_mcl_blast_resistance = 100 ,
2017-07-07 17:52:28 +03:00
-- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
_mcl_hardness = - 1 ,
} )
minetest.register_node ( " mcl_core:water_source " , {
2019-03-08 01:40:43 +03:00
description = S ( " Water Source " ) ,
_doc_items_entry_name = S ( " Water " ) ,
2017-07-07 17:52:28 +03:00
_doc_items_longdesc =
2019-03-24 10:03:50 +03:00
S ( " Water is abundant in oceans and also appears in a few springs in the ground. You can swim easily in water, but you need to catch your breath from time to time. " ) .. " \n \n " ..
S ( " Water interacts with lava in various ways: " ) .. " \n " ..
S ( " • When water is directly above or horizontally next to a lava source, the lava turns into obsidian. " ) .. " \n " ..
S ( " • When flowing water touches flowing lava either from above or horizontally, the lava turns into cobblestone. " ) .. " \n " ..
S ( " • When water is directly below lava, the water turns into stone. " ) ,
2017-07-07 17:52:28 +03:00
_doc_items_hidden = false ,
drawtype = " liquid " ,
2022-08-12 16:11:17 +03:00
waving = 3 ,
2017-07-07 17:52:28 +03:00
tiles = {
2017-07-17 13:20:15 +03:00
{ name = " default_water_source_animated.png " , animation = { type = " vertical_frames " , aspect_w = 16 , aspect_h = 16 , length = 5.0 } }
2017-07-07 17:52:28 +03:00
} ,
special_tiles = {
-- New-style water source material (mostly unused)
{
name = " default_water_source_animated.png " ,
2017-07-17 13:20:15 +03:00
animation = { type = " vertical_frames " , aspect_w = 16 , aspect_h = 16 , length = 5.0 } ,
2017-07-07 17:52:28 +03:00
backface_culling = false ,
}
} ,
2018-01-12 04:26:12 +03:00
sounds = mcl_sounds.node_sound_water_defaults ( ) ,
2020-06-07 22:32:55 +03:00
is_ground_content = false ,
2021-02-18 12:58:50 +03:00
use_texture_alpha = USE_TEXTURE_ALPHA ,
2017-07-07 17:52:28 +03:00
paramtype = " light " ,
walkable = false ,
pointable = false ,
diggable = false ,
buildable_to = true ,
drop = " " ,
drowning = 4 ,
liquidtype = " source " ,
liquid_alternative_flowing = " mcl_core:water_flowing " ,
liquid_alternative_source = " mcl_core:water_source " ,
liquid_viscosity = WATER_VISC ,
liquid_range = 7 ,
2022-11-15 01:43:13 +03:00
post_effect_color = { a = 60 , r = 0x03 , g = 0x3C , b = 0x5C } ,
2017-07-07 17:52:28 +03:00
stack_max = 64 ,
groups = { water = 3 , liquid = 3 , puts_out_fire = 1 , freezes = 1 , not_in_creative_inventory = 1 , dig_by_piston = 1 } ,
2020-04-15 14:27:29 +03:00
_mcl_blast_resistance = 100 ,
2017-07-07 17:52:28 +03:00
-- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
_mcl_hardness = - 1 ,
} )
minetest.register_node ( " mcl_core:lava_flowing " , {
2019-03-08 01:40:43 +03:00
description = S ( " Flowing Lava " ) ,
2017-07-07 17:52:28 +03:00
_doc_items_create_entry = false ,
2017-07-17 13:20:15 +03:00
wield_image = " default_lava_flowing_animated.png^[verticalframe:64:0 " ,
2017-07-07 17:52:28 +03:00
drawtype = " flowingliquid " ,
2017-07-17 13:20:15 +03:00
tiles = { " default_lava_flowing_animated.png^[verticalframe:64:0 " } ,
2017-07-07 17:52:28 +03:00
special_tiles = {
{
image = " default_lava_flowing_animated.png " ,
backface_culling = false ,
2017-07-17 13:20:15 +03:00
animation = { type = " vertical_frames " , aspect_w = 16 , aspect_h = 16 , length = 6.6 }
2017-07-07 17:52:28 +03:00
} ,
{
image = " default_lava_flowing_animated.png " ,
2020-01-20 00:56:37 +03:00
backface_culling = false ,
2017-07-17 13:20:15 +03:00
animation = { type = " vertical_frames " , aspect_w = 16 , aspect_h = 16 , length = 6.6 }
2017-07-07 17:52:28 +03:00
} ,
} ,
2019-02-01 08:23:12 +03:00
paramtype = " light " ,
2017-07-07 17:52:28 +03:00
paramtype2 = " flowingliquid " ,
2020-08-19 21:17:04 +03:00
light_source = LIGHT_LAVA ,
2020-06-07 22:32:55 +03:00
is_ground_content = false ,
2018-01-12 04:26:12 +03:00
sounds = mcl_sounds.node_sound_lava_defaults ( ) ,
2017-07-07 17:52:28 +03:00
walkable = false ,
pointable = false ,
diggable = false ,
buildable_to = true ,
drop = " " ,
--[[ Drowning in Minecraft deals 2 damage per second.
In Minetest , drowning damage is dealt every 2 seconds so this
translates to 4 drowning damage ] ]
drowning = 4 ,
liquidtype = " flowing " ,
liquid_alternative_flowing = " mcl_core:lava_flowing " ,
liquid_alternative_source = " mcl_core:lava_source " ,
liquid_viscosity = LAVA_VISC ,
liquid_renewable = false ,
liquid_range = 3 ,
damage_per_second = 4 * 2 ,
2020-07-01 01:56:27 +03:00
post_effect_color = { a = 245 , r = 208 , g = 73 , b = 10 } ,
2021-01-01 21:25:47 +03:00
groups = { lava = 3 , liquid = 2 , destroys_items = 1 , not_in_creative_inventory = 1 , dig_by_piston = 1 , set_on_fire = 15 } ,
2020-04-15 14:27:29 +03:00
_mcl_blast_resistance = 100 ,
2017-07-07 17:52:28 +03:00
-- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
_mcl_hardness = - 1 ,
} )
2019-04-09 16:25:27 +03:00
local fire_text
local fire_enabled = minetest.settings : get_bool ( " enable_fire " , true )
if fire_enabled then
fire_text = S ( " A lava source sets fire to a couple of air blocks above when they're next to a flammable block. " )
else
fire_text = " "
end
2017-07-07 17:52:28 +03:00
minetest.register_node ( " mcl_core:lava_source " , {
2019-03-08 01:40:43 +03:00
description = S ( " Lava Source " ) ,
2017-07-07 17:52:28 +03:00
_doc_items_entry_name = " Lava " ,
_doc_items_longdesc =
2019-03-08 01:40:43 +03:00
S ( " Lava is hot and rather dangerous. Don't touch it, it will hurt you a lot and it is hard to get out. " ) .. " \n " ..
2019-04-09 16:25:27 +03:00
fire_text .. " \n \n " ..
2019-03-24 10:03:50 +03:00
S ( " Lava interacts with water various ways: " ) .. " \n " ..
S ( " • When a lava source is directly below or horizontally next to water, the lava turns into obsidian. " ) .. " \n " ..
S ( " • When flowing water touches flowing lava either from above or horizontally, the lava turns into cobblestone. " ) .. " \n " ..
S ( " • When lava is directly above water, the water turns into stone. " ) ,
2017-07-07 17:52:28 +03:00
drawtype = " liquid " ,
tiles = {
{ name = " default_lava_source_animated.png " , animation = { type = " vertical_frames " , aspect_w = 16 , aspect_h = 16 , length = 3.0 } }
} ,
special_tiles = {
-- New-style lava source material (mostly unused)
{
name = " default_lava_source_animated.png " ,
2017-07-17 13:20:15 +03:00
animation = { type = " vertical_frames " , aspect_w = 16 , aspect_h = 16 , length = 3.0 } ,
2017-07-07 17:52:28 +03:00
backface_culling = false ,
}
} ,
2019-02-01 08:23:12 +03:00
paramtype = " light " ,
2020-08-19 21:17:04 +03:00
light_source = LIGHT_LAVA ,
2020-06-07 22:32:55 +03:00
is_ground_content = false ,
2018-01-12 04:26:12 +03:00
sounds = mcl_sounds.node_sound_lava_defaults ( ) ,
2017-07-07 17:52:28 +03:00
walkable = false ,
pointable = false ,
diggable = false ,
buildable_to = true ,
drop = " " ,
drowning = 4 ,
liquidtype = " source " ,
liquid_alternative_flowing = " mcl_core:lava_flowing " ,
liquid_alternative_source = " mcl_core:lava_source " ,
liquid_viscosity = LAVA_VISC ,
liquid_renewable = false ,
liquid_range = 3 ,
damage_per_second = 4 * 2 ,
2020-07-01 01:56:27 +03:00
post_effect_color = { a = 245 , r = 208 , g = 73 , b = 10 } ,
2017-07-07 17:52:28 +03:00
stack_max = 64 ,
2021-04-14 16:46:52 +03:00
groups = { lava = 3 , lava_source = 1 , liquid = 2 , destroys_items = 1 , not_in_creative_inventory = 1 , dig_by_piston = 1 , set_on_fire = 15 , fire_damage = 1 } ,
2020-04-15 14:27:29 +03:00
_mcl_blast_resistance = 100 ,
2017-07-07 17:52:28 +03:00
-- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
_mcl_hardness = - 1 ,
} )
2020-08-19 21:17:04 +03:00
2021-05-26 20:57:43 +03:00
local function emit_lava_particle ( pos )
2020-08-19 21:17:04 +03:00
local node = minetest.get_node ( pos )
if minetest.get_item_group ( node.name , " lava_source " ) == 0 then
return
end
local ppos = vector.add ( pos , { x = math.random ( - 7 , 7 ) / 16 , y = 0.45 , z = math.random ( - 7 , 7 ) / 16 } )
2021-05-23 01:09:07 +03:00
--local spos = vector.add(ppos, { x = 0, y = -0.2, z = 0 })
2020-08-19 21:17:04 +03:00
local vel = { x = math.random ( - 3 , 3 ) / 10 , y = math.random ( 4 , 7 ) , z = math.random ( - 3 , 3 ) / 10 }
local acc = { x = 0 , y = - 9.81 , z = 0 }
-- Lava droplet
minetest.add_particle ( {
pos = ppos ,
velocity = vel ,
acceleration = acc ,
expirationtime = 2.5 ,
collisiondetection = true ,
collision_removal = true ,
size = math.random ( 20 , 30 ) / 10 ,
texture = " mcl_particles_lava.png " ,
glow = LIGHT_LAVA ,
} )
end
2020-08-19 21:39:05 +03:00
if minetest.settings : get ( " mcl_node_particles " ) == " full " then
2020-08-19 21:17:04 +03:00
minetest.register_abm ( {
label = " Lava particles " ,
nodenames = { " group:lava_source " } ,
interval = 8.0 ,
chance = 20 ,
action = function ( pos , node )
local apos = { x = pos.x , y = pos.y + 1 , z = pos.z }
local anode = minetest.get_node ( apos )
-- Only emit partiles when directly below lava
if anode.name ~= " air " then
return
end
minetest.after ( math.random ( 0 , 800 ) * 0.01 , emit_lava_particle , pos )
end ,
} )
end