Version 0.41.3
[MineClone/MineClone2/MineClone2-Fixes.git] / mods / ITEMS / mcl_nether / nether_wart.lua
blob705fd059a0312da83bf6d7420b35fd9830e1af0f
1 minetest.register_node("mcl_nether:nether_wart_0", {
2 description = "Premature Nether Wart",
3 _doc_items_longdesc = "A premature nether wart has just recently been planted on soul sand. Nether wart slowly grows on soul sand in 4 stages (the second and third stages look identical). Although nether wart is home to the Nether, it grows in any dimension.",
4 paramtype = "light",
5 paramtype2 = "meshoptions",
6 place_param2 = 3,
7 walkable = false,
8 drawtype = "plantlike",
9 drop = "mcl_nether:nether_wart_item",
10 tiles = {"mcl_nether_nether_wart_stage_0.png"},
11 selection_box = {
12 type = "fixed",
13 fixed = {
14 {-0.5, -0.5, -0.5, 0.5, -0.125, 0.5}
17 groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
18 sounds = mcl_sounds.node_sound_leaves_defaults(),
21 minetest.register_node("mcl_nether:nether_wart_1", {
22 description = "Premature Nether Wart (Stage 2)",
23 _doc_items_create_entry = false,
24 paramtype = "light",
25 paramtype2 = "meshoptions",
26 place_param2 = 3,
27 walkable = false,
28 drawtype = "plantlike",
29 drop = "mcl_nether:nether_wart_item",
30 tiles = {"mcl_nether_nether_wart_stage_1.png"},
31 selection_box = {
32 type = "fixed",
33 fixed = {
34 {-0.5, -0.5, -0.5, 0.5, 0.15, 0.5}
37 groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
38 sounds = mcl_sounds.node_sound_leaves_defaults(),
41 minetest.register_node("mcl_nether:nether_wart_2", {
42 description = "Premature Nether Wart (Stage 3)",
43 _doc_items_create_entry = false,
44 paramtype = "light",
45 paramtype2 = "meshoptions",
46 place_param2 = 3,
47 walkable = false,
48 drawtype = "plantlike",
49 drop = "mcl_nether:nether_wart_item",
50 tiles = {"mcl_nether_nether_wart_stage_1.png"},
51 selection_box = {
52 type = "fixed",
53 fixed = {
54 {-0.5, -0.5, -0.5, 0.5, 0.15, 0.5}
57 groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
58 sounds = mcl_sounds.node_sound_leaves_defaults(),
61 minetest.register_node("mcl_nether:nether_wart", {
62 description = "Mature Nether Wart",
63 _doc_items_longdesc = "The mature nether wart is a plant from the Nether and reached its full size and won't grow any further. It is ready to be harvested for its items.",
64 paramtype = "light",
65 paramtype2 = "meshoptions",
66 place_param2 = 3,
67 walkable = false,
68 drawtype = "plantlike",
69 drop = {
70 max_items = 2,
71 items = {
72 { items = {"mcl_nether:nether_wart_item 2"}, rarity = 1 },
73 { items = {"mcl_nether:nether_wart_item 2"}, rarity = 3 },
74 { items = {"mcl_nether:nether_wart_item 1"}, rarity = 3 },
77 tiles = {"mcl_nether_nether_wart_stage_2.png"},
78 selection_box = {
79 type = "fixed",
80 fixed = {
81 {-0.5, -0.5, -0.5, 0.5, 0.45, 0.5}
84 groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
85 sounds = mcl_sounds.node_sound_leaves_defaults(),
88 minetest.register_craftitem("mcl_nether:nether_wart_item", {
89 description = "Nether Wart",
90 _doc_items_longdesc = "Nether warts are plants home to the Nether. They can be planted on soul sand and grow in 3 stages.",
91 _doc_items_usagehelp = "Place this item on soul sand to plant it and watch it grow.",
92 inventory_image = "mcl_nether_nether_wart.png",
93 wield_image = "mcl_nether_nether_wart.png",
94 on_place = function(itemstack, placer, pointed_thing)
95 if pointed_thing.type ~= "node" then
96 return itemstack
97 end
99 -- Use pointed node's on_rightclick function first, if present
100 local node = minetest.get_node(pointed_thing.under)
101 if placer and not placer:get_player_control().sneak then
102 if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
103 return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
107 local placepos = pointed_thing.above
108 local soilpos = table.copy(placepos)
109 soilpos.y = soilpos.y - 1
111 -- Check for correct soil type
112 local chk = minetest.get_item_group(minetest.get_node(soilpos).name, "soil_nether_wart")
113 if chk ~= 0 and chk ~= nil then
114 -- Check if node above soil node allows placement
115 if minetest.registered_items[minetest.get_node(placepos).name].buildable_to then
116 -- Place nether wart
117 minetest.sound_play({name="default_place_node", gain=1.0}, {pos=placepos})
118 minetest.set_node(placepos, {name="mcl_nether:nether_wart_0", param2 = 3})
120 if not minetest.settings:get_bool("creative_mode") then
121 itemstack:take_item()
123 return itemstack
126 end,
127 groups = { craftitem = 1 },
130 local names = {"mcl_nether:nether_wart_0", "mcl_nether:nether_wart_1", "mcl_nether:nether_wart_2"}
132 minetest.register_abm({
133 label = "Nether wart growth",
134 nodenames = {"mcl_nether:nether_wart_0", "mcl_nether:nether_wart_1", "mcl_nether:nether_wart_2"},
135 neighbors = {"group:soil_nether_wart"},
136 interval = 35,
137 chance = 11,
138 action = function(pos, node)
139 pos.y = pos.y-1
140 if minetest.get_item_group(minetest.get_node(pos).name, "soil_nether_wart") == 0 then
141 return
143 pos.y = pos.y+1
144 local step = nil
145 for i,name in ipairs(names) do
146 if name == node.name then
147 step = i
148 break
151 if step == nil then
152 return
154 local new_node = {name=names[step+1]}
155 if new_node.name == nil then
156 new_node.name = "mcl_nether:nether_wart"
158 new_node.param = node.param
159 new_node.param2 = node.param2
160 minetest.set_node(pos, new_node)
164 if minetest.get_modpath("doc") then
165 for i=1,2 do
166 doc.add_entry_alias("nodes", "mcl_nether:nether_wart_0", "nodes", "mcl_nether:nether_wart_"..i)