From b7f50d9028dd2e6f76d752e622b85da4aac2adf1 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 9 Jun 2017 19:18:23 +0200 Subject: [PATCH] Restrict flower place to dirt/grassblock and light --- mods/CORE/mcl_util/init.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 5a3a741d..acfcd98f 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -257,9 +257,18 @@ function mcl_util.on_place_non_mycelium_plant(itemstack, placer, pointed_thing) end soil_node = minetest.get_node({x=place_pos.x, y=place_pos.y-1, z=place_pos.z}) + + local light_night = minetest.get_node_light(place_pos, 0.0) + local light_day = minetest.get_node_light(place_pos, 0.5) + local light_ok = false + if (light_night and light_night >= 8) or (light_day and light_day >= minetest.LIGHT_MAX) then + light_ok = true + end + -- Placement rules: - -- * Allowed on everything except mycelium - if soil_node.name ~= "mcl_core:mycelium" then + -- * Allowed on dirt or grass block + -- * Only with light level >= 8 + if (soil_node.name == "mcl_core:dirt" or soil_node.name == "mcl_core:dirt_with_grass" or soil_node.name == "mcl_core:dirt_with_grass_snow") and light_ok then local idef = itemstack:get_definition() local new_itemstack, success = minetest.item_place_node(itemstack, placer, pointed_thing)