Add nil checks for placer
[oweals/minetest_game.git] / mods / default / nodes.lua
1 -- mods/default/nodes.lua
2
3
4 --[[ Node name convention:
5
6 Although many node names are in combined-word form, the required form for new
7 node names is words separated by underscores. If both forms are used in written
8 language (for example pinewood and pine wood) the underscore form should be used.
9
10 --]]
11
12
13 --[[ Index:
14
15 Stone
16 -----
17 (1. Material 2. Cobble variant 3. Brick variant 4. Modified forms)
18
19 default:stone
20 default:cobble
21 default:stonebrick
22 default:stone_block
23 default:mossycobble
24
25 default:desert_stone
26 default:desert_cobble
27 default:desert_stonebrick
28 default:desert_stone_block
29
30 default:sandstone
31 default:sandstonebrick
32 default:sandstone_block
33 default:desert_sandstone
34 default:desert_sandstone_brick
35 default:desert_sandstone_block
36 default:silver_sandstone
37 default:silver_sandstone_brick
38 default:silver_sandstone_block
39
40 default:obsidian
41 default:obsidianbrick
42 default:obsidian_block
43
44 Soft / Non-Stone
45 ----------------
46 (1. Material 2. Modified forms)
47
48 default:dirt
49 default:dirt_with_grass
50 default:dirt_with_grass_footsteps
51 default:dirt_with_dry_grass
52 default:dirt_with_snow
53 default:dirt_with_rainforest_litter
54
55 default:sand
56 default:desert_sand
57 default:silver_sand
58
59 default:gravel
60
61 default:clay
62
63 default:snow
64 default:snowblock
65
66 default:ice
67
68 Trees
69 -----
70 (1. Trunk 2. Fabricated trunk 3. Leaves 4. Sapling 5. Fruits)
71
72 default:tree
73 default:wood
74 default:leaves
75 default:sapling
76 default:apple
77
78 default:jungletree
79 default:junglewood
80 default:jungleleaves
81 default:junglesapling
82
83 default:pine_tree
84 default:pine_wood
85 default:pine_needles
86 default:pine_sapling
87
88 default:acacia_tree
89 default:acacia_wood
90 default:acacia_leaves
91 default:acacia_sapling
92
93 default:aspen_tree
94 default:aspen_wood
95 default:aspen_leaves
96 default:aspen_sapling
97
98 Ores
99 ----
100 (1. In stone 2. Blocks)
101
102 default:stone_with_coal
103 default:coalblock
104
105 default:stone_with_iron
106 default:steelblock
107
108 default:stone_with_copper
109 default:copperblock
110
111 default:stone_with_tin
112 default:tinblock
113
114 default:bronzeblock
115
116 default:stone_with_gold
117 default:goldblock
118
119 default:stone_with_mese
120 default:mese
121
122 default:stone_with_diamond
123 default:diamondblock
124
125 Plantlife
126 ---------
127
128 default:cactus
129 default:papyrus
130 default:dry_shrub
131 default:junglegrass
132
133 default:grass_1
134 default:grass_2
135 default:grass_3
136 default:grass_4
137 default:grass_5
138
139 default:dry_grass_1
140 default:dry_grass_2
141 default:dry_grass_3
142 default:dry_grass_4
143 default:dry_grass_5
144
145 default:bush_stem
146 default:bush_leaves
147 default:bush_sapling
148 default:acacia_bush_stem
149 default:acacia_bush_leaves
150 default:acacia_bush_sapling
151
152 Corals
153 ------
154
155 default:coral_brown
156 default:coral_orange
157 default:coral_skeleton
158
159 Liquids
160 -------
161 (1. Source 2. Flowing)
162
163 default:water_source
164 default:water_flowing
165
166 default:river_water_source
167 default:river_water_flowing
168
169 default:lava_source
170 default:lava_flowing
171
172 Tools / "Advanced" crafting / Non-"natural"
173 -------------------------------------------
174
175 default:chest
176 default:chest_locked
177
178 default:bookshelf
179
180 default:sign_wall_wood
181 default:sign_wall_steel
182
183 default:ladder_wood
184 default:ladder_steel
185
186 default:fence_wood
187 default:fence_acacia_wood
188 default:fence_junglewood
189 default:fence_pine_wood
190 default:fence_aspen_wood
191
192 default:glass
193 default:obsidian_glass
194
195 default:brick
196
197 default:meselamp
198 default:mese_post_light
199
200 Misc
201 ----
202
203 default:cloud
204
205 --]]
206
207 --
208 -- Stone
209 --
210
211 minetest.register_node("default:stone", {
212         description = "Stone",
213         tiles = {"default_stone.png"},
214         groups = {cracky = 3, stone = 1},
215         drop = 'default:cobble',
216         legacy_mineral = true,
217         sounds = default.node_sound_stone_defaults(),
218 })
219
220 minetest.register_node("default:cobble", {
221         description = "Cobblestone",
222         tiles = {"default_cobble.png"},
223         is_ground_content = false,
224         groups = {cracky = 3, stone = 2},
225         sounds = default.node_sound_stone_defaults(),
226 })
227
228 minetest.register_node("default:stonebrick", {
229         description = "Stone Brick",
230         paramtype2 = "facedir",
231         place_param2 = 0,
232         tiles = {"default_stone_brick.png"},
233         is_ground_content = false,
234         groups = {cracky = 2, stone = 1},
235         sounds = default.node_sound_stone_defaults(),
236 })
237
238 minetest.register_node("default:stone_block", {
239         description = "Stone Block",
240         tiles = {"default_stone_block.png"},
241         is_ground_content = false,
242         groups = {cracky = 2, stone = 1},
243         sounds = default.node_sound_stone_defaults(),
244 })
245
246 minetest.register_node("default:mossycobble", {
247         description = "Mossy Cobblestone",
248         tiles = {"default_mossycobble.png"},
249         is_ground_content = false,
250         groups = {cracky = 3, stone = 1},
251         sounds = default.node_sound_stone_defaults(),
252 })
253
254
255 minetest.register_node("default:desert_stone", {
256         description = "Desert Stone",
257         tiles = {"default_desert_stone.png"},
258         groups = {cracky = 3, stone = 1},
259         drop = 'default:desert_cobble',
260         legacy_mineral = true,
261         sounds = default.node_sound_stone_defaults(),
262 })
263
264 minetest.register_node("default:desert_cobble", {
265         description = "Desert Cobblestone",
266         tiles = {"default_desert_cobble.png"},
267         is_ground_content = false,
268         groups = {cracky = 3, stone = 2},
269         sounds = default.node_sound_stone_defaults(),
270 })
271
272 minetest.register_node("default:desert_stonebrick", {
273         description = "Desert Stone Brick",
274         paramtype2 = "facedir",
275         place_param2 = 0,
276         tiles = {"default_desert_stone_brick.png"},
277         is_ground_content = false,
278         groups = {cracky = 2, stone = 1},
279         sounds = default.node_sound_stone_defaults(),
280 })
281
282 minetest.register_node("default:desert_stone_block", {
283         description = "Desert Stone Block",
284         tiles = {"default_desert_stone_block.png"},
285         is_ground_content = false,
286         groups = {cracky = 2, stone = 1},
287         sounds = default.node_sound_stone_defaults(),
288 })
289
290 minetest.register_node("default:sandstone", {
291         description = "Sandstone",
292         tiles = {"default_sandstone.png"},
293         groups = {crumbly = 1, cracky = 3},
294         sounds = default.node_sound_stone_defaults(),
295 })
296
297 minetest.register_node("default:sandstonebrick", {
298         description = "Sandstone Brick",
299         paramtype2 = "facedir",
300         place_param2 = 0,
301         tiles = {"default_sandstone_brick.png"},
302         is_ground_content = false,
303         groups = {cracky = 2},
304         sounds = default.node_sound_stone_defaults(),
305 })
306
307 minetest.register_node("default:sandstone_block", {
308         description = "Sandstone Block",
309         tiles = {"default_sandstone_block.png"},
310         is_ground_content = false,
311         groups = {cracky = 2},
312         sounds = default.node_sound_stone_defaults(),
313 })
314
315 minetest.register_node("default:desert_sandstone", {
316         description = "Desert Sandstone",
317         tiles = {"default_desert_sandstone.png"},
318         groups = {crumbly = 1, cracky = 3},
319         sounds = default.node_sound_stone_defaults(),
320 })
321
322 minetest.register_node("default:desert_sandstone_brick", {
323         description = "Desert Sandstone Brick",
324         paramtype2 = "facedir",
325         place_param2 = 0,
326         tiles = {"default_desert_sandstone_brick.png"},
327         is_ground_content = false,
328         groups = {cracky = 2},
329         sounds = default.node_sound_stone_defaults(),
330 })
331
332 minetest.register_node("default:desert_sandstone_block", {
333         description = "Desert Sandstone Block",
334         tiles = {"default_desert_sandstone_block.png"},
335         is_ground_content = false,
336         groups = {cracky = 2},
337         sounds = default.node_sound_stone_defaults(),
338 })
339
340 minetest.register_node("default:silver_sandstone", {
341         description = "Silver Sandstone",
342         tiles = {"default_silver_sandstone.png"},
343         groups = {crumbly = 1, cracky = 3},
344         sounds = default.node_sound_stone_defaults(),
345 })
346
347 minetest.register_node("default:silver_sandstone_brick", {
348         description = "Silver Sandstone Brick",
349         paramtype2 = "facedir",
350         place_param2 = 0,
351         tiles = {"default_silver_sandstone_brick.png"},
352         is_ground_content = false,
353         groups = {cracky = 2},
354         sounds = default.node_sound_stone_defaults(),
355 })
356
357 minetest.register_node("default:silver_sandstone_block", {
358         description = "Silver Sandstone Block",
359         tiles = {"default_silver_sandstone_block.png"},
360         is_ground_content = false,
361         groups = {cracky = 2},
362         sounds = default.node_sound_stone_defaults(),
363 })
364
365 minetest.register_node("default:obsidian", {
366         description = "Obsidian",
367         tiles = {"default_obsidian.png"},
368         sounds = default.node_sound_stone_defaults(),
369         groups = {cracky = 1, level = 2},
370 })
371
372 minetest.register_node("default:obsidianbrick", {
373         description = "Obsidian Brick",
374         paramtype2 = "facedir",
375         place_param2 = 0,
376         tiles = {"default_obsidian_brick.png"},
377         is_ground_content = false,
378         sounds = default.node_sound_stone_defaults(),
379         groups = {cracky = 1, level = 2},
380 })
381
382 minetest.register_node("default:obsidian_block", {
383         description = "Obsidian Block",
384         tiles = {"default_obsidian_block.png"},
385         is_ground_content = false,
386         sounds = default.node_sound_stone_defaults(),
387         groups = {cracky = 1, level = 2},
388 })
389
390 --
391 -- Soft / Non-Stone
392 --
393
394 minetest.register_node("default:dirt", {
395         description = "Dirt",
396         tiles = {"default_dirt.png"},
397         groups = {crumbly = 3, soil = 1},
398         sounds = default.node_sound_dirt_defaults(),
399 })
400
401 minetest.register_node("default:dirt_with_grass", {
402         description = "Dirt with Grass",
403         tiles = {"default_grass.png", "default_dirt.png",
404                 {name = "default_dirt.png^default_grass_side.png",
405                         tileable_vertical = false}},
406         groups = {crumbly = 3, soil = 1, spreading_dirt_type = 1},
407         drop = 'default:dirt',
408         sounds = default.node_sound_dirt_defaults({
409                 footstep = {name = "default_grass_footstep", gain = 0.25},
410         }),
411 })
412
413 minetest.register_node("default:dirt_with_grass_footsteps", {
414         description = "Dirt with Grass and Footsteps",
415         tiles = {"default_grass.png^default_footprint.png", "default_dirt.png",
416                 {name = "default_dirt.png^default_grass_side.png",
417                         tileable_vertical = false}},
418         groups = {crumbly = 3, soil = 1, not_in_creative_inventory = 1},
419         drop = 'default:dirt',
420         sounds = default.node_sound_dirt_defaults({
421                 footstep = {name = "default_grass_footstep", gain = 0.25},
422         }),
423 })
424
425 minetest.register_node("default:dirt_with_dry_grass", {
426         description = "Dirt with Dry Grass",
427         tiles = {"default_dry_grass.png",
428                 "default_dirt.png",
429                 {name = "default_dirt.png^default_dry_grass_side.png",
430                         tileable_vertical = false}},
431         groups = {crumbly = 3, soil = 1, spreading_dirt_type = 1},
432         drop = 'default:dirt',
433         sounds = default.node_sound_dirt_defaults({
434                 footstep = {name = "default_grass_footstep", gain = 0.4},
435         }),
436 })
437
438 minetest.register_node("default:dirt_with_snow", {
439         description = "Dirt with Snow",
440         tiles = {"default_snow.png", "default_dirt.png",
441                 {name = "default_dirt.png^default_snow_side.png",
442                         tileable_vertical = false}},
443         groups = {crumbly = 3, spreading_dirt_type = 1, snowy = 1},
444         drop = 'default:dirt',
445         sounds = default.node_sound_dirt_defaults({
446                 footstep = {name = "default_snow_footstep", gain = 0.15},
447         }),
448 })
449
450 minetest.register_node("default:dirt_with_rainforest_litter", {
451         description = "Dirt with Rainforest Litter",
452         tiles = {
453                 "default_rainforest_litter.png",
454                 "default_dirt.png",
455                 {name = "default_dirt.png^default_rainforest_litter_side.png",
456                         tileable_vertical = false}
457         },
458         groups = {crumbly = 3, soil = 1, spreading_dirt_type = 1},
459         drop = "default:dirt",
460         sounds = default.node_sound_dirt_defaults({
461                 footstep = {name = "default_grass_footstep", gain = 0.4},
462         }),
463 })
464
465 minetest.register_node("default:sand", {
466         description = "Sand",
467         tiles = {"default_sand.png"},
468         groups = {crumbly = 3, falling_node = 1, sand = 1},
469         sounds = default.node_sound_sand_defaults(),
470 })
471
472 minetest.register_node("default:desert_sand", {
473         description = "Desert Sand",
474         tiles = {"default_desert_sand.png"},
475         groups = {crumbly = 3, falling_node = 1, sand = 1},
476         sounds = default.node_sound_sand_defaults(),
477 })
478
479 minetest.register_node("default:silver_sand", {
480         description = "Silver Sand",
481         tiles = {"default_silver_sand.png"},
482         groups = {crumbly = 3, falling_node = 1, sand = 1},
483         sounds = default.node_sound_sand_defaults(),
484 })
485
486
487 minetest.register_node("default:gravel", {
488         description = "Gravel",
489         tiles = {"default_gravel.png"},
490         groups = {crumbly = 2, falling_node = 1},
491         sounds = default.node_sound_gravel_defaults(),
492         drop = {
493                 max_items = 1,
494                 items = {
495                         {items = {'default:flint'}, rarity = 16},
496                         {items = {'default:gravel'}}
497                 }
498         }
499 })
500
501 minetest.register_node("default:clay", {
502         description = "Clay",
503         tiles = {"default_clay.png"},
504         groups = {crumbly = 3},
505         drop = 'default:clay_lump 4',
506         sounds = default.node_sound_dirt_defaults(),
507 })
508
509
510 minetest.register_node("default:snow", {
511         description = "Snow",
512         tiles = {"default_snow.png"},
513         inventory_image = "default_snowball.png",
514         wield_image = "default_snowball.png",
515         paramtype = "light",
516         buildable_to = true,
517         floodable = true,
518         drawtype = "nodebox",
519         node_box = {
520                 type = "fixed",
521                 fixed = {
522                         {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
523                 },
524         },
525         groups = {crumbly = 3, falling_node = 1, puts_out_fire = 1, snowy = 1},
526         sounds = default.node_sound_dirt_defaults({
527                 footstep = {name = "default_snow_footstep", gain = 0.15},
528                 dug = {name = "default_snow_footstep", gain = 0.2},
529                 dig = {name = "default_snow_footstep", gain = 0.2}
530         }),
531
532         on_construct = function(pos)
533                 pos.y = pos.y - 1
534                 if minetest.get_node(pos).name == "default:dirt_with_grass" then
535                         minetest.set_node(pos, {name = "default:dirt_with_snow"})
536                 end
537         end,
538 })
539
540 minetest.register_node("default:snowblock", {
541         description = "Snow Block",
542         tiles = {"default_snow.png"},
543         groups = {crumbly = 3, puts_out_fire = 1, cools_lava = 1, snowy = 1},
544         sounds = default.node_sound_dirt_defaults({
545                 footstep = {name = "default_snow_footstep", gain = 0.15},
546                 dug = {name = "default_snow_footstep", gain = 0.2},
547                 dig = {name = "default_snow_footstep", gain = 0.2}
548         }),
549
550         on_construct = function(pos)
551                 pos.y = pos.y - 1
552                 if minetest.get_node(pos).name == "default:dirt_with_grass" then
553                         minetest.set_node(pos, {name = "default:dirt_with_snow"})
554                 end
555         end,
556 })
557
558 minetest.register_node("default:ice", {
559         description = "Ice",
560         tiles = {"default_ice.png"},
561         is_ground_content = false,
562         paramtype = "light",
563         groups = {cracky = 3, puts_out_fire = 1, cools_lava = 1},
564         sounds = default.node_sound_glass_defaults(),
565 })
566
567 --
568 -- Trees
569 --
570
571 minetest.register_node("default:tree", {
572         description = "Tree",
573         tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
574         paramtype2 = "facedir",
575         is_ground_content = false,
576         groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
577         sounds = default.node_sound_wood_defaults(),
578
579         on_place = minetest.rotate_node
580 })
581
582 minetest.register_node("default:wood", {
583         description = "Wooden Planks",
584         paramtype2 = "facedir",
585         place_param2 = 0,
586         tiles = {"default_wood.png"},
587         is_ground_content = false,
588         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1},
589         sounds = default.node_sound_wood_defaults(),
590 })
591
592 minetest.register_node("default:sapling", {
593         description = "Sapling",
594         drawtype = "plantlike",
595         tiles = {"default_sapling.png"},
596         inventory_image = "default_sapling.png",
597         wield_image = "default_sapling.png",
598         paramtype = "light",
599         sunlight_propagates = true,
600         walkable = false,
601         on_timer = default.grow_sapling,
602         selection_box = {
603                 type = "fixed",
604                 fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
605         },
606         groups = {snappy = 2, dig_immediate = 3, flammable = 2,
607                 attached_node = 1, sapling = 1},
608         sounds = default.node_sound_leaves_defaults(),
609
610         on_construct = function(pos)
611                 minetest.get_node_timer(pos):start(math.random(300, 1500))
612         end,
613
614         on_place = function(itemstack, placer, pointed_thing)
615                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
616                         "default:sapling",
617                         -- minp, maxp to be checked, relative to sapling pos
618                         -- minp_relative.y = 1 because sapling pos has been checked
619                         {x = -2, y = 1, z = -2},
620                         {x = 2, y = 6, z = 2},
621                         -- maximum interval of interior volume check
622                         4)
623
624                 return itemstack
625         end,
626 })
627
628 minetest.register_node("default:leaves", {
629         description = "Leaves",
630         drawtype = "allfaces_optional",
631         waving = 1,
632         tiles = {"default_leaves.png"},
633         special_tiles = {"default_leaves_simple.png"},
634         paramtype = "light",
635         is_ground_content = false,
636         groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
637         drop = {
638                 max_items = 1,
639                 items = {
640                         {
641                                 -- player will get sapling with 1/20 chance
642                                 items = {'default:sapling'},
643                                 rarity = 20,
644                         },
645                         {
646                                 -- player will get leaves only if he get no saplings,
647                                 -- this is because max_items is 1
648                                 items = {'default:leaves'},
649                         }
650                 }
651         },
652         sounds = default.node_sound_leaves_defaults(),
653
654         after_place_node = default.after_place_leaves,
655 })
656
657 minetest.register_node("default:apple", {
658         description = "Apple",
659         drawtype = "plantlike",
660         tiles = {"default_apple.png"},
661         inventory_image = "default_apple.png",
662         paramtype = "light",
663         sunlight_propagates = true,
664         walkable = false,
665         is_ground_content = false,
666         selection_box = {
667                 type = "fixed",
668                 fixed = {-3 / 16, -7 / 16, -3 / 16, 3 / 16, 4 / 16, 3 / 16}
669         },
670         groups = {fleshy = 3, dig_immediate = 3, flammable = 2,
671                 leafdecay = 3, leafdecay_drop = 1},
672         on_use = minetest.item_eat(2),
673         sounds = default.node_sound_leaves_defaults(),
674
675         after_place_node = function(pos, placer, itemstack)
676                 minetest.set_node(pos, {name = "default:apple", param2 = 1})
677         end,
678 })
679
680
681 minetest.register_node("default:jungletree", {
682         description = "Jungle Tree",
683         tiles = {"default_jungletree_top.png", "default_jungletree_top.png",
684                 "default_jungletree.png"},
685         paramtype2 = "facedir",
686         is_ground_content = false,
687         groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
688         sounds = default.node_sound_wood_defaults(),
689
690         on_place = minetest.rotate_node
691 })
692
693 minetest.register_node("default:junglewood", {
694         description = "Jungle Wood Planks",
695         paramtype2 = "facedir",
696         place_param2 = 0,
697         tiles = {"default_junglewood.png"},
698         is_ground_content = false,
699         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1},
700         sounds = default.node_sound_wood_defaults(),
701 })
702
703 minetest.register_node("default:jungleleaves", {
704         description = "Jungle Leaves",
705         drawtype = "allfaces_optional",
706         waving = 1,
707         tiles = {"default_jungleleaves.png"},
708         special_tiles = {"default_jungleleaves_simple.png"},
709         paramtype = "light",
710         is_ground_content = false,
711         groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
712         drop = {
713                 max_items = 1,
714                 items = {
715                         {items = {'default:junglesapling'}, rarity = 20},
716                         {items = {'default:jungleleaves'}}
717                 }
718         },
719         sounds = default.node_sound_leaves_defaults(),
720
721         after_place_node = default.after_place_leaves,
722 })
723
724 minetest.register_node("default:junglesapling", {
725         description = "Jungle Sapling",
726         drawtype = "plantlike",
727         tiles = {"default_junglesapling.png"},
728         inventory_image = "default_junglesapling.png",
729         wield_image = "default_junglesapling.png",
730         paramtype = "light",
731         sunlight_propagates = true,
732         walkable = false,
733         on_timer = default.grow_sapling,
734         selection_box = {
735                 type = "fixed",
736                 fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
737         },
738         groups = {snappy = 2, dig_immediate = 3, flammable = 2,
739                 attached_node = 1, sapling = 1},
740         sounds = default.node_sound_leaves_defaults(),
741
742         on_construct = function(pos)
743                 minetest.get_node_timer(pos):start(math.random(300, 1500))
744         end,
745
746         on_place = function(itemstack, placer, pointed_thing)
747                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
748                         "default:junglesapling",
749                         -- minp, maxp to be checked, relative to sapling pos
750                         -- minp_relative.y = 1 because sapling pos has been checked
751                         {x = -2, y = 1, z = -2},
752                         {x = 2, y = 15, z = 2},
753                         -- maximum interval of interior volume check
754                         4)
755
756                 return itemstack
757         end,
758 })
759
760
761 minetest.register_node("default:pine_tree", {
762         description = "Pine Tree",
763         tiles = {"default_pine_tree_top.png", "default_pine_tree_top.png",
764                 "default_pine_tree.png"},
765         paramtype2 = "facedir",
766         is_ground_content = false,
767         groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3},
768         sounds = default.node_sound_wood_defaults(),
769
770         on_place = minetest.rotate_node
771 })
772
773 minetest.register_node("default:pine_wood", {
774         description = "Pine Wood Planks",
775         paramtype2 = "facedir",
776         place_param2 = 0,
777         tiles = {"default_pine_wood.png"},
778         is_ground_content = false,
779         groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
780         sounds = default.node_sound_wood_defaults(),
781 })
782
783 minetest.register_node("default:pine_needles",{
784         description = "Pine Needles",
785         drawtype = "allfaces_optional",
786         tiles = {"default_pine_needles.png"},
787         waving = 1,
788         paramtype = "light",
789         is_ground_content = false,
790         groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
791         drop = {
792                 max_items = 1,
793                 items = {
794                         {items = {"default:pine_sapling"}, rarity = 20},
795                         {items = {"default:pine_needles"}}
796                 }
797         },
798         sounds = default.node_sound_leaves_defaults(),
799
800         after_place_node = default.after_place_leaves,
801 })
802
803 minetest.register_node("default:pine_sapling", {
804         description = "Pine Sapling",
805         drawtype = "plantlike",
806         tiles = {"default_pine_sapling.png"},
807         inventory_image = "default_pine_sapling.png",
808         wield_image = "default_pine_sapling.png",
809         paramtype = "light",
810         sunlight_propagates = true,
811         walkable = false,
812         on_timer = default.grow_sapling,
813         selection_box = {
814                 type = "fixed",
815                 fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
816         },
817         groups = {snappy = 2, dig_immediate = 3, flammable = 3,
818                 attached_node = 1, sapling = 1},
819         sounds = default.node_sound_leaves_defaults(),
820
821         on_construct = function(pos)
822                 minetest.get_node_timer(pos):start(math.random(300, 1500))
823         end,
824
825         on_place = function(itemstack, placer, pointed_thing)
826                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
827                         "default:pine_sapling",
828                         -- minp, maxp to be checked, relative to sapling pos
829                         -- minp_relative.y = 1 because sapling pos has been checked
830                         {x = -2, y = 1, z = -2},
831                         {x = 2, y = 12, z = 2},
832                         -- maximum interval of interior volume check
833                         4)
834
835                 return itemstack
836         end,
837 })
838
839
840 minetest.register_node("default:acacia_tree", {
841         description = "Acacia Tree",
842         tiles = {"default_acacia_tree_top.png", "default_acacia_tree_top.png",
843                 "default_acacia_tree.png"},
844         paramtype2 = "facedir",
845         is_ground_content = false,
846         groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
847         sounds = default.node_sound_wood_defaults(),
848
849         on_place = minetest.rotate_node
850 })
851
852 minetest.register_node("default:acacia_wood", {
853         description = "Acacia Wood Planks",
854         paramtype2 = "facedir",
855         place_param2 = 0,
856         tiles = {"default_acacia_wood.png"},
857         is_ground_content = false,
858         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1},
859         sounds = default.node_sound_wood_defaults(),
860 })
861
862 minetest.register_node("default:acacia_leaves", {
863         description = "Acacia Leaves",
864         drawtype = "allfaces_optional",
865         tiles = {"default_acacia_leaves.png"},
866         special_tiles = {"default_acacia_leaves_simple.png"},
867         waving = 1,
868         paramtype = "light",
869         is_ground_content = false,
870         groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
871         drop = {
872                 max_items = 1,
873                 items = {
874                         {items = {"default:acacia_sapling"}, rarity = 20},
875                         {items = {"default:acacia_leaves"}}
876                 }
877         },
878         sounds = default.node_sound_leaves_defaults(),
879
880         after_place_node = default.after_place_leaves,
881 })
882
883 minetest.register_node("default:acacia_sapling", {
884         description = "Acacia Tree Sapling",
885         drawtype = "plantlike",
886         tiles = {"default_acacia_sapling.png"},
887         inventory_image = "default_acacia_sapling.png",
888         wield_image = "default_acacia_sapling.png",
889         paramtype = "light",
890         sunlight_propagates = true,
891         walkable = false,
892         on_timer = default.grow_sapling,
893         selection_box = {
894                 type = "fixed",
895                 fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
896         },
897         groups = {snappy = 2, dig_immediate = 3, flammable = 2,
898                 attached_node = 1, sapling = 1},
899         sounds = default.node_sound_leaves_defaults(),
900
901         on_construct = function(pos)
902                 minetest.get_node_timer(pos):start(math.random(300, 1500))
903         end,
904
905         on_place = function(itemstack, placer, pointed_thing)
906                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
907                         "default:acacia_sapling",
908                         -- minp, maxp to be checked, relative to sapling pos
909                         -- minp_relative.y = 1 because sapling pos has been checked
910                         {x = -4, y = 1, z = -4},
911                         {x = 4, y = 6, z = 4},
912                         -- maximum interval of interior volume check
913                         4)
914
915                 return itemstack
916         end,
917 })
918
919 minetest.register_node("default:aspen_tree", {
920         description = "Aspen Tree",
921         tiles = {"default_aspen_tree_top.png", "default_aspen_tree_top.png",
922                 "default_aspen_tree.png"},
923         paramtype2 = "facedir",
924         is_ground_content = false,
925         groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3},
926         sounds = default.node_sound_wood_defaults(),
927
928         on_place = minetest.rotate_node
929 })
930
931 minetest.register_node("default:aspen_wood", {
932         description = "Aspen Wood Planks",
933         paramtype2 = "facedir",
934         place_param2 = 0,
935         tiles = {"default_aspen_wood.png"},
936         is_ground_content = false,
937         groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
938         sounds = default.node_sound_wood_defaults(),
939 })
940
941 minetest.register_node("default:aspen_leaves", {
942         description = "Aspen Leaves",
943         drawtype = "allfaces_optional",
944         tiles = {"default_aspen_leaves.png"},
945         waving = 1,
946         paramtype = "light",
947         is_ground_content = false,
948         groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
949         drop = {
950                 max_items = 1,
951                 items = {
952                         {items = {"default:aspen_sapling"}, rarity = 20},
953                         {items = {"default:aspen_leaves"}}
954                 }
955         },
956         sounds = default.node_sound_leaves_defaults(),
957
958         after_place_node = default.after_place_leaves,
959 })
960
961 minetest.register_node("default:aspen_sapling", {
962         description = "Aspen Tree Sapling",
963         drawtype = "plantlike",
964         tiles = {"default_aspen_sapling.png"},
965         inventory_image = "default_aspen_sapling.png",
966         wield_image = "default_aspen_sapling.png",
967         paramtype = "light",
968         sunlight_propagates = true,
969         walkable = false,
970         on_timer = default.grow_sapling,
971         selection_box = {
972                 type = "fixed",
973                 fixed = {-3 / 16, -0.5, -3 / 16, 3 / 16, 0.5, 3 / 16}
974         },
975         groups = {snappy = 2, dig_immediate = 3, flammable = 3,
976                 attached_node = 1, sapling = 1},
977         sounds = default.node_sound_leaves_defaults(),
978
979         on_construct = function(pos)
980                 minetest.get_node_timer(pos):start(math.random(300, 1500))
981         end,
982
983         on_place = function(itemstack, placer, pointed_thing)
984                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
985                         "default:aspen_sapling",
986                         -- minp, maxp to be checked, relative to sapling pos
987                         -- minp_relative.y = 1 because sapling pos has been checked
988                         {x = -2, y = 1, z = -2},
989                         {x = 2, y = 12, z = 2},
990                         -- maximum interval of interior volume check
991                         4)
992
993                 return itemstack
994         end,
995 })
996
997 --
998 -- Ores
999 --
1000
1001 minetest.register_node("default:stone_with_coal", {
1002         description = "Coal Ore",
1003         tiles = {"default_stone.png^default_mineral_coal.png"},
1004         groups = {cracky = 3},
1005         drop = 'default:coal_lump',
1006         sounds = default.node_sound_stone_defaults(),
1007 })
1008
1009 minetest.register_node("default:coalblock", {
1010         description = "Coal Block",
1011         tiles = {"default_coal_block.png"},
1012         is_ground_content = false,
1013         groups = {cracky = 3},
1014         sounds = default.node_sound_stone_defaults(),
1015 })
1016
1017
1018 minetest.register_node("default:stone_with_iron", {
1019         description = "Iron Ore",
1020         tiles = {"default_stone.png^default_mineral_iron.png"},
1021         groups = {cracky = 2},
1022         drop = 'default:iron_lump',
1023         sounds = default.node_sound_stone_defaults(),
1024 })
1025
1026 minetest.register_node("default:steelblock", {
1027         description = "Steel Block",
1028         tiles = {"default_steel_block.png"},
1029         is_ground_content = false,
1030         groups = {cracky = 1, level = 2},
1031         sounds = default.node_sound_metal_defaults(),
1032 })
1033
1034
1035 minetest.register_node("default:stone_with_copper", {
1036         description = "Copper Ore",
1037         tiles = {"default_stone.png^default_mineral_copper.png"},
1038         groups = {cracky = 2},
1039         drop = 'default:copper_lump',
1040         sounds = default.node_sound_stone_defaults(),
1041 })
1042
1043 minetest.register_node("default:copperblock", {
1044         description = "Copper Block",
1045         tiles = {"default_copper_block.png"},
1046         is_ground_content = false,
1047         groups = {cracky = 1, level = 2},
1048         sounds = default.node_sound_metal_defaults(),
1049 })
1050
1051
1052 minetest.register_node("default:stone_with_tin", {
1053         description = "Tin Ore",
1054         tiles = {"default_stone.png^default_mineral_tin.png"},
1055         groups = {cracky = 2},
1056         drop = "default:tin_lump",
1057         sounds = default.node_sound_stone_defaults(),
1058 })
1059
1060 minetest.register_node("default:tinblock", {
1061         description = "Tin Block",
1062         tiles = {"default_tin_block.png"},
1063         is_ground_content = false,
1064         groups = {cracky = 1, level = 2},
1065         sounds = default.node_sound_metal_defaults(),
1066 })
1067
1068
1069 minetest.register_node("default:bronzeblock", {
1070         description = "Bronze Block",
1071         tiles = {"default_bronze_block.png"},
1072         is_ground_content = false,
1073         groups = {cracky = 1, level = 2},
1074         sounds = default.node_sound_metal_defaults(),
1075 })
1076
1077
1078 minetest.register_node("default:stone_with_mese", {
1079         description = "Mese Ore",
1080         tiles = {"default_stone.png^default_mineral_mese.png"},
1081         groups = {cracky = 1},
1082         drop = "default:mese_crystal",
1083         sounds = default.node_sound_stone_defaults(),
1084 })
1085
1086 minetest.register_node("default:mese", {
1087         description = "Mese Block",
1088         tiles = {"default_mese_block.png"},
1089         paramtype = "light",
1090         groups = {cracky = 1, level = 2},
1091         sounds = default.node_sound_stone_defaults(),
1092         light_source = 3,
1093 })
1094
1095
1096 minetest.register_node("default:stone_with_gold", {
1097         description = "Gold Ore",
1098         tiles = {"default_stone.png^default_mineral_gold.png"},
1099         groups = {cracky = 2},
1100         drop = "default:gold_lump",
1101         sounds = default.node_sound_stone_defaults(),
1102 })
1103
1104 minetest.register_node("default:goldblock", {
1105         description = "Gold Block",
1106         tiles = {"default_gold_block.png"},
1107         is_ground_content = false,
1108         groups = {cracky = 1},
1109         sounds = default.node_sound_metal_defaults(),
1110 })
1111
1112
1113 minetest.register_node("default:stone_with_diamond", {
1114         description = "Diamond Ore",
1115         tiles = {"default_stone.png^default_mineral_diamond.png"},
1116         groups = {cracky = 1},
1117         drop = "default:diamond",
1118         sounds = default.node_sound_stone_defaults(),
1119 })
1120
1121 minetest.register_node("default:diamondblock", {
1122         description = "Diamond Block",
1123         tiles = {"default_diamond_block.png"},
1124         is_ground_content = false,
1125         groups = {cracky = 1, level = 3},
1126         sounds = default.node_sound_stone_defaults(),
1127 })
1128
1129 --
1130 -- Plantlife (non-cubic)
1131 --
1132
1133 minetest.register_node("default:cactus", {
1134         description = "Cactus",
1135         tiles = {"default_cactus_top.png", "default_cactus_top.png",
1136                 "default_cactus_side.png"},
1137         paramtype2 = "facedir",
1138         groups = {choppy = 3},
1139         sounds = default.node_sound_wood_defaults(),
1140         on_place = minetest.rotate_node,
1141 })
1142
1143 minetest.register_node("default:papyrus", {
1144         description = "Papyrus",
1145         drawtype = "plantlike",
1146         tiles = {"default_papyrus.png"},
1147         inventory_image = "default_papyrus.png",
1148         wield_image = "default_papyrus.png",
1149         paramtype = "light",
1150         sunlight_propagates = true,
1151         walkable = false,
1152         selection_box = {
1153                 type = "fixed",
1154                 fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 0.5, 6 / 16},
1155         },
1156         groups = {snappy = 3, flammable = 2},
1157         sounds = default.node_sound_leaves_defaults(),
1158
1159         after_dig_node = function(pos, node, metadata, digger)
1160                 default.dig_up(pos, node, digger)
1161         end,
1162 })
1163
1164 minetest.register_node("default:dry_shrub", {
1165         description = "Dry Shrub",
1166         drawtype = "plantlike",
1167         waving = 1,
1168         tiles = {"default_dry_shrub.png"},
1169         inventory_image = "default_dry_shrub.png",
1170         wield_image = "default_dry_shrub.png",
1171         paramtype = "light",
1172         sunlight_propagates = true,
1173         walkable = false,
1174         buildable_to = true,
1175         groups = {snappy = 3, flammable = 3, attached_node = 1},
1176         sounds = default.node_sound_leaves_defaults(),
1177         selection_box = {
1178                 type = "fixed",
1179                 fixed = {-5 / 16, -0.5, -5 / 16, 5 / 16, 4 / 16, 5 / 16},
1180         },
1181 })
1182
1183 minetest.register_node("default:junglegrass", {
1184         description = "Jungle Grass",
1185         drawtype = "plantlike",
1186         waving = 1,
1187         visual_scale = 1.69,
1188         tiles = {"default_junglegrass.png"},
1189         inventory_image = "default_junglegrass.png",
1190         wield_image = "default_junglegrass.png",
1191         paramtype = "light",
1192         sunlight_propagates = true,
1193         walkable = false,
1194         buildable_to = true,
1195         groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1},
1196         sounds = default.node_sound_leaves_defaults(),
1197         selection_box = {
1198                 type = "fixed",
1199                 fixed = {-7 / 16, -0.5, -7 / 16, 7 / 16, 1.19, 7 / 16},
1200         },
1201 })
1202
1203
1204 minetest.register_node("default:grass_1", {
1205         description = "Grass",
1206         drawtype = "plantlike",
1207         waving = 1,
1208         tiles = {"default_grass_1.png"},
1209         -- Use texture of a taller grass stage in inventory
1210         inventory_image = "default_grass_3.png",
1211         wield_image = "default_grass_3.png",
1212         paramtype = "light",
1213         sunlight_propagates = true,
1214         walkable = false,
1215         buildable_to = true,
1216         groups = {snappy = 3, flora = 1, attached_node = 1, grass = 1, flammable = 1},
1217         sounds = default.node_sound_leaves_defaults(),
1218         selection_box = {
1219                 type = "fixed",
1220                 fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -5 / 16, 6 / 16},
1221         },
1222
1223         on_place = function(itemstack, placer, pointed_thing)
1224                 -- place a random grass node
1225                 local stack = ItemStack("default:grass_" .. math.random(1,5))
1226                 local ret = minetest.item_place(stack, placer, pointed_thing)
1227                 return ItemStack("default:grass_1 " ..
1228                         itemstack:get_count() - (1 - ret:get_count()))
1229         end,
1230 })
1231
1232 for i = 2, 5 do
1233         minetest.register_node("default:grass_" .. i, {
1234                 description = "Grass",
1235                 drawtype = "plantlike",
1236                 waving = 1,
1237                 tiles = {"default_grass_" .. i .. ".png"},
1238                 inventory_image = "default_grass_" .. i .. ".png",
1239                 wield_image = "default_grass_" .. i .. ".png",
1240                 paramtype = "light",
1241                 sunlight_propagates = true,
1242                 walkable = false,
1243                 buildable_to = true,
1244                 drop = "default:grass_1",
1245                 groups = {snappy = 3, flora = 1, attached_node = 1,
1246                         not_in_creative_inventory = 1, grass = 1, flammable = 1},
1247                 sounds = default.node_sound_leaves_defaults(),
1248                 selection_box = {
1249                         type = "fixed",
1250                         fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -3 / 16, 6 / 16},
1251                 },
1252         })
1253 end
1254
1255
1256 minetest.register_node("default:dry_grass_1", {
1257         description = "Dry Grass",
1258         drawtype = "plantlike",
1259         waving = 1,
1260         tiles = {"default_dry_grass_1.png"},
1261         inventory_image = "default_dry_grass_3.png",
1262         wield_image = "default_dry_grass_3.png",
1263         paramtype = "light",
1264         sunlight_propagates = true,
1265         walkable = false,
1266         buildable_to = true,
1267         groups = {snappy = 3, flammable = 3, flora = 1,
1268                 attached_node = 1, dry_grass = 1},
1269         sounds = default.node_sound_leaves_defaults(),
1270         selection_box = {
1271                 type = "fixed",
1272                 fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -3 / 16, 6 / 16},
1273         },
1274
1275         on_place = function(itemstack, placer, pointed_thing)
1276                 -- place a random dry grass node
1277                 local stack = ItemStack("default:dry_grass_" .. math.random(1, 5))
1278                 local ret = minetest.item_place(stack, placer, pointed_thing)
1279                 return ItemStack("default:dry_grass_1 " ..
1280                         itemstack:get_count() - (1 - ret:get_count()))
1281         end,
1282 })
1283
1284 for i = 2, 5 do
1285         minetest.register_node("default:dry_grass_" .. i, {
1286                 description = "Dry Grass",
1287                 drawtype = "plantlike",
1288                 waving = 1,
1289                 tiles = {"default_dry_grass_" .. i .. ".png"},
1290                 inventory_image = "default_dry_grass_" .. i .. ".png",
1291                 wield_image = "default_dry_grass_" .. i .. ".png",
1292                 paramtype = "light",
1293                 sunlight_propagates = true,
1294                 walkable = false,
1295                 buildable_to = true,
1296                 groups = {snappy = 3, flammable = 3, flora = 1, attached_node = 1,
1297                         not_in_creative_inventory=1, dry_grass = 1},
1298                 drop = "default:dry_grass_1",
1299                 sounds = default.node_sound_leaves_defaults(),
1300                 selection_box = {
1301                         type = "fixed",
1302                         fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -1 / 16, 6 / 16},
1303                 },
1304         })
1305 end
1306
1307
1308 minetest.register_node("default:bush_stem", {
1309         description = "Bush Stem",
1310         drawtype = "plantlike",
1311         visual_scale = 1.41,
1312         tiles = {"default_bush_stem.png"},
1313         inventory_image = "default_bush_stem.png",
1314         wield_image = "default_bush_stem.png",
1315         paramtype = "light",
1316         sunlight_propagates = true,
1317         groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
1318         sounds = default.node_sound_wood_defaults(),
1319         selection_box = {
1320                 type = "fixed",
1321                 fixed = {-7 / 16, -0.5, -7 / 16, 7 / 16, 0.5, 7 / 16},
1322         },
1323 })
1324
1325 minetest.register_node("default:bush_leaves", {
1326         description = "Bush Leaves",
1327         drawtype = "allfaces_optional",
1328         waving = 1,
1329         tiles = {"default_leaves_simple.png"},
1330         paramtype = "light",
1331         groups = {snappy = 3, flammable = 2, leaves = 1},
1332         drop = {
1333                 max_items = 1,
1334                 items = {
1335                         {items = {"default:bush_sapling"}, rarity = 5},
1336                         {items = {"default:bush_leaves"}}
1337                 }
1338         },
1339         sounds = default.node_sound_leaves_defaults(),
1340
1341         after_place_node = default.after_place_leaves,
1342 })
1343
1344 minetest.register_node("default:bush_sapling", {
1345         description = "Bush Sapling",
1346         drawtype = "plantlike",
1347         tiles = {"default_bush_sapling.png"},
1348         inventory_image = "default_bush_sapling.png",
1349         wield_image = "default_bush_sapling.png",
1350         paramtype = "light",
1351         sunlight_propagates = true,
1352         walkable = false,
1353         on_timer = default.grow_sapling,
1354         selection_box = {
1355                 type = "fixed",
1356                 fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 2 / 16, 4 / 16}
1357         },
1358         groups = {snappy = 2, dig_immediate = 3, flammable = 2,
1359                 attached_node = 1, sapling = 1},
1360         sounds = default.node_sound_leaves_defaults(),
1361
1362         on_construct = function(pos)
1363                 minetest.get_node_timer(pos):start(math.random(300, 1500))
1364         end,
1365
1366         on_place = function(itemstack, placer, pointed_thing)
1367                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
1368                         "default:bush_sapling",
1369                         -- minp, maxp to be checked, relative to sapling pos
1370                         {x = -1, y = 0, z = -1},
1371                         {x = 1, y = 1, z = 1},
1372                         -- maximum interval of interior volume check
1373                         2)
1374
1375                 return itemstack
1376         end,
1377 })
1378
1379 minetest.register_node("default:acacia_bush_stem", {
1380         description = "Acacia Bush Stem",
1381         drawtype = "plantlike",
1382         visual_scale = 1.41,
1383         tiles = {"default_acacia_bush_stem.png"},
1384         inventory_image = "default_acacia_bush_stem.png",
1385         wield_image = "default_acacia_bush_stem.png",
1386         paramtype = "light",
1387         sunlight_propagates = true,
1388         groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
1389         sounds = default.node_sound_wood_defaults(),
1390         selection_box = {
1391                 type = "fixed",
1392                 fixed = {-7 / 16, -0.5, -7 / 16, 7 / 16, 0.5, 7 / 16},
1393         },
1394 })
1395
1396 minetest.register_node("default:acacia_bush_leaves", {
1397         description = "Acacia Bush Leaves",
1398         drawtype = "allfaces_optional",
1399         waving = 1,
1400         tiles = {"default_acacia_leaves_simple.png"},
1401         paramtype = "light",
1402         groups = {snappy = 3, flammable = 2, leaves = 1},
1403         drop = {
1404                 max_items = 1,
1405                 items = {
1406                         {items = {"default:acacia_bush_sapling"}, rarity = 5},
1407                         {items = {"default:acacia_bush_leaves"}}
1408                 }
1409         },
1410         sounds = default.node_sound_leaves_defaults(),
1411
1412         after_place_node = default.after_place_leaves,
1413 })
1414
1415 minetest.register_node("default:acacia_bush_sapling", {
1416         description = "Acacia Bush Sapling",
1417         drawtype = "plantlike",
1418         tiles = {"default_acacia_bush_sapling.png"},
1419         inventory_image = "default_acacia_bush_sapling.png",
1420         wield_image = "default_acacia_bush_sapling.png",
1421         paramtype = "light",
1422         sunlight_propagates = true,
1423         walkable = false,
1424         on_timer = default.grow_sapling,
1425         selection_box = {
1426                 type = "fixed",
1427                 fixed = {-3 / 16, -0.5, -3 / 16, 3 / 16, 2 / 16, 3 / 16}
1428         },
1429         groups = {snappy = 2, dig_immediate = 3, flammable = 2,
1430                 attached_node = 1, sapling = 1},
1431         sounds = default.node_sound_leaves_defaults(),
1432
1433         on_construct = function(pos)
1434                 minetest.get_node_timer(pos):start(math.random(300, 1500))
1435         end,
1436
1437         on_place = function(itemstack, placer, pointed_thing)
1438                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
1439                         "default:acacia_bush_sapling",
1440                         -- minp, maxp to be checked, relative to sapling pos
1441                         {x = -1, y = 0, z = -1},
1442                         {x = 1, y = 1, z = 1},
1443                         -- maximum interval of interior volume check
1444                         2)
1445
1446                 return itemstack
1447         end,
1448 })
1449
1450
1451 --
1452 -- Corals
1453 --
1454
1455 minetest.register_node("default:coral_brown", {
1456         description = "Brown Coral",
1457         tiles = {"default_coral_brown.png"},
1458         groups = {cracky = 3},
1459         drop = "default:coral_skeleton",
1460         sounds = default.node_sound_stone_defaults(),
1461 })
1462
1463 minetest.register_node("default:coral_orange", {
1464         description = "Orange Coral",
1465         tiles = {"default_coral_orange.png"},
1466         groups = {cracky = 3},
1467         drop = "default:coral_skeleton",
1468         sounds = default.node_sound_stone_defaults(),
1469 })
1470
1471 minetest.register_node("default:coral_skeleton", {
1472         description = "Coral Skeleton",
1473         tiles = {"default_coral_skeleton.png"},
1474         groups = {cracky = 3},
1475         sounds = default.node_sound_stone_defaults(),
1476 })
1477
1478
1479 --
1480 -- Liquids
1481 --
1482
1483 minetest.register_node("default:water_source", {
1484         description = "Water Source",
1485         drawtype = "liquid",
1486         tiles = {
1487                 {
1488                         name = "default_water_source_animated.png",
1489                         animation = {
1490                                 type = "vertical_frames",
1491                                 aspect_w = 16,
1492                                 aspect_h = 16,
1493                                 length = 2.0,
1494                         },
1495                 },
1496         },
1497         special_tiles = {
1498                 -- New-style water source material (mostly unused)
1499                 {
1500                         name = "default_water_source_animated.png",
1501                         animation = {
1502                                 type = "vertical_frames",
1503                                 aspect_w = 16,
1504                                 aspect_h = 16,
1505                                 length = 2.0,
1506                         },
1507                         backface_culling = false,
1508                 },
1509         },
1510         alpha = 160,
1511         paramtype = "light",
1512         walkable = false,
1513         pointable = false,
1514         diggable = false,
1515         buildable_to = true,
1516         is_ground_content = false,
1517         drop = "",
1518         drowning = 1,
1519         liquidtype = "source",
1520         liquid_alternative_flowing = "default:water_flowing",
1521         liquid_alternative_source = "default:water_source",
1522         liquid_viscosity = 1,
1523         post_effect_color = {a = 103, r = 30, g = 60, b = 90},
1524         groups = {water = 3, liquid = 3, puts_out_fire = 1, cools_lava = 1},
1525         sounds = default.node_sound_water_defaults(),
1526 })
1527
1528 minetest.register_node("default:water_flowing", {
1529         description = "Flowing Water",
1530         drawtype = "flowingliquid",
1531         tiles = {"default_water.png"},
1532         special_tiles = {
1533                 {
1534                         name = "default_water_flowing_animated.png",
1535                         backface_culling = false,
1536                         animation = {
1537                                 type = "vertical_frames",
1538                                 aspect_w = 16,
1539                                 aspect_h = 16,
1540                                 length = 0.8,
1541                         },
1542                 },
1543                 {
1544                         name = "default_water_flowing_animated.png",
1545                         backface_culling = true,
1546                         animation = {
1547                                 type = "vertical_frames",
1548                                 aspect_w = 16,
1549                                 aspect_h = 16,
1550                                 length = 0.8,
1551                         },
1552                 },
1553         },
1554         alpha = 160,
1555         paramtype = "light",
1556         paramtype2 = "flowingliquid",
1557         walkable = false,
1558         pointable = false,
1559         diggable = false,
1560         buildable_to = true,
1561         is_ground_content = false,
1562         drop = "",
1563         drowning = 1,
1564         liquidtype = "flowing",
1565         liquid_alternative_flowing = "default:water_flowing",
1566         liquid_alternative_source = "default:water_source",
1567         liquid_viscosity = 1,
1568         post_effect_color = {a = 103, r = 30, g = 60, b = 90},
1569         groups = {water = 3, liquid = 3, puts_out_fire = 1,
1570                 not_in_creative_inventory = 1, cools_lava = 1},
1571         sounds = default.node_sound_water_defaults(),
1572 })
1573
1574
1575 minetest.register_node("default:river_water_source", {
1576         description = "River Water Source",
1577         drawtype = "liquid",
1578         tiles = {
1579                 {
1580                         name = "default_river_water_source_animated.png",
1581                         animation = {
1582                                 type = "vertical_frames",
1583                                 aspect_w = 16,
1584                                 aspect_h = 16,
1585                                 length = 2.0,
1586                         },
1587                 },
1588         },
1589         special_tiles = {
1590                 {
1591                         name = "default_river_water_source_animated.png",
1592                         animation = {
1593                                 type = "vertical_frames",
1594                                 aspect_w = 16,
1595                                 aspect_h = 16,
1596                                 length = 2.0,
1597                         },
1598                         backface_culling = false,
1599                 },
1600         },
1601         alpha = 160,
1602         paramtype = "light",
1603         walkable = false,
1604         pointable = false,
1605         diggable = false,
1606         buildable_to = true,
1607         is_ground_content = false,
1608         drop = "",
1609         drowning = 1,
1610         liquidtype = "source",
1611         liquid_alternative_flowing = "default:river_water_flowing",
1612         liquid_alternative_source = "default:river_water_source",
1613         liquid_viscosity = 1,
1614         liquid_renewable = false,
1615         liquid_range = 2,
1616         post_effect_color = {a = 103, r = 30, g = 76, b = 90},
1617         groups = {water = 3, liquid = 3, puts_out_fire = 1, cools_lava = 1},
1618         sounds = default.node_sound_water_defaults(),
1619 })
1620
1621 minetest.register_node("default:river_water_flowing", {
1622         description = "Flowing River Water",
1623         drawtype = "flowingliquid",
1624         tiles = {"default_river_water.png"},
1625         special_tiles = {
1626                 {
1627                         name = "default_river_water_flowing_animated.png",
1628                         backface_culling = false,
1629                         animation = {
1630                                 type = "vertical_frames",
1631                                 aspect_w = 16,
1632                                 aspect_h = 16,
1633                                 length = 0.8,
1634                         },
1635                 },
1636                 {
1637                         name = "default_river_water_flowing_animated.png",
1638                         backface_culling = true,
1639                         animation = {
1640                                 type = "vertical_frames",
1641                                 aspect_w = 16,
1642                                 aspect_h = 16,
1643                                 length = 0.8,
1644                         },
1645                 },
1646         },
1647         alpha = 160,
1648         paramtype = "light",
1649         paramtype2 = "flowingliquid",
1650         walkable = false,
1651         pointable = false,
1652         diggable = false,
1653         buildable_to = true,
1654         is_ground_content = false,
1655         drop = "",
1656         drowning = 1,
1657         liquidtype = "flowing",
1658         liquid_alternative_flowing = "default:river_water_flowing",
1659         liquid_alternative_source = "default:river_water_source",
1660         liquid_viscosity = 1,
1661         liquid_renewable = false,
1662         liquid_range = 2,
1663         post_effect_color = {a = 103, r = 30, g = 76, b = 90},
1664         groups = {water = 3, liquid = 3, puts_out_fire = 1,
1665                 not_in_creative_inventory = 1, cools_lava = 1},
1666         sounds = default.node_sound_water_defaults(),
1667 })
1668
1669
1670 minetest.register_node("default:lava_source", {
1671         description = "Lava Source",
1672         drawtype = "liquid",
1673         tiles = {
1674                 {
1675                         name = "default_lava_source_animated.png",
1676                         animation = {
1677                                 type = "vertical_frames",
1678                                 aspect_w = 16,
1679                                 aspect_h = 16,
1680                                 length = 3.0,
1681                         },
1682                 },
1683         },
1684         special_tiles = {
1685                 -- New-style lava source material (mostly unused)
1686                 {
1687                         name = "default_lava_source_animated.png",
1688                         animation = {
1689                                 type = "vertical_frames",
1690                                 aspect_w = 16,
1691                                 aspect_h = 16,
1692                                 length = 3.0,
1693                         },
1694                         backface_culling = false,
1695                 },
1696         },
1697         paramtype = "light",
1698         light_source = default.LIGHT_MAX - 1,
1699         walkable = false,
1700         pointable = false,
1701         diggable = false,
1702         buildable_to = true,
1703         is_ground_content = false,
1704         drop = "",
1705         drowning = 1,
1706         liquidtype = "source",
1707         liquid_alternative_flowing = "default:lava_flowing",
1708         liquid_alternative_source = "default:lava_source",
1709         liquid_viscosity = 7,
1710         liquid_renewable = false,
1711         damage_per_second = 4 * 2,
1712         post_effect_color = {a = 191, r = 255, g = 64, b = 0},
1713         groups = {lava = 3, liquid = 2, igniter = 1},
1714 })
1715
1716 minetest.register_node("default:lava_flowing", {
1717         description = "Flowing Lava",
1718         drawtype = "flowingliquid",
1719         tiles = {"default_lava.png"},
1720         special_tiles = {
1721                 {
1722                         name = "default_lava_flowing_animated.png",
1723                         backface_culling = false,
1724                         animation = {
1725                                 type = "vertical_frames",
1726                                 aspect_w = 16,
1727                                 aspect_h = 16,
1728                                 length = 3.3,
1729                         },
1730                 },
1731                 {
1732                         name = "default_lava_flowing_animated.png",
1733                         backface_culling = true,
1734                         animation = {
1735                                 type = "vertical_frames",
1736                                 aspect_w = 16,
1737                                 aspect_h = 16,
1738                                 length = 3.3,
1739                         },
1740                 },
1741         },
1742         paramtype = "light",
1743         paramtype2 = "flowingliquid",
1744         light_source = default.LIGHT_MAX - 1,
1745         walkable = false,
1746         pointable = false,
1747         diggable = false,
1748         buildable_to = true,
1749         is_ground_content = false,
1750         drop = "",
1751         drowning = 1,
1752         liquidtype = "flowing",
1753         liquid_alternative_flowing = "default:lava_flowing",
1754         liquid_alternative_source = "default:lava_source",
1755         liquid_viscosity = 7,
1756         liquid_renewable = false,
1757         damage_per_second = 4 * 2,
1758         post_effect_color = {a = 191, r = 255, g = 64, b = 0},
1759         groups = {lava = 3, liquid = 2, igniter = 1,
1760                 not_in_creative_inventory = 1},
1761 })
1762
1763 --
1764 -- Tools / "Advanced" crafting / Non-"natural"
1765 --
1766
1767 local function get_chest_formspec(pos)
1768         local spos = pos.x .. "," .. pos.y .. "," .. pos.z
1769         local formspec =
1770                 "size[8,9]" ..
1771                 default.gui_bg ..
1772                 default.gui_bg_img ..
1773                 default.gui_slots ..
1774                 "list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
1775                 "list[current_player;main;0,4.85;8,1;]" ..
1776                 "list[current_player;main;0,6.08;8,3;8]" ..
1777                 "listring[nodemeta:" .. spos .. ";main]" ..
1778                 "listring[current_player;main]" ..
1779                 default.get_hotbar_bg(0,4.85)
1780         return formspec
1781 end
1782
1783 local function chest_lid_obstructed(pos)
1784         local above = {x = pos.x, y = pos.y + 1, z = pos.z}
1785         local def = minetest.registered_nodes[minetest.get_node(above).name]
1786         -- allow ladders, signs, wallmounted things and torches to not obstruct
1787         if def and
1788                         (def.drawtype == "airlike" or
1789                         def.drawtype == "signlike" or
1790                         def.drawtype == "torchlike" or
1791                         (def.drawtype == "nodebox" and def.paramtype2 == "wallmounted")) then
1792                 return false
1793         end
1794         return true
1795 end
1796
1797 local open_chests = {}
1798
1799 local function chest_lid_close(pn)
1800         local pos = open_chests[pn].pos
1801         local sound = open_chests[pn].sound
1802         local swap = open_chests[pn].swap
1803
1804         open_chests[pn] = nil
1805         for k, v in pairs(open_chests) do
1806                 if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then
1807                         return true
1808                 end
1809         end
1810
1811         local node = minetest.get_node(pos)
1812         minetest.after(0.2, minetest.swap_node, pos, { name = "default:" .. swap,
1813                         param2 = node.param2 })
1814         minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10})
1815 end
1816
1817 minetest.register_on_player_receive_fields(function(player, formname, fields)
1818         if formname ~= "default:chest" then
1819                 return
1820         end
1821         if not player or not fields.quit then
1822                 return
1823         end
1824         local pn = player:get_player_name()
1825
1826         if not open_chests[pn] then
1827                 return
1828         end
1829
1830         chest_lid_close(pn)
1831         return true
1832 end)
1833
1834 minetest.register_on_leaveplayer(function(player)
1835         local pn = player:get_player_name()
1836         if open_chests[pn] then
1837                 chest_lid_close(pn)
1838         end
1839 end)
1840
1841 function default.register_chest(name, d)
1842         local def = table.copy(d)
1843         def.drawtype = "mesh"
1844         def.visual = "mesh"
1845         def.paramtype = "light"
1846         def.paramtype2 = "facedir"
1847         def.legacy_facedir_simple = true
1848         def.is_ground_content = false
1849
1850         if def.protected then
1851                 def.on_construct = function(pos)
1852                         local meta = minetest.get_meta(pos)
1853                         meta:set_string("infotext", "Locked Chest")
1854                         meta:set_string("owner", "")
1855                         local inv = meta:get_inventory()
1856                         inv:set_size("main", 8*4)
1857                 end
1858                 def.after_place_node = function(pos, placer)
1859                         local meta = minetest.get_meta(pos)
1860                         meta:set_string("owner", placer:get_player_name() or "")
1861                         meta:set_string("infotext", "Locked Chest (owned by " ..
1862                                         meta:get_string("owner") .. ")")
1863                 end
1864                 def.can_dig = function(pos,player)
1865                         local meta = minetest.get_meta(pos);
1866                         local inv = meta:get_inventory()
1867                         return inv:is_empty("main") and
1868                                         default.can_interact_with_node(player, pos)
1869                 end
1870                 def.allow_metadata_inventory_move = function(pos, from_list, from_index,
1871                                 to_list, to_index, count, player)
1872                         if not default.can_interact_with_node(player, pos) then
1873                                 return 0
1874                         end
1875                         return count
1876                 end
1877                 def.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
1878                         if not default.can_interact_with_node(player, pos) then
1879                                 return 0
1880                         end
1881                         return stack:get_count()
1882                 end
1883                 def.allow_metadata_inventory_take = function(pos, listname, index, stack, player)
1884                         if not default.can_interact_with_node(player, pos) then
1885                                 return 0
1886                         end
1887                         return stack:get_count()
1888                 end
1889                 def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
1890                         if not default.can_interact_with_node(clicker, pos) then
1891                                 return itemstack
1892                         end
1893
1894                         minetest.sound_play(def.sound_open, {gain = 0.3,
1895                                         pos = pos, max_hear_distance = 10})
1896                         if not chest_lid_obstructed(pos) then
1897                                 minetest.swap_node(pos,
1898                                                 { name = "default:" .. name .. "_open",
1899                                                 param2 = node.param2 })
1900                         end
1901                         minetest.after(0.2, minetest.show_formspec,
1902                                         clicker:get_player_name(),
1903                                         "default:chest", get_chest_formspec(pos))
1904                         open_chests[clicker:get_player_name()] = { pos = pos,
1905                                         sound = def.sound_close, swap = name }
1906                 end
1907                 def.on_blast = function() end
1908                 def.on_key_use = function(pos, player)
1909                         local secret = minetest.get_meta(pos):get_string("key_lock_secret")
1910                         local itemstack = player:get_wielded_item()
1911                         local key_meta = itemstack:get_meta()
1912
1913                         if key_meta:get_string("secret") == "" then
1914                                 key_meta:set_string("secret", minetest.parse_json(itemstack:get_metadata()).secret)
1915                                 itemstack:set_metadata("")
1916                         end
1917
1918                         if secret ~= key_meta:get_string("secret") then
1919                                 return
1920                         end
1921
1922                         minetest.show_formspec(
1923                                 player:get_player_name(),
1924                                 "default:chest_locked",
1925                                 get_chest_formspec(pos)
1926                         )
1927                 end
1928                 def.on_skeleton_key_use = function(pos, player, newsecret)
1929                         local meta = minetest.get_meta(pos)
1930                         local owner = meta:get_string("owner")
1931                         local pn = player:get_player_name()
1932
1933                         -- verify placer is owner of lockable chest
1934                         if owner ~= pn then
1935                                 minetest.record_protection_violation(pos, pn)
1936                                 minetest.chat_send_player(pn, "You do not own this chest.")
1937                                 return nil
1938                         end
1939
1940                         local secret = meta:get_string("key_lock_secret")
1941                         if secret == "" then
1942                                 secret = newsecret
1943                                 meta:set_string("key_lock_secret", secret)
1944                         end
1945
1946                         return secret, "a locked chest", owner
1947                 end
1948         else
1949                 def.on_construct = function(pos)
1950                         local meta = minetest.get_meta(pos)
1951                         meta:set_string("infotext", "Chest")
1952                         local inv = meta:get_inventory()
1953                         inv:set_size("main", 8*4)
1954                 end
1955                 def.can_dig = function(pos,player)
1956                         local meta = minetest.get_meta(pos);
1957                         local inv = meta:get_inventory()
1958                         return inv:is_empty("main")
1959                 end
1960                 def.on_rightclick = function(pos, node, clicker)
1961                         minetest.sound_play(def.sound_open, {gain = 0.3, pos = pos,
1962                                         max_hear_distance = 10})
1963                         if not chest_lid_obstructed(pos) then
1964                                 minetest.swap_node(pos, {
1965                                                 name = "default:" .. name .. "_open",
1966                                                 param2 = node.param2 })
1967                         end
1968                         minetest.after(0.2, minetest.show_formspec,
1969                                         clicker:get_player_name(),
1970                                         "default:chest", get_chest_formspec(pos))
1971                         open_chests[clicker:get_player_name()] = { pos = pos,
1972                                         sound = def.sound_close, swap = name }
1973                 end
1974                 def.on_blast = function(pos)
1975                         local drops = {}
1976                         default.get_inventory_drops(pos, "main", drops)
1977                         drops[#drops+1] = "default:" .. name
1978                         minetest.remove_node(pos)
1979                         return drops
1980                 end
1981         end
1982
1983         def.on_metadata_inventory_move = function(pos, from_list, from_index,
1984                         to_list, to_index, count, player)
1985                 minetest.log("action", player:get_player_name() ..
1986                         " moves stuff in chest at " .. minetest.pos_to_string(pos))
1987         end
1988         def.on_metadata_inventory_put = function(pos, listname, index, stack, player)
1989                 minetest.log("action", player:get_player_name() ..
1990                         " moves " .. stack:get_name() ..
1991                         " to chest at " .. minetest.pos_to_string(pos))
1992         end
1993         def.on_metadata_inventory_take = function(pos, listname, index, stack, player)
1994                 minetest.log("action", player:get_player_name() ..
1995                         " takes " .. stack:get_name() ..
1996                         " from chest at " .. minetest.pos_to_string(pos))
1997         end
1998
1999         local def_opened = table.copy(def)
2000         local def_closed = table.copy(def)
2001
2002         def_opened.mesh = "chest_open.obj"
2003         for i = 1, #def_opened.tiles do
2004                 if type(def_opened.tiles[i]) == "string" then
2005                         def_opened.tiles[i] = {name = def_opened.tiles[i], backface_culling = true}
2006                 elseif def_opened.tiles[i].backface_culling == nil then
2007                         def_opened.tiles[i].backface_culling = true
2008                 end
2009         end
2010         def_opened.drop = "default:" .. name
2011         def_opened.groups.not_in_creative_inventory = 1
2012         def_opened.selection_box = {
2013                 type = "fixed",
2014                 fixed = { -1/2, -1/2, -1/2, 1/2, 3/16, 1/2 },
2015         }
2016         def_opened.can_dig = function()
2017                 return false
2018         end
2019         def_opened.on_blast = function() end
2020
2021         def_closed.mesh = nil
2022         def_closed.drawtype = nil
2023         def_closed.tiles[6] = def.tiles[5] -- swap textures around for "normal"
2024         def_closed.tiles[5] = def.tiles[3] -- drawtype to make them match the mesh
2025         def_closed.tiles[3] = def.tiles[3].."^[transformFX"
2026
2027         minetest.register_node("default:" .. name, def_closed)
2028         minetest.register_node("default:" .. name .. "_open", def_opened)
2029
2030         -- convert old chests to this new variant
2031         minetest.register_lbm({
2032                 label = "update chests to opening chests",
2033                 name = "default:upgrade_" .. name .. "_v2",
2034                 nodenames = {"default:" .. name},
2035                 action = function(pos, node)
2036                         local meta = minetest.get_meta(pos)
2037                         meta:set_string("formspec", nil)
2038                         local inv = meta:get_inventory()
2039                         local list = inv:get_list("default:chest")
2040                         if list then
2041                                 inv:set_size("main", 8*4)
2042                                 inv:set_list("main", list)
2043                                 inv:set_list("default:chest", nil)
2044                         end
2045                 end
2046         })
2047 end
2048
2049
2050 default.register_chest("chest", {
2051         description = "Chest",
2052         tiles = {
2053                 "default_chest_top.png",
2054                 "default_chest_top.png",
2055                 "default_chest_side.png",
2056                 "default_chest_side.png",
2057                 "default_chest_front.png",
2058                 "default_chest_inside.png"
2059         },
2060         sounds = default.node_sound_wood_defaults(),
2061         sound_open = "default_chest_open",
2062         sound_close = "default_chest_close",
2063         groups = {choppy = 2, oddly_breakable_by_hand = 2},
2064 })
2065
2066 default.register_chest("chest_locked", {
2067         description = "Locked Chest",
2068         tiles = {
2069                 "default_chest_top.png",
2070                 "default_chest_top.png",
2071                 "default_chest_side.png",
2072                 "default_chest_side.png",
2073                 "default_chest_lock.png",
2074                 "default_chest_inside.png"
2075         },
2076         sounds = default.node_sound_wood_defaults(),
2077         sound_open = "default_chest_open",
2078         sound_close = "default_chest_close",
2079         groups = {choppy = 2, oddly_breakable_by_hand = 2},
2080         protected = true,
2081 })
2082
2083 local bookshelf_formspec =
2084         "size[8,7;]" ..
2085         default.gui_bg ..
2086         default.gui_bg_img ..
2087         default.gui_slots ..
2088         "list[context;books;0,0.3;8,2;]" ..
2089         "list[current_player;main;0,2.85;8,1;]" ..
2090         "list[current_player;main;0,4.08;8,3;8]" ..
2091         "listring[context;books]" ..
2092         "listring[current_player;main]" ..
2093         default.get_hotbar_bg(0,2.85)
2094
2095 local function get_bookshelf_formspec(inv)
2096         local formspec = bookshelf_formspec
2097         local invlist = inv and inv:get_list("books")
2098         -- Inventory slots overlay
2099         local bx, by = 0, 0.3
2100         for i = 1, 16 do
2101                 if i == 9 then
2102                         bx = 0
2103                         by = by + 1
2104                 end
2105                 if not invlist or invlist[i]:is_empty() then
2106                         formspec = formspec ..
2107                                 "image[" .. bx .. "," .. by .. ";1,1;default_bookshelf_slot.png]"
2108                 end
2109                 bx = bx + 1
2110         end
2111         return formspec
2112 end
2113
2114 minetest.register_node("default:bookshelf", {
2115         description = "Bookshelf",
2116         tiles = {"default_wood.png", "default_wood.png", "default_wood.png",
2117                 "default_wood.png", "default_bookshelf.png", "default_bookshelf.png"},
2118         paramtype2 = "facedir",
2119         is_ground_content = false,
2120         groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
2121         sounds = default.node_sound_wood_defaults(),
2122
2123         on_construct = function(pos)
2124                 local meta = minetest.get_meta(pos)
2125                 meta:set_string("formspec", get_bookshelf_formspec(nil))
2126                 local inv = meta:get_inventory()
2127                 inv:set_size("books", 8 * 2)
2128         end,
2129         can_dig = function(pos,player)
2130                 local inv = minetest.get_meta(pos):get_inventory()
2131                 return inv:is_empty("books")
2132         end,
2133         allow_metadata_inventory_put = function(pos, listname, index, stack)
2134                 if minetest.get_item_group(stack:get_name(), "book") ~= 0 then
2135                         return stack:get_count()
2136                 end
2137                 return 0
2138         end,
2139         on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
2140                 minetest.log("action", player:get_player_name() ..
2141                         " moves stuff in bookshelf at " .. minetest.pos_to_string(pos))
2142                 local meta = minetest.get_meta(pos)
2143                 meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
2144         end,
2145         on_metadata_inventory_put = function(pos, listname, index, stack, player)
2146                 minetest.log("action", player:get_player_name() ..
2147                         " moves stuff to bookshelf at " .. minetest.pos_to_string(pos))
2148                 local meta = minetest.get_meta(pos)
2149                 meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
2150         end,
2151         on_metadata_inventory_take = function(pos, listname, index, stack, player)
2152                 minetest.log("action", player:get_player_name() ..
2153                         " takes stuff from bookshelf at " .. minetest.pos_to_string(pos))
2154                 local meta = minetest.get_meta(pos)
2155                 meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
2156         end,
2157         on_blast = function(pos)
2158                 local drops = {}
2159                 default.get_inventory_drops(pos, "books", drops)
2160                 drops[#drops+1] = "default:bookshelf"
2161                 minetest.remove_node(pos)
2162                 return drops
2163         end,
2164 })
2165
2166 local function register_sign(material, desc, def)
2167         minetest.register_node("default:sign_wall_" .. material, {
2168                 description = desc .. " Sign",
2169                 drawtype = "nodebox",
2170                 tiles = {"default_sign_wall_" .. material .. ".png"},
2171                 inventory_image = "default_sign_" .. material .. ".png",
2172                 wield_image = "default_sign_" .. material .. ".png",
2173                 paramtype = "light",
2174                 paramtype2 = "wallmounted",
2175                 sunlight_propagates = true,
2176                 is_ground_content = false,
2177                 walkable = false,
2178                 node_box = {
2179                         type = "wallmounted",
2180                         wall_top    = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
2181                         wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
2182                         wall_side   = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375},
2183                 },
2184                 groups = def.groups,
2185                 legacy_wallmounted = true,
2186                 sounds = def.sounds,
2187
2188                 on_construct = function(pos)
2189                         --local n = minetest.get_node(pos)
2190                         local meta = minetest.get_meta(pos)
2191                         meta:set_string("formspec", "field[text;;${text}]")
2192                 end,
2193                 on_receive_fields = function(pos, formname, fields, sender)
2194                         --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
2195                         local player_name = sender:get_player_name()
2196                         if minetest.is_protected(pos, player_name) then
2197                                 minetest.record_protection_violation(pos, player_name)
2198                                 return
2199                         end
2200                         local meta = minetest.get_meta(pos)
2201                         if not fields.text then return end
2202                         minetest.log("action", (player_name or "") .. " wrote \"" ..
2203                                 fields.text .. "\" to sign at " .. minetest.pos_to_string(pos))
2204                         meta:set_string("text", fields.text)
2205                         meta:set_string("infotext", '"' .. fields.text .. '"')
2206                 end,
2207         })
2208 end
2209
2210 register_sign("wood", "Wooden", {
2211         sounds = default.node_sound_wood_defaults(),
2212         groups = {choppy = 2, attached_node = 1, flammable = 2, oddly_breakable_by_hand = 3}
2213 })
2214
2215 register_sign("steel", "Steel", {
2216         sounds = default.node_sound_metal_defaults(),
2217         groups = {cracky = 2, attached_node = 1}
2218 })
2219
2220 minetest.register_node("default:ladder_wood", {
2221         description = "Wooden Ladder",
2222         drawtype = "signlike",
2223         tiles = {"default_ladder_wood.png"},
2224         inventory_image = "default_ladder_wood.png",
2225         wield_image = "default_ladder_wood.png",
2226         paramtype = "light",
2227         paramtype2 = "wallmounted",
2228         sunlight_propagates = true,
2229         walkable = false,
2230         climbable = true,
2231         is_ground_content = false,
2232         selection_box = {
2233                 type = "wallmounted",
2234                 --wall_top = = <default>
2235                 --wall_bottom = = <default>
2236                 --wall_side = = <default>
2237         },
2238         groups = {choppy = 2, oddly_breakable_by_hand = 3, flammable = 2},
2239         legacy_wallmounted = true,
2240         sounds = default.node_sound_wood_defaults(),
2241 })
2242
2243 minetest.register_node("default:ladder_steel", {
2244         description = "Steel Ladder",
2245         drawtype = "signlike",
2246         tiles = {"default_ladder_steel.png"},
2247         inventory_image = "default_ladder_steel.png",
2248         wield_image = "default_ladder_steel.png",
2249         paramtype = "light",
2250         paramtype2 = "wallmounted",
2251         sunlight_propagates = true,
2252         walkable = false,
2253         climbable = true,
2254         is_ground_content = false,
2255         selection_box = {
2256                 type = "wallmounted",
2257                 --wall_top = = <default>
2258                 --wall_bottom = = <default>
2259                 --wall_side = = <default>
2260         },
2261         groups = {cracky = 2},
2262         sounds = default.node_sound_metal_defaults(),
2263 })
2264
2265 default.register_fence("default:fence_wood", {
2266         description = "Wooden Fence",
2267         texture = "default_fence_wood.png",
2268         inventory_image = "default_fence_overlay.png^default_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2269         wield_image = "default_fence_overlay.png^default_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2270         material = "default:wood",
2271         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
2272         sounds = default.node_sound_wood_defaults()
2273 })
2274
2275 default.register_fence("default:fence_acacia_wood", {
2276         description = "Acacia Fence",
2277         texture = "default_fence_acacia_wood.png",
2278         inventory_image = "default_fence_overlay.png^default_acacia_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2279         wield_image = "default_fence_overlay.png^default_acacia_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2280         material = "default:acacia_wood",
2281         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
2282         sounds = default.node_sound_wood_defaults()
2283 })
2284
2285 default.register_fence("default:fence_junglewood", {
2286         description = "Jungle Wood Fence",
2287         texture = "default_fence_junglewood.png",
2288         inventory_image = "default_fence_overlay.png^default_junglewood.png^default_fence_overlay.png^[makealpha:255,126,126",
2289         wield_image = "default_fence_overlay.png^default_junglewood.png^default_fence_overlay.png^[makealpha:255,126,126",
2290         material = "default:junglewood",
2291         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
2292         sounds = default.node_sound_wood_defaults()
2293 })
2294
2295 default.register_fence("default:fence_pine_wood", {
2296         description = "Pine Fence",
2297         texture = "default_fence_pine_wood.png",
2298         inventory_image = "default_fence_overlay.png^default_pine_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2299         wield_image = "default_fence_overlay.png^default_pine_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2300         material = "default:pine_wood",
2301         groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
2302         sounds = default.node_sound_wood_defaults()
2303 })
2304
2305 default.register_fence("default:fence_aspen_wood", {
2306         description = "Aspen Fence",
2307         texture = "default_fence_aspen_wood.png",
2308         inventory_image = "default_fence_overlay.png^default_aspen_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2309         wield_image = "default_fence_overlay.png^default_aspen_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2310         material = "default:aspen_wood",
2311         groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
2312         sounds = default.node_sound_wood_defaults()
2313 })
2314
2315 minetest.register_node("default:glass", {
2316         description = "Glass",
2317         drawtype = "glasslike_framed_optional",
2318         tiles = {"default_glass.png", "default_glass_detail.png"},
2319         paramtype = "light",
2320         paramtype2 = "glasslikeliquidlevel",
2321         sunlight_propagates = true,
2322         is_ground_content = false,
2323         groups = {cracky = 3, oddly_breakable_by_hand = 3},
2324         sounds = default.node_sound_glass_defaults(),
2325 })
2326
2327 minetest.register_node("default:obsidian_glass", {
2328         description = "Obsidian Glass",
2329         drawtype = "glasslike_framed_optional",
2330         tiles = {"default_obsidian_glass.png", "default_obsidian_glass_detail.png"},
2331         paramtype = "light",
2332         paramtype2 = "glasslikeliquidlevel",
2333         is_ground_content = false,
2334         sunlight_propagates = true,
2335         sounds = default.node_sound_glass_defaults(),
2336         groups = {cracky = 3},
2337 })
2338
2339
2340 minetest.register_node("default:brick", {
2341         description = "Brick Block",
2342         paramtype2 = "facedir",
2343         place_param2 = 0,
2344         tiles = {"default_brick.png"},
2345         is_ground_content = false,
2346         groups = {cracky = 3},
2347         sounds = default.node_sound_stone_defaults(),
2348 })
2349
2350
2351 minetest.register_node("default:meselamp", {
2352         description = "Mese Lamp",
2353         drawtype = "glasslike",
2354         tiles = {"default_meselamp.png"},
2355         paramtype = "light",
2356         sunlight_propagates = true,
2357         is_ground_content = false,
2358         groups = {cracky = 3, oddly_breakable_by_hand = 3},
2359         sounds = default.node_sound_glass_defaults(),
2360         light_source = default.LIGHT_MAX,
2361 })
2362
2363 minetest.register_node("default:mese_post_light", {
2364         description = "Mese Post Light",
2365         tiles = {"default_mese_post_light_top.png", "default_mese_post_light_top.png",
2366                 "default_mese_post_light_side_dark.png", "default_mese_post_light_side_dark.png",
2367                 "default_mese_post_light_side.png", "default_mese_post_light_side.png"},
2368         wield_image = "default_mese_post_light_side.png",
2369         drawtype = "nodebox",
2370         node_box = {
2371                 type = "fixed",
2372                 fixed = {
2373                         {-2 / 16, -8 / 16, -2 / 16, 2 / 16, 8 / 16, 2 / 16},
2374                 },
2375         },
2376         paramtype = "light",
2377         light_source = default.LIGHT_MAX,
2378         sunlight_propagates = true,
2379         is_ground_content = false,
2380         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
2381         sounds = default.node_sound_wood_defaults(),
2382 })
2383
2384 --
2385 -- Misc
2386 --
2387
2388 minetest.register_node("default:cloud", {
2389         description = "Cloud",
2390         tiles = {"default_cloud.png"},
2391         is_ground_content = false,
2392         sounds = default.node_sound_defaults(),
2393         groups = {not_in_creative_inventory = 1},
2394 })
2395
2396 --
2397 -- register trees for leafdecay
2398 --
2399
2400 if minetest.get_mapgen_setting("mg_name") == "v6" then
2401         default.register_leafdecay({
2402                 trunks = {"default:tree"},
2403                 leaves = {"default:apple", "default:leaves"},
2404                 radius = 2,
2405         })
2406
2407         default.register_leafdecay({
2408                 trunks = {"default:jungletree"},
2409                 leaves = {"default:jungleleaves"},
2410                 radius = 3,
2411         })
2412
2413         default.register_leafdecay({
2414                 trunks = {"default:pine_tree"},
2415                 leaves = {"default:pine_needles"},
2416                 radius = 3,
2417         })
2418 else
2419         default.register_leafdecay({
2420                 trunks = {"default:tree"},
2421                 leaves = {"default:apple", "default:leaves"},
2422                 radius = 3,
2423         })
2424
2425         default.register_leafdecay({
2426                 trunks = {"default:jungletree"},
2427                 leaves = {"default:jungleleaves"},
2428                 radius = 2,
2429         })
2430
2431         default.register_leafdecay({
2432                 trunks = {"default:pine_tree"},
2433                 leaves = {"default:pine_needles"},
2434                 radius = 2,
2435         })
2436 end
2437
2438 default.register_leafdecay({
2439         trunks = {"default:acacia_tree"},
2440         leaves = {"default:acacia_leaves"},
2441         radius = 2,
2442 })
2443
2444 default.register_leafdecay({
2445         trunks = {"default:aspen_tree"},
2446         leaves = {"default:aspen_leaves"},
2447         radius = 3,
2448 })
2449
2450 default.register_leafdecay({
2451         trunks = {"default:bush_stem"},
2452         leaves = {"default:bush_leaves"},
2453         radius = 1,
2454 })
2455
2456 default.register_leafdecay({
2457         trunks = {"default:acacia_bush_stem"},
2458         leaves = {"default:acacia_bush_leaves"},
2459         radius = 1,
2460 })