From c71cd66e505074d1b28cd84f9f9f352c7a23762a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 9 Jun 2017 19:59:49 +0200 Subject: [PATCH] Pop out flowers automatically --- mods/ITEMS/mcl_flowers/init.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index 62cedc9e..ea0b3032 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -250,6 +250,25 @@ add_large_plant("sunflower", "Sunflower", "A sunflower is a large plant which oc add_large_plant("double_grass", "Double Tallgrass", "Double tallgrass a variant of tall grass and occupies two blocks. It can be harvested for wheat seeds.", "mcl_flowers_double_plant_grass_bottom.png", "mcl_flowers_double_plant_grass_top.png", nil, 5/16, 7/16, wheat_seed_drop, false) add_large_plant("double_fern", "Large Fern", "Large fern is a variant of fern and occupies two blocks. It can be harvested for wheat seeds.", "mcl_flowers_double_plant_fern_bottom.png", "mcl_flowers_double_plant_fern_top.png", nil, 6/16, 5/16, wheat_seed_drop, false) +minetest.register_abm({ + label = "Pop out small plants", + nodenames = {"group:plant"}, + interval = 12, + chance = 2, + action = function(pos, node) + local below = minetest.get_node_or_nil({x=pos.x, y=pos.y-1, z=pos.z}) + if not below then + return + end + -- Pop out flower if not on dirt, grass block or too low brightness + if (below.name ~= "mcl_core:dirt" and below.name ~= "mcl_core:dirt_with_grass" and below.name ~= "mcl_core:dirt_with_grass_snow") or (minetest.get_node_light(pos, 0.5) < 8) then + minetest.dig_node(pos) + return + end + end, +}) + + -- Lily Pad minetest.register_node("mcl_flowers:waterlily", { description = "Lily Pad",