From f9372b02f6beb236ab73799d4b91b19d7a596cbc Mon Sep 17 00:00:00 2001 From: cora Date: Thu, 15 Sep 2022 05:02:48 +0200 Subject: [PATCH] Better bone mealing behavior --- mods/ITEMS/mcl_crimson/init.lua | 93 +++++++++--------- .../textures/mcl_crimson_weeping_vines.png | Bin 0 -> 6361 bytes 2 files changed, 45 insertions(+), 48 deletions(-) create mode 100644 mods/ITEMS/mcl_crimson/textures/mcl_crimson_weeping_vines.png diff --git a/mods/ITEMS/mcl_crimson/init.lua b/mods/ITEMS/mcl_crimson/init.lua index 4262e41bb..b0ba09d33 100644 --- a/mods/ITEMS/mcl_crimson/init.lua +++ b/mods/ITEMS/mcl_crimson/init.lua @@ -28,6 +28,38 @@ function grow_vines(pos, moreontop ,vine, dir) until n.name ~= "air" and n.name ~= vine end +local nether_plants = { + ["mcl_crimson:crimson_nylium"] = { + "mcl_crimson:crimson_roots", + "mcl_crimson:crimson_fungus", + "mcl_crimson:warped_fungus", + }, + ["mcl_crimson:warped_nylium"] = { + "mcl_crimson:warped_roots", + "mcl_crimson:warped_fungus", + "mcl_crimson:twisting_vines", + "mcl_crimson:nether_sprouts", + }, +} + +local function has_nylium_neighbor(pos) + local p = minetest.find_node_near(pos,1,{"mcl_crimson:warped_nylium","mcl_crimson:crimson_nylium"}) + if p then + return minetest.get_node(p) + end +end + +local function spread_nether_plants(pos,node) + local n = node.name + local nn = minetest.find_nodes_in_area_under_air(vector.offset(pos,-5,-3,-5),vector.offset(pos,5,3,5),{n}) + table.shuffle(nn) + nn[1] = pos + for i=1,math.random(1,math.min(#nn,12)) do + minetest.set_node(vector.offset(nn[i],0,1,0),{name=nether_plants[n][math.random(#nether_plants[n])]}) + mcl_dye.add_bone_meal_particle(vector.offset(nn[i],0,1,0)) + end +end + minetest.register_node("mcl_crimson:warped_fungus", { description = S("Warped Fungus Mushroom"), drawtype = "plantlike", @@ -483,54 +515,6 @@ minetest.register_node("mcl_crimson:crimson_nylium", { _mcl_silk_touch_drop = true, }) -local function has_nylium_neighbor(pos) - local p = minetest.find_node_near(pos,1,{"mcl_crimson:warped_nylium","mcl_crimson:crimson_nylium"}) - if p then - return minetest.get_node(p) - end -end - -local nether_plants = { - ["mcl_crimson:crimson_nylium"] = { - "mcl_crimson:crimson_roots", - "mcl_crimson:crimson_fungus", - "mcl_crimson:weeping_vines", - "mcl_crimson:warped_fungus", - }, - ["mcl_crimson:warped_nylium"] = { - "mcl_crimson:warped_roots", - "mcl_crimson:warped_fungus", - "mcl_crimson:twisting_vines", - "mcl_crimson:nether_sprouts", - }, -} - -local function spread_nylium(pos) - local nn = minetest.find_nodes_in_area_under_air(vector.offset(pos,-5,-3,-5),vector.offset(pos,5,3,5),{"mcl_nether:netherrack"}) - table.insert(nn,pos) - table.sort(nn,function(a, b) - return vector.distance(pos, a) < vector.distance(pos, b) - end) - for i=1,math.random(1,math.min(#nn,15)) do - local n = has_nylium_neighbor(nn[i]) - if n then - minetest.set_node(nn[i],n) - if math.random(5) == 1 then - minetest.set_node(vector.offset(nn[i],0,1,0),{name=nether_plants[n.name][math.random(#nether_plants[n.name])]}) - end - mcl_dye.add_bone_meal_particle(vector.offset(nn[i],0,1,0)) - end - end -end - -mcl_dye.register_on_bone_meal_apply(function(pt,user) - if not pt.type == "node" then return end - if minetest.get_node(pt.under).name ~= "mcl_nether:netherrack" then return end - if has_nylium_neighbor(pt.under) then - spread_nylium(pt.under) - end -end) - minetest.register_craft({ output = "mcl_crimson:crimson_hyphae_wood 4", recipe = { @@ -548,6 +532,19 @@ minetest.register_craft({ mcl_stairs.register_stair_and_slab_simple("crimson_hyphae_wood", "mcl_crimson:crimson_hyphae_wood", S("Crimson Stair"), S("Crimson Slab"), S("Double Crimson Slab")) +mcl_dye.register_on_bone_meal_apply(function(pt,user) + if not pt.type == "node" then return end + local node = minetest.get_node(pt.under) + if node.name == "mcl_nether:netherrack" then + local n = has_nylium_neighbor(pt.under) + if n then + minetest.set_node(pt.under,n) + end + elseif node.name == "mcl_crimson:warped_nylium" or node.name == "mcl_crimson:crimson_nylium" then + spread_nether_plants(pt.under,node) + end +end) + minetest.register_abm({ label = "mcl_crimson:crimson_fungus", nodenames = {"mcl_crimson:crimson_fungus"}, diff --git a/mods/ITEMS/mcl_crimson/textures/mcl_crimson_weeping_vines.png b/mods/ITEMS/mcl_crimson/textures/mcl_crimson_weeping_vines.png new file mode 100644 index 0000000000000000000000000000000000000000..efe1cb5538fa6550c001ff607d7dbecf07ac705f GIT binary patch literal 6361 zcmeHLdpwkB`=6X6izKAYG)a^>8s-p{!(h@Nhp0%;%sev<=3r(Rl(v;3N(x&!DV(q<|9lJlV`Qlhe}gX(=|sPw-3?)&TW`Mv+eXU5$3{k^`|b${>cy6$-#aC31~ zS6!qEgTd6PPWJB5Urp&tMG1O0eE9)@!4!`~c>0Ll0SR0nnh{l zLlDEu`}!0L4`l_`4JR)*F|(-^Mg6pg*w`5~{;W0Hlf5<6d1@+uw>E)kX#4C=XU)zV z+ue?zO$@5IIPSUbrYp5h;eJ9}@df|Lx(6s*XKmu(udZG3n?@3DH=iL45ZvmTg7^J+ z)_k;iO+r$5=#@pN-5r}>6r19Id9ZI%3dR+AayH~GwKm(Mt4zNH+> zP%wQkhow{%wQ-I3bTMDA3w+UDp}7fXqZhI=Z}(e+wyidWA-A=;@5gl}9=O=%H6M8* zIVT5i30;zUzyDq359IT53XOt`F+T=7d)VVHRb(rruD%13C;meDkGNPE z?Zk2{lOy^qL1p*EwH3CB?B;aX9R2HxTS^ud!|FwS24loUfgR(E9h&4cm4HDQEm7qh ze!ju0flJCUnObKKVeb(KXqe`>)_XpI8Kb|V$-$la>CPtH9m!oxbS#N@mCgXt-bwyH;@Ymc#x>96GlX2J65^vI=Plc1sNt3dQ2hJwN z?usb|=W{wo3W`qOR4TCGRHm{{1YX&dB4mN0m$Zl%0M)krrgDuRst z-W+~2ZBNA$l|6U6v0YZ2#sa%GY?s`!mGkVJ|50Pwq9q?yIsb%%a_9=7Zg=v%AEFJ$ zZsmX1)3?qg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