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 zcmeHLX;c&0wl0|kX>dS6Y>iP7lq8i9$RI%(0z?cTprC?SNh+a$3?u~!IJAu@h>9rK z3WDv#sDOYB(x8H4ON-JMP-YbrL=jZFolx&eK*aZaeV;$>KX+EGl{)9!-#+I%d+)Q7 zou2M4`nof90RYfvxjK0P0AQ$mbhH2fnDg=@1OS@*qI~>NFG!A&NX2|46vm*D5*Pz3 z5Iz7XTJn6G4|Gu{4GX53MgxPBVtY0ou8z5I#c_YeFYSya+-5A(3$t|*a5neC2Vviw zO@5WDTBzb}C8l=t-iwoeyl~TFmb_)CydYLM;D5D|SZzGzENM`;DE%^QB#|7&( z-c*|X8IJ8;(AlYxx94QY<=*54=9cy~vglv7Qg60|4nAv)@e!t}fox(GLn=e1WJGf1ycK`0tx@&b`!j1Y9lrDOmC-Bh&|`&S<5u{^-Eza#BzxoVMcG^4nci7vpBH{(s_?_0(a-~T zhwS=&Pvoc7Fbxs2Q|{k;U-1(?Urpntq&W8HFgI@}(%JG1t&}CVqql4IPtudZ6SwX< zQ}#0{4qzW%K;$8^KN57d3|(C4kSM56116YU(p+0Ky%4x2>ogsp&J1ZDoaJ1nW~c>q z1MEbd)8r|pue;7_#~z=2Vh^#2+QkOz;~Sg&Lel$xC(y%MOa$q&4$T==ivB%i9gzi_ z28j~G`7TpKCDpNpoXeS$_s{D{@H6B-n9o|66e|5aE0LqMxv0*p^=XkWt=q5M)&7Wi zY54;;^FlAp1G)K`Eq%EK$F6GSS|b%H{KFyVw@)`{aAo^l@L%e(C!#@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