From 0925cfc788dc639e900cb523c357b2c2db285f52 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 3 Aug 2017 18:58:35 +0200 Subject: [PATCH] Allow to grow huge mushrooms with bone meal --- mods/ITEMS/mcl_dye/init.lua | 48 ++++++++++++++++++ .../schematics/mcl_mushrooms_huge_brown.mts | Bin 0 -> 293 bytes .../schematics/mcl_mushrooms_huge_red.mts | Bin 0 -> 291 bytes 3 files changed, 48 insertions(+) create mode 100644 mods/ITEMS/mcl_mushrooms/schematics/mcl_mushrooms_huge_brown.mts create mode 100644 mods/ITEMS/mcl_mushrooms/schematics/mcl_mushrooms_huge_red.mts diff --git a/mods/ITEMS/mcl_dye/init.lua b/mods/ITEMS/mcl_dye/init.lua index fa1cb3b2a8..fa173dac52 100644 --- a/mods/ITEMS/mcl_dye/init.lua +++ b/mods/ITEMS/mcl_dye/init.lua @@ -129,6 +129,54 @@ mcl_dye.apply_bone_meal = function(pointed_thing) if math.random(1,100) <= 45 then return mcl_core.grow_sapling(pos, n) end + elseif minetest.get_item_group(n.name, "mushroom") == 1 then + -- Try to grow huge mushroom + + -- Must be on a dirt-type block + local below = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}) + if below.name ~= "mcl_core:mycelium" and below.name ~= "mcl_core:dirt" and below.name ~= "mcl_core:dirt_with_grass" and below.name ~= "mcl_core:coarse_dirt" and below.name ~= "mcl_core:podzol" then + return false + end + + -- Select schematic + local schematic, offset, height + if n.name == "mcl_mushrooms:mushroom_brown" then + schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_huge_brown.mts" + offset = { x = -3, y = 0, z = -3 } + height = 8 + elseif n.name == "mcl_mushrooms:mushroom_red" then + schematic = minetest.get_modpath("mcl_mushrooms").."/schematics/mcl_mushrooms_huge_red.mts" + offset = { x = -2, y = 0, z = -2 } + height = 8 + else + return false + end + -- 40% chance + if math.random(1,100) <= 40 then + -- Check space requirements + for i=1,3 do + local cpos = vector.add(pos, {x=0, y=i, z=0}) + if minetest.get_node(cpos).name ~= "air" then + return false + end + end + local yoff = 3 + local minp, maxp = {x=pos.x-3, y=pos.y+yoff, z=pos.z-3}, {x=pos.x+3, y=pos.y+yoff+(height-3), z=pos.z+3} + local diff = vector.subtract(maxp, minp) + diff = vector.add(diff, {x=1,y=1,z=1}) + local totalnodes = diff.x * diff.y * diff.z + local goodnodes = minetest.find_nodes_in_area(minp, maxp, {"air", "group:leaves"}) + if #goodnodes < totalnodes then + return false + end + + -- Place the huge mushroom + minetest.remove_node(pos) + local place_pos = vector.add(pos, offset) + local ok = minetest.place_schematic(place_pos, schematic, 0, nil, false) + return ok ~= nil + end + return false -- Wheat, Potato, Carrot, Pumpkin Stem, Melon Stem: Advance by 2-5 stages elseif string.find(n.name, "mcl_farming:wheat_") ~= nil then local stages = math.random(2, 5) diff --git a/mods/ITEMS/mcl_mushrooms/schematics/mcl_mushrooms_huge_brown.mts b/mods/ITEMS/mcl_mushrooms/schematics/mcl_mushrooms_huge_brown.mts new file mode 100644 index 0000000000000000000000000000000000000000..371e3c5ac609abbf25c9395c16b8a3d388ec82bf GIT binary patch literal 293 zcmeYb3HD`RVPI$AU|_F@0tQwF=ETe*2Ho7`ocP?*;*6sF{M=%zq@w)tJUBl-DJMTU zJ3cwFAU-+2C@-~$L7PbB#hEFo3|d4gF3B%oP$xodaY<@!#hm1X1)K>f2~5szw_T`M-1i(-0sy=RaX0_~ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_mushrooms/schematics/mcl_mushrooms_huge_red.mts b/mods/ITEMS/mcl_mushrooms/schematics/mcl_mushrooms_huge_red.mts new file mode 100644 index 0000000000000000000000000000000000000000..c0c4a31f41c885d9c2406d8f4cfb6576f2eb225f GIT binary patch literal 291 zcmeYb3HD`RVPIw8U|_9>0w9k$F|&w4J2yEeKDV?uqbNT=x7eyEH3iO#Ps+(p&W=w` zEQn9eFUm_TV$dW?adBo!DuXIPrNt$wxeOWvm4U1;$uFpwb2liOuR($5cGUZ~SDz|6 zpJ}N5k;=K$K{Lfsg+p}8GXBtTQz=6Rv$Cs`?w#BcT-+LcFm$JU+2!l+yA>k#e^&qC jeIX-u=N`|+J1f5!p56KJDnH{7JCzLq+hcmelD_}|YchB{ literal 0 HcmV?d00001