1 -- Liquids: Water and lava
3 local S
= minetest
.get_translator("mcl_core")
4 local N
= function(s
) return s
end
6 local WATER_ALPHA
= 179
9 local LIGHT_LAVA
= minetest
.LIGHT_MAX
11 local lava_death_messages
= {
12 N("@1 melted in lava."),
13 N("@1 took a bath in a hot lava tub."),
14 N("@1 died in lava."),
15 N("@1 could not survive in lava."),
18 minetest
.register_node("mcl_core:water_flowing", {
19 description
= S("Flowing Water"),
20 _doc_items_create_entry
= false,
21 wield_image
= "default_water_flowing_animated.png^[verticalframe:64:0",
22 drawtype
= "flowingliquid",
23 tiles
= {"default_water_flowing_animated.png^[verticalframe:64:0"},
26 image
="default_water_flowing_animated.png",
27 backface_culling
=false,
28 animation
={type="vertical_frames", aspect_w
=16, aspect_h
=16, length
=4.0}
31 image
="default_water_flowing_animated.png",
32 backface_culling
=false,
33 animation
={type="vertical_frames", aspect_w
=16, aspect_h
=16, length
=4.0}
36 sounds
= mcl_sounds
.node_sound_water_defaults(),
37 is_ground_content
= false,
40 paramtype2
= "flowingliquid",
47 liquidtype
= "flowing",
48 liquid_alternative_flowing
= "mcl_core:water_flowing",
49 liquid_alternative_source
= "mcl_core:water_source",
50 liquid_viscosity
= WATER_VISC
,
52 post_effect_color
= {a
=209, r
=0x03, g
=0x3C, b
=0x5C},
53 groups
= { water
=3, liquid
=3, puts_out_fire
=1, not_in_creative_inventory
=1, freezes
=1, melt_around
=1, dig_by_piston
=1},
54 _mcl_blast_resistance
= 100,
55 -- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
59 minetest
.register_node("mcl_core:water_source", {
60 description
= S("Water Source"),
61 _doc_items_entry_name
= S("Water"),
63 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"..
64 S("Water interacts with lava in various ways:").."\n"..
65 S("• When water is directly above or horizontally next to a lava source, the lava turns into obsidian.").."\n"..
66 S("• When flowing water touches flowing lava either from above or horizontally, the lava turns into cobblestone.").."\n"..
67 S("• When water is directly below lava, the water turns into stone."),
68 _doc_items_hidden
= false,
71 {name
="default_water_source_animated.png", animation
={type="vertical_frames", aspect_w
=16, aspect_h
=16, length
=5.0}}
74 -- New-style water source material (mostly unused)
76 name
="default_water_source_animated.png",
77 animation
={type="vertical_frames", aspect_w
=16, aspect_h
=16, length
=5.0},
78 backface_culling
= false,
81 sounds
= mcl_sounds
.node_sound_water_defaults(),
82 is_ground_content
= false,
91 liquidtype
= "source",
92 liquid_alternative_flowing
= "mcl_core:water_flowing",
93 liquid_alternative_source
= "mcl_core:water_source",
94 liquid_viscosity
= WATER_VISC
,
96 post_effect_color
= {a
=209, r
=0x03, g
=0x3C, b
=0x5C},
98 groups
= { water
=3, liquid
=3, puts_out_fire
=1, freezes
=1, not_in_creative_inventory
=1, dig_by_piston
=1},
99 _mcl_blast_resistance
= 100,
100 -- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
104 minetest
.register_node("mcl_core:lava_flowing", {
105 description
= S("Flowing Lava"),
106 _doc_items_create_entry
= false,
107 wield_image
= "default_lava_flowing_animated.png^[verticalframe:64:0",
108 drawtype
= "flowingliquid",
109 tiles
= {"default_lava_flowing_animated.png^[verticalframe:64:0"},
112 image
="default_lava_flowing_animated.png",
113 backface_culling
=false,
114 animation
={type="vertical_frames", aspect_w
=16, aspect_h
=16, length
=6.6}
117 image
="default_lava_flowing_animated.png",
118 backface_culling
=false,
119 animation
={type="vertical_frames", aspect_w
=16, aspect_h
=16, length
=6.6}
123 paramtype2
= "flowingliquid",
124 light_source
= LIGHT_LAVA
,
125 is_ground_content
= false,
126 sounds
= mcl_sounds
.node_sound_lava_defaults(),
132 --[[ Drowning in Minecraft deals 2 damage per second.
133 In Minetest, drowning damage is dealt every 2 seconds so this
134 translates to 4 drowning damage ]]
136 liquidtype
= "flowing",
137 liquid_alternative_flowing
= "mcl_core:lava_flowing",
138 liquid_alternative_source
= "mcl_core:lava_source",
139 liquid_viscosity
= LAVA_VISC
,
140 liquid_renewable
= false,
142 damage_per_second
= 4*2,
143 _mcl_node_death_message
= lava_death_messages
,
144 post_effect_color
= {a
=245, r
=208, g
=73, b
=10},
145 groups
= { lava
=3, liquid
=2, destroys_items
=1, not_in_creative_inventory
=1, dig_by_piston
=1},
146 _mcl_blast_resistance
= 100,
147 -- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
152 local fire_enabled
= minetest
.settings
:get_bool("enable_fire", true)
154 fire_text
= S("A lava source sets fire to a couple of air blocks above when they're next to a flammable block.")
159 minetest
.register_node("mcl_core:lava_source", {
160 description
= S("Lava Source"),
161 _doc_items_entry_name
= "Lava",
162 _doc_items_longdesc
=
163 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"..
165 S("Lava interacts with water various ways:").."\n"..
166 S("• When a lava source is directly below or horizontally next to water, the lava turns into obsidian.").."\n"..
167 S("• When flowing water touches flowing lava either from above or horizontally, the lava turns into cobblestone.").."\n"..
168 S("• When lava is directly above water, the water turns into stone."),
171 {name
="default_lava_source_animated.png", animation
={type="vertical_frames", aspect_w
=16, aspect_h
=16, length
=3.0}}
174 -- New-style lava source material (mostly unused)
176 name
="default_lava_source_animated.png",
177 animation
={type="vertical_frames", aspect_w
=16, aspect_h
=16, length
=3.0},
178 backface_culling
= false,
182 light_source
= LIGHT_LAVA
,
183 is_ground_content
= false,
184 sounds
= mcl_sounds
.node_sound_lava_defaults(),
191 liquidtype
= "source",
192 liquid_alternative_flowing
= "mcl_core:lava_flowing",
193 liquid_alternative_source
= "mcl_core:lava_source",
194 liquid_viscosity
= LAVA_VISC
,
195 liquid_renewable
= false,
197 damage_per_second
= 4*2,
198 _mcl_node_death_message
= lava_death_messages
,
199 post_effect_color
= {a
=245, r
=208, g
=73, b
=10},
201 groups
= { lava
=3, lava_source
=1, liquid
=2, destroys_items
=1, not_in_creative_inventory
=1, dig_by_piston
=1},
202 _mcl_blast_resistance
= 100,
203 -- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode
207 local emit_lava_particle
= function(pos
)
208 local node
= minetest
.get_node(pos
)
209 if minetest
.get_item_group(node
.name
, "lava_source") == 0 then
212 local ppos
= vector
.add(pos
, { x
= math
.random(-7, 7)/16, y
= 0.45, z
= math
.random(-7, 7)/16})
213 local spos
= vector
.add(ppos
, { x
= 0, y
= -0.2, z
= 0 })
214 local vel
= { x
= math
.random(-3, 3)/10, y
= math
.random(4, 7), z
= math
.random(-3, 3)/10 }
215 local acc
= { x
= 0, y
= -9.81, z
= 0 }
217 minetest
.add_particle({
221 expirationtime
= 2.5,
222 collisiondetection
= true,
223 collision_removal
= true,
224 size
= math
.random(20, 30)/10,
225 texture
= "mcl_particles_lava.png",
230 if minetest
.settings
:get("mcl_node_particles") == "full" then
231 minetest
.register_abm({
232 label
= "Lava particles",
233 nodenames
= {"group:lava_source"},
236 action
= function(pos
, node
)
237 local apos
= {x
=pos
.x
, y
=pos
.y
+1, z
=pos
.z
}
238 local anode
= minetest
.get_node(apos
)
239 -- Only emit partiles when directly below lava
240 if anode
.name
~= "air" then
244 minetest
.after(math
.random(0, 800)*0.01, emit_lava_particle
, pos
)