From 077242efa41f3e176e7a65135db552f58c7009ae Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 27 May 2017 00:55:56 +0200 Subject: [PATCH] Disable cocoa generator for non v6 mapgens --- mods/ITEMS/mcl_cocoas/init.lua | 85 +++++++++++++++++----------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/mods/ITEMS/mcl_cocoas/init.lua b/mods/ITEMS/mcl_cocoas/init.lua index e354d43f9b..2af1a49cb3 100644 --- a/mods/ITEMS/mcl_cocoas/init.lua +++ b/mods/ITEMS/mcl_cocoas/init.lua @@ -184,51 +184,52 @@ crop_def.selection_box = { crop_def.drop = "mcl_dye:brown 3" minetest.register_node("mcl_cocoas:cocoa_3", table.copy(crop_def)) --- Add random cocoa pods to jungle trees +-- Add random cocoa pods to jungle trees (v6 only) --- TODO: Do this more efficiently, with LuaVoxelManip -minetest.register_on_generated(function(minp, maxp) - - if maxp.y < 0 then - return - end - - local pos, treepos, dir - local cocoa = minetest.find_nodes_in_area(minp, maxp, "mcl_core:jungletree") - - for n = 1, #cocoa do - - pos = cocoa[n] - treepos = table.copy(pos) - - if minetest.find_node_near(pos, 1, {"mcl_core:jungleleaves"}) then - - dir = math.random(1, 40) - - if dir == 1 then - pos.z = pos.z + 1 - elseif dir == 2 then - pos.z = pos.z - 1 - elseif dir == 3 then - pos.x = pos.x + 1 - elseif dir == 4 then - pos.x = pos.x -1 - end - - local nn = minetest.get_node(pos).name - - if dir < 5 - and nn == "air" - and minetest.get_node_light(pos) > 12 then - minetest.swap_node(pos, { - name = "mcl_cocoas:cocoa_" .. tostring(math.random(1, 3)), - param2 = minetest.dir_to_facedir(vector.subtract(treepos, pos)) - }) - end +if minetest.get_mapgen_setting("mg_name") == "v6" then + minetest.register_on_generated(function(minp, maxp) + if maxp.y < 0 then + return end - end -end) + + local pos, treepos, dir + local cocoa = minetest.find_nodes_in_area(minp, maxp, "mcl_core:jungletree") + + for n = 1, #cocoa do + + pos = cocoa[n] + treepos = table.copy(pos) + + if minetest.find_node_near(pos, 1, {"mcl_core:jungleleaves"}) then + + dir = math.random(1, 40) + + if dir == 1 then + pos.z = pos.z + 1 + elseif dir == 2 then + pos.z = pos.z - 1 + elseif dir == 3 then + pos.x = pos.x + 1 + elseif dir == 4 then + pos.x = pos.x -1 + end + + local nn = minetest.get_node(pos).name + + if dir < 5 + and nn == "air" + and minetest.get_node_light(pos) > 12 then + minetest.swap_node(pos, { + name = "mcl_cocoas:cocoa_" .. tostring(math.random(1, 3)), + param2 = minetest.dir_to_facedir(vector.subtract(treepos, pos)) + }) + end + + end + end + end) +end minetest.register_abm({ label = "Cocoa growth",