Creative: Make the placenode registration check for non-player placers
[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                 if placer:is_player() then
677                         minetest.set_node(pos, {name = "default:apple", param2 = 1})
678                 end
679         end,
680 })
681
682
683 minetest.register_node("default:jungletree", {
684         description = "Jungle Tree",
685         tiles = {"default_jungletree_top.png", "default_jungletree_top.png",
686                 "default_jungletree.png"},
687         paramtype2 = "facedir",
688         is_ground_content = false,
689         groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
690         sounds = default.node_sound_wood_defaults(),
691
692         on_place = minetest.rotate_node
693 })
694
695 minetest.register_node("default:junglewood", {
696         description = "Jungle Wood Planks",
697         paramtype2 = "facedir",
698         place_param2 = 0,
699         tiles = {"default_junglewood.png"},
700         is_ground_content = false,
701         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1},
702         sounds = default.node_sound_wood_defaults(),
703 })
704
705 minetest.register_node("default:jungleleaves", {
706         description = "Jungle Leaves",
707         drawtype = "allfaces_optional",
708         waving = 1,
709         tiles = {"default_jungleleaves.png"},
710         special_tiles = {"default_jungleleaves_simple.png"},
711         paramtype = "light",
712         is_ground_content = false,
713         groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
714         drop = {
715                 max_items = 1,
716                 items = {
717                         {items = {'default:junglesapling'}, rarity = 20},
718                         {items = {'default:jungleleaves'}}
719                 }
720         },
721         sounds = default.node_sound_leaves_defaults(),
722
723         after_place_node = default.after_place_leaves,
724 })
725
726 minetest.register_node("default:junglesapling", {
727         description = "Jungle Sapling",
728         drawtype = "plantlike",
729         tiles = {"default_junglesapling.png"},
730         inventory_image = "default_junglesapling.png",
731         wield_image = "default_junglesapling.png",
732         paramtype = "light",
733         sunlight_propagates = true,
734         walkable = false,
735         on_timer = default.grow_sapling,
736         selection_box = {
737                 type = "fixed",
738                 fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
739         },
740         groups = {snappy = 2, dig_immediate = 3, flammable = 2,
741                 attached_node = 1, sapling = 1},
742         sounds = default.node_sound_leaves_defaults(),
743
744         on_construct = function(pos)
745                 minetest.get_node_timer(pos):start(math.random(300, 1500))
746         end,
747
748         on_place = function(itemstack, placer, pointed_thing)
749                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
750                         "default:junglesapling",
751                         -- minp, maxp to be checked, relative to sapling pos
752                         -- minp_relative.y = 1 because sapling pos has been checked
753                         {x = -2, y = 1, z = -2},
754                         {x = 2, y = 15, z = 2},
755                         -- maximum interval of interior volume check
756                         4)
757
758                 return itemstack
759         end,
760 })
761
762
763 minetest.register_node("default:pine_tree", {
764         description = "Pine Tree",
765         tiles = {"default_pine_tree_top.png", "default_pine_tree_top.png",
766                 "default_pine_tree.png"},
767         paramtype2 = "facedir",
768         is_ground_content = false,
769         groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3},
770         sounds = default.node_sound_wood_defaults(),
771
772         on_place = minetest.rotate_node
773 })
774
775 minetest.register_node("default:pine_wood", {
776         description = "Pine Wood Planks",
777         paramtype2 = "facedir",
778         place_param2 = 0,
779         tiles = {"default_pine_wood.png"},
780         is_ground_content = false,
781         groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
782         sounds = default.node_sound_wood_defaults(),
783 })
784
785 minetest.register_node("default:pine_needles",{
786         description = "Pine Needles",
787         drawtype = "allfaces_optional",
788         tiles = {"default_pine_needles.png"},
789         waving = 1,
790         paramtype = "light",
791         is_ground_content = false,
792         groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
793         drop = {
794                 max_items = 1,
795                 items = {
796                         {items = {"default:pine_sapling"}, rarity = 20},
797                         {items = {"default:pine_needles"}}
798                 }
799         },
800         sounds = default.node_sound_leaves_defaults(),
801
802         after_place_node = default.after_place_leaves,
803 })
804
805 minetest.register_node("default:pine_sapling", {
806         description = "Pine Sapling",
807         drawtype = "plantlike",
808         tiles = {"default_pine_sapling.png"},
809         inventory_image = "default_pine_sapling.png",
810         wield_image = "default_pine_sapling.png",
811         paramtype = "light",
812         sunlight_propagates = true,
813         walkable = false,
814         on_timer = default.grow_sapling,
815         selection_box = {
816                 type = "fixed",
817                 fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
818         },
819         groups = {snappy = 2, dig_immediate = 3, flammable = 3,
820                 attached_node = 1, sapling = 1},
821         sounds = default.node_sound_leaves_defaults(),
822
823         on_construct = function(pos)
824                 minetest.get_node_timer(pos):start(math.random(300, 1500))
825         end,
826
827         on_place = function(itemstack, placer, pointed_thing)
828                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
829                         "default:pine_sapling",
830                         -- minp, maxp to be checked, relative to sapling pos
831                         -- minp_relative.y = 1 because sapling pos has been checked
832                         {x = -2, y = 1, z = -2},
833                         {x = 2, y = 12, z = 2},
834                         -- maximum interval of interior volume check
835                         4)
836
837                 return itemstack
838         end,
839 })
840
841
842 minetest.register_node("default:acacia_tree", {
843         description = "Acacia Tree",
844         tiles = {"default_acacia_tree_top.png", "default_acacia_tree_top.png",
845                 "default_acacia_tree.png"},
846         paramtype2 = "facedir",
847         is_ground_content = false,
848         groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
849         sounds = default.node_sound_wood_defaults(),
850
851         on_place = minetest.rotate_node
852 })
853
854 minetest.register_node("default:acacia_wood", {
855         description = "Acacia Wood Planks",
856         paramtype2 = "facedir",
857         place_param2 = 0,
858         tiles = {"default_acacia_wood.png"},
859         is_ground_content = false,
860         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1},
861         sounds = default.node_sound_wood_defaults(),
862 })
863
864 minetest.register_node("default:acacia_leaves", {
865         description = "Acacia Leaves",
866         drawtype = "allfaces_optional",
867         tiles = {"default_acacia_leaves.png"},
868         special_tiles = {"default_acacia_leaves_simple.png"},
869         waving = 1,
870         paramtype = "light",
871         is_ground_content = false,
872         groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
873         drop = {
874                 max_items = 1,
875                 items = {
876                         {items = {"default:acacia_sapling"}, rarity = 20},
877                         {items = {"default:acacia_leaves"}}
878                 }
879         },
880         sounds = default.node_sound_leaves_defaults(),
881
882         after_place_node = default.after_place_leaves,
883 })
884
885 minetest.register_node("default:acacia_sapling", {
886         description = "Acacia Tree Sapling",
887         drawtype = "plantlike",
888         tiles = {"default_acacia_sapling.png"},
889         inventory_image = "default_acacia_sapling.png",
890         wield_image = "default_acacia_sapling.png",
891         paramtype = "light",
892         sunlight_propagates = true,
893         walkable = false,
894         on_timer = default.grow_sapling,
895         selection_box = {
896                 type = "fixed",
897                 fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
898         },
899         groups = {snappy = 2, dig_immediate = 3, flammable = 2,
900                 attached_node = 1, sapling = 1},
901         sounds = default.node_sound_leaves_defaults(),
902
903         on_construct = function(pos)
904                 minetest.get_node_timer(pos):start(math.random(300, 1500))
905         end,
906
907         on_place = function(itemstack, placer, pointed_thing)
908                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
909                         "default:acacia_sapling",
910                         -- minp, maxp to be checked, relative to sapling pos
911                         -- minp_relative.y = 1 because sapling pos has been checked
912                         {x = -4, y = 1, z = -4},
913                         {x = 4, y = 6, z = 4},
914                         -- maximum interval of interior volume check
915                         4)
916
917                 return itemstack
918         end,
919 })
920
921 minetest.register_node("default:aspen_tree", {
922         description = "Aspen Tree",
923         tiles = {"default_aspen_tree_top.png", "default_aspen_tree_top.png",
924                 "default_aspen_tree.png"},
925         paramtype2 = "facedir",
926         is_ground_content = false,
927         groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3},
928         sounds = default.node_sound_wood_defaults(),
929
930         on_place = minetest.rotate_node
931 })
932
933 minetest.register_node("default:aspen_wood", {
934         description = "Aspen Wood Planks",
935         paramtype2 = "facedir",
936         place_param2 = 0,
937         tiles = {"default_aspen_wood.png"},
938         is_ground_content = false,
939         groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
940         sounds = default.node_sound_wood_defaults(),
941 })
942
943 minetest.register_node("default:aspen_leaves", {
944         description = "Aspen Leaves",
945         drawtype = "allfaces_optional",
946         tiles = {"default_aspen_leaves.png"},
947         waving = 1,
948         paramtype = "light",
949         is_ground_content = false,
950         groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
951         drop = {
952                 max_items = 1,
953                 items = {
954                         {items = {"default:aspen_sapling"}, rarity = 20},
955                         {items = {"default:aspen_leaves"}}
956                 }
957         },
958         sounds = default.node_sound_leaves_defaults(),
959
960         after_place_node = default.after_place_leaves,
961 })
962
963 minetest.register_node("default:aspen_sapling", {
964         description = "Aspen Tree Sapling",
965         drawtype = "plantlike",
966         tiles = {"default_aspen_sapling.png"},
967         inventory_image = "default_aspen_sapling.png",
968         wield_image = "default_aspen_sapling.png",
969         paramtype = "light",
970         sunlight_propagates = true,
971         walkable = false,
972         on_timer = default.grow_sapling,
973         selection_box = {
974                 type = "fixed",
975                 fixed = {-3 / 16, -0.5, -3 / 16, 3 / 16, 0.5, 3 / 16}
976         },
977         groups = {snappy = 2, dig_immediate = 3, flammable = 3,
978                 attached_node = 1, sapling = 1},
979         sounds = default.node_sound_leaves_defaults(),
980
981         on_construct = function(pos)
982                 minetest.get_node_timer(pos):start(math.random(300, 1500))
983         end,
984
985         on_place = function(itemstack, placer, pointed_thing)
986                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
987                         "default:aspen_sapling",
988                         -- minp, maxp to be checked, relative to sapling pos
989                         -- minp_relative.y = 1 because sapling pos has been checked
990                         {x = -2, y = 1, z = -2},
991                         {x = 2, y = 12, z = 2},
992                         -- maximum interval of interior volume check
993                         4)
994
995                 return itemstack
996         end,
997 })
998
999 --
1000 -- Ores
1001 --
1002
1003 minetest.register_node("default:stone_with_coal", {
1004         description = "Coal Ore",
1005         tiles = {"default_stone.png^default_mineral_coal.png"},
1006         groups = {cracky = 3},
1007         drop = 'default:coal_lump',
1008         sounds = default.node_sound_stone_defaults(),
1009 })
1010
1011 minetest.register_node("default:coalblock", {
1012         description = "Coal Block",
1013         tiles = {"default_coal_block.png"},
1014         is_ground_content = false,
1015         groups = {cracky = 3},
1016         sounds = default.node_sound_stone_defaults(),
1017 })
1018
1019
1020 minetest.register_node("default:stone_with_iron", {
1021         description = "Iron Ore",
1022         tiles = {"default_stone.png^default_mineral_iron.png"},
1023         groups = {cracky = 2},
1024         drop = 'default:iron_lump',
1025         sounds = default.node_sound_stone_defaults(),
1026 })
1027
1028 minetest.register_node("default:steelblock", {
1029         description = "Steel Block",
1030         tiles = {"default_steel_block.png"},
1031         is_ground_content = false,
1032         groups = {cracky = 1, level = 2},
1033         sounds = default.node_sound_metal_defaults(),
1034 })
1035
1036
1037 minetest.register_node("default:stone_with_copper", {
1038         description = "Copper Ore",
1039         tiles = {"default_stone.png^default_mineral_copper.png"},
1040         groups = {cracky = 2},
1041         drop = 'default:copper_lump',
1042         sounds = default.node_sound_stone_defaults(),
1043 })
1044
1045 minetest.register_node("default:copperblock", {
1046         description = "Copper Block",
1047         tiles = {"default_copper_block.png"},
1048         is_ground_content = false,
1049         groups = {cracky = 1, level = 2},
1050         sounds = default.node_sound_metal_defaults(),
1051 })
1052
1053
1054 minetest.register_node("default:stone_with_tin", {
1055         description = "Tin Ore",
1056         tiles = {"default_stone.png^default_mineral_tin.png"},
1057         groups = {cracky = 2},
1058         drop = "default:tin_lump",
1059         sounds = default.node_sound_stone_defaults(),
1060 })
1061
1062 minetest.register_node("default:tinblock", {
1063         description = "Tin Block",
1064         tiles = {"default_tin_block.png"},
1065         is_ground_content = false,
1066         groups = {cracky = 1, level = 2},
1067         sounds = default.node_sound_metal_defaults(),
1068 })
1069
1070
1071 minetest.register_node("default:bronzeblock", {
1072         description = "Bronze Block",
1073         tiles = {"default_bronze_block.png"},
1074         is_ground_content = false,
1075         groups = {cracky = 1, level = 2},
1076         sounds = default.node_sound_metal_defaults(),
1077 })
1078
1079
1080 minetest.register_node("default:stone_with_mese", {
1081         description = "Mese Ore",
1082         tiles = {"default_stone.png^default_mineral_mese.png"},
1083         groups = {cracky = 1},
1084         drop = "default:mese_crystal",
1085         sounds = default.node_sound_stone_defaults(),
1086 })
1087
1088 minetest.register_node("default:mese", {
1089         description = "Mese Block",
1090         tiles = {"default_mese_block.png"},
1091         paramtype = "light",
1092         groups = {cracky = 1, level = 2},
1093         sounds = default.node_sound_stone_defaults(),
1094         light_source = 3,
1095 })
1096
1097
1098 minetest.register_node("default:stone_with_gold", {
1099         description = "Gold Ore",
1100         tiles = {"default_stone.png^default_mineral_gold.png"},
1101         groups = {cracky = 2},
1102         drop = "default:gold_lump",
1103         sounds = default.node_sound_stone_defaults(),
1104 })
1105
1106 minetest.register_node("default:goldblock", {
1107         description = "Gold Block",
1108         tiles = {"default_gold_block.png"},
1109         is_ground_content = false,
1110         groups = {cracky = 1},
1111         sounds = default.node_sound_metal_defaults(),
1112 })
1113
1114
1115 minetest.register_node("default:stone_with_diamond", {
1116         description = "Diamond Ore",
1117         tiles = {"default_stone.png^default_mineral_diamond.png"},
1118         groups = {cracky = 1},
1119         drop = "default:diamond",
1120         sounds = default.node_sound_stone_defaults(),
1121 })
1122
1123 minetest.register_node("default:diamondblock", {
1124         description = "Diamond Block",
1125         tiles = {"default_diamond_block.png"},
1126         is_ground_content = false,
1127         groups = {cracky = 1, level = 3},
1128         sounds = default.node_sound_stone_defaults(),
1129 })
1130
1131 --
1132 -- Plantlife (non-cubic)
1133 --
1134
1135 minetest.register_node("default:cactus", {
1136         description = "Cactus",
1137         tiles = {"default_cactus_top.png", "default_cactus_top.png",
1138                 "default_cactus_side.png"},
1139         paramtype2 = "facedir",
1140         groups = {choppy = 3},
1141         sounds = default.node_sound_wood_defaults(),
1142         on_place = minetest.rotate_node,
1143 })
1144
1145 minetest.register_node("default:papyrus", {
1146         description = "Papyrus",
1147         drawtype = "plantlike",
1148         tiles = {"default_papyrus.png"},
1149         inventory_image = "default_papyrus.png",
1150         wield_image = "default_papyrus.png",
1151         paramtype = "light",
1152         sunlight_propagates = true,
1153         walkable = false,
1154         selection_box = {
1155                 type = "fixed",
1156                 fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 0.5, 6 / 16},
1157         },
1158         groups = {snappy = 3, flammable = 2},
1159         sounds = default.node_sound_leaves_defaults(),
1160
1161         after_dig_node = function(pos, node, metadata, digger)
1162                 default.dig_up(pos, node, digger)
1163         end,
1164 })
1165
1166 minetest.register_node("default:dry_shrub", {
1167         description = "Dry Shrub",
1168         drawtype = "plantlike",
1169         waving = 1,
1170         tiles = {"default_dry_shrub.png"},
1171         inventory_image = "default_dry_shrub.png",
1172         wield_image = "default_dry_shrub.png",
1173         paramtype = "light",
1174         sunlight_propagates = true,
1175         walkable = false,
1176         buildable_to = true,
1177         groups = {snappy = 3, flammable = 3, attached_node = 1},
1178         sounds = default.node_sound_leaves_defaults(),
1179         selection_box = {
1180                 type = "fixed",
1181                 fixed = {-5 / 16, -0.5, -5 / 16, 5 / 16, 4 / 16, 5 / 16},
1182         },
1183 })
1184
1185 minetest.register_node("default:junglegrass", {
1186         description = "Jungle Grass",
1187         drawtype = "plantlike",
1188         waving = 1,
1189         visual_scale = 1.69,
1190         tiles = {"default_junglegrass.png"},
1191         inventory_image = "default_junglegrass.png",
1192         wield_image = "default_junglegrass.png",
1193         paramtype = "light",
1194         sunlight_propagates = true,
1195         walkable = false,
1196         buildable_to = true,
1197         groups = {snappy = 3, flora = 1, attached_node = 1, flammable = 1},
1198         sounds = default.node_sound_leaves_defaults(),
1199         selection_box = {
1200                 type = "fixed",
1201                 fixed = {-7 / 16, -0.5, -7 / 16, 7 / 16, 1.19, 7 / 16},
1202         },
1203 })
1204
1205
1206 minetest.register_node("default:grass_1", {
1207         description = "Grass",
1208         drawtype = "plantlike",
1209         waving = 1,
1210         tiles = {"default_grass_1.png"},
1211         -- Use texture of a taller grass stage in inventory
1212         inventory_image = "default_grass_3.png",
1213         wield_image = "default_grass_3.png",
1214         paramtype = "light",
1215         sunlight_propagates = true,
1216         walkable = false,
1217         buildable_to = true,
1218         groups = {snappy = 3, flora = 1, attached_node = 1, grass = 1, flammable = 1},
1219         sounds = default.node_sound_leaves_defaults(),
1220         selection_box = {
1221                 type = "fixed",
1222                 fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -5 / 16, 6 / 16},
1223         },
1224
1225         on_place = function(itemstack, placer, pointed_thing)
1226                 -- place a random grass node
1227                 local stack = ItemStack("default:grass_" .. math.random(1,5))
1228                 local ret = minetest.item_place(stack, placer, pointed_thing)
1229                 return ItemStack("default:grass_1 " ..
1230                         itemstack:get_count() - (1 - ret:get_count()))
1231         end,
1232 })
1233
1234 for i = 2, 5 do
1235         minetest.register_node("default:grass_" .. i, {
1236                 description = "Grass",
1237                 drawtype = "plantlike",
1238                 waving = 1,
1239                 tiles = {"default_grass_" .. i .. ".png"},
1240                 inventory_image = "default_grass_" .. i .. ".png",
1241                 wield_image = "default_grass_" .. i .. ".png",
1242                 paramtype = "light",
1243                 sunlight_propagates = true,
1244                 walkable = false,
1245                 buildable_to = true,
1246                 drop = "default:grass_1",
1247                 groups = {snappy = 3, flora = 1, attached_node = 1,
1248                         not_in_creative_inventory = 1, grass = 1, flammable = 1},
1249                 sounds = default.node_sound_leaves_defaults(),
1250                 selection_box = {
1251                         type = "fixed",
1252                         fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -3 / 16, 6 / 16},
1253                 },
1254         })
1255 end
1256
1257
1258 minetest.register_node("default:dry_grass_1", {
1259         description = "Dry Grass",
1260         drawtype = "plantlike",
1261         waving = 1,
1262         tiles = {"default_dry_grass_1.png"},
1263         inventory_image = "default_dry_grass_3.png",
1264         wield_image = "default_dry_grass_3.png",
1265         paramtype = "light",
1266         sunlight_propagates = true,
1267         walkable = false,
1268         buildable_to = true,
1269         groups = {snappy = 3, flammable = 3, flora = 1,
1270                 attached_node = 1, dry_grass = 1},
1271         sounds = default.node_sound_leaves_defaults(),
1272         selection_box = {
1273                 type = "fixed",
1274                 fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -3 / 16, 6 / 16},
1275         },
1276
1277         on_place = function(itemstack, placer, pointed_thing)
1278                 -- place a random dry grass node
1279                 local stack = ItemStack("default:dry_grass_" .. math.random(1, 5))
1280                 local ret = minetest.item_place(stack, placer, pointed_thing)
1281                 return ItemStack("default:dry_grass_1 " ..
1282                         itemstack:get_count() - (1 - ret:get_count()))
1283         end,
1284 })
1285
1286 for i = 2, 5 do
1287         minetest.register_node("default:dry_grass_" .. i, {
1288                 description = "Dry Grass",
1289                 drawtype = "plantlike",
1290                 waving = 1,
1291                 tiles = {"default_dry_grass_" .. i .. ".png"},
1292                 inventory_image = "default_dry_grass_" .. i .. ".png",
1293                 wield_image = "default_dry_grass_" .. i .. ".png",
1294                 paramtype = "light",
1295                 sunlight_propagates = true,
1296                 walkable = false,
1297                 buildable_to = true,
1298                 groups = {snappy = 3, flammable = 3, flora = 1, attached_node = 1,
1299                         not_in_creative_inventory=1, dry_grass = 1},
1300                 drop = "default:dry_grass_1",
1301                 sounds = default.node_sound_leaves_defaults(),
1302                 selection_box = {
1303                         type = "fixed",
1304                         fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, -1 / 16, 6 / 16},
1305                 },
1306         })
1307 end
1308
1309
1310 minetest.register_node("default:bush_stem", {
1311         description = "Bush Stem",
1312         drawtype = "plantlike",
1313         visual_scale = 1.41,
1314         tiles = {"default_bush_stem.png"},
1315         inventory_image = "default_bush_stem.png",
1316         wield_image = "default_bush_stem.png",
1317         paramtype = "light",
1318         sunlight_propagates = true,
1319         groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
1320         sounds = default.node_sound_wood_defaults(),
1321         selection_box = {
1322                 type = "fixed",
1323                 fixed = {-7 / 16, -0.5, -7 / 16, 7 / 16, 0.5, 7 / 16},
1324         },
1325 })
1326
1327 minetest.register_node("default:bush_leaves", {
1328         description = "Bush Leaves",
1329         drawtype = "allfaces_optional",
1330         waving = 1,
1331         tiles = {"default_leaves_simple.png"},
1332         paramtype = "light",
1333         groups = {snappy = 3, flammable = 2, leaves = 1},
1334         drop = {
1335                 max_items = 1,
1336                 items = {
1337                         {items = {"default:bush_sapling"}, rarity = 5},
1338                         {items = {"default:bush_leaves"}}
1339                 }
1340         },
1341         sounds = default.node_sound_leaves_defaults(),
1342
1343         after_place_node = default.after_place_leaves,
1344 })
1345
1346 minetest.register_node("default:bush_sapling", {
1347         description = "Bush Sapling",
1348         drawtype = "plantlike",
1349         tiles = {"default_bush_sapling.png"},
1350         inventory_image = "default_bush_sapling.png",
1351         wield_image = "default_bush_sapling.png",
1352         paramtype = "light",
1353         sunlight_propagates = true,
1354         walkable = false,
1355         on_timer = default.grow_sapling,
1356         selection_box = {
1357                 type = "fixed",
1358                 fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 2 / 16, 4 / 16}
1359         },
1360         groups = {snappy = 2, dig_immediate = 3, flammable = 2,
1361                 attached_node = 1, sapling = 1},
1362         sounds = default.node_sound_leaves_defaults(),
1363
1364         on_construct = function(pos)
1365                 minetest.get_node_timer(pos):start(math.random(300, 1500))
1366         end,
1367
1368         on_place = function(itemstack, placer, pointed_thing)
1369                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
1370                         "default:bush_sapling",
1371                         -- minp, maxp to be checked, relative to sapling pos
1372                         {x = -1, y = 0, z = -1},
1373                         {x = 1, y = 1, z = 1},
1374                         -- maximum interval of interior volume check
1375                         2)
1376
1377                 return itemstack
1378         end,
1379 })
1380
1381 minetest.register_node("default:acacia_bush_stem", {
1382         description = "Acacia Bush Stem",
1383         drawtype = "plantlike",
1384         visual_scale = 1.41,
1385         tiles = {"default_acacia_bush_stem.png"},
1386         inventory_image = "default_acacia_bush_stem.png",
1387         wield_image = "default_acacia_bush_stem.png",
1388         paramtype = "light",
1389         sunlight_propagates = true,
1390         groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
1391         sounds = default.node_sound_wood_defaults(),
1392         selection_box = {
1393                 type = "fixed",
1394                 fixed = {-7 / 16, -0.5, -7 / 16, 7 / 16, 0.5, 7 / 16},
1395         },
1396 })
1397
1398 minetest.register_node("default:acacia_bush_leaves", {
1399         description = "Acacia Bush Leaves",
1400         drawtype = "allfaces_optional",
1401         waving = 1,
1402         tiles = {"default_acacia_leaves_simple.png"},
1403         paramtype = "light",
1404         groups = {snappy = 3, flammable = 2, leaves = 1},
1405         drop = {
1406                 max_items = 1,
1407                 items = {
1408                         {items = {"default:acacia_bush_sapling"}, rarity = 5},
1409                         {items = {"default:acacia_bush_leaves"}}
1410                 }
1411         },
1412         sounds = default.node_sound_leaves_defaults(),
1413
1414         after_place_node = default.after_place_leaves,
1415 })
1416
1417 minetest.register_node("default:acacia_bush_sapling", {
1418         description = "Acacia Bush Sapling",
1419         drawtype = "plantlike",
1420         tiles = {"default_acacia_bush_sapling.png"},
1421         inventory_image = "default_acacia_bush_sapling.png",
1422         wield_image = "default_acacia_bush_sapling.png",
1423         paramtype = "light",
1424         sunlight_propagates = true,
1425         walkable = false,
1426         on_timer = default.grow_sapling,
1427         selection_box = {
1428                 type = "fixed",
1429                 fixed = {-3 / 16, -0.5, -3 / 16, 3 / 16, 2 / 16, 3 / 16}
1430         },
1431         groups = {snappy = 2, dig_immediate = 3, flammable = 2,
1432                 attached_node = 1, sapling = 1},
1433         sounds = default.node_sound_leaves_defaults(),
1434
1435         on_construct = function(pos)
1436                 minetest.get_node_timer(pos):start(math.random(300, 1500))
1437         end,
1438
1439         on_place = function(itemstack, placer, pointed_thing)
1440                 itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
1441                         "default:acacia_bush_sapling",
1442                         -- minp, maxp to be checked, relative to sapling pos
1443                         {x = -1, y = 0, z = -1},
1444                         {x = 1, y = 1, z = 1},
1445                         -- maximum interval of interior volume check
1446                         2)
1447
1448                 return itemstack
1449         end,
1450 })
1451
1452
1453 --
1454 -- Corals
1455 --
1456
1457 minetest.register_node("default:coral_brown", {
1458         description = "Brown Coral",
1459         tiles = {"default_coral_brown.png"},
1460         groups = {cracky = 3},
1461         drop = "default:coral_skeleton",
1462         sounds = default.node_sound_stone_defaults(),
1463 })
1464
1465 minetest.register_node("default:coral_orange", {
1466         description = "Orange Coral",
1467         tiles = {"default_coral_orange.png"},
1468         groups = {cracky = 3},
1469         drop = "default:coral_skeleton",
1470         sounds = default.node_sound_stone_defaults(),
1471 })
1472
1473 minetest.register_node("default:coral_skeleton", {
1474         description = "Coral Skeleton",
1475         tiles = {"default_coral_skeleton.png"},
1476         groups = {cracky = 3},
1477         sounds = default.node_sound_stone_defaults(),
1478 })
1479
1480
1481 --
1482 -- Liquids
1483 --
1484
1485 minetest.register_node("default:water_source", {
1486         description = "Water Source",
1487         drawtype = "liquid",
1488         tiles = {
1489                 {
1490                         name = "default_water_source_animated.png",
1491                         animation = {
1492                                 type = "vertical_frames",
1493                                 aspect_w = 16,
1494                                 aspect_h = 16,
1495                                 length = 2.0,
1496                         },
1497                 },
1498         },
1499         special_tiles = {
1500                 -- New-style water source material (mostly unused)
1501                 {
1502                         name = "default_water_source_animated.png",
1503                         animation = {
1504                                 type = "vertical_frames",
1505                                 aspect_w = 16,
1506                                 aspect_h = 16,
1507                                 length = 2.0,
1508                         },
1509                         backface_culling = false,
1510                 },
1511         },
1512         alpha = 160,
1513         paramtype = "light",
1514         walkable = false,
1515         pointable = false,
1516         diggable = false,
1517         buildable_to = true,
1518         is_ground_content = false,
1519         drop = "",
1520         drowning = 1,
1521         liquidtype = "source",
1522         liquid_alternative_flowing = "default:water_flowing",
1523         liquid_alternative_source = "default:water_source",
1524         liquid_viscosity = 1,
1525         post_effect_color = {a = 103, r = 30, g = 60, b = 90},
1526         groups = {water = 3, liquid = 3, puts_out_fire = 1, cools_lava = 1},
1527         sounds = default.node_sound_water_defaults(),
1528 })
1529
1530 minetest.register_node("default:water_flowing", {
1531         description = "Flowing Water",
1532         drawtype = "flowingliquid",
1533         tiles = {"default_water.png"},
1534         special_tiles = {
1535                 {
1536                         name = "default_water_flowing_animated.png",
1537                         backface_culling = false,
1538                         animation = {
1539                                 type = "vertical_frames",
1540                                 aspect_w = 16,
1541                                 aspect_h = 16,
1542                                 length = 0.8,
1543                         },
1544                 },
1545                 {
1546                         name = "default_water_flowing_animated.png",
1547                         backface_culling = true,
1548                         animation = {
1549                                 type = "vertical_frames",
1550                                 aspect_w = 16,
1551                                 aspect_h = 16,
1552                                 length = 0.8,
1553                         },
1554                 },
1555         },
1556         alpha = 160,
1557         paramtype = "light",
1558         paramtype2 = "flowingliquid",
1559         walkable = false,
1560         pointable = false,
1561         diggable = false,
1562         buildable_to = true,
1563         is_ground_content = false,
1564         drop = "",
1565         drowning = 1,
1566         liquidtype = "flowing",
1567         liquid_alternative_flowing = "default:water_flowing",
1568         liquid_alternative_source = "default:water_source",
1569         liquid_viscosity = 1,
1570         post_effect_color = {a = 103, r = 30, g = 60, b = 90},
1571         groups = {water = 3, liquid = 3, puts_out_fire = 1,
1572                 not_in_creative_inventory = 1, cools_lava = 1},
1573         sounds = default.node_sound_water_defaults(),
1574 })
1575
1576
1577 minetest.register_node("default:river_water_source", {
1578         description = "River Water Source",
1579         drawtype = "liquid",
1580         tiles = {
1581                 {
1582                         name = "default_river_water_source_animated.png",
1583                         animation = {
1584                                 type = "vertical_frames",
1585                                 aspect_w = 16,
1586                                 aspect_h = 16,
1587                                 length = 2.0,
1588                         },
1589                 },
1590         },
1591         special_tiles = {
1592                 {
1593                         name = "default_river_water_source_animated.png",
1594                         animation = {
1595                                 type = "vertical_frames",
1596                                 aspect_w = 16,
1597                                 aspect_h = 16,
1598                                 length = 2.0,
1599                         },
1600                         backface_culling = false,
1601                 },
1602         },
1603         alpha = 160,
1604         paramtype = "light",
1605         walkable = false,
1606         pointable = false,
1607         diggable = false,
1608         buildable_to = true,
1609         is_ground_content = false,
1610         drop = "",
1611         drowning = 1,
1612         liquidtype = "source",
1613         liquid_alternative_flowing = "default:river_water_flowing",
1614         liquid_alternative_source = "default:river_water_source",
1615         liquid_viscosity = 1,
1616         liquid_renewable = false,
1617         liquid_range = 2,
1618         post_effect_color = {a = 103, r = 30, g = 76, b = 90},
1619         groups = {water = 3, liquid = 3, puts_out_fire = 1, cools_lava = 1},
1620         sounds = default.node_sound_water_defaults(),
1621 })
1622
1623 minetest.register_node("default:river_water_flowing", {
1624         description = "Flowing River Water",
1625         drawtype = "flowingliquid",
1626         tiles = {"default_river_water.png"},
1627         special_tiles = {
1628                 {
1629                         name = "default_river_water_flowing_animated.png",
1630                         backface_culling = false,
1631                         animation = {
1632                                 type = "vertical_frames",
1633                                 aspect_w = 16,
1634                                 aspect_h = 16,
1635                                 length = 0.8,
1636                         },
1637                 },
1638                 {
1639                         name = "default_river_water_flowing_animated.png",
1640                         backface_culling = true,
1641                         animation = {
1642                                 type = "vertical_frames",
1643                                 aspect_w = 16,
1644                                 aspect_h = 16,
1645                                 length = 0.8,
1646                         },
1647                 },
1648         },
1649         alpha = 160,
1650         paramtype = "light",
1651         paramtype2 = "flowingliquid",
1652         walkable = false,
1653         pointable = false,
1654         diggable = false,
1655         buildable_to = true,
1656         is_ground_content = false,
1657         drop = "",
1658         drowning = 1,
1659         liquidtype = "flowing",
1660         liquid_alternative_flowing = "default:river_water_flowing",
1661         liquid_alternative_source = "default:river_water_source",
1662         liquid_viscosity = 1,
1663         liquid_renewable = false,
1664         liquid_range = 2,
1665         post_effect_color = {a = 103, r = 30, g = 76, b = 90},
1666         groups = {water = 3, liquid = 3, puts_out_fire = 1,
1667                 not_in_creative_inventory = 1, cools_lava = 1},
1668         sounds = default.node_sound_water_defaults(),
1669 })
1670
1671
1672 minetest.register_node("default:lava_source", {
1673         description = "Lava Source",
1674         drawtype = "liquid",
1675         tiles = {
1676                 {
1677                         name = "default_lava_source_animated.png",
1678                         animation = {
1679                                 type = "vertical_frames",
1680                                 aspect_w = 16,
1681                                 aspect_h = 16,
1682                                 length = 3.0,
1683                         },
1684                 },
1685         },
1686         special_tiles = {
1687                 -- New-style lava source material (mostly unused)
1688                 {
1689                         name = "default_lava_source_animated.png",
1690                         animation = {
1691                                 type = "vertical_frames",
1692                                 aspect_w = 16,
1693                                 aspect_h = 16,
1694                                 length = 3.0,
1695                         },
1696                         backface_culling = false,
1697                 },
1698         },
1699         paramtype = "light",
1700         light_source = default.LIGHT_MAX - 1,
1701         walkable = false,
1702         pointable = false,
1703         diggable = false,
1704         buildable_to = true,
1705         is_ground_content = false,
1706         drop = "",
1707         drowning = 1,
1708         liquidtype = "source",
1709         liquid_alternative_flowing = "default:lava_flowing",
1710         liquid_alternative_source = "default:lava_source",
1711         liquid_viscosity = 7,
1712         liquid_renewable = false,
1713         damage_per_second = 4 * 2,
1714         post_effect_color = {a = 191, r = 255, g = 64, b = 0},
1715         groups = {lava = 3, liquid = 2, igniter = 1},
1716 })
1717
1718 minetest.register_node("default:lava_flowing", {
1719         description = "Flowing Lava",
1720         drawtype = "flowingliquid",
1721         tiles = {"default_lava.png"},
1722         special_tiles = {
1723                 {
1724                         name = "default_lava_flowing_animated.png",
1725                         backface_culling = false,
1726                         animation = {
1727                                 type = "vertical_frames",
1728                                 aspect_w = 16,
1729                                 aspect_h = 16,
1730                                 length = 3.3,
1731                         },
1732                 },
1733                 {
1734                         name = "default_lava_flowing_animated.png",
1735                         backface_culling = true,
1736                         animation = {
1737                                 type = "vertical_frames",
1738                                 aspect_w = 16,
1739                                 aspect_h = 16,
1740                                 length = 3.3,
1741                         },
1742                 },
1743         },
1744         paramtype = "light",
1745         paramtype2 = "flowingliquid",
1746         light_source = default.LIGHT_MAX - 1,
1747         walkable = false,
1748         pointable = false,
1749         diggable = false,
1750         buildable_to = true,
1751         is_ground_content = false,
1752         drop = "",
1753         drowning = 1,
1754         liquidtype = "flowing",
1755         liquid_alternative_flowing = "default:lava_flowing",
1756         liquid_alternative_source = "default:lava_source",
1757         liquid_viscosity = 7,
1758         liquid_renewable = false,
1759         damage_per_second = 4 * 2,
1760         post_effect_color = {a = 191, r = 255, g = 64, b = 0},
1761         groups = {lava = 3, liquid = 2, igniter = 1,
1762                 not_in_creative_inventory = 1},
1763 })
1764
1765 --
1766 -- Tools / "Advanced" crafting / Non-"natural"
1767 --
1768
1769 local function get_chest_formspec(pos)
1770         local spos = pos.x .. "," .. pos.y .. "," .. pos.z
1771         local formspec =
1772                 "size[8,9]" ..
1773                 default.gui_bg ..
1774                 default.gui_bg_img ..
1775                 default.gui_slots ..
1776                 "list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
1777                 "list[current_player;main;0,4.85;8,1;]" ..
1778                 "list[current_player;main;0,6.08;8,3;8]" ..
1779                 "listring[nodemeta:" .. spos .. ";main]" ..
1780                 "listring[current_player;main]" ..
1781                 default.get_hotbar_bg(0,4.85)
1782         return formspec
1783 end
1784
1785 local function chest_lid_obstructed(pos)
1786         local above = {x = pos.x, y = pos.y + 1, z = pos.z}
1787         local def = minetest.registered_nodes[minetest.get_node(above).name]
1788         -- allow ladders, signs, wallmounted things and torches to not obstruct
1789         if def and
1790                         (def.drawtype == "airlike" or
1791                         def.drawtype == "signlike" or
1792                         def.drawtype == "torchlike" or
1793                         (def.drawtype == "nodebox" and def.paramtype2 == "wallmounted")) then
1794                 return false
1795         end
1796         return true
1797 end
1798
1799 local open_chests = {}
1800
1801 local function chest_lid_close(pn)
1802         local pos = open_chests[pn].pos
1803         local sound = open_chests[pn].sound
1804         local swap = open_chests[pn].swap
1805
1806         open_chests[pn] = nil
1807         for k, v in pairs(open_chests) do
1808                 if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then
1809                         return true
1810                 end
1811         end
1812
1813         local node = minetest.get_node(pos)
1814         minetest.after(0.2, minetest.swap_node, pos, { name = "default:" .. swap,
1815                         param2 = node.param2 })
1816         minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10})
1817 end
1818
1819 minetest.register_on_player_receive_fields(function(player, formname, fields)
1820         if formname ~= "default:chest" then
1821                 return
1822         end
1823         if not player or not fields.quit then
1824                 return
1825         end
1826         local pn = player:get_player_name()
1827
1828         if not open_chests[pn] then
1829                 return
1830         end
1831
1832         chest_lid_close(pn)
1833         return true
1834 end)
1835
1836 minetest.register_on_leaveplayer(function(player)
1837         local pn = player:get_player_name()
1838         if open_chests[pn] then
1839                 chest_lid_close(pn)
1840         end
1841 end)
1842
1843 function default.register_chest(name, d)
1844         local def = table.copy(d)
1845         def.drawtype = "mesh"
1846         def.visual = "mesh"
1847         def.paramtype = "light"
1848         def.paramtype2 = "facedir"
1849         def.legacy_facedir_simple = true
1850         def.is_ground_content = false
1851
1852         if def.protected then
1853                 def.on_construct = function(pos)
1854                         local meta = minetest.get_meta(pos)
1855                         meta:set_string("infotext", "Locked Chest")
1856                         meta:set_string("owner", "")
1857                         local inv = meta:get_inventory()
1858                         inv:set_size("main", 8*4)
1859                 end
1860                 def.after_place_node = function(pos, placer)
1861                         local meta = minetest.get_meta(pos)
1862                         meta:set_string("owner", placer:get_player_name() or "")
1863                         meta:set_string("infotext", "Locked Chest (owned by " ..
1864                                         meta:get_string("owner") .. ")")
1865                 end
1866                 def.can_dig = function(pos,player)
1867                         local meta = minetest.get_meta(pos);
1868                         local inv = meta:get_inventory()
1869                         return inv:is_empty("main") and
1870                                         default.can_interact_with_node(player, pos)
1871                 end
1872                 def.allow_metadata_inventory_move = function(pos, from_list, from_index,
1873                                 to_list, to_index, count, player)
1874                         if not default.can_interact_with_node(player, pos) then
1875                                 return 0
1876                         end
1877                         return count
1878                 end
1879                 def.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
1880                         if not default.can_interact_with_node(player, pos) then
1881                                 return 0
1882                         end
1883                         return stack:get_count()
1884                 end
1885                 def.allow_metadata_inventory_take = function(pos, listname, index, stack, player)
1886                         if not default.can_interact_with_node(player, pos) then
1887                                 return 0
1888                         end
1889                         return stack:get_count()
1890                 end
1891                 def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
1892                         if not default.can_interact_with_node(clicker, pos) then
1893                                 return itemstack
1894                         end
1895
1896                         minetest.sound_play(def.sound_open, {gain = 0.3,
1897                                         pos = pos, max_hear_distance = 10})
1898                         if not chest_lid_obstructed(pos) then
1899                                 minetest.swap_node(pos,
1900                                                 { name = "default:" .. name .. "_open",
1901                                                 param2 = node.param2 })
1902                         end
1903                         minetest.after(0.2, minetest.show_formspec,
1904                                         clicker:get_player_name(),
1905                                         "default:chest", get_chest_formspec(pos))
1906                         open_chests[clicker:get_player_name()] = { pos = pos,
1907                                         sound = def.sound_close, swap = name }
1908                 end
1909                 def.on_blast = function() end
1910                 def.on_key_use = function(pos, player)
1911                         local secret = minetest.get_meta(pos):get_string("key_lock_secret")
1912                         local itemstack = player:get_wielded_item()
1913                         local key_meta = itemstack:get_meta()
1914
1915                         if key_meta:get_string("secret") == "" then
1916                                 key_meta:set_string("secret", minetest.parse_json(itemstack:get_metadata()).secret)
1917                                 itemstack:set_metadata("")
1918                         end
1919
1920                         if secret ~= key_meta:get_string("secret") then
1921                                 return
1922                         end
1923
1924                         minetest.show_formspec(
1925                                 player:get_player_name(),
1926                                 "default:chest_locked",
1927                                 get_chest_formspec(pos)
1928                         )
1929                 end
1930                 def.on_skeleton_key_use = function(pos, player, newsecret)
1931                         local meta = minetest.get_meta(pos)
1932                         local owner = meta:get_string("owner")
1933                         local pn = player:get_player_name()
1934
1935                         -- verify placer is owner of lockable chest
1936                         if owner ~= pn then
1937                                 minetest.record_protection_violation(pos, pn)
1938                                 minetest.chat_send_player(pn, "You do not own this chest.")
1939                                 return nil
1940                         end
1941
1942                         local secret = meta:get_string("key_lock_secret")
1943                         if secret == "" then
1944                                 secret = newsecret
1945                                 meta:set_string("key_lock_secret", secret)
1946                         end
1947
1948                         return secret, "a locked chest", owner
1949                 end
1950         else
1951                 def.on_construct = function(pos)
1952                         local meta = minetest.get_meta(pos)
1953                         meta:set_string("infotext", "Chest")
1954                         local inv = meta:get_inventory()
1955                         inv:set_size("main", 8*4)
1956                 end
1957                 def.can_dig = function(pos,player)
1958                         local meta = minetest.get_meta(pos);
1959                         local inv = meta:get_inventory()
1960                         return inv:is_empty("main")
1961                 end
1962                 def.on_rightclick = function(pos, node, clicker)
1963                         minetest.sound_play(def.sound_open, {gain = 0.3, pos = pos,
1964                                         max_hear_distance = 10})
1965                         if not chest_lid_obstructed(pos) then
1966                                 minetest.swap_node(pos, {
1967                                                 name = "default:" .. name .. "_open",
1968                                                 param2 = node.param2 })
1969                         end
1970                         minetest.after(0.2, minetest.show_formspec,
1971                                         clicker:get_player_name(),
1972                                         "default:chest", get_chest_formspec(pos))
1973                         open_chests[clicker:get_player_name()] = { pos = pos,
1974                                         sound = def.sound_close, swap = name }
1975                 end
1976                 def.on_blast = function(pos)
1977                         local drops = {}
1978                         default.get_inventory_drops(pos, "main", drops)
1979                         drops[#drops+1] = "default:" .. name
1980                         minetest.remove_node(pos)
1981                         return drops
1982                 end
1983         end
1984
1985         def.on_metadata_inventory_move = function(pos, from_list, from_index,
1986                         to_list, to_index, count, player)
1987                 minetest.log("action", player:get_player_name() ..
1988                         " moves stuff in chest at " .. minetest.pos_to_string(pos))
1989         end
1990         def.on_metadata_inventory_put = function(pos, listname, index, stack, player)
1991                 minetest.log("action", player:get_player_name() ..
1992                         " moves " .. stack:get_name() ..
1993                         " to chest at " .. minetest.pos_to_string(pos))
1994         end
1995         def.on_metadata_inventory_take = function(pos, listname, index, stack, player)
1996                 minetest.log("action", player:get_player_name() ..
1997                         " takes " .. stack:get_name() ..
1998                         " from chest at " .. minetest.pos_to_string(pos))
1999         end
2000
2001         local def_opened = table.copy(def)
2002         local def_closed = table.copy(def)
2003
2004         def_opened.mesh = "chest_open.obj"
2005         for i = 1, #def_opened.tiles do
2006                 if type(def_opened.tiles[i]) == "string" then
2007                         def_opened.tiles[i] = {name = def_opened.tiles[i], backface_culling = true}
2008                 elseif def_opened.tiles[i].backface_culling == nil then
2009                         def_opened.tiles[i].backface_culling = true
2010                 end
2011         end
2012         def_opened.drop = "default:" .. name
2013         def_opened.groups.not_in_creative_inventory = 1
2014         def_opened.selection_box = {
2015                 type = "fixed",
2016                 fixed = { -1/2, -1/2, -1/2, 1/2, 3/16, 1/2 },
2017         }
2018         def_opened.can_dig = function()
2019                 return false
2020         end
2021         def_opened.on_blast = function() end
2022
2023         def_closed.mesh = nil
2024         def_closed.drawtype = nil
2025         def_closed.tiles[6] = def.tiles[5] -- swap textures around for "normal"
2026         def_closed.tiles[5] = def.tiles[3] -- drawtype to make them match the mesh
2027         def_closed.tiles[3] = def.tiles[3].."^[transformFX"
2028
2029         minetest.register_node("default:" .. name, def_closed)
2030         minetest.register_node("default:" .. name .. "_open", def_opened)
2031
2032         -- convert old chests to this new variant
2033         minetest.register_lbm({
2034                 label = "update chests to opening chests",
2035                 name = "default:upgrade_" .. name .. "_v2",
2036                 nodenames = {"default:" .. name},
2037                 action = function(pos, node)
2038                         local meta = minetest.get_meta(pos)
2039                         meta:set_string("formspec", nil)
2040                         local inv = meta:get_inventory()
2041                         local list = inv:get_list("default:chest")
2042                         if list then
2043                                 inv:set_size("main", 8*4)
2044                                 inv:set_list("main", list)
2045                                 inv:set_list("default:chest", nil)
2046                         end
2047                 end
2048         })
2049 end
2050
2051
2052 default.register_chest("chest", {
2053         description = "Chest",
2054         tiles = {
2055                 "default_chest_top.png",
2056                 "default_chest_top.png",
2057                 "default_chest_side.png",
2058                 "default_chest_side.png",
2059                 "default_chest_front.png",
2060                 "default_chest_inside.png"
2061         },
2062         sounds = default.node_sound_wood_defaults(),
2063         sound_open = "default_chest_open",
2064         sound_close = "default_chest_close",
2065         groups = {choppy = 2, oddly_breakable_by_hand = 2},
2066 })
2067
2068 default.register_chest("chest_locked", {
2069         description = "Locked Chest",
2070         tiles = {
2071                 "default_chest_top.png",
2072                 "default_chest_top.png",
2073                 "default_chest_side.png",
2074                 "default_chest_side.png",
2075                 "default_chest_lock.png",
2076                 "default_chest_inside.png"
2077         },
2078         sounds = default.node_sound_wood_defaults(),
2079         sound_open = "default_chest_open",
2080         sound_close = "default_chest_close",
2081         groups = {choppy = 2, oddly_breakable_by_hand = 2},
2082         protected = true,
2083 })
2084
2085 local bookshelf_formspec =
2086         "size[8,7;]" ..
2087         default.gui_bg ..
2088         default.gui_bg_img ..
2089         default.gui_slots ..
2090         "list[context;books;0,0.3;8,2;]" ..
2091         "list[current_player;main;0,2.85;8,1;]" ..
2092         "list[current_player;main;0,4.08;8,3;8]" ..
2093         "listring[context;books]" ..
2094         "listring[current_player;main]" ..
2095         default.get_hotbar_bg(0,2.85)
2096
2097 local function get_bookshelf_formspec(inv)
2098         local formspec = bookshelf_formspec
2099         local invlist = inv and inv:get_list("books")
2100         -- Inventory slots overlay
2101         local bx, by = 0, 0.3
2102         for i = 1, 16 do
2103                 if i == 9 then
2104                         bx = 0
2105                         by = by + 1
2106                 end
2107                 if not invlist or invlist[i]:is_empty() then
2108                         formspec = formspec ..
2109                                 "image[" .. bx .. "," .. by .. ";1,1;default_bookshelf_slot.png]"
2110                 end
2111                 bx = bx + 1
2112         end
2113         return formspec
2114 end
2115
2116 minetest.register_node("default:bookshelf", {
2117         description = "Bookshelf",
2118         tiles = {"default_wood.png", "default_wood.png", "default_wood.png",
2119                 "default_wood.png", "default_bookshelf.png", "default_bookshelf.png"},
2120         paramtype2 = "facedir",
2121         is_ground_content = false,
2122         groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
2123         sounds = default.node_sound_wood_defaults(),
2124
2125         on_construct = function(pos)
2126                 local meta = minetest.get_meta(pos)
2127                 meta:set_string("formspec", get_bookshelf_formspec(nil))
2128                 local inv = meta:get_inventory()
2129                 inv:set_size("books", 8 * 2)
2130         end,
2131         can_dig = function(pos,player)
2132                 local inv = minetest.get_meta(pos):get_inventory()
2133                 return inv:is_empty("books")
2134         end,
2135         allow_metadata_inventory_put = function(pos, listname, index, stack)
2136                 if minetest.get_item_group(stack:get_name(), "book") ~= 0 then
2137                         return stack:get_count()
2138                 end
2139                 return 0
2140         end,
2141         on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
2142                 minetest.log("action", player:get_player_name() ..
2143                         " moves stuff in bookshelf at " .. minetest.pos_to_string(pos))
2144                 local meta = minetest.get_meta(pos)
2145                 meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
2146         end,
2147         on_metadata_inventory_put = function(pos, listname, index, stack, player)
2148                 minetest.log("action", player:get_player_name() ..
2149                         " moves stuff to bookshelf at " .. minetest.pos_to_string(pos))
2150                 local meta = minetest.get_meta(pos)
2151                 meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
2152         end,
2153         on_metadata_inventory_take = function(pos, listname, index, stack, player)
2154                 minetest.log("action", player:get_player_name() ..
2155                         " takes stuff from bookshelf at " .. minetest.pos_to_string(pos))
2156                 local meta = minetest.get_meta(pos)
2157                 meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
2158         end,
2159         on_blast = function(pos)
2160                 local drops = {}
2161                 default.get_inventory_drops(pos, "books", drops)
2162                 drops[#drops+1] = "default:bookshelf"
2163                 minetest.remove_node(pos)
2164                 return drops
2165         end,
2166 })
2167
2168 local function register_sign(material, desc, def)
2169         minetest.register_node("default:sign_wall_" .. material, {
2170                 description = desc .. " Sign",
2171                 drawtype = "nodebox",
2172                 tiles = {"default_sign_wall_" .. material .. ".png"},
2173                 inventory_image = "default_sign_" .. material .. ".png",
2174                 wield_image = "default_sign_" .. material .. ".png",
2175                 paramtype = "light",
2176                 paramtype2 = "wallmounted",
2177                 sunlight_propagates = true,
2178                 is_ground_content = false,
2179                 walkable = false,
2180                 node_box = {
2181                         type = "wallmounted",
2182                         wall_top    = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
2183                         wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
2184                         wall_side   = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375},
2185                 },
2186                 groups = def.groups,
2187                 legacy_wallmounted = true,
2188                 sounds = def.sounds,
2189
2190                 on_construct = function(pos)
2191                         --local n = minetest.get_node(pos)
2192                         local meta = minetest.get_meta(pos)
2193                         meta:set_string("formspec", "field[text;;${text}]")
2194                 end,
2195                 on_receive_fields = function(pos, formname, fields, sender)
2196                         --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
2197                         local player_name = sender:get_player_name()
2198                         if minetest.is_protected(pos, player_name) then
2199                                 minetest.record_protection_violation(pos, player_name)
2200                                 return
2201                         end
2202                         local meta = minetest.get_meta(pos)
2203                         if not fields.text then return end
2204                         minetest.log("action", (player_name or "") .. " wrote \"" ..
2205                                 fields.text .. "\" to sign at " .. minetest.pos_to_string(pos))
2206                         meta:set_string("text", fields.text)
2207                         meta:set_string("infotext", '"' .. fields.text .. '"')
2208                 end,
2209         })
2210 end
2211
2212 register_sign("wood", "Wooden", {
2213         sounds = default.node_sound_wood_defaults(),
2214         groups = {choppy = 2, attached_node = 1, flammable = 2, oddly_breakable_by_hand = 3}
2215 })
2216
2217 register_sign("steel", "Steel", {
2218         sounds = default.node_sound_metal_defaults(),
2219         groups = {cracky = 2, attached_node = 1}
2220 })
2221
2222 minetest.register_node("default:ladder_wood", {
2223         description = "Wooden Ladder",
2224         drawtype = "signlike",
2225         tiles = {"default_ladder_wood.png"},
2226         inventory_image = "default_ladder_wood.png",
2227         wield_image = "default_ladder_wood.png",
2228         paramtype = "light",
2229         paramtype2 = "wallmounted",
2230         sunlight_propagates = true,
2231         walkable = false,
2232         climbable = true,
2233         is_ground_content = false,
2234         selection_box = {
2235                 type = "wallmounted",
2236                 --wall_top = = <default>
2237                 --wall_bottom = = <default>
2238                 --wall_side = = <default>
2239         },
2240         groups = {choppy = 2, oddly_breakable_by_hand = 3, flammable = 2},
2241         legacy_wallmounted = true,
2242         sounds = default.node_sound_wood_defaults(),
2243 })
2244
2245 minetest.register_node("default:ladder_steel", {
2246         description = "Steel Ladder",
2247         drawtype = "signlike",
2248         tiles = {"default_ladder_steel.png"},
2249         inventory_image = "default_ladder_steel.png",
2250         wield_image = "default_ladder_steel.png",
2251         paramtype = "light",
2252         paramtype2 = "wallmounted",
2253         sunlight_propagates = true,
2254         walkable = false,
2255         climbable = true,
2256         is_ground_content = false,
2257         selection_box = {
2258                 type = "wallmounted",
2259                 --wall_top = = <default>
2260                 --wall_bottom = = <default>
2261                 --wall_side = = <default>
2262         },
2263         groups = {cracky = 2},
2264         sounds = default.node_sound_metal_defaults(),
2265 })
2266
2267 default.register_fence("default:fence_wood", {
2268         description = "Wooden Fence",
2269         texture = "default_fence_wood.png",
2270         inventory_image = "default_fence_overlay.png^default_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2271         wield_image = "default_fence_overlay.png^default_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2272         material = "default:wood",
2273         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
2274         sounds = default.node_sound_wood_defaults()
2275 })
2276
2277 default.register_fence("default:fence_acacia_wood", {
2278         description = "Acacia Fence",
2279         texture = "default_fence_acacia_wood.png",
2280         inventory_image = "default_fence_overlay.png^default_acacia_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2281         wield_image = "default_fence_overlay.png^default_acacia_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2282         material = "default:acacia_wood",
2283         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
2284         sounds = default.node_sound_wood_defaults()
2285 })
2286
2287 default.register_fence("default:fence_junglewood", {
2288         description = "Jungle Wood Fence",
2289         texture = "default_fence_junglewood.png",
2290         inventory_image = "default_fence_overlay.png^default_junglewood.png^default_fence_overlay.png^[makealpha:255,126,126",
2291         wield_image = "default_fence_overlay.png^default_junglewood.png^default_fence_overlay.png^[makealpha:255,126,126",
2292         material = "default:junglewood",
2293         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
2294         sounds = default.node_sound_wood_defaults()
2295 })
2296
2297 default.register_fence("default:fence_pine_wood", {
2298         description = "Pine Fence",
2299         texture = "default_fence_pine_wood.png",
2300         inventory_image = "default_fence_overlay.png^default_pine_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2301         wield_image = "default_fence_overlay.png^default_pine_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2302         material = "default:pine_wood",
2303         groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
2304         sounds = default.node_sound_wood_defaults()
2305 })
2306
2307 default.register_fence("default:fence_aspen_wood", {
2308         description = "Aspen Fence",
2309         texture = "default_fence_aspen_wood.png",
2310         inventory_image = "default_fence_overlay.png^default_aspen_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2311         wield_image = "default_fence_overlay.png^default_aspen_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
2312         material = "default:aspen_wood",
2313         groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
2314         sounds = default.node_sound_wood_defaults()
2315 })
2316
2317 minetest.register_node("default:glass", {
2318         description = "Glass",
2319         drawtype = "glasslike_framed_optional",
2320         tiles = {"default_glass.png", "default_glass_detail.png"},
2321         paramtype = "light",
2322         paramtype2 = "glasslikeliquidlevel",
2323         sunlight_propagates = true,
2324         is_ground_content = false,
2325         groups = {cracky = 3, oddly_breakable_by_hand = 3},
2326         sounds = default.node_sound_glass_defaults(),
2327 })
2328
2329 minetest.register_node("default:obsidian_glass", {
2330         description = "Obsidian Glass",
2331         drawtype = "glasslike_framed_optional",
2332         tiles = {"default_obsidian_glass.png", "default_obsidian_glass_detail.png"},
2333         paramtype = "light",
2334         paramtype2 = "glasslikeliquidlevel",
2335         is_ground_content = false,
2336         sunlight_propagates = true,
2337         sounds = default.node_sound_glass_defaults(),
2338         groups = {cracky = 3},
2339 })
2340
2341
2342 minetest.register_node("default:brick", {
2343         description = "Brick Block",
2344         paramtype2 = "facedir",
2345         place_param2 = 0,
2346         tiles = {"default_brick.png"},
2347         is_ground_content = false,
2348         groups = {cracky = 3},
2349         sounds = default.node_sound_stone_defaults(),
2350 })
2351
2352
2353 minetest.register_node("default:meselamp", {
2354         description = "Mese Lamp",
2355         drawtype = "glasslike",
2356         tiles = {"default_meselamp.png"},
2357         paramtype = "light",
2358         sunlight_propagates = true,
2359         is_ground_content = false,
2360         groups = {cracky = 3, oddly_breakable_by_hand = 3},
2361         sounds = default.node_sound_glass_defaults(),
2362         light_source = default.LIGHT_MAX,
2363 })
2364
2365 minetest.register_node("default:mese_post_light", {
2366         description = "Mese Post Light",
2367         tiles = {"default_mese_post_light_top.png", "default_mese_post_light_top.png",
2368                 "default_mese_post_light_side_dark.png", "default_mese_post_light_side_dark.png",
2369                 "default_mese_post_light_side.png", "default_mese_post_light_side.png"},
2370         wield_image = "default_mese_post_light_side.png",
2371         drawtype = "nodebox",
2372         node_box = {
2373                 type = "fixed",
2374                 fixed = {
2375                         {-2 / 16, -8 / 16, -2 / 16, 2 / 16, 8 / 16, 2 / 16},
2376                 },
2377         },
2378         paramtype = "light",
2379         light_source = default.LIGHT_MAX,
2380         sunlight_propagates = true,
2381         is_ground_content = false,
2382         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
2383         sounds = default.node_sound_wood_defaults(),
2384 })
2385
2386 --
2387 -- Misc
2388 --
2389
2390 minetest.register_node("default:cloud", {
2391         description = "Cloud",
2392         tiles = {"default_cloud.png"},
2393         is_ground_content = false,
2394         sounds = default.node_sound_defaults(),
2395         groups = {not_in_creative_inventory = 1},
2396 })
2397
2398 --
2399 -- register trees for leafdecay
2400 --
2401
2402 if minetest.get_mapgen_setting("mg_name") == "v6" then
2403         default.register_leafdecay({
2404                 trunks = {"default:tree"},
2405                 leaves = {"default:apple", "default:leaves"},
2406                 radius = 2,
2407         })
2408
2409         default.register_leafdecay({
2410                 trunks = {"default:jungletree"},
2411                 leaves = {"default:jungleleaves"},
2412                 radius = 3,
2413         })
2414
2415         default.register_leafdecay({
2416                 trunks = {"default:pine_tree"},
2417                 leaves = {"default:pine_needles"},
2418                 radius = 3,
2419         })
2420 else
2421         default.register_leafdecay({
2422                 trunks = {"default:tree"},
2423                 leaves = {"default:apple", "default:leaves"},
2424                 radius = 3,
2425         })
2426
2427         default.register_leafdecay({
2428                 trunks = {"default:jungletree"},
2429                 leaves = {"default:jungleleaves"},
2430                 radius = 2,
2431         })
2432
2433         default.register_leafdecay({
2434                 trunks = {"default:pine_tree"},
2435                 leaves = {"default:pine_needles"},
2436                 radius = 2,
2437         })
2438 end
2439
2440 default.register_leafdecay({
2441         trunks = {"default:acacia_tree"},
2442         leaves = {"default:acacia_leaves"},
2443         radius = 2,
2444 })
2445
2446 default.register_leafdecay({
2447         trunks = {"default:aspen_tree"},
2448         leaves = {"default:aspen_leaves"},
2449         radius = 3,
2450 })
2451
2452 default.register_leafdecay({
2453         trunks = {"default:bush_stem"},
2454         leaves = {"default:bush_leaves"},
2455         radius = 1,
2456 })
2457
2458 default.register_leafdecay({
2459         trunks = {"default:acacia_bush_stem"},
2460         leaves = {"default:acacia_bush_leaves"},
2461         radius = 1,
2462 })