Disable some demanding particles by default
[MineClone/MineClone2.git] / mods / ITEMS / mcl_core / nodes_liquid.lua
blob57b3e588f5c183542d6df856bad6de641fa64513
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
7 local WATER_VISC = 1
8 local LAVA_VISC = 7
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"},
24 special_tiles = {
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,
38 alpha = WATER_ALPHA,
39 paramtype = "light",
40 paramtype2 = "flowingliquid",
41 walkable = false,
42 pointable = false,
43 diggable = false,
44 buildable_to = true,
45 drop = "",
46 drowning = 4,
47 liquidtype = "flowing",
48 liquid_alternative_flowing = "mcl_core:water_flowing",
49 liquid_alternative_source = "mcl_core:water_source",
50 liquid_viscosity = WATER_VISC,
51 liquid_range = 7,
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
56 _mcl_hardness = -1,
59 minetest.register_node("mcl_core:water_source", {
60 description = S("Water Source"),
61 _doc_items_entry_name = S("Water"),
62 _doc_items_longdesc =
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,
69 drawtype = "liquid",
70 tiles = {
71 {name="default_water_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=5.0}}
73 special_tiles = {
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,
83 alpha = WATER_ALPHA,
84 paramtype = "light",
85 walkable = false,
86 pointable = false,
87 diggable = false,
88 buildable_to = true,
89 drop = "",
90 drowning = 4,
91 liquidtype = "source",
92 liquid_alternative_flowing = "mcl_core:water_flowing",
93 liquid_alternative_source = "mcl_core:water_source",
94 liquid_viscosity = WATER_VISC,
95 liquid_range = 7,
96 post_effect_color = {a=209, r=0x03, g=0x3C, b=0x5C},
97 stack_max = 64,
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
101 _mcl_hardness = -1,
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"},
110 special_tiles = {
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}
122 paramtype = "light",
123 paramtype2 = "flowingliquid",
124 light_source = LIGHT_LAVA,
125 is_ground_content = false,
126 sounds = mcl_sounds.node_sound_lava_defaults(),
127 walkable = false,
128 pointable = false,
129 diggable = false,
130 buildable_to = true,
131 drop = "",
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 ]]
135 drowning = 4,
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,
141 liquid_range = 3,
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
148 _mcl_hardness = -1,
151 local fire_text
152 local fire_enabled = minetest.settings:get_bool("enable_fire", true)
153 if fire_enabled then
154 fire_text = S("A lava source sets fire to a couple of air blocks above when they're next to a flammable block.")
155 else
156 fire_text = ""
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"..
164 fire_text.."\n\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."),
169 drawtype = "liquid",
170 tiles = {
171 {name="default_lava_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}}
173 special_tiles = {
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,
181 paramtype = "light",
182 light_source = LIGHT_LAVA,
183 is_ground_content = false,
184 sounds = mcl_sounds.node_sound_lava_defaults(),
185 walkable = false,
186 pointable = false,
187 diggable = false,
188 buildable_to = true,
189 drop = "",
190 drowning = 4,
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,
196 liquid_range = 3,
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},
200 stack_max = 64,
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
204 _mcl_hardness = -1,
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
210 return
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 }
216 -- Lava droplet
217 minetest.add_particle({
218 pos = ppos,
219 velocity = vel,
220 acceleration = acc,
221 expirationtime = 2.5,
222 collisiondetection = true,
223 collision_removal = true,
224 size = math.random(20, 30)/10,
225 texture = "mcl_particles_lava.png",
226 glow = LIGHT_LAVA,
230 if minetest.settings:get("mcl_node_particles") == "full" then
231 minetest.register_abm({
232 label = "Lava particles",
233 nodenames = {"group:lava_source"},
234 interval = 8.0,
235 chance = 20,
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
241 return
244 minetest.after(math.random(0, 800)*0.01, emit_lava_particle, pos)
245 end,