diff --git a/nodes.lua b/nodes.lua index e0f2bfb..9685602 100644 --- a/nodes.lua +++ b/nodes.lua @@ -314,12 +314,6 @@ if mobs and mobs.mod == "redo" then recipe = "fun_caves:meat_pie_uncooked" }) - minetest.register_craftitem("fun_caves:onion", { - description = "Onion", - inventory_image = "fun_caves_onion.png", - on_use = minetest.item_eat(2), - }) - minetest.register_craftitem("fun_caves:meat_pie_slice", { description = "Meat Pie Slice", inventory_image = "fun_caves_meat_pie_slice.png", @@ -335,6 +329,66 @@ if mobs and mobs.mod == "redo" then }) end +farming.register_plant("fun_caves:onion", { + description = "Onion", + inventory_image = "fun_caves_onion.png", + steps = 3, + minlight = 13, + maxlight = default.LIGHT_MAX, + fertility = {"grassland"} +}) + +minetest.registered_items['fun_caves:seed_onion'] = nil +minetest.registered_nodes['fun_caves:seed_onion'] = nil +minetest.registered_craftitems['fun_caves:seed_onion'] = nil +minetest.register_alias('fun_caves:seed_onion', 'fun_caves:onion') +for i = 1, 3 do + local onion = minetest.registered_items['fun_caves:onion_'..i] + if onion then + onion.drop = { + max_items = i, + items = { + { items = {'fun_caves:onion'}, rarity = 4 - i, }, + { items = {'fun_caves:onion'}, rarity = (4 - i) * 3, }, + { items = {'fun_caves:onion'}, rarity = (4 - i) * 6, }, + }, + } + end +end + +minetest.register_node("fun_caves:onion", { + description = "Onion", + drawtype = "plantlike", + visual_scale = 0.75, + tiles = {"fun_caves_onion.png"}, + inventory_image = "fun_caves_onion.png", + paramtype = "light", + sunlight_propagates = true, + walkable = false, + is_ground_content = false, + selection_box = { + type = "fixed", + fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2} + }, + fertility = {'grassland'}, + groups = {seed = 1, fleshy = 3, dig_immediate = 3, flammable = 2}, + on_use = minetest.item_eat(2), + sounds = default.node_sound_leaves_defaults(), + next_plant = 'fun_caves:onion_1', + on_timer = farming.grow_plant, + minlight = 10, + maxlight = 15, + + on_place = function(itemstack, placer, pointed_thing) + local stack = farming.place_seed(itemstack, placer, pointed_thing, 'fun_caves:onion') + if stack then + return stack + end + + return minetest.item_place(itemstack, placer, pointed_thing) + end, +}) + minetest.register_craft({ output = 'fun_caves:apple_pie_uncooked', type = 'shapeless', diff --git a/textures/fun_caves_onion_1.png b/textures/fun_caves_onion_1.png new file mode 100644 index 0000000..101fefa Binary files /dev/null and b/textures/fun_caves_onion_1.png differ diff --git a/textures/fun_caves_onion_2.png b/textures/fun_caves_onion_2.png new file mode 100644 index 0000000..72c721a Binary files /dev/null and b/textures/fun_caves_onion_2.png differ diff --git a/textures/fun_caves_onion_3.png b/textures/fun_caves_onion_3.png new file mode 100644 index 0000000..7fd6838 Binary files /dev/null and b/textures/fun_caves_onion_3.png differ