From 714d1590728a1ce3c94e728c552c2144350e2e71 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Wed, 8 Feb 2023 16:05:34 +0000 Subject: [PATCH 01/54] Add batch 1 of the new leaf textures --- textures/default_acacia_leaves.png | Bin 211 -> 530 bytes textures/default_jungleleaves.png | Bin 230 -> 498 bytes textures/default_leaves.png | Bin 224 -> 537 bytes textures/mcl_core_leaves_big_oak.png | Bin 194 -> 540 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/textures/default_acacia_leaves.png b/textures/default_acacia_leaves.png index 6d89629bb2c3cda06f6860ec00ab667b38f7a414..f7d091e6015c6d1c4b30048f449ae558d32825fd 100644 GIT binary patch delta 516 zcmV+f0{i{b0g?oe7=H)`0000V^Z#K0000JJOGiWi{{XZAv^{)XssI2032;bRa{vGi zz5oCYz5(h&vA_TT00(qQO+^Rg3j61pJo5!4goH1c_9I3DeuLj&FDS&VCOhKJOn-8=Pi$VNXIeE?uj;+( zS4dH21^|YB7T(iD0RWbD!_dzH07aRZ_qSIZPgg0*%nP@#|Q&p$98 z?E)<8hL6uL06-l5e5Z+m2LN4@+hR7X+fm{ufYy_^sz^kPN7-6Wk|qjWlN&Ozpl(Ou zn9(k<*s9ta>3^EsEbE5%w^smokg4@#^K9TMuG>*OH}UKD4MRT*_+z6h|<$N#z>}$L8*X?K(G3Iej_i>J=t8fe+GE%V$ebntJ!r<-i{lNt`q=l}E zs@fZ3Ju-aX?%={Oru8H$^dGEcE{*~eWoA6eOB01OQGFQt*)kMmW{#(;bWLup?3&zY zJxR3t8P9X&aZV;(H#n*aeO%55v#cB9D1bNgvn=ZddQFSmV&--<0WD=qEAJy{!0000Do`|hLOeW*-?O#ju_c`mpj<41 x*V9K##%|fN13f9$KvuH|Q+>pIuL0ziSbv#c588T9p-2D#002ovPDHLkV1fl{QM&*D diff --git a/textures/default_jungleleaves.png b/textures/default_jungleleaves.png index e247a16f091fe0aab4b489c94621a76683037bf5..77fd4b5ca3ef85933cfe4e2781c0d98a5d51e73d 100644 GIT binary patch delta 484 zcmV}=80B;Zfcxdx0YFxi2&34*uv6f71k^9|sOlB~5JvGY+&~8k zVXJ(xKB!3_pI12vs5M>3 zg6mlDW)oC(tABI}qnK573r@lja6B5~FIsbNsv6T9e!m<$9i)qP3j8iBN(f=AMtv*? z04W<)2&0&}j)gw8e(d~!?figo>Z+hQWdkW2MMVf3 z-fUttBrOXP} z6{Xs2@VehB8k#pR2EJ)cPNprkBKN)uF_R+`DsZ@0fLzMq$&{VRT a=zIfHdD_Wut~8PW00009aJ77VIvw!8z*ll z7(*Dyop;3m0007XQchC^1$&Oo@&Et;dr3q=R0tgf!9fm!Fcd}63vFjnrUj0ti7@f<2s9?WN)3C-V(dT3@v#<+xPQA@cj%1@oa+eM{QfO^N5$&31y zc(kj)X|`sIBwia>K)JGg`~-Y)&%1gL=ceD*Ho?%)8N!Qvln7<|O~*CnKg9YK2KWNi Qn*aa+07*qoM6N<$f@EJ-)c^nh diff --git a/textures/default_leaves.png b/textures/default_leaves.png index 6ef923cfd60f9b70559faa52888548fd56a25242..c81100557ef9fefbe9c0329c89f3ba5281e76910 100644 GIT binary patch delta 524 zcmV+n0`vXg0ht7l7=H)`0000V^Z#K0000JJOGiWi{{XZAv^{)XssI2032;bRa{vGi zz5oCYz5(h&vA_TT00(qQO+^Rg3&&3sSwdtKdZQ~?OWNX=(s{papM@fC3tYWWVrNC7-O2HHJ4B?u#> z?4tE%%eCJIV41GSi#;~@F+ek^-|K3?GzcKTXfjn&BYDZ4NU|Hh-$DH(Q)?!C)AxY*!c-ey7FT+q;n^Y-Fe-&7N0B8VAEztv6e0Zp8pC z(-nhZtVFxis`+fJ?WDa>(SPip04sp|+Z!!(C6bp{{yzWv23o#~)9-b4&8_hJ*H7&8 z)ZB`>Ob|v&rkDNU*pxi4PV(}4aMCym_5JOQmW!0bv48c513$7HyFu8ECR3H|3Ouil z=hZ)VAXG$?y_3s}bFSJy4#34w*M6Htl731kTh#Bg@H;IA!&oiT)q!rQTO{eB6Ky+7 zlpmIDp!H_UXfjofZ3@vZI?G$PWy05AWU1mFRX7=Hu<0002(-QrRJ000$GOjJc2IUFfcC`gh=IBz#DT`eR^Bo{9i zSyonf00003bW%=J|NjN2p!v=K004JML_t&t9R=TRKclA#e6x-C7>2^huE_Pj%!ZF?_d^rB*Pn zgNRO;cDt}R8p$=}ktp33=}zb7+0IbQagi;7zWiSDDhT^EyYvTq(G(Z*`_}OQ0000< KMNUMnLSTX@d{bZm diff --git a/textures/mcl_core_leaves_big_oak.png b/textures/mcl_core_leaves_big_oak.png index 53e552debb5a82668d0b077fd218bbcf68274fd4..a9739cd6c3ea7aa389132e60b6e413aba68fb369 100644 GIT binary patch delta 527 zcmV+q0`UF90h|Po7=H)`0000V^Z#K0000JJOGiWi{{XZAv^{)XssI2032;bRa{vGi zz5oCYz5(h&vA_TT00(qQO+^Rg3~>z3GU{ z?9BgIwOCgUpznGB(q#%j^Xs<)kh-2}4$lXYJONn%tR6l>XuO87e z4Zz{~06=)z#D6!LsUI*|%&@;;ve@&HmxW80De3ZKiOFIjd$zQ7qalc267SRVY?-C(^yYT`^hgp~z!-SvY|pk55AR z#I~ViA<05$_+O&DEL`Zo&mr4IoiOKR9QGIQJUd)z>&<@#lkXg!pO=OE17Zj7^a8mJ R1ONa400>D%PDHLkV1l&Y@W}uG delta 178 zcmbQka)@z)L_G^L0|Ud`yN`l^6n}tEh^xmWcTpE95mRv?e(9pnp;9|q~E&pfDVN_BS+9bHo;oQbr zmModPRqtu%vgrQJ3L?^*0cyYnnFE^F6$wi+L1V`ivgSbpltye-qS e7kcjKWw6UQ$FY68`I%&(Z492SelF{r5}E)a6F*G= From c26cddeafc1c925faf5072c382db06bdac247f1b Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Wed, 8 Feb 2023 16:06:08 +0000 Subject: [PATCH 02/54] Add batch 2 of the new leaf textures + foliage palette --- textures/mcl_core_leaves_birch.png | Bin 206 -> 366 bytes textures/mcl_core_leaves_spruce.png | Bin 205 -> 456 bytes textures/mcl_core_palette_foliage.png | Bin 0 -> 149 bytes textures/mcl_mangrove_leaves.png | Bin 229 -> 6349 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 textures/mcl_core_palette_foliage.png diff --git a/textures/mcl_core_leaves_birch.png b/textures/mcl_core_leaves_birch.png index b4ad81d1d8e27a3d70ef56849ec133eddd6df43a..0432500d11b4f49f2b8307e806096d711da65460 100644 GIT binary patch delta 351 zcmV-l0igcQ0qz2j7=H)`0000V^Z#K0000DMK}|sb0I`n?{9y$E000SaNLh0L01mqV z01mqW$N1DX0000ObVXQnQ*UN;cVTj60B~VxZgehgWpp4kE-@}OWJg$10002&Nklg4Epp4U^MOd4pwF*yLgUycQOa07T(15v?2hv5boBJi|`*^_~RoTT~vI2ZJQ zE`TS?{Z4v><*;ErJg=D>SnH)Ww2cS`m~KBkGjEcsn=a4IW|YW4exEQL7?6k2s|UoD zfjoQofSiyDz*sC0xHN>k17HBP;nceeQA{(?lf7L)-T^f*)Ef9-05njK1gAIvcU}Jn x-|BsdHs|%-EQffzX4kCn6*C^7cQWru s@Eh7ldM@4^0Qq&u837qun7x8we`Tu->uQ~MxBvhE07*qoM6N<$f+S2yZ~y=R diff --git a/textures/mcl_core_leaves_spruce.png b/textures/mcl_core_leaves_spruce.png index e95b849f14db4c73d261f274e1231b9bc9d9d869..3e2128a7521520aa1af8e4852532651c4b0c1296 100644 GIT binary patch delta 442 zcmV;r0Y(1J0muW87=H)`0000V^Z#K0000JJOGiWi{{XZAv^{)XssI2032;bRa{vGi zz5oCYz5(h&vA_TT00(qQO+^Rg3$DP3<@DaQK1Jf6%kLLxL-tYnl^qr`!JkcjOaUjF+1b=&KGuyOX1KHjD$$t4& zQEU4C92EeRrlP_0sx%d?(}M7@g^a=Uu8(s{F1P^zGM!VLCQmm3K(vowXA5;ap9lc# zY~jb>?H6&HIB^z<_7MP}Yg!e^)49O0*@f<(58@l$zJ34zLD#gZYg*-xu}%wK<+#77 zHN9j|)Y|14GJkWCV(J;3u4z@KbK2}e_Y#r^$2u)gJfEGdgJWm=uwk7RynVdG2Oh`< zIp1}>IH*2c27Z?>YE5!(N&a{~QKoasbWVQFG4P!yf%=?e%?a?#>@eRv(tX_T81RCX z`CHVQ{8{-wP7}mwf?%B%w~!E}kyw;#d>{a*qSh21wljCve~VhxZDm3urmZPiiO2mPwWHQ!{F)a=d#Wzp$Pz>XfHt}>M)sxVM*PN7D9PCFrRwUCkO7ZnUO(xdGe04-ES(&d`2P4f z#BF2X;s(YmvW^k&$@Xo};tHZHc#T_Yo^2KGJJF|1XTK&5uN&`p)L($jUI9E=n{0ks z_x=dIqNVo1JT#+_(O{4TuE5ZfpQ;C`bp&URdS8i~``1Ia&YgA|kbP()FU>w1_23cD zel#`7 z{(8Zg&oiFpOCN~dbh!>SmpAWxnkH@W-jHMd_CzJBw36nZbCR)UBB--A3!m7VoOKZ2 z);I5h@pV9|U$nwcp!UQ$tmbj+f)ph;Gq)Y{$)$a{E6to*_A4K5&28J8GS`@Dbn2%) zFD=MA%kx52-hr1Rko{(hmL&8EbC^9B^hmiOyO)oTPf1TF2mQ9pv!K6eVQ=ro?Hc)J zzr1RngX|ooL1y)1adxyaHI1r$occML4+~S;ZkL|g$lxG&N1wfx*0>z|LD^ORZ`LYw zHH~o3>-#L09#GbQv*NNv{oXTYFDcD|(zTAWBX+A>UFoI_s4S^^5t~{ch`3^y;W8hQ z_0xXUv&Rw=7j}9<*8`tQCG{z3n7F=El80kG*6(E@iQ1TVdWqW&el|GU+u)|>J%5>V zy4sUx$1_aV?8Yy%@;D>KSv#1@_E5@yZQ~_q9gK`}Gwjdg#r*nouXFza-^ZbvvB%%d zPt6MOk)`^Sp065=DE47_Xv^-pm$#80Ic6^UE6vM{3`{_i)Xf$7*Og1k40Jki(EUaGNAV_Tsw6Elo3{Td_SpPfm-7ZC)N2uC*B`hUn2h~?GV_;? z4xZ{@)%M?{I~;Bo+t!^+dqmB3pSQWy1mjz`oVfR1J#f#V@B(|k-4Y8<6|N&Cx{RGb zDCt7wB?((A4nAwTEu+~*|HSrqL2so-u5w2oGaqZ^_4X_Ma(f9@HoEfruHOdTafjyD z0^5sRUfBND`LO&}`;oQ;PuyS-$e4F4e0WS}987A}!U$UZ5yi&`cHY^(P)4g6vCBW6 zV7}Wo&%{gP;@a1KukByyOp5<(1kj56Od>cEj#*`;{J<6f`Wus?2*nJ zb@|;F4JuC$RHf=tYfrsD>^{=l!x;0^;hXfIsIBPV^3R<^FYg>>JT18$pR;yyDSOPX zGN7lvQ8-j<-F>N;K`DB!e({n3qLvvs{{Z+vZ&uMD+NHEov$r&uS{!LPx)G(bg5 zcB;KJsaa;?n3-&T?V7g`ZT0SKK(sLGZdd&}Jrz59<3rK~8wwhxmhD)C|BLb4zV4dF zZfpDE{RcLm-=kd0F>DU-Yi0X4T>gIi8C^FSw+io@QM9PzwehC6uZKo3SIRHlnxIx? zNt+QzTy0v!S5X@+4nM3A-yCZ&U7xj}SJaD7!nlq%MgQ7Qxv9ES^{^qKqnX;PcQzm# zxVR(mwpU8guB)k~-nDz90v}(x7KmOK(06!zN4@mCw3pWA&~Rp#)qFkE{6y`n5L3q! zE~zQzFB!Ju%IS6vnA~8akS7NihO5jQbtl#9s>#Ed-|>BLniX~TMjLT@_f!Yh-Je{2 z{^f_cJwK|IRTS0*D|1#ePg_>L)^D%T4i2V}<8&`PQ2KC0+`QMg+0(b_>9)7T4~0Lp zZ_yH$Rn?G3qdp)CN>0d(dV2H>R(g%*HC9^(Z5ey(o?mBjat>4*F|mCLfzXw5;d?Z| z!=1(w@Gt;d5DH>qc|!P}MIdbKVub)J0u&=d!7wi07WJyS4u#~hZBhPY51faP4u*4G z;~~&DeytxXK7vJMqwH2|+Qiae0v;#^kg>c-zK9lUi&F5?;Lq}DEDEWBh$C!K0UlmR zx&Q)^Bn%0ILp#TEV+g3#nn)Xn&7t`?xy(?&BU@CsSS+Mru@Z>{BOzi0P#6|ZrBbmt z0+v8P!w9q}jxPpc(R`7aoMM{82^6s)u29Ss@R4#(AXE@7wnd@fb>s{=yvlNpg(qhm z$j1tLk(iBT!UGb#9~gio;BZ!G905(BVrSdKs~#SotofoD6=6NGv49YZ$KbF$-WL`k zv2)C4e}8Bp@`Jz5V0}Q5AR1zU&M_cgY&P4eFfv*++h?>0lus$*j%0JNa8L@*vuzkm z53f%)av8(8JfXruj-HKVvp(U3(NLrU!)9T@NRS5yB7&LmU*N@D&gTRAVn6bge+vY5 z_lf@t^hdoEu_$z+r=0mm$qGIwzVt~&AJud3ZN8 zIs^h@0puqTMB1X{(IVxPilRc=%#;hwUBFTpD!?FHUU4%u=Lm#h6+;{BpMn34$v0de z;s4)wK0`mTI6z{F0E+O0JVQ5wEb*W7{1NyQlMmeOL}Dn8`5!j*KX5kF3F`{m3ZS@I z{(Zry>CtpcisUM!LLwDyfCjLp~aKsV-0v*EO9DvUmE-uA6BUjAi z-^wqek%WWt8*Msh*uOPxOE&HsX%Wj~Xn|H*tdY}%SG5XQk(94_{h@c-2P9{{Hr+_@}}FB1G& z=(8cyvdp@O;Fzc9;0q4EFR`C4%$Y2a7t(+6XD0jpiymO=Z%)2S-*0k#lk2M#_$u(X z?D{6xS1IsS;BVRW|0b8_=SOak4}b5Izz@{db0j_R!?;?g8^Z}PCI3BIQWX-L?s<{SLp^1x&pBr`l;KpHc^|~a9#?Z?C z1D5aehNqs|6)m#QYp5zU`f#{qxTShzVx-h!cu%F&gM2xbRFI}@g;=BNH-cTGiqJ5A zXIph6l3&C;2_w4R1|w7om?!hw87i$s&s$3dlSwI+K1y-k8&|H2P9ixp| delta 213 zcmX?W_>^&iL_G^L0|Ud`yN`l^6mzkYX9x!e$L)vy4}e^u0G|+7Ak8PjCZ) z>VBV}WG%ohZppClp!hLvN&od{T|d<2bm%`&TILtd9ra{$r?y*;NvCjHhGILLius@K zeEo|~i_eu?Cb{h9!7YckFsIL)liI{R`S+{^kIu|G=l05Ezu#~6rZu8>I2MWa0 Date: Wed, 8 Feb 2023 16:11:38 +0000 Subject: [PATCH 03/54] Change stuff in mcl_core Simply put, this commit changes some code so that leaves don't use `param2` to see if they rot or not, and will now use the biome colours. This commit also makes it so vines do the same (use biome colours). --- mods/ITEMS/mcl_core/functions.lua | 24 ++++++++++ mods/ITEMS/mcl_core/nodes_climb.lua | 25 +++++++++- mods/ITEMS/mcl_core/nodes_trees.lua | 71 +++++++++++++++++------------ 3 files changed, 89 insertions(+), 31 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index 19c56b4d3..fcc2e5078 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -820,6 +820,30 @@ function mcl_core.get_grass_block_type(pos) return {name = "mcl_core:dirt_with_grass", param2 = mcl_core.get_grass_palette_index(pos)} end +function mcl_core.get_foliage_name(pos) + local nodename = minetest.get_node(pos).name + return nodename +end + +function mcl_core.get_foliage_palette_index(pos) + local biome_data = minetest.get_biome_data(pos) + local index = 0 + if biome_data then + local biome = biome_data.biome + local biome_name = minetest.get_biome_name(biome) + local reg_biome = minetest.registered_biomes[biome_name] + if reg_biome then + index = reg_biome._mcl_foliage_palette_index + end + end + return index +end + +-- Return appropriate foliage block node for pos +function mcl_core.get_foliage_block_type(pos) + return {name = mcl_core.get_foliage_name(pos), param2 = mcl_core.get_foliage_palette_index(pos)} +end + ------------------------------ -- Spread grass blocks and mycelium on neighbor dirt ------------------------------ diff --git a/mods/ITEMS/mcl_core/nodes_climb.lua b/mods/ITEMS/mcl_core/nodes_climb.lua index 8893db21b..b69b715ba 100644 --- a/mods/ITEMS/mcl_core/nodes_climb.lua +++ b/mods/ITEMS/mcl_core/nodes_climb.lua @@ -92,11 +92,13 @@ minetest.register_node("mcl_core:vine", { _doc_items_longdesc = S("Vines are climbable blocks which can be placed on the sides of solid full-cube blocks. Vines slowly grow and spread."), drawtype = "signlike", tiles = {"mcl_core_vine.png"}, + color = "#48B518", inventory_image = "mcl_core_vine.png", wield_image = "mcl_core_vine.png", paramtype = "light", sunlight_propagates = true, - paramtype2 = "wallmounted", + paramtype2 = "colorwallmounted", + palette = "[combine:16x2:0,0=mcl_core_palette_foliage.png", walkable = false, climbable = true, buildable_to = true, @@ -107,7 +109,7 @@ minetest.register_node("mcl_core:vine", { groups = { handy = 1, axey = 1, shearsy = 1, swordy = 1, deco_block = 1, dig_by_piston = 1, destroy_by_lava_flow = 1, compostability = 50, - flammable = 2, fire_encouragement = 15, fire_flammability = 100 + flammable = 2, fire_encouragement = 15, fire_flammability = 100, foliage_palette_wallmounted = 1 }, sounds = mcl_sounds.node_sound_leaves_defaults(), drop = "", @@ -155,6 +157,25 @@ minetest.register_node("mcl_core:vine", { return itemstack end, + on_construct = function(pos) + if mg_name ~= "v6" and mg_name ~= "singlenode" then + local node = minetest.get_node(pos) + local biome_data = minetest.get_biome_data(pos) + local biome = biome_data.biome + local biome_name = minetest.get_biome_name(biome) + local reg_biome = minetest.registered_biomes[biome_name] + if node.name == "mcl_core:vine" then + local biome_param2 = reg_biome._mcl_foliage_palette_index + local rotation_param2 = node.param2 + local final_param2 = (biome_param2 * 8) + rotation_param2 + if node.param2 ~= final_param2 and rotation_param2 < 6 then + node.param2 = final_param2 + minetest.swap_node(pos, node) + end + end + end +end, + -- If dug, also dig a “dependant” vine below it. -- A vine is dependant if it hangs from this node and has no supporting block. on_dig = function(pos, node, digger) diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index 0207b4ec1..343d9a7a3 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -15,11 +15,10 @@ end -- -- Whenever a trunk node is removed, all `group:leaves` nodes in a sphere -- with radius 6 are checked. Every such node that does not have a trunk --- node within a distance of 6 blocks is converted into a orphan leaf node. +-- node within a distance of 6 blocks and wasn't placed by a player is +-- converted into a orphan leaf node. -- An ABM will gradually decay these nodes. -- --- If param2 of the node is set to a nonzero value, the node will always --- be preserved. This is set automatically when leaves are placed manually. -- -- @param pos the position of the removed trunk node. -- @param oldnode the node table of the removed trunk node. @@ -29,20 +28,16 @@ function mcl_core.update_leaves(pos, oldnode) local leaves = minetest.find_nodes_in_area(pos1, pos2, "group:leaves") for _, lpos in pairs(leaves) do lnode = minetest.get_node(lpos) - -- skip already decaying leaf nodes - if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 then + -- skip already decaying leaf nodes and player leaves + if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 and minetest.get_item_group(lnode.name, "player_leaves") ~= 1 then if not minetest.find_node_near(lpos, 6, "group:tree") then - -- manually placed leaf nodes have param2 - -- set and will never decay automatically - if lnode.param2 == 0 then - local orphan_name = lnode.name .. "_orphan" - local def = minetest.registered_nodes[orphan_name] - if def then - --minetest.log("Registered: ".. orphan_name) - minetest.swap_node(lpos, {name = orphan_name}) - else - --minetest.log("Not registered: ".. orphan_name) - end + local orphan_name = lnode.name .. "_orphan" + local def = minetest.registered_nodes[orphan_name] + if def then + --minetest.log("Registered: ".. orphan_name) + minetest.set_node(lpos, {name = orphan_name}) + else + --minetest.log("Not registered: ".. orphan_name) end end end @@ -149,7 +144,7 @@ local function register_wooden_planks(subname, description, tiles) }) end -local function register_leaves(subname, description, longdesc, tiles, sapling, drop_apples, sapling_chances) +local function register_leaves(subname, description, longdesc, tiles, color, paramtype2, sapling, drop_apples, sapling_chances, foliage_palette) local apple_chances = {200, 180, 160, 120, 40} local stick_chances = {50, 45, 30, 35, 10} @@ -180,20 +175,22 @@ local function register_leaves(subname, description, longdesc, tiles, sapling, d return drop end - local l_def = { + local pl_def = { description = description, _doc_items_longdesc = longdesc, _doc_items_hidden = false, drawtype = "allfaces_optional", waving = 2, - place_param2 = 1, -- Prevent leafdecay for placed nodes tiles = tiles, + color = color, paramtype = "light", + paramtype2 = paramtype2, + palette = "mcl_core_palette_foliage.png", stack_max = 64, groups = { handy = 1, hoey = 1, shearsy = 1, swordy = 1, dig_by_piston = 1, flammable = 2, fire_encouragement = 30, fire_flammability = 60, - leaves = 1, deco_block = 1, compostability = 30 + leaves = 1, deco_block = 1, compostability = 30, foliage_palette = foliage_palette, player_leaves = 1, not_in_creative_inventory = 0, }, drop = get_drops(0), _mcl_shears_drop = true, @@ -202,17 +199,33 @@ local function register_leaves(subname, description, longdesc, tiles, sapling, d _mcl_hardness = 0.2, _mcl_silk_touch_drop = true, _mcl_fortune_drop = { get_drops(1), get_drops(2), get_drops(3), get_drops(4) }, + on_construct = function(pos) + local node = minetest.get_node(pos) + if node.param2 == 0 then + local new_node = mcl_core.get_foliage_block_type(pos) + if new_node.param2 ~= 0 then + minetest.swap_node(pos, new_node) + end + end + end, } + minetest.register_node("mcl_core:player" .. subname, pl_def) + + local l_def = table.copy(pl_def) + l_def.groups.player_leaves = nil + l_def.groups.not_in_creative_inventory = 1 + l_def._mcl_shears_drop = {"mcl_core:player" .. subname} + l_def._mcl_silk_touch_drop = {"mcl_core:player" .. subname} + minetest.register_node("mcl_core:" .. subname, l_def) local o_def = table.copy(l_def) o_def._doc_items_create_entry = false - o_def.place_param2 = nil o_def.groups.not_in_creative_inventory = 1 o_def.groups.orphan_leaves = 1 - o_def._mcl_shears_drop = {"mcl_core:" .. subname} - o_def._mcl_silk_touch_drop = {"mcl_core:" .. subname} + o_def._mcl_shears_drop = {"mcl_core:player" .. subname} + o_def._mcl_silk_touch_drop = {"mcl_core:player" .. subname} minetest.register_node("mcl_core:" .. subname .. "_orphan", o_def) end @@ -310,12 +323,12 @@ register_sapling("birchsapling", S("Birch Sapling"), "mcl_core_sapling_birch.png", {-4/16, -0.5, -4/16, 4/16, 0.5, 4/16}) -register_leaves("leaves", S("Oak Leaves"), S("Oak leaves are grown from oak trees."), {"default_leaves.png"}, "mcl_core:sapling", true, {20, 16, 12, 10}) -register_leaves("darkleaves", S("Dark Oak Leaves"), S("Dark oak leaves are grown from dark oak trees."), {"mcl_core_leaves_big_oak.png"}, "mcl_core:darksapling", true, {20, 16, 12, 10}) -register_leaves("jungleleaves", S("Jungle Leaves"), S("Jungle leaves are grown from jungle trees."), {"default_jungleleaves.png"}, "mcl_core:junglesapling", false, {40, 26, 32, 24, 10}) -register_leaves("acacialeaves", S("Acacia Leaves"), S("Acacia leaves are grown from acacia trees."), {"default_acacia_leaves.png"}, "mcl_core:acaciasapling", false, {20, 16, 12, 10}) -register_leaves("spruceleaves", S("Spruce Leaves"), S("Spruce leaves are grown from spruce trees."), {"mcl_core_leaves_spruce.png"}, "mcl_core:sprucesapling", false, {20, 16, 12, 10}) -register_leaves("birchleaves", S("Birch Leaves"), S("Birch leaves are grown from birch trees."), {"mcl_core_leaves_birch.png"}, "mcl_core:birchsapling", false, {20, 16, 12, 10}) +register_leaves("leaves", S("Oak Leaves"), S("Oak leaves are grown from oak trees."), {"default_leaves.png"}, "#48B518", "color", "mcl_core:sapling", true, {20, 16, 12, 10}, 1) +register_leaves("darkleaves", S("Dark Oak Leaves"), S("Dark oak leaves are grown from dark oak trees."), {"mcl_core_leaves_big_oak.png"}, "#48B518", "color", "mcl_core:darksapling", true, {20, 16, 12, 10}, 1) +register_leaves("jungleleaves", S("Jungle Leaves"), S("Jungle leaves are grown from jungle trees."), {"default_jungleleaves.png"}, "#48B518", "color", "mcl_core:junglesapling", false, {40, 26, 32, 24, 10}, 1) +register_leaves("acacialeaves", S("Acacia Leaves"), S("Acacia leaves are grown from acacia trees."), {"default_acacia_leaves.png"}, "#48B518", "color", "mcl_core:acaciasapling", false, {20, 16, 12, 10}, 1) +register_leaves("spruceleaves", S("Spruce Leaves"), S("Spruce leaves are grown from spruce trees."), {"mcl_core_leaves_spruce.png"}, "#619961", "none", "mcl_core:sprucesapling", false, {20, 16, 12, 10}, 0) +register_leaves("birchleaves", S("Birch Leaves"), S("Birch leaves are grown from birch trees."), {"mcl_core_leaves_birch.png"}, "#80A755", "none", "mcl_core:birchsapling", false, {20, 16, 12, 10}, 0) From f4e8088e600000b3ceb03662e148f8931db5766a Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Wed, 8 Feb 2023 16:13:13 +0000 Subject: [PATCH 04/54] Improve mangrove leaves This commit makes it so mangrove leaves also no longer use `param2` to see if they rot or not. The leaves also use the biome colours now. --- mods/ITEMS/mcl_mangrove/init.lua | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_mangrove/init.lua b/mods/ITEMS/mcl_mangrove/init.lua index 410da28d4..81b8bd1c5 100644 --- a/mods/ITEMS/mcl_mangrove/init.lua +++ b/mods/ITEMS/mcl_mangrove/init.lua @@ -86,19 +86,21 @@ minetest.register_node("mcl_mangrove:mangrove_wood", { _mcl_hardness = 2, }) -local l_def = { +local pl_def = { description = S("Mangrove Leaves"), _doc_items_longdesc = S("mangrove leaves are grown from mangrove trees."), _doc_items_hidden = false, drawtype = "allfaces_optional", waving = 2, - place_param2 = 1, -- Prevent leafdecay for placed nodes tiles = {"mcl_mangrove_leaves.png"}, + color = "#48B518", paramtype = "light", + paramtype2 = "color", + palette = "mcl_core_palette_foliage.png", groups = { handy = 1, hoey = 1, shearsy = 1, swordy = 1, dig_by_piston = 1, flammable = 2, fire_encouragement = 30, fire_flammability = 60, - leaves = 1, deco_block = 1, compostability = 30 + leaves = 1, deco_block = 1, compostability = 30, foliage_palette = 1, player_leaves = 1, not_in_creative_inventory = 0, }, drop = get_drops(0), _mcl_shears_drop = true, @@ -107,17 +109,33 @@ local l_def = { _mcl_hardness = 0.2, _mcl_silk_touch_drop = true, _mcl_fortune_drop = { get_drops(1), get_drops(2), get_drops(3), get_drops(4) }, + on_construct = function(pos) + local node = minetest.get_node(pos) + if node.param2 == 0 then + local new_node = mcl_core.get_foliage_block_type(pos) + if new_node.param2 ~= 0 then + minetest.swap_node(pos, new_node) + end + end + end, } +minetest.register_node("mcl_mangrove:playermangroveleaves", pl_def) + +local l_def = table.copy(pl_def) +l_def.groups.player_leaves = nil +l_def.groups.not_in_creative_inventory = 1 +l_def._mcl_shears_drop = {"mcl_mangrove:playermangroveleaves"} +l_def._mcl_silk_touch_drop = {"mcl_mangrove:playermangroveleaves"} + minetest.register_node("mcl_mangrove:mangroveleaves", l_def) local o_def = table.copy(l_def) o_def._doc_items_create_entry = false -o_def.place_param2 = nil o_def.groups.not_in_creative_inventory = 1 o_def.groups.orphan_leaves = 1 -o_def._mcl_shears_drop = {"mcl_mangrove:mangroveleaves"} -o_def._mcl_silk_touch_drop = {"mcl_mangrove:mangroveleaves"} +o_def._mcl_shears_drop = {"mcl_mangrove:playermangroveleaves"} +o_def._mcl_silk_touch_drop = {"mcl_mangrove:playermangroveleaves"} minetest.register_node("mcl_mangrove:mangroveleaves_orphan", o_def) From 07f332f0cdc09f197498f7c8ac09e26ecdc65dda Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Wed, 8 Feb 2023 16:15:04 +0000 Subject: [PATCH 05/54] Add foliage palette indexes This commit adds foliage palette indexes to every biome, this makes it possible for foliage to use biome colouring. --- mods/MAPGEN/mcl_biomes/init.lua | 107 ++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index fc2864fcf..3b9ca2d46 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -51,6 +51,7 @@ local function register_classic_superflat_biome() heat_point = 50, _mcl_biome_type = "medium", _mcl_grass_palette_index = 0, + _mcl_foliage_palette_index = 1, _mcl_skycolor = "#78A7FF", _mcl_fogcolor = overworld_fogcolor }) @@ -161,6 +162,7 @@ local function register_biomes() heat_point = -5, _mcl_biome_type = "snowy", _mcl_grass_palette_index = 2, + _mcl_foliage_palette_index = 2, _mcl_skycolor = "#7FA1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -179,6 +181,7 @@ local function register_biomes() heat_point = -5, _mcl_biome_type = "snowy", _mcl_grass_palette_index = 2, + _mcl_foliage_palette_index = 2, _mcl_skycolor = "#7FA1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -199,6 +202,7 @@ local function register_biomes() heat_point = 8, _mcl_biome_type = "snowy", _mcl_grass_palette_index = 3, + _mcl_foliage_palette_index = 2, _mcl_skycolor = "#839EFF", _mcl_fogcolor = overworld_fogcolor }) @@ -221,6 +225,7 @@ local function register_biomes() heat_point = 8, _mcl_biome_type = "snowy", _mcl_grass_palette_index = 3, + _mcl_foliage_palette_index = 16, _mcl_skycolor = "#7FA1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -241,6 +246,7 @@ local function register_biomes() heat_point = 8, _mcl_biome_type = "snowy", _mcl_grass_palette_index = 3, + _mcl_foliage_palette_index = 16, _mcl_skycolor = "#7FA1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -259,6 +265,7 @@ local function register_biomes() vertical_blend = 1, _mcl_biome_type = "snowy", _mcl_grass_palette_index = 3, + _mcl_foliage_palette_index = 2, _mcl_skycolor = "#7FA1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -278,6 +285,7 @@ local function register_biomes() heat_point = 10, _mcl_biome_type = "cold", _mcl_grass_palette_index = 4, + _mcl_foliage_palette_index = 9, _mcl_skycolor = "#7CA3FF", _mcl_fogcolor = overworld_fogcolor }) @@ -295,6 +303,7 @@ local function register_biomes() heat_point = 10, _mcl_biome_type = "cold", _mcl_grass_palette_index = 4, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -314,6 +323,7 @@ local function register_biomes() heat_point = 8, _mcl_biome_type = "cold", _mcl_grass_palette_index = 5, + _mcl_foliage_palette_index = 10, _mcl_skycolor = "#7DA3FF", _mcl_fogcolor = overworld_fogcolor }) @@ -331,6 +341,7 @@ local function register_biomes() heat_point = 8, _mcl_biome_type = "cold", _mcl_grass_palette_index = 5, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -351,6 +362,7 @@ local function register_biomes() heat_point = 45, _mcl_biome_type = "cold", _mcl_grass_palette_index = 6, + _mcl_foliage_palette_index = 11, _mcl_skycolor = "#7DA2FF", _mcl_fogcolor = overworld_fogcolor }) @@ -369,6 +381,7 @@ local function register_biomes() heat_point = 45, _mcl_biome_type = "cold", _mcl_grass_palette_index = 6, + _mcl_foliage_palette_index = 1, _mcl_skycolor = beach_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -387,6 +400,7 @@ local function register_biomes() heat_point = 45, _mcl_biome_type = "cold", _mcl_grass_palette_index = 6, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -407,6 +421,7 @@ local function register_biomes() heat_point = 25, _mcl_biome_type = "cold", _mcl_grass_palette_index = 7, + _mcl_foliage_palette_index = 11, _mcl_skycolor = "#7DA2FF", _mcl_fogcolor = overworld_fogcolor }) @@ -424,6 +439,7 @@ local function register_biomes() heat_point = 25, _mcl_biome_type = "cold", _mcl_grass_palette_index = 7, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -446,6 +462,7 @@ local function register_biomes() vertical_blend = 6, _mcl_biome_type = "cold", _mcl_grass_palette_index = 8, + _mcl_foliage_palette_index = 11, _mcl_skycolor = "#7DA2FF", _mcl_fogcolor = overworld_fogcolor }) @@ -466,6 +483,7 @@ local function register_biomes() heat_point = 25, _mcl_biome_type = "cold", _mcl_grass_palette_index = 8, + _mcl_foliage_palette_index = 11, _mcl_skycolor = "#7DA2FF", _mcl_fogcolor = overworld_fogcolor }) @@ -483,6 +501,7 @@ local function register_biomes() heat_point = 25, _mcl_biome_type = "cold", _mcl_grass_palette_index = 8, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -500,6 +519,7 @@ local function register_biomes() heat_point = 8, _mcl_biome_type = "cold", _mcl_grass_palette_index = 9, + _mcl_foliage_palette_index = 11, _mcl_skycolor = "#7DA2FF", _mcl_fogcolor = overworld_fogcolor }) @@ -517,6 +537,7 @@ local function register_biomes() heat_point = 8, _mcl_biome_type = "cold", _mcl_grass_palette_index = 9, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -540,6 +561,7 @@ local function register_biomes() heat_point = 8, _mcl_biome_type = "snowy", _mcl_grass_palette_index = 10, + _mcl_foliage_palette_index = 2, _mcl_skycolor = "#7FA1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -557,6 +579,7 @@ local function register_biomes() heat_point = 8, _mcl_biome_type = "snowy", _mcl_grass_palette_index = 10, + _mcl_foliage_palette_index = 2, _mcl_skycolor = "#7FA1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -576,6 +599,7 @@ local function register_biomes() heat_point = 58, _mcl_biome_type = "medium", _mcl_grass_palette_index = 0, + _mcl_foliage_palette_index = 1, _mcl_skycolor = "#78A7FF", _mcl_fogcolor = overworld_fogcolor }) @@ -593,6 +617,7 @@ local function register_biomes() heat_point = 58, _mcl_biome_type = "medium", _mcl_grass_palette_index = 0, + _mcl_foliage_palette_index = 1, _mcl_skycolor = beach_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -610,6 +635,7 @@ local function register_biomes() heat_point = 58, _mcl_biome_type = "medium", _mcl_grass_palette_index = 0, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -629,6 +655,7 @@ local function register_biomes() heat_point = 45, _mcl_biome_type = "medium", _mcl_grass_palette_index = 11, + _mcl_foliage_palette_index = 1, _mcl_skycolor = "#78A7FF", _mcl_fogcolor = overworld_fogcolor }) @@ -646,6 +673,7 @@ local function register_biomes() heat_point = 45, _mcl_biome_type = "medium", _mcl_grass_palette_index = 11, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -665,6 +693,7 @@ local function register_biomes() heat_point = 22, _mcl_biome_type = "cold", _mcl_grass_palette_index = 12, + _mcl_foliage_palette_index = 10, _mcl_skycolor = "#7DA3FF", _mcl_fogcolor = overworld_fogcolor }) @@ -682,6 +711,7 @@ local function register_biomes() heat_point = 22, _mcl_biome_type = "cold", _mcl_grass_palette_index = 12, + _mcl_foliage_palette_index = 1, _mcl_skycolor = beach_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -699,6 +729,7 @@ local function register_biomes() heat_point = 22, _mcl_biome_type = "cold", _mcl_grass_palette_index = 12, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -718,6 +749,7 @@ local function register_biomes() heat_point = 45, _mcl_biome_type = "medium", _mcl_grass_palette_index = 13, + _mcl_foliage_palette_index = 7, _mcl_skycolor = "#79A6FF", _mcl_fogcolor = overworld_fogcolor }) @@ -735,6 +767,7 @@ local function register_biomes() heat_point = 45, _mcl_biome_type = "medium", _mcl_grass_palette_index = 13, + _mcl_foliage_palette_index = 1, _mcl_skycolor = beach_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -752,6 +785,7 @@ local function register_biomes() heat_point = 45, _mcl_biome_type = "medium", _mcl_grass_palette_index = 13, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -771,6 +805,7 @@ local function register_biomes() heat_point = 32, _mcl_biome_type = "medium", _mcl_grass_palette_index = 14, + _mcl_foliage_palette_index = 7, _mcl_skycolor = "#79A6FF", _mcl_fogcolor = overworld_fogcolor }) @@ -788,6 +823,7 @@ local function register_biomes() heat_point = 32, _mcl_biome_type = "medium", _mcl_grass_palette_index = 14, + _mcl_foliage_palette_index = 1, _mcl_skycolor = beach_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -805,6 +841,7 @@ local function register_biomes() heat_point = 32, _mcl_biome_type = "medium", _mcl_grass_palette_index = 14, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -824,6 +861,7 @@ local function register_biomes() heat_point = 31, _mcl_biome_type = "medium", _mcl_grass_palette_index = 15, + _mcl_foliage_palette_index = 8, _mcl_skycolor = "#7AA5FF", _mcl_fogcolor = overworld_fogcolor }) @@ -841,6 +879,7 @@ local function register_biomes() heat_point = 31, _mcl_biome_type = "medium", _mcl_grass_palette_index = 15, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -860,6 +899,7 @@ local function register_biomes() heat_point = 27, _mcl_biome_type = "medium", _mcl_grass_palette_index = 16, + _mcl_foliage_palette_index = 8, _mcl_skycolor = "#7AA5FF", _mcl_fogcolor = overworld_fogcolor }) @@ -877,6 +917,7 @@ local function register_biomes() heat_point = 27, _mcl_biome_type = "medium", _mcl_grass_palette_index = 16, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -897,6 +938,7 @@ local function register_biomes() heat_point = 94, _mcl_biome_type = "hot", _mcl_grass_palette_index = 17, + _mcl_foliage_palette_index = 3, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -914,6 +956,7 @@ local function register_biomes() heat_point = 94, _mcl_biome_type = "hot", _mcl_grass_palette_index = 17, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -933,6 +976,7 @@ local function register_biomes() heat_point = 27, _mcl_biome_type = "medium", _mcl_grass_palette_index = 18, + _mcl_foliage_palette_index = 7, _mcl_skycolor = "#79A6FF", _mcl_fogcolor = overworld_fogcolor }) @@ -950,6 +994,7 @@ local function register_biomes() heat_point = 27, _mcl_biome_type = "medium", _mcl_grass_palette_index = 18, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -970,6 +1015,7 @@ local function register_biomes() heat_point = 100, _mcl_biome_type = "hot", _mcl_grass_palette_index = 19, + _mcl_foliage_palette_index = 4, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -989,6 +1035,7 @@ local function register_biomes() heat_point = 100, _mcl_biome_type = "hot", _mcl_grass_palette_index = 19, + _mcl_foliage_palette_index = 4, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1007,6 +1054,7 @@ local function register_biomes() heat_point = 100, _mcl_biome_type = "hot", _mcl_grass_palette_index = 19, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1026,6 +1074,7 @@ local function register_biomes() heat_point = 100, _mcl_biome_type = "hot", _mcl_grass_palette_index = 20, + _mcl_foliage_palette_index = 4, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1044,6 +1093,7 @@ local function register_biomes() heat_point = 100, _mcl_biome_type = "hot", _mcl_grass_palette_index = 20, + _mcl_foliage_palette_index = 4, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1062,6 +1112,7 @@ local function register_biomes() heat_point = 100, _mcl_biome_type = "hot", _mcl_grass_palette_index = 20, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1083,6 +1134,7 @@ local function register_biomes() vertical_blend = 0, -- we want a sharp transition _mcl_biome_type = "hot", _mcl_grass_palette_index = 21, + _mcl_foliage_palette_index = 4, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1104,6 +1156,7 @@ local function register_biomes() heat_point = 60, _mcl_biome_type = "hot", _mcl_grass_palette_index = 21, + _mcl_foliage_palette_index = 4, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1122,6 +1175,7 @@ local function register_biomes() heat_point = 60, _mcl_biome_type = "hot", _mcl_grass_palette_index = 21, + _mcl_foliage_palette_index = 4, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1140,6 +1194,7 @@ local function register_biomes() heat_point = 60, _mcl_biome_type = "hot", _mcl_grass_palette_index = 21, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1163,6 +1218,7 @@ local function register_biomes() vertical_blend = 5, _mcl_biome_type = "hot", _mcl_grass_palette_index = 22, + _mcl_foliage_palette_index = 4, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1182,6 +1238,7 @@ local function register_biomes() heat_point = 60, _mcl_biome_type = "hot", _mcl_grass_palette_index = 22, + _mcl_foliage_palette_index = 4, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1202,6 +1259,7 @@ local function register_biomes() vertical_blend = 4, _mcl_biome_type = "hot", _mcl_grass_palette_index = 22, + _mcl_foliage_palette_index = 4, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1220,6 +1278,7 @@ local function register_biomes() heat_point = 60, _mcl_biome_type = "hot", _mcl_grass_palette_index = 22, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1240,6 +1299,7 @@ local function register_biomes() heat_point = 79, _mcl_biome_type = "hot", _mcl_grass_palette_index = 1, + _mcl_foliage_palette_index = 3, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1257,6 +1317,7 @@ local function register_biomes() heat_point = 79, _mcl_biome_type = "hot", _mcl_grass_palette_index = 1, + _mcl_foliage_palette_index = 1, _mcl_skycolor = beach_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1274,6 +1335,7 @@ local function register_biomes() heat_point = 79, _mcl_biome_type = "hot", _mcl_grass_palette_index = 1, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1295,6 +1357,7 @@ local function register_biomes() heat_point = 100, _mcl_biome_type = "hot", _mcl_grass_palette_index = 23, + _mcl_foliage_palette_index = 3, _mcl_skycolor = "#6EB1FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1312,6 +1375,7 @@ local function register_biomes() heat_point = 100, _mcl_biome_type = "hot", _mcl_grass_palette_index = 23, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1331,6 +1395,7 @@ local function register_biomes() heat_point = 81, _mcl_biome_type = "medium", _mcl_grass_palette_index = 24, + _mcl_foliage_palette_index = 12, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1348,6 +1413,7 @@ local function register_biomes() heat_point = 81, _mcl_biome_type = "medium", _mcl_grass_palette_index = 24, + _mcl_foliage_palette_index = 12, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1366,6 +1432,7 @@ local function register_biomes() heat_point = 81, _mcl_biome_type = "medium", _mcl_grass_palette_index = 24, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1386,6 +1453,7 @@ local function register_biomes() heat_point = 81, _mcl_biome_type = "medium", _mcl_grass_palette_index = 25, + _mcl_foliage_palette_index = 12, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1403,6 +1471,7 @@ local function register_biomes() heat_point = 81, _mcl_biome_type = "medium", _mcl_grass_palette_index = 25, + _mcl_foliage_palette_index = 12, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1421,6 +1490,7 @@ local function register_biomes() heat_point = 81, _mcl_biome_type = "medium", _mcl_grass_palette_index = 25, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1440,6 +1510,7 @@ local function register_biomes() heat_point = 76, _mcl_biome_type = "medium", _mcl_grass_palette_index = 26, + _mcl_foliage_palette_index = 13, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1457,6 +1528,7 @@ local function register_biomes() heat_point = 76, _mcl_biome_type = "medium", _mcl_grass_palette_index = 26, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1479,6 +1551,7 @@ local function register_biomes() heat_point = 79, _mcl_biome_type = "medium", _mcl_grass_palette_index = 27, + _mcl_foliage_palette_index = 13, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1496,6 +1569,7 @@ local function register_biomes() heat_point = 79, _mcl_biome_type = "medium", _mcl_grass_palette_index = 27, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1516,6 +1590,7 @@ local function register_biomes() heat_point = 94, _mcl_biome_type = "hot", _mcl_grass_palette_index = 27, + _mcl_foliage_palette_index = 6, _mcl_skycolor = "#78A7FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1533,6 +1608,7 @@ local function register_biomes() heat_point = 94, _mcl_biome_type = "hot", _mcl_grass_palette_index = 27, + _mcl_foliage_palette_index = 6, _mcl_skycolor = "#78A7FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1551,6 +1627,7 @@ local function register_biomes() heat_point = 94, _mcl_biome_type = "hot", _mcl_grass_palette_index = 27, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1570,6 +1647,7 @@ local function register_biomes() heat_point = 50, _mcl_biome_type = "medium", _mcl_grass_palette_index = 28, + _mcl_foliage_palette_index = 5, _mcl_skycolor = "#78A7FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1587,6 +1665,7 @@ local function register_biomes() heat_point = 50, _mcl_biome_type = "medium", _mcl_grass_palette_index = 28, + _mcl_foliage_palette_index = 5, _mcl_skycolor = "#78A7FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1605,6 +1684,7 @@ local function register_biomes() heat_point = 50, _mcl_biome_type = "medium", _mcl_grass_palette_index = 28, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1627,6 +1707,7 @@ local function register_biomes() heat_point = 50, _mcl_biome_type = "medium", _mcl_grass_palette_index = 29, + _mcl_foliage_palette_index = 17, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1645,6 +1726,7 @@ local function register_biomes() heat_point = 50, _mcl_biome_type = "medium", _mcl_grass_palette_index = 29, + _mcl_foliage_palette_index = 17, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1662,6 +1744,7 @@ local function register_biomes() heat_point = 50, _mcl_biome_type = "medium", _mcl_grass_palette_index = 29, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1682,6 +1765,7 @@ local function register_biomes() heat_point = 95, _mcl_biome_type = "medium", _mcl_grass_palette_index = 24, + _mcl_foliage_palette_index = 12, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1699,6 +1783,7 @@ local function register_biomes() heat_point = 95, _mcl_biome_type = "medium", _mcl_grass_palette_index = 24, + _mcl_foliage_palette_index = 12, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1717,6 +1802,7 @@ local function register_biomes() heat_point = 90, _mcl_biome_type = "medium", _mcl_grass_palette_index = 24, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1737,6 +1823,7 @@ local function register_biomes() heat_point = 95, _mcl_biome_type = "medium", _mcl_grass_palette_index = 25, + _mcl_foliage_palette_index = 12, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1754,6 +1841,7 @@ local function register_biomes() heat_point = 90, _mcl_biome_type = "medium", _mcl_grass_palette_index = 25, + _mcl_foliage_palette_index = 12, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1772,6 +1860,7 @@ local function register_biomes() heat_point = 95, _mcl_biome_type = "medium", _mcl_grass_palette_index = 25, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1791,6 +1880,7 @@ local function register_biomes() heat_point = 90, _mcl_biome_type = "medium", _mcl_grass_palette_index = 26, + _mcl_foliage_palette_index = 13, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1808,6 +1898,7 @@ local function register_biomes() heat_point = 88, _mcl_biome_type = "medium", _mcl_grass_palette_index = 26, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1830,6 +1921,7 @@ local function register_biomes() heat_point = 95, _mcl_biome_type = "medium", _mcl_grass_palette_index = 27, + _mcl_foliage_palette_index = 13, _mcl_skycolor = "#77A8FF", _mcl_fogcolor = overworld_fogcolor }) @@ -1847,6 +1939,7 @@ local function register_biomes() heat_point = 90, _mcl_biome_type = "medium", _mcl_grass_palette_index = 27, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1871,6 +1964,7 @@ local function register_biomes() vertical_blend = 5, _mcl_biome_type = minetest.registered_biomes[biome]._mcl_biome_type, _mcl_grass_palette_index = minetest.registered_biomes[biome]._mcl_grass_palette_index, + _mcl_foliage_palette_index = 0, _mcl_skycolor = ocean_skycolor, _mcl_fogcolor = overworld_fogcolor }) @@ -1885,6 +1979,7 @@ local function register_biomes() y_max = DEEP_OCEAN_MIN - 1, _mcl_biome_type = minetest.registered_biomes[biome]._mcl_biome_type, _mcl_grass_palette_index = minetest.registered_biomes[biome]._mcl_grass_palette_index, + _mcl_foliage_palette_index = minetest.registered_biomes[biome]._mcl_foliage_palette_index, _mcl_skycolor = minetest.registered_biomes[biome]._mcl_skycolor, _mcl_fogcolor = minetest.registered_biomes[biome]._mcl_fogcolor, }) @@ -1940,6 +2035,7 @@ local function register_dimension_biomes() humidity_point = 0, _mcl_biome_type = "hot", _mcl_grass_palette_index = 17, + _mcl_foliage_palette_index = 3, _mcl_skycolor = nether_skycolor, _mcl_fogcolor = "#330808" }) @@ -1971,6 +2067,7 @@ local function register_dimension_biomes() humidity_point = 33, _mcl_biome_type = "hot", _mcl_grass_palette_index = 17, + _mcl_foliage_palette_index = 3, _mcl_skycolor = nether_skycolor, _mcl_fogcolor = "#1B4745" }) @@ -2022,6 +2119,7 @@ local function register_dimension_biomes() humidity_point = 47, _mcl_biome_type = "hot", _mcl_grass_palette_index = 17, + _mcl_foliage_palette_index = 3, _mcl_skycolor = nether_skycolor, _mcl_fogcolor = "#330303" }) @@ -2051,6 +2149,7 @@ local function register_dimension_biomes() humidity_point = 70, _mcl_biome_type = "hot", _mcl_grass_palette_index = 17, + _mcl_foliage_palette_index = 3, _mcl_skycolor = nether_skycolor, _mcl_fogcolor = "#1A051A" }) @@ -2080,6 +2179,7 @@ local function register_dimension_biomes() humidity_point = 80, _mcl_biome_type = "hot", _mcl_grass_palette_index = 17, + _mcl_foliage_palette_index = 3, _mcl_skycolor = nether_skycolor, _mcl_fogcolor = "#685F70" }) @@ -2134,6 +2234,7 @@ local function register_dimension_biomes() vertical_blend = 16, _mcl_biome_type = "medium", _mcl_grass_palette_index = 0, + _mcl_foliage_palette_index = 0, _mcl_skycolor = end_skycolor, _mcl_fogcolor = end_fogcolor }) @@ -2151,6 +2252,7 @@ local function register_dimension_biomes() vertical_blend = 16, _mcl_biome_type = "medium", _mcl_grass_palette_index = 0, + _mcl_foliage_palette_index = 0, _mcl_skycolor = end_skycolor, _mcl_fogcolor = end_fogcolor }) @@ -2168,6 +2270,7 @@ local function register_dimension_biomes() vertical_blend = 16, _mcl_biome_type = "medium", _mcl_grass_palette_index = 0, + _mcl_foliage_palette_index = 0, _mcl_skycolor = end_skycolor, _mcl_fogcolor = end_fogcolor }) @@ -2185,6 +2288,7 @@ local function register_dimension_biomes() vertical_blend = 16, _mcl_biome_type = "medium", _mcl_grass_palette_index = 0, + _mcl_foliage_palette_index = 0, _mcl_skycolor = end_skycolor, _mcl_fogcolor = end_fogcolor }) @@ -2202,6 +2306,7 @@ local function register_dimension_biomes() vertical_blend = 16, _mcl_biome_type = "medium", _mcl_grass_palette_index = 0, + _mcl_foliage_palette_index = 0, _mcl_skycolor = end_skycolor, _mcl_fogcolor = end_fogcolor }) @@ -2222,6 +2327,7 @@ local function register_dimension_biomes() min_pos = {x = -1250, y = mcl_vars.mg_end_min, z = -1250}, _mcl_biome_type = "medium", _mcl_grass_palette_index = 0, + _mcl_foliage_palette_index = 0, _mcl_skycolor = end_skycolor, _mcl_fogcolor = end_fogcolor }) @@ -2240,6 +2346,7 @@ local function register_dimension_biomes() vertical_blend = 16, _mcl_biome_type = "medium", _mcl_grass_palette_index = 0, + _mcl_foliage_palette_index = 0, _mcl_skycolor = end_skycolor, _mcl_fogcolor = end_fogcolor }) From b95ebb3fca883bafab8bd67541ab0b7d7735fb2b Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Wed, 8 Feb 2023 16:17:33 +0000 Subject: [PATCH 06/54] Add LBMs, ABMs, and more This commit adds 1 new LBM (for foliage) and 2 new ABMs (one for foliage, and one for grass). This also adds a new generator so any new maps created will have biome coloured leaves with a faster method. (Vines are excluded from this generator since I don't know yet how to get those to work with this.) --- mods/MAPGEN/mcl_mapgen_core/init.lua | 120 +++++++++++++++++++++++++-- 1 file changed, 115 insertions(+), 5 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 960ce1cfe..9755cfa3e 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -268,7 +268,7 @@ local function set_layers(data, area, content_id, check, min, max, minp, maxp, l return lvm_used end -local function set_palette(minp,maxp,data2,area,biomemap,nodes) +local function set_grass_palette(minp,maxp,data2,area,biomemap,nodes) -- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration: if not biomemap then return end local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}}) @@ -289,6 +289,27 @@ local function set_palette(minp,maxp,data2,area,biomemap,nodes) return lvm_used end +local function set_foliage_palette(minp,maxp,data2,area,biomemap,nodes) + -- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration: + if not biomemap then return end + local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}}) + local nodes = minetest.find_nodes_in_area(minp, maxp, nodes) + for n=1, #nodes do + local n = nodes[n] + local p_pos = area:index(n.x, n.y, n.z) + local b_pos = aream:index(n.x, 0, n.z) + local bn = minetest.get_biome_name(biomemap[b_pos]) + if bn then + local biome = minetest.registered_biomes[bn] + if biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index then + data2[p_pos] = biome._mcl_foliage_palette_index + lvm_used = true + end + end + end + return lvm_used +end + -- Below the bedrock, generate air/void local function world_structure(vm, data, data2, emin, emax, area, minp, maxp, blockseed) local biomemap --ymin, ymax @@ -344,13 +365,24 @@ local function world_structure(vm, data, data2, emin, emax, area, minp, maxp, bl return lvm_used, lvm_used, deco, ores end -local function block_fixes(vm, data, data2, emin, emax, area, minp, maxp, blockseed) +local function block_fixes_grass(vm, data, data2, emin, emax, area, minp, maxp, blockseed) local biomemap = minetest.get_mapgen_object("biomemap") local lvm_used = false local pr = PseudoRandom(blockseed) if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then -- Set param2 (=color) of nodes which use the grass colour palette. - lvm_used = set_palette(minp,maxp,data2,area,biomemap,{"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"}) + lvm_used = set_grass_palette(minp,maxp,data2,area,biomemap,{"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"}) + end + return lvm_used +end + +local function block_fixes_foliage(vm, data, data2, emin, emax, area, minp, maxp, blockseed) + local biomemap = minetest.get_mapgen_object("biomemap") + local lvm_used = false + local pr = PseudoRandom(blockseed) + if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then + -- Set param2 (=color) of nodes which use the foliage colour palette. + lvm_used = set_foliage_palette(minp,maxp,data2,area,biomemap,{"group:foliage_palette"}) end return lvm_used end @@ -382,7 +414,8 @@ mcl_mapgen_core.register_generator("end_fixes", end_basic, function(minp,maxp) end, 9999, true) if mg_name ~= "v6" and mg_name ~= "singlenode" then - mcl_mapgen_core.register_generator("block_fixes", block_fixes, nil, 9999, true) + mcl_mapgen_core.register_generator("block_fixes_grass", block_fixes_grass, nil, 9999, true) + mcl_mapgen_core.register_generator("block_fixes_foliage", block_fixes_foliage, nil, 9999, true) end if mg_name == "v6" then @@ -419,7 +452,7 @@ mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blocks end, 100, true) minetest.register_lbm({ - label = "Fix grass palette indexes", + label = "Fix grass palette indexes", -- This LBM fixes any incorrect grass palette indexes. name = "mcl_mapgen_core:fix_grass_palette_indexes", nodenames = {"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"}, run_at_every_load = true, @@ -436,3 +469,80 @@ minetest.register_lbm({ end end, }) + +minetest.register_abm({ + label = "Fix grass palette indexes missed", -- This ABM fixes any incorrect grass palette indexes which were missed. Likely to be any grass from a schematic. + name = "mcl_mapgen_core:fix_grass_palette_indexes missed", + nodenames = {"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"}, + neighbors = {"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"}, + interval = 60, + chance = 1, + action = function(pos, node) + if mg_name ~= "v6" and mg_name ~= "singlenode" then + local biome_data = minetest.get_biome_data(pos) + local biome = biome_data.biome + local biome_name = minetest.get_biome_name(biome) + local reg_biome = minetest.registered_biomes[biome_name] + if node.param2 ~= reg_biome._mcl_grass_palette_index then + node.param2 = reg_biome._mcl_grass_palette_index + minetest.set_node(pos, node) + end + end + end, +}) + +minetest.register_lbm({ + label = "Fix foliage palette indexes", -- This LBM fixes any incorrect foliage palette indexes + name = "mcl_mapgen_core:fix_foliage_palette_indexes", + nodenames = {"group:foliage_palette", "group:foliage_palette_wallmounted"}, + run_at_every_load = true, + action = function(pos, node) + if mg_name ~= "v6" and mg_name ~= "singlenode" then + local biome_data = minetest.get_biome_data(pos) + local biome = biome_data.biome + local biome_name = minetest.get_biome_name(biome) + local reg_biome = minetest.registered_biomes[biome_name] + if node.param2 ~= reg_biome._mcl_foliage_palette_index and node.name ~= "mcl_core:vine" then + node.param2 = reg_biome._mcl_foliage_palette_index + minetest.set_node(pos, node) + elseif node.name == "mcl_core:vine" then + local biome_param2 = reg_biome._mcl_foliage_palette_index + local rotation_param2 = node.param2 + local final_param2 = (biome_param2 * 8) + rotation_param2 + if node.param2 ~= final_param2 and rotation_param2 < 6 then + node.param2 = final_param2 + minetest.set_node(pos, node) + end + end + end +end, +}) + +minetest.register_abm({ + label = "Fix foliage palette indexes missed", -- This ABM fixes any incorrect foliage palette indexes which were missed. Likely to be any foliage from a player sapling. + name = "mcl_mapgen_core:fix_foliage_palette_indexes missed", + nodenames = {"group:foliage_palette", "group:foliage_palette_wallmounted"}, + neighbors = {"group:foliage_palette", "group:foliage_palette_wallmounted"}, + interval = 60, + chance = 1, + action = function(pos, node) + if mg_name ~= "v6" and mg_name ~= "singlenode" then + local biome_data = minetest.get_biome_data(pos) + local biome = biome_data.biome + local biome_name = minetest.get_biome_name(biome) + local reg_biome = minetest.registered_biomes[biome_name] + if node.param2 ~= reg_biome._mcl_foliage_palette_index and node.name ~= "mcl_core:vine" then + node.param2 = reg_biome._mcl_foliage_palette_index + minetest.set_node(pos, node) + elseif node.name == "mcl_core:vine" then + local biome_param2 = reg_biome._mcl_foliage_palette_index + local rotation_param2 = node.param2 + local final_param2 = (biome_param2 * 8) + rotation_param2 + if node.param2 ~= final_param2 and rotation_param2 < 6 then + node.param2 = final_param2 + minetest.set_node(pos, node) + end + end + end +end, +}) From 4757e629688397e554630780fb9df9afea119bf5 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Wed, 8 Feb 2023 16:20:42 +0000 Subject: [PATCH 07/54] Add vine texture I forgot I forgot to add this one with the batch. --- textures/mcl_core_vine.png | Bin 185 -> 355 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/textures/mcl_core_vine.png b/textures/mcl_core_vine.png index d0e55cb4582c5c7b3c6be9b5d3ef3242b7b18733..acee7a6315875c6163e374b094cee919bd550752 100644 GIT binary patch delta 340 zcmV-a0jvJG0pkLY7=H)`0000V^Z#K0000DMK}|sb0I`n?{9y$E000SaNLh0L01mkT z01mkUxCR%$0000ObVXQnQ*UN;cVTj60B~VxZgehgWpp4kE-@}OWJg$10002tNkl Date: Thu, 9 Feb 2023 09:40:17 +0000 Subject: [PATCH 08/54] Add new waterlily texture --- textures/flowers_waterlily.png | Bin 358 -> 294 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/textures/flowers_waterlily.png b/textures/flowers_waterlily.png index f3ca54b19e97b44133e8e00a6da4459f0d171639..a8e3e08d9238e57111f831c42ab803a9b6a5f1eb 100644 GIT binary patch delta 263 zcmV+i0r>vr0;U3x7zqdl0000V^Z#LyArpTIa7bBm000ia000ia0czHX2><{97<5Hg zbW?9;ba!ELWdLwtX>N2bZe?^JG%hhNHDpIvQUCw|q)9|UR5(x7k+BMcKoCUlTT=>_ z3D^e<>yRoRAeMg3{mq33JKicPi=6|5=kCnhx~BW#-8JReKFW7^6)UZQ03ygaTeWjy z{Pj!UN);66=~ECXU>iaY+G_;{NRtqmJx{?{O82*Orf0Ha=(~7oNlXI60efc7)J%2` zgbEPDW&wky@uT~lKr6?g075T?un+&2{B$8;QiyhCtvIxoOXhu~^aoWq)1DihYR3Qo N002ovPDHLkV1jC1Y3%?2 literal 358 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPF?NMQuIvxlMT9N*CSCZ{ z1r&1eba4#fkYzpC$mpOTz;NI&(^VFI-USg1Z|x^r1LZ9XSmQUGOIYN0;IGwz7jKz& zo{`mAs-_^Wb%0~RUiE{nVMM{nrIssSs56V&RsYUMMG|WN@iLmZVfC4B$a>~7(8A5T-G@yGywqT CRbuP_ From 169019096e8147b2eecad10b7bb8ad55c6da8c26 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Thu, 9 Feb 2023 09:46:18 +0000 Subject: [PATCH 09/54] Change the waterlily code Waterlilies now use a brownish grey texture with a coded hex colour. --- mods/ITEMS/mcl_flowers/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index 0ea7f77ad..acc59e104 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -427,6 +427,7 @@ minetest.register_node("mcl_flowers:waterlily", { paramtype = "light", paramtype2 = "facedir", tiles = {"flowers_waterlily.png", "flowers_waterlily.png^[transformFY"}, + color = "#208030", use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true, inventory_image = "flowers_waterlily.png", wield_image = "flowers_waterlily.png", From aff1d5f6671aa6496e0cc4da4e7f56a2d820665e Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Thu, 9 Feb 2023 13:01:23 +0000 Subject: [PATCH 10/54] Optimised foliage 1 --- textures/default_acacia_leaves.png | Bin 530 -> 202 bytes textures/default_jungleleaves.png | Bin 498 -> 198 bytes textures/default_leaves.png | Bin 537 -> 210 bytes textures/mcl_core_leaves_big_oak.png | Bin 540 -> 215 bytes textures/mcl_core_leaves_birch.png | Bin 366 -> 212 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/textures/default_acacia_leaves.png b/textures/default_acacia_leaves.png index f7d091e6015c6d1c4b30048f449ae558d32825fd..41b4532f2af21d5c4dc7fbc0c29665e511752a8f 100644 GIT binary patch delta 186 zcmbQla*A<+L_G^L0|Ud`yN`l^6n}tEh%1l|4YSJ4b#JK;nKvo!Vf*{LKq1DGAirP+ zhi5m^fSgQE7sn6|S=NJ%qE3oD%m*$QF>K{IaGX_WH^Z+R^=j`0bX#w7-3Wfap~e1g zOtnJnwiEm%$(a@h=j*?j$B^f}D&cj68vm<j61pJo5!4goH1c_9I3DeuLj&FDS&VCOhKJOn-8=Pi$VNXIeE?uj;+( zS4dH21^|YB7T(iD0RWbD!_dzH07aRZ_qSIZPgg0*%nP@#|Q&p$98 z?E)<8hL6uL06-l5e5Z+m2LN4@+hR7X+fm{ufYy_^sz^kPN7-6Wk|qjWlN&Ozpl(Ou zn9(k<*s9ta>3^EsEbE5%w^smokg4@#^K9TMuG>*OH}UKD4MRT*_+z6h|<$N#z>}$L8*X?K(G3Iej_i>J=t8fe+GE%V$ebntJ!r<-i{lNt`q=l}E zs@fZ3Ju-aX?%={Oru8H$^dGEcE{*~eWoA6eOB01OQGFQt*)kMmW{#(;bWLup?3&zY zJxR3t8P9X&aZV;(H#n*aeO%55v#cB9D1bNgvn=ZddQFSmV&--<0WD=qEAJy{!00005zO`6tKwtjJspPtlVpb%q8kY6x^ z!?PP{Ku)Tsi(?3fEbGBW!NUqXEC=OXSQS|-Qn)5qa!qLdwO(`gCWT+;10>d*4*0U^ zxPxK*&yMJa$`M&c?<}kX9-i?kG1wEdYPGzb-p*sU^t&fi>=8;~u}weemGb#g&CHt) hHJO}xWvk?W%BT7Z_fK8+`YzB$22WQ%mvv4FO#lmlMd<(l delta 484 zcmV}=80B;Zfcxdx0YFxi2&34*uv6f71k^9|sOlB~5JvGY+&~8k zVXJ(xKB!3_pI12vs5M>3 zg6mlDW)oC(tABI}qnK573r@lja6B5~FIsbNsv6T9e!m<$9i)qP3j8iBN(f=AMtv*? z04W<)2&0&}j)gw8e(d~!?figo>Z+hQWdkW2MMVf3 z-fUttBrOXP} z6{Xs2@VehB8k#pR2EJ)cPNprkBKN)uF_R+`DsZ@0fLzMq$&{VRT a=zIfHdD_Wut~8PW0000-$jrHkK$lm`d znW4soVhAkTM<~FRrI&-Y7 w?iZq)8~qoB#ct^+>xro_mua&&3sSwdtKdZQ~?OWNX=(s{papM@fC3tYWWVrNC7-O2HHJ4B?u#> z?4tE%%eCJIV41GSi#;~@F+ek^-|K3?GzcKTXfjn&BYDZ4NU|Hh-$DH(Q)?!C)AxY*!c-ey7FT+q;n^Y-Fe-&7N0B8VAEztv6e0Zp8pC z(-nhZtVFxis`+fJ?WDa>(SPip04sp|+Z!!(C6bp{{yzWv23o#~)9-b4&8_hJ*H7&8 z)ZB`>Ob|v&rkDNU*pxi4PV(}4aMCym_5JOQmW!0bv48c513$7HyFu8ECR3H|3Ouil z=hZ)VAXG$?y_3s}bFSJy4#34w*M6Htl731kTh#Bg@H;IA!&oiT)q!rQTO{eB6Ky+7 zlpmIDp!H_UXfjofZ3@vZI?G$PWyi_@%0d!JMQvg8b*k%9#0CP!1K~xAG1;H^AgCGD!!EeM~GO>?@?hlvv zl}g45kH+0c$?v5OB$*saT{?OZil&O5$1Kz4;SU{t7&%AH0%-sM002ovPDHLkV1gA6 BPgVc` delta 527 zcmV+q0`UFU0h|Po7=H)`0000V^Z#K0000JJOGiWi{{XZAv^{)XssI2032;bRa{vGi zz5oCYz5(h&vA_TT00(qQO+^Rg3~>z3GU{ z?9BgIwOCgUpznGB(q#%j^Xs<)kh-2}4$lXYJONn%tR6l>XuO87e z4Zz{~06=)z#D6!LsUI*|%&@;;ve@&HmxW80De3ZKiOFIjd$zQ7qalc267SRVY?-C(^yYT`^hgp~z!-SvY|pk55AR z#I~ViA<05$_+O&DEL`Zo&mr4IoiOKR9QGIQJUd)z>&<@#lkXg!pO=OE17Zj7^a8mJ R1ONa400>D%PDHLkV1nQp@ZJCb diff --git a/textures/mcl_core_leaves_birch.png b/textures/mcl_core_leaves_birch.png index 0432500d11b4f49f2b8307e806096d711da65460..9fed93ef32cee8f878b5264d393965a6565efbea 100644 GIT binary patch delta 196 zcmV;#06YKg0@MMJ7=Hu<0002(-QrRJ000tDOjJbxZ)}cPH=}MpvVKCuibBzuKp8|* zI{*Lx0d!JMQvg8b*k%9#0B}h}K~xAG1;H^6!Y~X#(VyDvwtyX)9>B$6FG|^is^0%9 zyayT*+Gk>Fx>{D&)LtCL8~OMSK(}dmbAnsekWQBSAt6C-8a>5;+d$Gy delta 351 zcmV-l0igcW0qz2j7=H)`0000V^Z#K0000DMK}|sb0I`n?{9y$E000SaNLh0L01mqV z01mqW$N1DX0000ObVXQnQ*UN;cVTj60B~VxZgehgWpp4kE-@}OWJg$10002&Nklg4Epp4U^MOd4pwF*yLgUycQOa07T(15v?2hv5boBJi|`*^_~RoTT~vI2ZJQ zE`TS?{Z4v><*;ErJg=D>SnH)Ww2cS`m~KBkGjEcsn=a4IW|YW4exEQL7?6k2s|UoD zfjoQofSiyDz*sC0xHN>k17HBP;nceeQA{(?lf7L)-T^f*)Ef9-05njK1gAIvcU}Jn x-|BsdHs|%-EQffzX Date: Thu, 9 Feb 2023 13:02:02 +0000 Subject: [PATCH 11/54] Optimised foliage 2 --- textures/flowers_waterlily.png | Bin 294 -> 173 bytes textures/mcl_core_leaves_spruce.png | Bin 456 -> 199 bytes textures/mcl_core_vine.png | Bin 355 -> 202 bytes textures/mcl_mangrove_leaves.png | Bin 6349 -> 214 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/textures/flowers_waterlily.png b/textures/flowers_waterlily.png index a8e3e08d9238e57111f831c42ab803a9b6a5f1eb..1d5bc6849420b853577698c869334a536c163f29 100644 GIT binary patch delta 157 zcmZ3+w3cy#L_G^L0|Ud`yN`l^lu&?Ah$};WPHApZOJ&xyuCf(#+BU74V$85~2~d`? zB*-tA!Qt7BG$6;*)5S4_LzeYmx1fW82*ZX1#^X#;Y!zRu8tyao{SBW8RN~PnBjfm; zP5cyZgrD?`;93W{{h}txFB=tu8J;oRD`t9ik2#k~>;e17e{3)9*y?8iwJ>4H zyLf6zOaj9JduGnmOm+^03J}9)0fVOTqx+peE61S#LNA4|5C50^bRl3;h<0VIIJB2b d=6$5}2UR%Jo)8W&X`qtH)=UQP>8W4$S;_| z;n|HeAScb!#W93Kmh~W`V2gr?!@=htm{*7t9AJ2%%pmvWe97(@&CqBeY00@dwLY~Q z4qcbDcF}r!ytB6`SFB`CTKuB(Z){cHiTsu0<`QH#U|y{vJtKW{^@lf)V{5%~ryNx; i-Ibp=HT&zDDfT~11pj-S-8BhlC4;A{pUXO@geCxRh(xpi delta 442 zcmV;r0Y(1D0muW87=H)`0000V^Z#K0000JJOGiWi{{XZAv^{)XssI2032;bRa{vGi zz5oCYz5(h&vA_TT00(qQO+^Rg3$DP3<@DaQK1Jf6%kLLxL-tYnl^qr`!JkcjOaUjF+1b=&KGuyOX1KHjD$$t4& zQEU4C92EeRrlP_0sx%d?(}M7@g^a=Uu8(s{F1P^zGM!VLCQmm3K(vowXA5;ap9lc# zY~jb>?H6&HIB^z<_7MP}Yg!e^)49O0*@f<(58@l$zJ34zLD#gZYg*-xu}%wK<+#77 zHN9j|)Y|14GJkWCV(J;3u4z@KbK2}e_Y#r^$2u)gJfEGdgJWm=uwk7RynVdG2Oh`< zIp1}>IH*2c27Z?>YE5!(N&a{~QKoasbWVQFG4P!yf%=?e%?a?#>@eRv(tX_T81RCX z`CHVQ{8{-wP7}mwf?%B%w~!E}kyw;#d>{a*qSh21wljCv diff --git a/textures/mcl_core_vine.png b/textures/mcl_core_vine.png index acee7a6315875c6163e374b094cee919bd550752..47cb195d0e267d63b335f16805c352ec0ddc1681 100644 GIT binary patch delta 186 zcmV;r07d`f0?Gl97=Hu<0002(-QrRJ000tDOjJbxZ){aiNMTq_YhzV-Z(n_NWdQ+= zPyhe`0d!JMQvg8b*k%9#0A@)dB*3j&VR%JWth#5xW4VJUEJqq>Gw;`|M?=ur?*of;A*DldJCGKd$ oJ;{Y!r|jG4k5IicX4fwH1NfW{IB?XUY5)KL07*qoM6N<$f~8SP{r~^~ delta 340 zcmV-a0jvJX0pkLY7=H)`0000V^Z#K0000DMK}|sb0I`n?{9y$E000SaNLh0L01mkT z01mkUxCR%$0000ObVXQnQ*UN;cVTj60B~VxZgehgWpp4kE-@}OWJg$10002tNkl)QFm=%hk9q4i*mE1h@+JP zMgRZ+0d!JMQvg8b*k%9#0CGu0K~xAG1;M)wz#t3-zy~sYA~66&uz~3<8+v~G&yqV3 z2NyX2p}`l%3mH$Z%|-BjY=|%5BBoahTI92dD@JTIi4$gMAwP!(Bscu`4v(VC7o8ra z8K&96w8OLmXPKO3f(w)TnxNv$n$AY*G`~*!2ZF2>+z6r-jQ{`u07*qoM6N<$g3aSh AzyJUM literal 6349 zcmeHLdpwlu+8#MZPOT0^+Zal<)|_XI8RRe+6LKtvt@4_Ahlx3OXBf1zR+K_fi-@Kp z<5cN@b`eqvp(I+ZT}nh{)hgL^aN6$-mA<{cwZDG9Z~qs+8S^~Pbzk@WT+e;q&%9E+ z)-tp;muMmo2yLdTlMnn?PyW(SgWpYtrvL;(^+dd1fY=9+Acc^C!;J)y;y59Q1Y@}z z1S0kyr`B_SF0-6B{>t}>M)sxVM*PN7D9PCFrRwUCkO7ZnUO(xdGe04-ES(&d`2P4f z#BF2X;s(YmvW^k&$@Xo};tHZHc#T_Yo^2KGJJF|1XTK&5uN&`p)L($jUI9E=n{0ks z_x=dIqNVo1JT#+_(O{4TuE5ZfpQ;C`bp&URdS8i~``1Ia&YgA|kbP()FU>w1_23cD zel#`7 z{(8Zg&oiFpOCN~dbh!>SmpAWxnkH@W-jHMd_CzJBw36nZbCR)UBB--A3!m7VoOKZ2 z);I5h@pV9|U$nwcp!UQ$tmbj+f)ph;Gq)Y{$)$a{E6to*_A4K5&28J8GS`@Dbn2%) zFD=MA%kx52-hr1Rko{(hmL&8EbC^9B^hmiOyO)oTPf1TF2mQ9pv!K6eVQ=ro?Hc)J zzr1RngX|ooL1y)1adxyaHI1r$occML4+~S;ZkL|g$lxG&N1wfx*0>z|LD^ORZ`LYw zHH~o3>-#L09#GbQv*NNv{oXTYFDcD|(zTAWBX+A>UFoI_s4S^^5t~{ch`3^y;W8hQ z_0xXUv&Rw=7j}9<*8`tQCG{z3n7F=El80kG*6(E@iQ1TVdWqW&el|GU+u)|>J%5>V zy4sUx$1_aV?8Yy%@;D>KSv#1@_E5@yZQ~_q9gK`}Gwjdg#r*nouXFza-^ZbvvB%%d zPt6MOk)`^Sp065=DE47_Xv^-pm$#80Ic6^UE6vM{3`{_i)Xf$7*Og1k40Jki(EUaGNAV_Tsw6Elo3{Td_SpPfm-7ZC)N2uC*B`hUn2h~?GV_;? z4xZ{@)%M?{I~;Bo+t!^+dqmB3pSQWy1mjz`oVfR1J#f#V@B(|k-4Y8<6|N&Cx{RGb zDCt7wB?((A4nAwTEu+~*|HSrqL2so-u5w2oGaqZ^_4X_Ma(f9@HoEfruHOdTafjyD z0^5sRUfBND`LO&}`;oQ;PuyS-$e4F4e0WS}987A}!U$UZ5yi&`cHY^(P)4g6vCBW6 zV7}Wo&%{gP;@a1KukByyOp5<(1kj56Od>cEj#*`;{J<6f`Wus?2*nJ zb@|;F4JuC$RHf=tYfrsD>^{=l!x;0^;hXfIsIBPV^3R<^FYg>>JT18$pR;yyDSOPX zGN7lvQ8-j<-F>N;K`DB!e({n3qLvvs{{Z+vZ&uMD+NHEov$r&uS{!LPx)G(bg5 zcB;KJsaa;?n3-&T?V7g`ZT0SKK(sLGZdd&}Jrz59<3rK~8wwhxmhD)C|BLb4zV4dF zZfpDE{RcLm-=kd0F>DU-Yi0X4T>gIi8C^FSw+io@QM9PzwehC6uZKo3SIRHlnxIx? zNt+QzTy0v!S5X@+4nM3A-yCZ&U7xj}SJaD7!nlq%MgQ7Qxv9ES^{^qKqnX;PcQzm# zxVR(mwpU8guB)k~-nDz90v}(x7KmOK(06!zN4@mCw3pWA&~Rp#)qFkE{6y`n5L3q! zE~zQzFB!Ju%IS6vnA~8akS7NihO5jQbtl#9s>#Ed-|>BLniX~TMjLT@_f!Yh-Je{2 z{^f_cJwK|IRTS0*D|1#ePg_>L)^D%T4i2V}<8&`PQ2KC0+`QMg+0(b_>9)7T4~0Lp zZ_yH$Rn?G3qdp)CN>0d(dV2H>R(g%*HC9^(Z5ey(o?mBjat>4*F|mCLfzXw5;d?Z| z!=1(w@Gt;d5DH>qc|!P}MIdbKVub)J0u&=d!7wi07WJyS4u#~hZBhPY51faP4u*4G z;~~&DeytxXK7vJMqwH2|+Qiae0v;#^kg>c-zK9lUi&F5?;Lq}DEDEWBh$C!K0UlmR zx&Q)^Bn%0ILp#TEV+g3#nn)Xn&7t`?xy(?&BU@CsSS+Mru@Z>{BOzi0P#6|ZrBbmt z0+v8P!w9q}jxPpc(R`7aoMM{82^6s)u29Ss@R4#(AXE@7wnd@fb>s{=yvlNpg(qhm z$j1tLk(iBT!UGb#9~gio;BZ!G905(BVrSdKs~#SotofoD6=6NGv49YZ$KbF$-WL`k zv2)C4e}8Bp@`Jz5V0}Q5AR1zU&M_cgY&P4eFfv*++h?>0lus$*j%0JNa8L@*vuzkm z53f%)av8(8JfXruj-HKVvp(U3(NLrU!)9T@NRS5yB7&LmU*N@D&gTRAVn6bge+vY5 z_lf@t^hdoEu_$z+r=0mm$qGIwzVt~&AJud3ZN8 zIs^h@0puqTMB1X{(IVxPilRc=%#;hwUBFTpD!?FHUU4%u=Lm#h6+;{BpMn34$v0de z;s4)wK0`mTI6z{F0E+O0JVQ5wEb*W7{1NyQlMmeOL}Dn8`5!j*KX5kF3F`{m3ZS@I z{(Zry>CtpcisUM!LLwDyfCjLp~aKsV-0v*EO9DvUmE-uA6BUjAi z-^wqek%WWt8*Msh*uOPxOE&HsX%Wj~Xn|H*tdY}%SG5XQk(94_{h@c-2P9{{Hr+_@}}FB1G& z=(8cyvdp@O;Fzc9;0q4EFR`C4%$Y2a7t(+6XD0jpiymO=Z%)2S-*0k#lk2M#_$u(X z?D{6xS1IsS;BVRW|0b8_=SOak4}b5Izz@{db0j_R!?;?g8^Z}PCI3BIQWX-L?s<{SLp^1x&pBr`l;KpHc^|~a9#?Z?C z1D5aehNqs|6)m#QYp5zU`f#{qxTShzVx-h!cu%F&gM2xbRFI}@g;=BNH-cTGiqJ5A zXIph6l3&C;2_w4R1|w7om?!hw87i$s&s$3dlSwI+K1y-k8&|H2P9ixp| From 4ddab8bdf118e4b2e01df28bbfcf424f4d9ace13 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Thu, 9 Feb 2023 16:16:13 +0000 Subject: [PATCH 12/54] Remove the ABMs There are likely better ways to fix any palettes that the LBMs missed. --- mods/MAPGEN/mcl_mapgen_core/init.lua | 50 ---------------------------- 1 file changed, 50 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 9755cfa3e..a1840c691 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -470,27 +470,6 @@ minetest.register_lbm({ end, }) -minetest.register_abm({ - label = "Fix grass palette indexes missed", -- This ABM fixes any incorrect grass palette indexes which were missed. Likely to be any grass from a schematic. - name = "mcl_mapgen_core:fix_grass_palette_indexes missed", - nodenames = {"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"}, - neighbors = {"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"}, - interval = 60, - chance = 1, - action = function(pos, node) - if mg_name ~= "v6" and mg_name ~= "singlenode" then - local biome_data = minetest.get_biome_data(pos) - local biome = biome_data.biome - local biome_name = minetest.get_biome_name(biome) - local reg_biome = minetest.registered_biomes[biome_name] - if node.param2 ~= reg_biome._mcl_grass_palette_index then - node.param2 = reg_biome._mcl_grass_palette_index - minetest.set_node(pos, node) - end - end - end, -}) - minetest.register_lbm({ label = "Fix foliage palette indexes", -- This LBM fixes any incorrect foliage palette indexes name = "mcl_mapgen_core:fix_foliage_palette_indexes", @@ -517,32 +496,3 @@ minetest.register_lbm({ end end, }) - -minetest.register_abm({ - label = "Fix foliage palette indexes missed", -- This ABM fixes any incorrect foliage palette indexes which were missed. Likely to be any foliage from a player sapling. - name = "mcl_mapgen_core:fix_foliage_palette_indexes missed", - nodenames = {"group:foliage_palette", "group:foliage_palette_wallmounted"}, - neighbors = {"group:foliage_palette", "group:foliage_palette_wallmounted"}, - interval = 60, - chance = 1, - action = function(pos, node) - if mg_name ~= "v6" and mg_name ~= "singlenode" then - local biome_data = minetest.get_biome_data(pos) - local biome = biome_data.biome - local biome_name = minetest.get_biome_name(biome) - local reg_biome = minetest.registered_biomes[biome_name] - if node.param2 ~= reg_biome._mcl_foliage_palette_index and node.name ~= "mcl_core:vine" then - node.param2 = reg_biome._mcl_foliage_palette_index - minetest.set_node(pos, node) - elseif node.name == "mcl_core:vine" then - local biome_param2 = reg_biome._mcl_foliage_palette_index - local rotation_param2 = node.param2 - local final_param2 = (biome_param2 * 8) + rotation_param2 - if node.param2 ~= final_param2 and rotation_param2 < 6 then - node.param2 = final_param2 - minetest.set_node(pos, node) - end - end - end -end, -}) From 197d3ae00bfbec7995aadd5f244cd5abf4a50858 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 08:04:13 +0000 Subject: [PATCH 13/54] Make sapling foliage grab biome colour --- mods/ITEMS/mcl_core/functions.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index fcc2e5078..d8572d3fc 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -1108,6 +1108,16 @@ local grow_acacia = sapling_grow_action(ACACIA_TREE_ID, 2, true, false) local grow_spruce = sapling_grow_action(SPRUCE_TREE_ID, 1, true, true, "mcl_core:sprucesapling") local grow_birch = sapling_grow_action(BIRCH_TREE_ID, 1, true, false) +function mcl_core.update_sapling_foliage_colors(pos) + local pos1, pos2 = vector.offset(pos, -6, 0, -6), vector.offset(pos, 6, 128, 6) + local lnode + local leaves = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) + for _, lpos in pairs(leaves) do + lnode = minetest.get_node(lpos) + minetest.set_node(lpos, lnode) + end +end + -- Attempts to grow the sapling at the specified position -- pos: Position -- node: Node table of the node at this position, from minetest.get_node @@ -1129,6 +1139,7 @@ function mcl_core.grow_sapling(pos, node) end if grow then grow(pos) + mcl_core.update_sapling_foliage_colors(pos) return true else return false From d163faeb42646e17ae1c6db93d9dc3f6df701333 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 08:08:28 +0000 Subject: [PATCH 14/54] Use more fitting names for the newly added function Basically renaming anything related to leaves in the new function to something more broad such as foliage, so vines aren't indirectly considered leaves. An aesthetic change, basically. --- mods/ITEMS/mcl_core/functions.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index d8572d3fc..8ef0e75ff 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -1110,11 +1110,11 @@ local grow_birch = sapling_grow_action(BIRCH_TREE_ID, 1, true, false) function mcl_core.update_sapling_foliage_colors(pos) local pos1, pos2 = vector.offset(pos, -6, 0, -6), vector.offset(pos, 6, 128, 6) - local lnode - local leaves = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) - for _, lpos in pairs(leaves) do - lnode = minetest.get_node(lpos) - minetest.set_node(lpos, lnode) + local fnode + local foliage = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) + for _, fpos in pairs(foliage) do + fnode = minetest.get_node(fpos) + minetest.set_node(fpos, fnode) end end From 1defd03408b266ef1d90f3b8aadfd428d970625e Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 10:06:55 +0000 Subject: [PATCH 15/54] Make the function work self grown saplings Saplings now also get the biome's foliage colour when grown by themselves. --- mods/ITEMS/mcl_core/functions.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index 8ef0e75ff..3a2672832 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -1052,6 +1052,7 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, minetest.remove_node(p3) minetest.remove_node(p4) mcl_core.generate_tree(pos, tree_id, { two_by_two = true }) + mcl_core.update_sapling_foliage_colors(pos) return elseif s3 and s5 and s6 and check_tree_growth(p6, tree_id, { two_by_two = true }) then minetest.remove_node(pos) @@ -1059,6 +1060,7 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, minetest.remove_node(p5) minetest.remove_node(p6) mcl_core.generate_tree(p6, tree_id, { two_by_two = true }) + mcl_core.update_sapling_foliage_colors(pos) return elseif s6 and s7 and s8 and check_tree_growth(p7, tree_id, { two_by_two = true }) then minetest.remove_node(pos) @@ -1066,6 +1068,7 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, minetest.remove_node(p7) minetest.remove_node(p8) mcl_core.generate_tree(p7, tree_id, { two_by_two = true }) + mcl_core.update_sapling_foliage_colors(pos) return elseif s2 and s8 and s9 and check_tree_growth(p8, tree_id, { two_by_two = true }) then minetest.remove_node(pos) @@ -1073,6 +1076,7 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, minetest.remove_node(p8) minetest.remove_node(p9) mcl_core.generate_tree(p8, tree_id, { two_by_two = true }) + mcl_core.update_sapling_foliage_colors(pos) return end end @@ -1083,6 +1087,7 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, if check_tree_growth(pos, tree_id, { balloon = true }) then minetest.set_node(pos, {name="air"}) mcl_core.generate_tree(pos, tree_id, { balloon = true }) + mcl_core.update_sapling_foliage_colors(pos) return end end @@ -1093,6 +1098,7 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, minetest.set_node(pos, {name="air"}) --local r = math.random(1, 12) mcl_core.generate_tree(pos, tree_id) + mcl_core.update_sapling_foliage_colors(pos) return end else From fdb23334935ec58af95a6e44baf6af7cb9364965 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 10:39:43 +0000 Subject: [PATCH 16/54] Make placed leaves always become player leaves Any players which still have leaves in their inventory from before this update would have had those leaves rot if someone were to break any log withing 6 nodes of the leaves if they were placed. This commit adds an `after_place_node` callback which makes sure that any leaves placed by the player, become non-rotting player leaves. --- mods/ITEMS/mcl_core/nodes_trees.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index 343d9a7a3..cf966425e 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -44,6 +44,14 @@ function mcl_core.update_leaves(pos, oldnode) end end +function mcl_core.make_player_leaves(pos) + local node = minetest.get_node(pos) + if minetest.get_item_group(node.name, "player_leaves") ~= 1 then + local playerleafname = node.name .. "_player" + minetest.set_node(pos, {name = playerleafname}) + end +end + -- Register tree trunk (wood) and bark local function register_tree_trunk(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_variant) minetest.register_node("mcl_core:"..subname, { @@ -207,10 +215,13 @@ local function register_leaves(subname, description, longdesc, tiles, color, par minetest.swap_node(pos, new_node) end end + end, + after_place_node = function(pos) + mcl_core.make_player_leaves(pos) -- Leaves placed by the player should always be player leaves. end, } - minetest.register_node("mcl_core:player" .. subname, pl_def) + minetest.register_node("mcl_core:" .. subname .. "_player", pl_def) local l_def = table.copy(pl_def) l_def.groups.player_leaves = nil From 6744967d028ebeaa95459d547ca882ffd6c689f3 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 10:41:43 +0000 Subject: [PATCH 17/54] Make placed mangrove leaves always become player leaves The same thing as with the `mcl_core` leaves. --- mods/ITEMS/mcl_mangrove/init.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_mangrove/init.lua b/mods/ITEMS/mcl_mangrove/init.lua index 81b8bd1c5..d55e80f1a 100644 --- a/mods/ITEMS/mcl_mangrove/init.lua +++ b/mods/ITEMS/mcl_mangrove/init.lua @@ -118,15 +118,18 @@ local pl_def = { end end end, -} + after_place_node = function(pos) + mcl_core.make_player_leaves(pos) -- Leaves placed by the player should always be player leaves. + end, + } -minetest.register_node("mcl_mangrove:playermangroveleaves", pl_def) +minetest.register_node("mcl_mangrove:mangroveleaves_player", pl_def) local l_def = table.copy(pl_def) l_def.groups.player_leaves = nil l_def.groups.not_in_creative_inventory = 1 -l_def._mcl_shears_drop = {"mcl_mangrove:playermangroveleaves"} -l_def._mcl_silk_touch_drop = {"mcl_mangrove:playermangroveleaves"} +l_def._mcl_shears_drop = {"mcl_mangrove:mangroveleaves_player"} +l_def._mcl_silk_touch_drop = {"mcl_mangrove:mangroveleaves_player"} minetest.register_node("mcl_mangrove:mangroveleaves", l_def) @@ -134,8 +137,8 @@ local o_def = table.copy(l_def) o_def._doc_items_create_entry = false o_def.groups.not_in_creative_inventory = 1 o_def.groups.orphan_leaves = 1 -o_def._mcl_shears_drop = {"mcl_mangrove:playermangroveleaves"} -o_def._mcl_silk_touch_drop = {"mcl_mangrove:playermangroveleaves"} +o_def._mcl_shears_drop = {"mcl_mangrove:mangroveleaves_player"} +o_def._mcl_silk_touch_drop = {"mcl_mangrove:mangroveleaves_player"} minetest.register_node("mcl_mangrove:mangroveleaves_orphan", o_def) From 953044cc4b31aceadcd20a7206a6b550b5e81aff Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 11:33:58 +0000 Subject: [PATCH 18/54] Mangrove propagules also grab biome colour on growth --- mods/ITEMS/mcl_mangrove/init.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_mangrove/init.lua b/mods/ITEMS/mcl_mangrove/init.lua index d55e80f1a..19c9267b2 100644 --- a/mods/ITEMS/mcl_mangrove/init.lua +++ b/mods/ITEMS/mcl_mangrove/init.lua @@ -111,7 +111,7 @@ local pl_def = { _mcl_fortune_drop = { get_drops(1), get_drops(2), get_drops(3), get_drops(4) }, on_construct = function(pos) local node = minetest.get_node(pos) - if node.param2 == 0 then + if node.param2 == 0 or node.param2 == 1 then -- Check if param2 is 1 as well, since the schematics accidentally have the param2 of mangrove leaves be 1. local new_node = mcl_core.get_foliage_block_type(pos) if new_node.param2 ~= 0 then minetest.swap_node(pos, new_node) @@ -570,6 +570,7 @@ minetest.register_abm({ local nn = minetest.find_nodes_in_area(vector.offset(pos,0,-1,0),vector.offset(pos,0,h,0),{"group:water","air"}) if #nn >= h then minetest.place_schematic(pos, path, "random", function() + mcl_core.update_sapling_foliage_colors(pos) local nnv = minetest.find_nodes_in_area(vector.offset(pos,-5,-1,-5),vector.offset(pos,5,h/2,5),{"mcl_core:vine"}) minetest.bulk_set_node(nnv,{"air"}) end, true, "place_center_x, place_center_z") @@ -579,6 +580,7 @@ minetest.register_abm({ if r > 3 then h = 18 end if mcl_core.check_growth_width(pos,w,h) then minetest.place_schematic(pos, path, "random", nil, true, "place_center_x, place_center_z") + mcl_core.update_sapling_foliage_colors(pos) end end }) From 7fbc84971ee5b87c723973bf3aa8a60d8f2230e3 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 15:12:37 +0000 Subject: [PATCH 19/54] Remove useless function This commit removes an useless function which wasn't really needed. --- mods/ITEMS/mcl_core/functions.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index 3a2672832..0c4241aa7 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -820,11 +820,6 @@ function mcl_core.get_grass_block_type(pos) return {name = "mcl_core:dirt_with_grass", param2 = mcl_core.get_grass_palette_index(pos)} end -function mcl_core.get_foliage_name(pos) - local nodename = minetest.get_node(pos).name - return nodename -end - function mcl_core.get_foliage_palette_index(pos) local biome_data = minetest.get_biome_data(pos) local index = 0 @@ -841,7 +836,7 @@ end -- Return appropriate foliage block node for pos function mcl_core.get_foliage_block_type(pos) - return {name = mcl_core.get_foliage_name(pos), param2 = mcl_core.get_foliage_palette_index(pos)} + return {name = minetest.get_node(pos).name, param2 = mcl_core.get_foliage_palette_index(pos)} end ------------------------------ From d63ecac7cb78afa03a96b36f1d5a080c45ef751c Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 15:14:53 +0000 Subject: [PATCH 20/54] Indentation improvements --- mods/ITEMS/nodes_trees.lua | 349 +++++++++++++++++++++++++++++++++++++ 1 file changed, 349 insertions(+) create mode 100644 mods/ITEMS/nodes_trees.lua diff --git a/mods/ITEMS/nodes_trees.lua b/mods/ITEMS/nodes_trees.lua new file mode 100644 index 000000000..5c34cad87 --- /dev/null +++ b/mods/ITEMS/nodes_trees.lua @@ -0,0 +1,349 @@ +-- Tree nodes: Wood, Wooden Planks, Sapling, Leaves, Stripped Wood +local S = minetest.get_translator(minetest.get_current_modname()) + +local mod_screwdriver = minetest.get_modpath("screwdriver") + +local on_rotate +if mod_screwdriver then + on_rotate = screwdriver.rotate_3way +end + +-- Check dug/destroyed tree trunks for orphaned leaves. +-- +-- This function is meant to be called by the `after_destruct` handler of +-- treetrunk nodes. +-- +-- Whenever a trunk node is removed, all `group:leaves` nodes in a sphere +-- with radius 6 are checked. Every such node that does not have a trunk +-- node within a distance of 6 blocks and wasn't placed by a player is +-- converted into a orphan leaf node. +-- An ABM will gradually decay these nodes. +-- +-- +-- @param pos the position of the removed trunk node. +-- @param oldnode the node table of the removed trunk node. +function mcl_core.update_leaves(pos, oldnode) + local pos1, pos2 = vector.offset(pos, -6, -6, -6), vector.offset(pos, 6, 6, 6) + local lnode + local leaves = minetest.find_nodes_in_area(pos1, pos2, "group:leaves") + for _, lpos in pairs(leaves) do + lnode = minetest.get_node(lpos) + -- skip already decaying leaf nodes and player leaves + if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 and minetest.get_item_group(lnode.name, "player_leaves") ~= 1 then + if not minetest.find_node_near(lpos, 6, "group:tree") then + local orphan_name = lnode.name .. "_orphan" + local def = minetest.registered_nodes[orphan_name] + if def then + --minetest.log("Registered: ".. orphan_name) + minetest.set_node(lpos, {name = orphan_name}) + else + --minetest.log("Not registered: ".. orphan_name) + end + end + end + end +end + +function mcl_core.make_player_leaves(pos) + local node = minetest.get_node(pos) + if minetest.get_item_group(node.name, "player_leaves") ~= 1 then + local playerleafname = node.name .. "_player" + minetest.set_node(pos, {name = playerleafname}) + end +end + +-- Register tree trunk (wood) and bark +local function register_tree_trunk(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_variant) + minetest.register_node("mcl_core:"..subname, { + description = description_trunk, + _doc_items_longdesc = longdesc, + _doc_items_hidden = false, + tiles = {tile_inner, tile_inner, tile_bark}, + paramtype2 = "facedir", + on_place = mcl_util.rotate_axis, + after_destruct = mcl_core.update_leaves, + stack_max = 64, + groups = {handy=1,axey=1, tree=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, + sounds = mcl_sounds.node_sound_wood_defaults(), + on_rotate = on_rotate, + _mcl_blast_resistance = 2, + _mcl_hardness = 2, + _mcl_stripped_variant = stripped_variant, + }) + + minetest.register_node("mcl_core:"..subname.."_bark", { + description = description_bark, + _doc_items_longdesc = S("This is a decorative block surrounded by the bark of a tree trunk."), + tiles = {tile_bark}, + paramtype2 = "facedir", + on_place = mcl_util.rotate_axis, + stack_max = 64, + groups = {handy=1,axey=1, bark=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, + sounds = mcl_sounds.node_sound_wood_defaults(), + is_ground_content = false, + on_rotate = on_rotate, + _mcl_blast_resistance = 2, + _mcl_hardness = 2, + _mcl_stripped_variant = stripped_variant.."_bark", + }) + + minetest.register_craft({ + output = "mcl_core:"..subname.."_bark 3", + recipe = { + { "mcl_core:"..subname, "mcl_core:"..subname }, + { "mcl_core:"..subname, "mcl_core:"..subname }, + } + }) +end + +-- Register stripped trunk and stripped wood +local function register_stripped_trunk(subname, description_stripped_trunk, description_stripped_bark, longdesc, longdesc_wood, tile_stripped_inner, tile_stripped_bark) + minetest.register_node("mcl_core:"..subname, { + description = description_stripped_trunk, + _doc_items_longdesc = longdesc, + _doc_items_hidden = false, + tiles = {tile_stripped_inner, tile_stripped_inner, tile_stripped_bark}, + paramtype2 = "facedir", + on_place = mcl_util.rotate_axis, + stack_max = 64, + groups = {handy=1, axey=1, tree=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, + sounds = mcl_sounds.node_sound_wood_defaults(), + on_rotate = on_rotate, + _mcl_blast_resistance = 2, + _mcl_hardness = 2, + }) + + minetest.register_node("mcl_core:"..subname.."_bark", { + description = description_stripped_bark, + _doc_items_longdesc = longdesc_wood, + tiles = {tile_stripped_bark}, + paramtype2 = "facedir", + on_place = mcl_util.rotate_axis, + stack_max = 64, + groups = {handy=1, axey=1, bark=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, + sounds = mcl_sounds.node_sound_wood_defaults(), + is_ground_content = false, + on_rotate = on_rotate, + _mcl_blast_resistance = 2, + _mcl_hardness = 2, + }) + + minetest.register_craft({ + output = "mcl_core:"..subname.."_bark 3", + recipe = { + { "mcl_core:"..subname, "mcl_core:"..subname }, + { "mcl_core:"..subname, "mcl_core:"..subname }, + } + }) +end + +local function register_wooden_planks(subname, description, tiles) + minetest.register_node("mcl_core:"..subname, { + description = description, + _doc_items_longdesc = doc.sub.items.temp.build, + _doc_items_hidden = false, + tiles = tiles, + stack_max = 64, + is_ground_content = false, + groups = {handy=1,axey=1, flammable=3,wood=1,building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=20}, + sounds = mcl_sounds.node_sound_wood_defaults(), + _mcl_blast_resistance = 3, + _mcl_hardness = 2, + }) +end + +local function register_leaves(subname, description, longdesc, tiles, color, paramtype2, sapling, drop_apples, sapling_chances, foliage_palette) + local apple_chances = {200, 180, 160, 120, 40} + local stick_chances = {50, 45, 30, 35, 10} + + local function get_drops(fortune_level) + local drop = { + max_items = 1, + items = { + { + items = {sapling}, + rarity = sapling_chances[fortune_level + 1] or sapling_chances[fortune_level] + }, + { + items = {"mcl_core:stick 1"}, + rarity = stick_chances[fortune_level + 1] + }, + { + items = {"mcl_core:stick 2"}, + rarity = stick_chances[fortune_level + 1] + }, + } + } + if drop_apples then + table.insert(drop.items, { + items = {"mcl_core:apple"}, + rarity = apple_chances[fortune_level + 1] + }) + end + return drop + end + + local pl_def = { + description = description, + _doc_items_longdesc = longdesc, + _doc_items_hidden = false, + drawtype = "allfaces_optional", + waving = 2, + tiles = tiles, + color = color, + paramtype = "light", + paramtype2 = paramtype2, + palette = "mcl_core_palette_foliage.png", + stack_max = 64, + groups = { + handy = 1, hoey = 1, shearsy = 1, swordy = 1, dig_by_piston = 1, + flammable = 2, fire_encouragement = 30, fire_flammability = 60, + leaves = 1, deco_block = 1, compostability = 30, foliage_palette = foliage_palette, player_leaves = 1, not_in_creative_inventory = 0, + }, + drop = get_drops(0), + _mcl_shears_drop = true, + sounds = mcl_sounds.node_sound_leaves_defaults(), + _mcl_blast_resistance = 0.2, + _mcl_hardness = 0.2, + _mcl_silk_touch_drop = true, + _mcl_fortune_drop = { get_drops(1), get_drops(2), get_drops(3), get_drops(4) }, + on_construct = function(pos) + local node = minetest.get_node(pos) + if node.param2 == 0 then + local new_node = mcl_core.get_foliage_block_type(pos) + if new_node.param2 ~= 0 then + minetest.swap_node(pos, new_node) + end + end + end, + after_place_node = function(pos) + mcl_core.make_player_leaves(pos) -- Leaves placed by the player should always be player leaves. + end, + } + + minetest.register_node("mcl_core:" .. subname .. "_player", pl_def) + + local l_def = table.copy(pl_def) + l_def.groups.player_leaves = nil + l_def.groups.not_in_creative_inventory = 1 + l_def._mcl_shears_drop = {"mcl_core:player" .. subname} + l_def._mcl_silk_touch_drop = {"mcl_core:player" .. subname} + + minetest.register_node("mcl_core:" .. subname, l_def) + + local o_def = table.copy(l_def) + o_def._doc_items_create_entry = false + o_def.groups.not_in_creative_inventory = 1 + o_def.groups.orphan_leaves = 1 + o_def._mcl_shears_drop = {"mcl_core:player" .. subname} + o_def._mcl_silk_touch_drop = {"mcl_core:player" .. subname} + + minetest.register_node("mcl_core:" .. subname .. "_orphan", o_def) +end + +local function register_sapling(subname, description, longdesc, tt_help, texture, selbox) + minetest.register_node("mcl_core:"..subname, { + description = description, + _tt_help = tt_help, + _doc_items_longdesc = longdesc, + _doc_items_hidden = false, + drawtype = "plantlike", + waving = 1, + visual_scale = 1.0, + tiles = {texture}, + inventory_image = texture, + wield_image = texture, + paramtype = "light", + sunlight_propagates = true, + walkable = false, + selection_box = { + type = "fixed", + fixed = selbox + }, + stack_max = 64, + groups = { + plant = 1, sapling = 1, non_mycelium_plant = 1, attached_node = 1, + deco_block = 1, dig_immediate = 3, dig_by_water = 1, dig_by_piston = 1, + destroy_by_lava_flow = 1, compostability = 30 + }, + sounds = mcl_sounds.node_sound_leaves_defaults(), + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_int("stage", 0) + end, + on_place = mcl_util.generate_on_place_plant_function(function(pos, node) + local node_below = minetest.get_node_or_nil({x=pos.x,y=pos.y-1,z=pos.z}) + if not node_below then return false end + local nn = node_below.name + return minetest.get_item_group(nn, "grass_block") == 1 or + nn == "mcl_core:podzol" or nn == "mcl_core:podzol_snow" or + nn == "mcl_core:dirt" or nn == "mcl_core:mycelium" or nn == "mcl_core:coarse_dirt" + end), + node_placement_prediction = "", + _mcl_blast_resistance = 0, + _mcl_hardness = 0, + }) +end + +--------------------- + +register_tree_trunk("tree", S("Oak Wood"), S("Oak Bark"), S("The trunk of an oak tree."), "default_tree_top.png", "default_tree.png", "mcl_core:stripped_oak") +register_tree_trunk("darktree", S("Dark Oak Wood"), S("Dark Oak Bark"), S("The trunk of a dark oak tree."), "mcl_core_log_big_oak_top.png", "mcl_core_log_big_oak.png", "mcl_core:stripped_dark_oak") +register_tree_trunk("acaciatree", S("Acacia Wood"), S("Acacia Bark"), S("The trunk of an acacia."), "default_acacia_tree_top.png", "default_acacia_tree.png", "mcl_core:stripped_acacia") +register_tree_trunk("sprucetree", S("Spruce Wood"), S("Spruce Bark"), S("The trunk of a spruce tree."), "mcl_core_log_spruce_top.png", "mcl_core_log_spruce.png", "mcl_core:stripped_spruce") +register_tree_trunk("birchtree", S("Birch Wood"), S("Birch Bark"), S("The trunk of a birch tree."), "mcl_core_log_birch_top.png", "mcl_core_log_birch.png", "mcl_core:stripped_birch") +register_tree_trunk("jungletree", S("Jungle Wood"), S("Jungle Bark"), S("The trunk of a jungle tree."), "default_jungletree_top.png", "default_jungletree.png", "mcl_core:stripped_jungle") + +register_stripped_trunk("stripped_oak", S("Stripped Oak Log"), S("Stripped Oak Wood"), S("The stripped trunk of an oak tree."), S("The stripped wood of an oak tree."), "mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_side.png") +register_stripped_trunk("stripped_acacia", S("Stripped Acacia Log"), S("Stripped Acacia Wood"), S("The stripped trunk of an acacia tree."), S("The stripped wood of an acacia tree."), "mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_side.png") +register_stripped_trunk("stripped_dark_oak", S("Stripped Dark Oak Log"), S("Stripped Dark Oak Wood"), S("The stripped trunk of a dark oak tree."), S("The stripped wood of a dark oak tree."), "mcl_core_stripped_dark_oak_top.png", "mcl_core_stripped_dark_oak_side.png") +register_stripped_trunk("stripped_birch", S("Stripped Birch Log"), S("Stripped Birch Wood"), S("The stripped trunk of a birch tree."), S("The stripped wood of a birch tree."), "mcl_core_stripped_birch_top.png", "mcl_core_stripped_birch_side.png") +register_stripped_trunk("stripped_spruce", S("Stripped Spruce Log"), S("Stripped Spruce Wood"), S("The stripped trunk of a spruce tree."), S("The stripped wood of a spruce tree."), "mcl_core_stripped_spruce_top.png", "mcl_core_stripped_spruce_side.png") +register_stripped_trunk("stripped_jungle", S("Stripped Jungle Log"), S("Stripped Jungle Wood"), S("The stripped trunk of a jungle tree."), S("The stripped wood of a jungle tree."),"mcl_core_stripped_jungle_top.png", "mcl_core_stripped_jungle_side.png") +register_wooden_planks("wood", S("Oak Wood Planks"), {"default_wood.png"}) +register_wooden_planks("darkwood", S("Dark Oak Wood Planks"), {"mcl_core_planks_big_oak.png"}) +register_wooden_planks("junglewood", S("Jungle Wood Planks"), {"default_junglewood.png"}) +register_wooden_planks("sprucewood", S("Spruce Wood Planks"), {"mcl_core_planks_spruce.png"}) +register_wooden_planks("acaciawood", S("Acacia Wood Planks"), {"default_acacia_wood.png"}) +register_wooden_planks("birchwood", S("Birch Wood Planks"), {"mcl_core_planks_birch.png"}) + + +register_sapling("sapling", S("Oak Sapling"), + S("When placed on soil (such as dirt) and exposed to light, an oak sapling will grow into an oak after some time."), + S("Needs soil and light to grow"), + "default_sapling.png", {-5/16, -0.5, -5/16, 5/16, 0.5, 5/16}) +register_sapling("darksapling", S("Dark Oak Sapling"), + S("Dark oak saplings can grow into dark oaks, but only in groups. A lonely dark oak sapling won't grow. A group of four dark oak saplings grows into a dark oak after some time when they are placed on soil (such as dirt) in a 2×2 square and exposed to light."), + S("Needs soil and light to grow") .. "\n" .. S("2×2 saplings required"), + "mcl_core_sapling_big_oak.png", {-5/16, -0.5, -5/16, 5/16, 7/16, 5/16}) +register_sapling("junglesapling", S("Jungle Sapling"), + S("When placed on soil (such as dirt) and exposed to light, a jungle sapling will grow into a jungle tree after some time. When there are 4 jungle saplings in a 2×2 square, they will grow to a huge jungle tree."), + S("Needs soil and light to grow") .. "\n" .. S("2×2 saplings = large tree"), + "default_junglesapling.png", {-5/16, -0.5, -5/16, 5/16, 0.5, 5/16}) +register_sapling("acaciasapling", S("Acacia Sapling"), + S("When placed on soil (such as dirt) and exposed to light, an acacia sapling will grow into an acacia after some time."), + S("Needs soil and light to grow"), + "default_acacia_sapling.png", {-5/16, -0.5, -5/16, 5/16, 4/16, 5/16}) +register_sapling("sprucesapling", S("Spruce Sapling"), + S("When placed on soil (such as dirt) and exposed to light, a spruce sapling will grow into a spruce after some time. When there are 4 spruce saplings in a 2×2 square, they will grow to a huge spruce."), + S("Needs soil and light to grow") .. "\n" .. S("2×2 saplings = large tree"), + "mcl_core_sapling_spruce.png", {-4/16, -0.5, -4/16, 4/16, 0.5, 4/16}) +register_sapling("birchsapling", S("Birch Sapling"), + S("When placed on soil (such as dirt) and exposed to light, a birch sapling will grow into a birch after some time."), + S("Needs soil and light to grow"), + "mcl_core_sapling_birch.png", {-4/16, -0.5, -4/16, 4/16, 0.5, 4/16}) + + +register_leaves("leaves", S("Oak Leaves"), S("Oak leaves are grown from oak trees."), {"default_leaves.png"}, "#48B518", "color", "mcl_core:sapling", true, {20, 16, 12, 10}, 1) +register_leaves("darkleaves", S("Dark Oak Leaves"), S("Dark oak leaves are grown from dark oak trees."), {"mcl_core_leaves_big_oak.png"}, "#48B518", "color", "mcl_core:darksapling", true, {20, 16, 12, 10}, 1) +register_leaves("jungleleaves", S("Jungle Leaves"), S("Jungle leaves are grown from jungle trees."), {"default_jungleleaves.png"}, "#48B518", "color", "mcl_core:junglesapling", false, {40, 26, 32, 24, 10}, 1) +register_leaves("acacialeaves", S("Acacia Leaves"), S("Acacia leaves are grown from acacia trees."), {"default_acacia_leaves.png"}, "#48B518", "color", "mcl_core:acaciasapling", false, {20, 16, 12, 10}, 1) +register_leaves("spruceleaves", S("Spruce Leaves"), S("Spruce leaves are grown from spruce trees."), {"mcl_core_leaves_spruce.png"}, "#619961", "none", "mcl_core:sprucesapling", false, {20, 16, 12, 10}, 0) +register_leaves("birchleaves", S("Birch Leaves"), S("Birch leaves are grown from birch trees."), {"mcl_core_leaves_birch.png"}, "#80A755", "none", "mcl_core:birchsapling", false, {20, 16, 12, 10}, 0) + + + +-- Node aliases + +minetest.register_alias("default:acacia_tree", "mcl_core:acaciatree") +minetest.register_alias("default:acacia_leaves", "mcl_core:acacialeaves") From f368fb3e43dd6c739a3e4b776a4eb62bf84b941d Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 15:17:46 +0000 Subject: [PATCH 21/54] Indentation improvements --- mods/ITEMS/mcl_mangrove/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_mangrove/init.lua b/mods/ITEMS/mcl_mangrove/init.lua index 19c9267b2..e7ac8090b 100644 --- a/mods/ITEMS/mcl_mangrove/init.lua +++ b/mods/ITEMS/mcl_mangrove/init.lua @@ -119,7 +119,7 @@ local pl_def = { end end, after_place_node = function(pos) - mcl_core.make_player_leaves(pos) -- Leaves placed by the player should always be player leaves. + mcl_core.make_player_leaves(pos) -- Leaves placed by the player should always be player leaves. end, } @@ -571,8 +571,8 @@ minetest.register_abm({ if #nn >= h then minetest.place_schematic(pos, path, "random", function() mcl_core.update_sapling_foliage_colors(pos) - local nnv = minetest.find_nodes_in_area(vector.offset(pos,-5,-1,-5),vector.offset(pos,5,h/2,5),{"mcl_core:vine"}) - minetest.bulk_set_node(nnv,{"air"}) + local nnv = minetest.find_nodes_in_area(vector.offset(pos,-5,-1,-5),vector.offset(pos,5,h/2,5),{"mcl_core:vine"}) + minetest.bulk_set_node(nnv,{"air"}) end, true, "place_center_x, place_center_z") end return @@ -582,5 +582,5 @@ minetest.register_abm({ minetest.place_schematic(pos, path, "random", nil, true, "place_center_x, place_center_z") mcl_core.update_sapling_foliage_colors(pos) end -end + end, }) From b789845f627411245b546cff20e4c269f2eb84a2 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 15:19:02 +0000 Subject: [PATCH 22/54] Indentation improvements --- mods/MAPGEN/mcl_mapgen_core/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index a1840c691..b5d0f343a 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -491,8 +491,8 @@ minetest.register_lbm({ if node.param2 ~= final_param2 and rotation_param2 < 6 then node.param2 = final_param2 minetest.set_node(pos, node) + end end end - end -end, + end, }) From 1fb300ef188bfada0c4175c65d8da97e933dcacc Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Fri, 10 Feb 2023 18:40:35 +0000 Subject: [PATCH 23/54] Fix leaves not dropping Due to some renaming, leaves no longer dropped from any of the `mcl_core` trees. This has now been fixed. --- mods/ITEMS/mcl_core/nodes_trees.lua | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index cf966425e..a4413c17a 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -46,9 +46,9 @@ end function mcl_core.make_player_leaves(pos) local node = minetest.get_node(pos) - if minetest.get_item_group(node.name, "player_leaves") ~= 1 then - local playerleafname = node.name .. "_player" - minetest.set_node(pos, {name = playerleafname}) + if minetest.get_item_group(node.name, "player_leaves") ~= 1 then + local playerleafname = node.name .. "_player" + minetest.set_node(pos, {name = playerleafname}) end end @@ -208,26 +208,26 @@ local function register_leaves(subname, description, longdesc, tiles, color, par _mcl_silk_touch_drop = true, _mcl_fortune_drop = { get_drops(1), get_drops(2), get_drops(3), get_drops(4) }, on_construct = function(pos) - local node = minetest.get_node(pos) - if node.param2 == 0 then - local new_node = mcl_core.get_foliage_block_type(pos) - if new_node.param2 ~= 0 then - minetest.swap_node(pos, new_node) + local node = minetest.get_node(pos) + if node.param2 == 0 then + local new_node = mcl_core.get_foliage_block_type(pos) + if new_node.param2 ~= 0 then + minetest.swap_node(pos, new_node) + end end - end - end, + end, after_place_node = function(pos) - mcl_core.make_player_leaves(pos) -- Leaves placed by the player should always be player leaves. - end, - } + mcl_core.make_player_leaves(pos) -- Leaves placed by the player should always be player leaves. + end, + } minetest.register_node("mcl_core:" .. subname .. "_player", pl_def) local l_def = table.copy(pl_def) l_def.groups.player_leaves = nil l_def.groups.not_in_creative_inventory = 1 - l_def._mcl_shears_drop = {"mcl_core:player" .. subname} - l_def._mcl_silk_touch_drop = {"mcl_core:player" .. subname} + l_def._mcl_shears_drop = {"mcl_core:" .. subname .. "_player"} + l_def._mcl_silk_touch_drop = {"mcl_core:" .. subname .. "_player"} minetest.register_node("mcl_core:" .. subname, l_def) @@ -235,8 +235,8 @@ local function register_leaves(subname, description, longdesc, tiles, color, par o_def._doc_items_create_entry = false o_def.groups.not_in_creative_inventory = 1 o_def.groups.orphan_leaves = 1 - o_def._mcl_shears_drop = {"mcl_core:player" .. subname} - o_def._mcl_silk_touch_drop = {"mcl_core:player" .. subname} + o_def._mcl_shears_drop = {"mcl_core:" .. subname .. "_player"} + o_def._mcl_silk_touch_drop = {"mcl_core:" .. subname .. "_player"} minetest.register_node("mcl_core:" .. subname .. "_orphan", o_def) end From 81dbdaab944cba7af310ad0b5502eb6f740e8e45 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Sat, 11 Feb 2023 07:53:12 +0000 Subject: [PATCH 24/54] Adjust palette foliage check The excessive 128 blocks high check has been changed to now check only up to 30 blocks, since the tallest 2x2 jungle tree I seemed to get was only 29 blocks tall. I also discovered that the search area wasn't wide enough, so sometimes the most outer leaves avoided the check. I also adjusted that. --- mods/ITEMS/mcl_core/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index 0c4241aa7..e123887a5 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -1110,7 +1110,7 @@ local grow_spruce = sapling_grow_action(SPRUCE_TREE_ID, 1, true, true, "mcl_core local grow_birch = sapling_grow_action(BIRCH_TREE_ID, 1, true, false) function mcl_core.update_sapling_foliage_colors(pos) - local pos1, pos2 = vector.offset(pos, -6, 0, -6), vector.offset(pos, 6, 128, 6) + local pos1, pos2 = vector.offset(pos, -8, 0, -8), vector.offset(pos, 8, 30, 8) local fnode local foliage = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) for _, fpos in pairs(foliage) do From b4e84dadb0429fbe13703a9d09cb7551ee33288c Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Sun, 12 Feb 2023 07:57:04 +0000 Subject: [PATCH 25/54] Add new function Adds the `get_registered_biome_from_pos` function, which does what the name says. --- mods/CORE/mcl_util/init.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index f37b34444..13da7e78b 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -1011,3 +1011,13 @@ function mcl_util.check_position_protection(position, player) return false end + +function mcl_util.get_registered_biome_from_pos(pos) + if mg_name ~= "v6" and mg_name ~= "singlenode" then + local biome_data = minetest.get_biome_data(pos) + local biome = biome_data.biome + local biome_name = minetest.get_biome_name(biome) + local reg_biome = minetest.registered_biomes[biome_name] + return reg_biome + end +end From a70a6ef13d625152e9e3e039154a3c6c0dfe1026 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Sun, 12 Feb 2023 08:21:14 +0000 Subject: [PATCH 26/54] Improve some foliage code --- mods/ITEMS/mcl_core/functions.lua | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index e123887a5..b34292d40 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -405,6 +405,7 @@ function mcl_core.generate_tree(pos, tree_type, options) elseif tree_type == BIRCH_TREE_ID then mcl_core.generate_birch_tree(pos) end + mcl_core.update_sapling_foliage_colors(pos) end -- Classic oak in v6 style @@ -821,16 +822,8 @@ function mcl_core.get_grass_block_type(pos) end function mcl_core.get_foliage_palette_index(pos) - local biome_data = minetest.get_biome_data(pos) - local index = 0 - if biome_data then - local biome = biome_data.biome - local biome_name = minetest.get_biome_name(biome) - local reg_biome = minetest.registered_biomes[biome_name] - if reg_biome then - index = reg_biome._mcl_foliage_palette_index - end - end + local reg_biome = mcl_util.get_registered_biome_from_pos(pos) + local index = reg_biome._mcl_foliage_palette_index return index end @@ -1047,7 +1040,6 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, minetest.remove_node(p3) minetest.remove_node(p4) mcl_core.generate_tree(pos, tree_id, { two_by_two = true }) - mcl_core.update_sapling_foliage_colors(pos) return elseif s3 and s5 and s6 and check_tree_growth(p6, tree_id, { two_by_two = true }) then minetest.remove_node(pos) @@ -1055,7 +1047,6 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, minetest.remove_node(p5) minetest.remove_node(p6) mcl_core.generate_tree(p6, tree_id, { two_by_two = true }) - mcl_core.update_sapling_foliage_colors(pos) return elseif s6 and s7 and s8 and check_tree_growth(p7, tree_id, { two_by_two = true }) then minetest.remove_node(pos) @@ -1063,7 +1054,6 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, minetest.remove_node(p7) minetest.remove_node(p8) mcl_core.generate_tree(p7, tree_id, { two_by_two = true }) - mcl_core.update_sapling_foliage_colors(pos) return elseif s2 and s8 and s9 and check_tree_growth(p8, tree_id, { two_by_two = true }) then minetest.remove_node(pos) @@ -1071,7 +1061,6 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, minetest.remove_node(p8) minetest.remove_node(p9) mcl_core.generate_tree(p8, tree_id, { two_by_two = true }) - mcl_core.update_sapling_foliage_colors(pos) return end end @@ -1082,7 +1071,6 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, if check_tree_growth(pos, tree_id, { balloon = true }) then minetest.set_node(pos, {name="air"}) mcl_core.generate_tree(pos, tree_id, { balloon = true }) - mcl_core.update_sapling_foliage_colors(pos) return end end @@ -1093,7 +1081,6 @@ local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, minetest.set_node(pos, {name="air"}) --local r = math.random(1, 12) mcl_core.generate_tree(pos, tree_id) - mcl_core.update_sapling_foliage_colors(pos) return end else @@ -1140,7 +1127,6 @@ function mcl_core.grow_sapling(pos, node) end if grow then grow(pos) - mcl_core.update_sapling_foliage_colors(pos) return true else return false From d1ceacf7ba7b4af2bc5784fbeb8da8b63e891d11 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Sun, 12 Feb 2023 08:22:07 +0000 Subject: [PATCH 27/54] Improve some vines code --- mods/ITEMS/mcl_core/nodes_climb.lua | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_climb.lua b/mods/ITEMS/mcl_core/nodes_climb.lua index b69b715ba..005cd8b5a 100644 --- a/mods/ITEMS/mcl_core/nodes_climb.lua +++ b/mods/ITEMS/mcl_core/nodes_climb.lua @@ -158,20 +158,15 @@ minetest.register_node("mcl_core:vine", { end, on_construct = function(pos) - if mg_name ~= "v6" and mg_name ~= "singlenode" then - local node = minetest.get_node(pos) - local biome_data = minetest.get_biome_data(pos) - local biome = biome_data.biome - local biome_name = minetest.get_biome_name(biome) - local reg_biome = minetest.registered_biomes[biome_name] - if node.name == "mcl_core:vine" then - local biome_param2 = reg_biome._mcl_foliage_palette_index - local rotation_param2 = node.param2 - local final_param2 = (biome_param2 * 8) + rotation_param2 - if node.param2 ~= final_param2 and rotation_param2 < 6 then - node.param2 = final_param2 - minetest.swap_node(pos, node) - end + local node = minetest.get_node(pos) + local reg_biome = mcl_util.get_registered_biome_from_pos(pos) + if node.name == "mcl_core:vine" then + local biome_param2 = reg_biome._mcl_foliage_palette_index + local rotation_param2 = node.param2 + local final_param2 = (biome_param2 * 8) + rotation_param2 + if node.param2 ~= final_param2 and rotation_param2 < 6 then + node.param2 = final_param2 + minetest.swap_node(pos, node) end end end, From 3590ff6dfba90496cdf4cf444668c15153e72673 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Sun, 12 Feb 2023 08:23:19 +0000 Subject: [PATCH 28/54] Improve some LBM code --- mods/MAPGEN/mcl_mapgen_core/init.lua | 38 ++++++++++------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index b5d0f343a..6aa216dcb 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -457,15 +457,10 @@ minetest.register_lbm({ nodenames = {"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"}, run_at_every_load = true, action = function(pos, node) - if mg_name ~= "v6" and mg_name ~= "singlenode" then - local biome_data = minetest.get_biome_data(pos) - local biome = biome_data.biome - local biome_name = minetest.get_biome_name(biome) - local reg_biome = minetest.registered_biomes[biome_name] - if node.param2 ~= reg_biome._mcl_grass_palette_index then - node.param2 = reg_biome._mcl_grass_palette_index - minetest.set_node(pos, node) - end + local reg_biome = mcl_util.get_registered_biome_from_pos(pos) + if node.param2 ~= reg_biome._mcl_grass_palette_index then + node.param2 = reg_biome._mcl_grass_palette_index + minetest.set_node(pos, node) end end, }) @@ -476,22 +471,17 @@ minetest.register_lbm({ nodenames = {"group:foliage_palette", "group:foliage_palette_wallmounted"}, run_at_every_load = true, action = function(pos, node) - if mg_name ~= "v6" and mg_name ~= "singlenode" then - local biome_data = minetest.get_biome_data(pos) - local biome = biome_data.biome - local biome_name = minetest.get_biome_name(biome) - local reg_biome = minetest.registered_biomes[biome_name] - if node.param2 ~= reg_biome._mcl_foliage_palette_index and node.name ~= "mcl_core:vine" then - node.param2 = reg_biome._mcl_foliage_palette_index + local reg_biome = mcl_util.get_registered_biome_from_pos(pos) + if node.param2 ~= reg_biome._mcl_foliage_palette_index and node.name ~= "mcl_core:vine" then + node.param2 = reg_biome._mcl_foliage_palette_index + minetest.set_node(pos, node) + elseif node.name == "mcl_core:vine" then + local biome_param2 = reg_biome._mcl_foliage_palette_index + local rotation_param2 = node.param2 + local final_param2 = (biome_param2 * 8) + rotation_param2 + if node.param2 ~= final_param2 and rotation_param2 < 6 then + node.param2 = final_param2 minetest.set_node(pos, node) - elseif node.name == "mcl_core:vine" then - local biome_param2 = reg_biome._mcl_foliage_palette_index - local rotation_param2 = node.param2 - local final_param2 = (biome_param2 * 8) + rotation_param2 - if node.param2 ~= final_param2 and rotation_param2 < 6 then - node.param2 = final_param2 - minetest.set_node(pos, node) - end end end end, From 0400d9a2a50d294185ccf7c3ddd7fa0ce47529c4 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Sun, 12 Feb 2023 08:28:21 +0000 Subject: [PATCH 29/54] Even further improvements to some foliage code --- mods/ITEMS/mcl_core/functions.lua | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index b34292d40..764cd7ef5 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -803,17 +803,7 @@ end local grass_spread_randomizer = PseudoRandom(minetest.get_mapgen_setting("seed")) function mcl_core.get_grass_palette_index(pos) - local biome_data = minetest.get_biome_data(pos) - local index = 0 - if biome_data then - local biome = biome_data.biome - local biome_name = minetest.get_biome_name(biome) - local reg_biome = minetest.registered_biomes[biome_name] - if reg_biome then - index = reg_biome._mcl_grass_palette_index - end - end - return index + return mcl_util.get_registered_biome_from_pos(pos)._mcl_grass_palette_index end -- Return appropriate grass block node for pos @@ -822,9 +812,7 @@ function mcl_core.get_grass_block_type(pos) end function mcl_core.get_foliage_palette_index(pos) - local reg_biome = mcl_util.get_registered_biome_from_pos(pos) - local index = reg_biome._mcl_foliage_palette_index - return index + return mcl_util.get_registered_biome_from_pos(pos)._mcl_foliage_palette_index end -- Return appropriate foliage block node for pos From a2087b19a5d324453b3895784ffc3ad6a3aad0ff Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Mon, 13 Feb 2023 10:20:48 +0000 Subject: [PATCH 30/54] Delete rogue file --- mods/ITEMS/nodes_trees.lua | 349 ------------------------------------- 1 file changed, 349 deletions(-) delete mode 100644 mods/ITEMS/nodes_trees.lua diff --git a/mods/ITEMS/nodes_trees.lua b/mods/ITEMS/nodes_trees.lua deleted file mode 100644 index 5c34cad87..000000000 --- a/mods/ITEMS/nodes_trees.lua +++ /dev/null @@ -1,349 +0,0 @@ --- Tree nodes: Wood, Wooden Planks, Sapling, Leaves, Stripped Wood -local S = minetest.get_translator(minetest.get_current_modname()) - -local mod_screwdriver = minetest.get_modpath("screwdriver") - -local on_rotate -if mod_screwdriver then - on_rotate = screwdriver.rotate_3way -end - --- Check dug/destroyed tree trunks for orphaned leaves. --- --- This function is meant to be called by the `after_destruct` handler of --- treetrunk nodes. --- --- Whenever a trunk node is removed, all `group:leaves` nodes in a sphere --- with radius 6 are checked. Every such node that does not have a trunk --- node within a distance of 6 blocks and wasn't placed by a player is --- converted into a orphan leaf node. --- An ABM will gradually decay these nodes. --- --- --- @param pos the position of the removed trunk node. --- @param oldnode the node table of the removed trunk node. -function mcl_core.update_leaves(pos, oldnode) - local pos1, pos2 = vector.offset(pos, -6, -6, -6), vector.offset(pos, 6, 6, 6) - local lnode - local leaves = minetest.find_nodes_in_area(pos1, pos2, "group:leaves") - for _, lpos in pairs(leaves) do - lnode = minetest.get_node(lpos) - -- skip already decaying leaf nodes and player leaves - if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 and minetest.get_item_group(lnode.name, "player_leaves") ~= 1 then - if not minetest.find_node_near(lpos, 6, "group:tree") then - local orphan_name = lnode.name .. "_orphan" - local def = minetest.registered_nodes[orphan_name] - if def then - --minetest.log("Registered: ".. orphan_name) - minetest.set_node(lpos, {name = orphan_name}) - else - --minetest.log("Not registered: ".. orphan_name) - end - end - end - end -end - -function mcl_core.make_player_leaves(pos) - local node = minetest.get_node(pos) - if minetest.get_item_group(node.name, "player_leaves") ~= 1 then - local playerleafname = node.name .. "_player" - minetest.set_node(pos, {name = playerleafname}) - end -end - --- Register tree trunk (wood) and bark -local function register_tree_trunk(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_variant) - minetest.register_node("mcl_core:"..subname, { - description = description_trunk, - _doc_items_longdesc = longdesc, - _doc_items_hidden = false, - tiles = {tile_inner, tile_inner, tile_bark}, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - after_destruct = mcl_core.update_leaves, - stack_max = 64, - groups = {handy=1,axey=1, tree=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - on_rotate = on_rotate, - _mcl_blast_resistance = 2, - _mcl_hardness = 2, - _mcl_stripped_variant = stripped_variant, - }) - - minetest.register_node("mcl_core:"..subname.."_bark", { - description = description_bark, - _doc_items_longdesc = S("This is a decorative block surrounded by the bark of a tree trunk."), - tiles = {tile_bark}, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - stack_max = 64, - groups = {handy=1,axey=1, bark=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - is_ground_content = false, - on_rotate = on_rotate, - _mcl_blast_resistance = 2, - _mcl_hardness = 2, - _mcl_stripped_variant = stripped_variant.."_bark", - }) - - minetest.register_craft({ - output = "mcl_core:"..subname.."_bark 3", - recipe = { - { "mcl_core:"..subname, "mcl_core:"..subname }, - { "mcl_core:"..subname, "mcl_core:"..subname }, - } - }) -end - --- Register stripped trunk and stripped wood -local function register_stripped_trunk(subname, description_stripped_trunk, description_stripped_bark, longdesc, longdesc_wood, tile_stripped_inner, tile_stripped_bark) - minetest.register_node("mcl_core:"..subname, { - description = description_stripped_trunk, - _doc_items_longdesc = longdesc, - _doc_items_hidden = false, - tiles = {tile_stripped_inner, tile_stripped_inner, tile_stripped_bark}, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - stack_max = 64, - groups = {handy=1, axey=1, tree=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - on_rotate = on_rotate, - _mcl_blast_resistance = 2, - _mcl_hardness = 2, - }) - - minetest.register_node("mcl_core:"..subname.."_bark", { - description = description_stripped_bark, - _doc_items_longdesc = longdesc_wood, - tiles = {tile_stripped_bark}, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - stack_max = 64, - groups = {handy=1, axey=1, bark=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - is_ground_content = false, - on_rotate = on_rotate, - _mcl_blast_resistance = 2, - _mcl_hardness = 2, - }) - - minetest.register_craft({ - output = "mcl_core:"..subname.."_bark 3", - recipe = { - { "mcl_core:"..subname, "mcl_core:"..subname }, - { "mcl_core:"..subname, "mcl_core:"..subname }, - } - }) -end - -local function register_wooden_planks(subname, description, tiles) - minetest.register_node("mcl_core:"..subname, { - description = description, - _doc_items_longdesc = doc.sub.items.temp.build, - _doc_items_hidden = false, - tiles = tiles, - stack_max = 64, - is_ground_content = false, - groups = {handy=1,axey=1, flammable=3,wood=1,building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=20}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 3, - _mcl_hardness = 2, - }) -end - -local function register_leaves(subname, description, longdesc, tiles, color, paramtype2, sapling, drop_apples, sapling_chances, foliage_palette) - local apple_chances = {200, 180, 160, 120, 40} - local stick_chances = {50, 45, 30, 35, 10} - - local function get_drops(fortune_level) - local drop = { - max_items = 1, - items = { - { - items = {sapling}, - rarity = sapling_chances[fortune_level + 1] or sapling_chances[fortune_level] - }, - { - items = {"mcl_core:stick 1"}, - rarity = stick_chances[fortune_level + 1] - }, - { - items = {"mcl_core:stick 2"}, - rarity = stick_chances[fortune_level + 1] - }, - } - } - if drop_apples then - table.insert(drop.items, { - items = {"mcl_core:apple"}, - rarity = apple_chances[fortune_level + 1] - }) - end - return drop - end - - local pl_def = { - description = description, - _doc_items_longdesc = longdesc, - _doc_items_hidden = false, - drawtype = "allfaces_optional", - waving = 2, - tiles = tiles, - color = color, - paramtype = "light", - paramtype2 = paramtype2, - palette = "mcl_core_palette_foliage.png", - stack_max = 64, - groups = { - handy = 1, hoey = 1, shearsy = 1, swordy = 1, dig_by_piston = 1, - flammable = 2, fire_encouragement = 30, fire_flammability = 60, - leaves = 1, deco_block = 1, compostability = 30, foliage_palette = foliage_palette, player_leaves = 1, not_in_creative_inventory = 0, - }, - drop = get_drops(0), - _mcl_shears_drop = true, - sounds = mcl_sounds.node_sound_leaves_defaults(), - _mcl_blast_resistance = 0.2, - _mcl_hardness = 0.2, - _mcl_silk_touch_drop = true, - _mcl_fortune_drop = { get_drops(1), get_drops(2), get_drops(3), get_drops(4) }, - on_construct = function(pos) - local node = minetest.get_node(pos) - if node.param2 == 0 then - local new_node = mcl_core.get_foliage_block_type(pos) - if new_node.param2 ~= 0 then - minetest.swap_node(pos, new_node) - end - end - end, - after_place_node = function(pos) - mcl_core.make_player_leaves(pos) -- Leaves placed by the player should always be player leaves. - end, - } - - minetest.register_node("mcl_core:" .. subname .. "_player", pl_def) - - local l_def = table.copy(pl_def) - l_def.groups.player_leaves = nil - l_def.groups.not_in_creative_inventory = 1 - l_def._mcl_shears_drop = {"mcl_core:player" .. subname} - l_def._mcl_silk_touch_drop = {"mcl_core:player" .. subname} - - minetest.register_node("mcl_core:" .. subname, l_def) - - local o_def = table.copy(l_def) - o_def._doc_items_create_entry = false - o_def.groups.not_in_creative_inventory = 1 - o_def.groups.orphan_leaves = 1 - o_def._mcl_shears_drop = {"mcl_core:player" .. subname} - o_def._mcl_silk_touch_drop = {"mcl_core:player" .. subname} - - minetest.register_node("mcl_core:" .. subname .. "_orphan", o_def) -end - -local function register_sapling(subname, description, longdesc, tt_help, texture, selbox) - minetest.register_node("mcl_core:"..subname, { - description = description, - _tt_help = tt_help, - _doc_items_longdesc = longdesc, - _doc_items_hidden = false, - drawtype = "plantlike", - waving = 1, - visual_scale = 1.0, - tiles = {texture}, - inventory_image = texture, - wield_image = texture, - paramtype = "light", - sunlight_propagates = true, - walkable = false, - selection_box = { - type = "fixed", - fixed = selbox - }, - stack_max = 64, - groups = { - plant = 1, sapling = 1, non_mycelium_plant = 1, attached_node = 1, - deco_block = 1, dig_immediate = 3, dig_by_water = 1, dig_by_piston = 1, - destroy_by_lava_flow = 1, compostability = 30 - }, - sounds = mcl_sounds.node_sound_leaves_defaults(), - on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_int("stage", 0) - end, - on_place = mcl_util.generate_on_place_plant_function(function(pos, node) - local node_below = minetest.get_node_or_nil({x=pos.x,y=pos.y-1,z=pos.z}) - if not node_below then return false end - local nn = node_below.name - return minetest.get_item_group(nn, "grass_block") == 1 or - nn == "mcl_core:podzol" or nn == "mcl_core:podzol_snow" or - nn == "mcl_core:dirt" or nn == "mcl_core:mycelium" or nn == "mcl_core:coarse_dirt" - end), - node_placement_prediction = "", - _mcl_blast_resistance = 0, - _mcl_hardness = 0, - }) -end - ---------------------- - -register_tree_trunk("tree", S("Oak Wood"), S("Oak Bark"), S("The trunk of an oak tree."), "default_tree_top.png", "default_tree.png", "mcl_core:stripped_oak") -register_tree_trunk("darktree", S("Dark Oak Wood"), S("Dark Oak Bark"), S("The trunk of a dark oak tree."), "mcl_core_log_big_oak_top.png", "mcl_core_log_big_oak.png", "mcl_core:stripped_dark_oak") -register_tree_trunk("acaciatree", S("Acacia Wood"), S("Acacia Bark"), S("The trunk of an acacia."), "default_acacia_tree_top.png", "default_acacia_tree.png", "mcl_core:stripped_acacia") -register_tree_trunk("sprucetree", S("Spruce Wood"), S("Spruce Bark"), S("The trunk of a spruce tree."), "mcl_core_log_spruce_top.png", "mcl_core_log_spruce.png", "mcl_core:stripped_spruce") -register_tree_trunk("birchtree", S("Birch Wood"), S("Birch Bark"), S("The trunk of a birch tree."), "mcl_core_log_birch_top.png", "mcl_core_log_birch.png", "mcl_core:stripped_birch") -register_tree_trunk("jungletree", S("Jungle Wood"), S("Jungle Bark"), S("The trunk of a jungle tree."), "default_jungletree_top.png", "default_jungletree.png", "mcl_core:stripped_jungle") - -register_stripped_trunk("stripped_oak", S("Stripped Oak Log"), S("Stripped Oak Wood"), S("The stripped trunk of an oak tree."), S("The stripped wood of an oak tree."), "mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_side.png") -register_stripped_trunk("stripped_acacia", S("Stripped Acacia Log"), S("Stripped Acacia Wood"), S("The stripped trunk of an acacia tree."), S("The stripped wood of an acacia tree."), "mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_side.png") -register_stripped_trunk("stripped_dark_oak", S("Stripped Dark Oak Log"), S("Stripped Dark Oak Wood"), S("The stripped trunk of a dark oak tree."), S("The stripped wood of a dark oak tree."), "mcl_core_stripped_dark_oak_top.png", "mcl_core_stripped_dark_oak_side.png") -register_stripped_trunk("stripped_birch", S("Stripped Birch Log"), S("Stripped Birch Wood"), S("The stripped trunk of a birch tree."), S("The stripped wood of a birch tree."), "mcl_core_stripped_birch_top.png", "mcl_core_stripped_birch_side.png") -register_stripped_trunk("stripped_spruce", S("Stripped Spruce Log"), S("Stripped Spruce Wood"), S("The stripped trunk of a spruce tree."), S("The stripped wood of a spruce tree."), "mcl_core_stripped_spruce_top.png", "mcl_core_stripped_spruce_side.png") -register_stripped_trunk("stripped_jungle", S("Stripped Jungle Log"), S("Stripped Jungle Wood"), S("The stripped trunk of a jungle tree."), S("The stripped wood of a jungle tree."),"mcl_core_stripped_jungle_top.png", "mcl_core_stripped_jungle_side.png") -register_wooden_planks("wood", S("Oak Wood Planks"), {"default_wood.png"}) -register_wooden_planks("darkwood", S("Dark Oak Wood Planks"), {"mcl_core_planks_big_oak.png"}) -register_wooden_planks("junglewood", S("Jungle Wood Planks"), {"default_junglewood.png"}) -register_wooden_planks("sprucewood", S("Spruce Wood Planks"), {"mcl_core_planks_spruce.png"}) -register_wooden_planks("acaciawood", S("Acacia Wood Planks"), {"default_acacia_wood.png"}) -register_wooden_planks("birchwood", S("Birch Wood Planks"), {"mcl_core_planks_birch.png"}) - - -register_sapling("sapling", S("Oak Sapling"), - S("When placed on soil (such as dirt) and exposed to light, an oak sapling will grow into an oak after some time."), - S("Needs soil and light to grow"), - "default_sapling.png", {-5/16, -0.5, -5/16, 5/16, 0.5, 5/16}) -register_sapling("darksapling", S("Dark Oak Sapling"), - S("Dark oak saplings can grow into dark oaks, but only in groups. A lonely dark oak sapling won't grow. A group of four dark oak saplings grows into a dark oak after some time when they are placed on soil (such as dirt) in a 2×2 square and exposed to light."), - S("Needs soil and light to grow") .. "\n" .. S("2×2 saplings required"), - "mcl_core_sapling_big_oak.png", {-5/16, -0.5, -5/16, 5/16, 7/16, 5/16}) -register_sapling("junglesapling", S("Jungle Sapling"), - S("When placed on soil (such as dirt) and exposed to light, a jungle sapling will grow into a jungle tree after some time. When there are 4 jungle saplings in a 2×2 square, they will grow to a huge jungle tree."), - S("Needs soil and light to grow") .. "\n" .. S("2×2 saplings = large tree"), - "default_junglesapling.png", {-5/16, -0.5, -5/16, 5/16, 0.5, 5/16}) -register_sapling("acaciasapling", S("Acacia Sapling"), - S("When placed on soil (such as dirt) and exposed to light, an acacia sapling will grow into an acacia after some time."), - S("Needs soil and light to grow"), - "default_acacia_sapling.png", {-5/16, -0.5, -5/16, 5/16, 4/16, 5/16}) -register_sapling("sprucesapling", S("Spruce Sapling"), - S("When placed on soil (such as dirt) and exposed to light, a spruce sapling will grow into a spruce after some time. When there are 4 spruce saplings in a 2×2 square, they will grow to a huge spruce."), - S("Needs soil and light to grow") .. "\n" .. S("2×2 saplings = large tree"), - "mcl_core_sapling_spruce.png", {-4/16, -0.5, -4/16, 4/16, 0.5, 4/16}) -register_sapling("birchsapling", S("Birch Sapling"), - S("When placed on soil (such as dirt) and exposed to light, a birch sapling will grow into a birch after some time."), - S("Needs soil and light to grow"), - "mcl_core_sapling_birch.png", {-4/16, -0.5, -4/16, 4/16, 0.5, 4/16}) - - -register_leaves("leaves", S("Oak Leaves"), S("Oak leaves are grown from oak trees."), {"default_leaves.png"}, "#48B518", "color", "mcl_core:sapling", true, {20, 16, 12, 10}, 1) -register_leaves("darkleaves", S("Dark Oak Leaves"), S("Dark oak leaves are grown from dark oak trees."), {"mcl_core_leaves_big_oak.png"}, "#48B518", "color", "mcl_core:darksapling", true, {20, 16, 12, 10}, 1) -register_leaves("jungleleaves", S("Jungle Leaves"), S("Jungle leaves are grown from jungle trees."), {"default_jungleleaves.png"}, "#48B518", "color", "mcl_core:junglesapling", false, {40, 26, 32, 24, 10}, 1) -register_leaves("acacialeaves", S("Acacia Leaves"), S("Acacia leaves are grown from acacia trees."), {"default_acacia_leaves.png"}, "#48B518", "color", "mcl_core:acaciasapling", false, {20, 16, 12, 10}, 1) -register_leaves("spruceleaves", S("Spruce Leaves"), S("Spruce leaves are grown from spruce trees."), {"mcl_core_leaves_spruce.png"}, "#619961", "none", "mcl_core:sprucesapling", false, {20, 16, 12, 10}, 0) -register_leaves("birchleaves", S("Birch Leaves"), S("Birch leaves are grown from birch trees."), {"mcl_core_leaves_birch.png"}, "#80A755", "none", "mcl_core:birchsapling", false, {20, 16, 12, 10}, 0) - - - --- Node aliases - -minetest.register_alias("default:acacia_tree", "mcl_core:acaciatree") -minetest.register_alias("default:acacia_leaves", "mcl_core:acacialeaves") From 4d29fab932560e3697b0e6adb9601365c04ca50e Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Mon, 13 Feb 2023 10:22:28 +0000 Subject: [PATCH 31/54] Improve some trees code --- mods/ITEMS/mcl_core/nodes_trees.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index a4413c17a..687c6a1ef 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -28,8 +28,8 @@ function mcl_core.update_leaves(pos, oldnode) local leaves = minetest.find_nodes_in_area(pos1, pos2, "group:leaves") for _, lpos in pairs(leaves) do lnode = minetest.get_node(lpos) - -- skip already decaying leaf nodes and player leaves - if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 and minetest.get_item_group(lnode.name, "player_leaves") ~= 1 then + -- skip already decaying leaf nodes + if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 then if not minetest.find_node_near(lpos, 6, "group:tree") then local orphan_name = lnode.name .. "_orphan" local def = minetest.registered_nodes[orphan_name] From 1c84bc657266c5dd0803b676751201927d66f458 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Mon, 13 Feb 2023 10:33:47 +0000 Subject: [PATCH 32/54] Put all affected grass blocks in a local This commit puts all nodes which make use of the grass palette in a local, to make for less messy code. --- mods/MAPGEN/mcl_mapgen_core/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 6aa216dcb..d3385ee91 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -365,13 +365,15 @@ local function world_structure(vm, data, data2, emin, emax, area, minp, maxp, bl return lvm_used, lvm_used, deco, ores end +local affected_grass_blocks = {"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"} + local function block_fixes_grass(vm, data, data2, emin, emax, area, minp, maxp, blockseed) local biomemap = minetest.get_mapgen_object("biomemap") local lvm_used = false local pr = PseudoRandom(blockseed) if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then -- Set param2 (=color) of nodes which use the grass colour palette. - lvm_used = set_grass_palette(minp,maxp,data2,area,biomemap,{"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"}) + lvm_used = set_grass_palette(minp,maxp,data2,area,biomemap,affected_grass_blocks) end return lvm_used end @@ -454,7 +456,7 @@ end, 100, true) minetest.register_lbm({ label = "Fix grass palette indexes", -- This LBM fixes any incorrect grass palette indexes. name = "mcl_mapgen_core:fix_grass_palette_indexes", - nodenames = {"mcl_core:dirt_with_grass", "mcl_flowers:tallgrass", "mcl_flowers:double_grass", "mcl_flowers:double_grass_top", "mcl_flowers:fern", "mcl_flowers:double_fern", "mcl_flowers:double_fern_top", "mcl_core:reeds", "mcl_core:dirt_with_grass_snow"}, + nodenames = affected_grass_blocks, run_at_every_load = true, action = function(pos, node) local reg_biome = mcl_util.get_registered_biome_from_pos(pos) From 17cae6896e36d34eda3a2c74679062f7b159f7c6 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Mon, 13 Feb 2023 11:17:51 +0000 Subject: [PATCH 33/54] Add back the logical code? My gut feeling tells me that it is somehow a bad idea to have removed this. --- mods/ITEMS/mcl_core/nodes_trees.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index 687c6a1ef..a4413c17a 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -28,8 +28,8 @@ function mcl_core.update_leaves(pos, oldnode) local leaves = minetest.find_nodes_in_area(pos1, pos2, "group:leaves") for _, lpos in pairs(leaves) do lnode = minetest.get_node(lpos) - -- skip already decaying leaf nodes - if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 then + -- skip already decaying leaf nodes and player leaves + if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 and minetest.get_item_group(lnode.name, "player_leaves") ~= 1 then if not minetest.find_node_near(lpos, 6, "group:tree") then local orphan_name = lnode.name .. "_orphan" local def = minetest.registered_nodes[orphan_name] From e17fab385bda7509342ddd4e86129d259709b552 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Mon, 13 Feb 2023 15:44:23 +0000 Subject: [PATCH 34/54] Add nil checks --- mods/ITEMS/mcl_core/functions.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index c03d9d66e..ef35bc549 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -803,7 +803,12 @@ end local grass_spread_randomizer = PseudoRandom(minetest.get_mapgen_setting("seed")) function mcl_core.get_grass_palette_index(pos) - return mcl_util.get_registered_biome_from_pos(pos)._mcl_grass_palette_index + local reg_biome = mcl_util.get_registered_biome_from_pos(pos) + if reg_biome and reg_biome._mcl_grass_palette_index then + return reg_biome._mcl_grass_palette_index + else + return index + end end -- Return appropriate grass block node for pos @@ -812,7 +817,12 @@ function mcl_core.get_grass_block_type(pos) end function mcl_core.get_foliage_palette_index(pos) - return mcl_util.get_registered_biome_from_pos(pos)._mcl_foliage_palette_index + local reg_biome = mcl_util.get_registered_biome_from_pos(pos) + if reg_biome and reg_biome._mcl_foliage_palette_index then + return reg_biome._mcl_foliage_palette_index + else + return index + end end -- Return appropriate foliage block node for pos From abdd5e11c068db01d00a5910e3b4f211cf675cf9 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Mon, 13 Feb 2023 15:46:08 +0000 Subject: [PATCH 35/54] Shorten code slightly --- mods/ITEMS/mcl_core/functions.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index ef35bc549..1ea741382 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -806,8 +806,6 @@ function mcl_core.get_grass_palette_index(pos) local reg_biome = mcl_util.get_registered_biome_from_pos(pos) if reg_biome and reg_biome._mcl_grass_palette_index then return reg_biome._mcl_grass_palette_index - else - return index end end @@ -820,8 +818,6 @@ function mcl_core.get_foliage_palette_index(pos) local reg_biome = mcl_util.get_registered_biome_from_pos(pos) if reg_biome and reg_biome._mcl_foliage_palette_index then return reg_biome._mcl_foliage_palette_index - else - return index end end From 3a24903a01aafde15c1d137a8c0140e98290993f Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Mon, 13 Feb 2023 15:46:45 +0000 Subject: [PATCH 36/54] Add nil check --- mods/ITEMS/mcl_core/nodes_climb.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_climb.lua b/mods/ITEMS/mcl_core/nodes_climb.lua index 005cd8b5a..a47a533aa 100644 --- a/mods/ITEMS/mcl_core/nodes_climb.lua +++ b/mods/ITEMS/mcl_core/nodes_climb.lua @@ -160,16 +160,16 @@ minetest.register_node("mcl_core:vine", { on_construct = function(pos) local node = minetest.get_node(pos) local reg_biome = mcl_util.get_registered_biome_from_pos(pos) - if node.name == "mcl_core:vine" then + if node.name == "mcl_core:vine" and reg_biome and reg_biome._mcl_foliage_palette_index then local biome_param2 = reg_biome._mcl_foliage_palette_index local rotation_param2 = node.param2 local final_param2 = (biome_param2 * 8) + rotation_param2 if node.param2 ~= final_param2 and rotation_param2 < 6 then node.param2 = final_param2 minetest.swap_node(pos, node) + end end - end -end, + end, -- If dug, also dig a “dependant” vine below it. -- A vine is dependant if it hangs from this node and has no supporting block. From 2ccfd8937924ed35374f3121bdeeddb9b4896060 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Mon, 13 Feb 2023 15:49:19 +0000 Subject: [PATCH 37/54] Add nil checks --- mods/MAPGEN/mcl_mapgen_core/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index d3385ee91..475a9723a 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -460,7 +460,7 @@ minetest.register_lbm({ run_at_every_load = true, action = function(pos, node) local reg_biome = mcl_util.get_registered_biome_from_pos(pos) - if node.param2 ~= reg_biome._mcl_grass_palette_index then + if reg_biome and reg_biome._mcl_grass_palette_index and node.param2 ~= reg_biome._mcl_grass_palette_index then node.param2 = reg_biome._mcl_grass_palette_index minetest.set_node(pos, node) end @@ -474,7 +474,7 @@ minetest.register_lbm({ run_at_every_load = true, action = function(pos, node) local reg_biome = mcl_util.get_registered_biome_from_pos(pos) - if node.param2 ~= reg_biome._mcl_foliage_palette_index and node.name ~= "mcl_core:vine" then + if reg_biome and reg_biome._mcl_foliage_palette_index and node.param2 ~= reg_biome._mcl_foliage_palette_index and node.name ~= "mcl_core:vine" then node.param2 = reg_biome._mcl_foliage_palette_index minetest.set_node(pos, node) elseif node.name == "mcl_core:vine" then From aeddb7675ffca9a7220ad0ccf9810a225802eb20 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Mon, 13 Feb 2023 18:50:26 +0000 Subject: [PATCH 38/54] Don't run LBMs at every load This commit makes it so the LBMs don't run at every load. This commit also adds some new `minetest.register_on_generated()` code, which should ensure that any newly generated mapblocks have the correct foliage colours. --- mods/MAPGEN/mcl_mapgen_core/init.lua | 60 ++++++++++++---------------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 475a9723a..407660ecb 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -289,27 +289,6 @@ local function set_grass_palette(minp,maxp,data2,area,biomemap,nodes) return lvm_used end -local function set_foliage_palette(minp,maxp,data2,area,biomemap,nodes) - -- Flat area at y=0 to read biome 3 times faster than 5.3.0.get_biome_data(pos).biome: 43us vs 125us per iteration: - if not biomemap then return end - local aream = VoxelArea:new({MinEdge={x=minp.x, y=0, z=minp.z}, MaxEdge={x=maxp.x, y=0, z=maxp.z}}) - local nodes = minetest.find_nodes_in_area(minp, maxp, nodes) - for n=1, #nodes do - local n = nodes[n] - local p_pos = area:index(n.x, n.y, n.z) - local b_pos = aream:index(n.x, 0, n.z) - local bn = minetest.get_biome_name(biomemap[b_pos]) - if bn then - local biome = minetest.registered_biomes[bn] - if biome and biome._mcl_biome_type and biome._mcl_foliage_palette_index then - data2[p_pos] = biome._mcl_foliage_palette_index - lvm_used = true - end - end - end - return lvm_used -end - -- Below the bedrock, generate air/void local function world_structure(vm, data, data2, emin, emax, area, minp, maxp, blockseed) local biomemap --ymin, ymax @@ -378,17 +357,6 @@ local function block_fixes_grass(vm, data, data2, emin, emax, area, minp, maxp, return lvm_used end -local function block_fixes_foliage(vm, data, data2, emin, emax, area, minp, maxp, blockseed) - local biomemap = minetest.get_mapgen_object("biomemap") - local lvm_used = false - local pr = PseudoRandom(blockseed) - if minp.y <= mcl_vars.mg_overworld_max and maxp.y >= mcl_vars.mg_overworld_min then - -- Set param2 (=color) of nodes which use the foliage colour palette. - lvm_used = set_foliage_palette(minp,maxp,data2,area,biomemap,{"group:foliage_palette"}) - end - return lvm_used -end - -- End block fixes: local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed) @@ -417,7 +385,6 @@ end, 9999, true) if mg_name ~= "v6" and mg_name ~= "singlenode" then mcl_mapgen_core.register_generator("block_fixes_grass", block_fixes_grass, nil, 9999, true) - mcl_mapgen_core.register_generator("block_fixes_foliage", block_fixes_foliage, nil, 9999, true) end if mg_name == "v6" then @@ -457,7 +424,7 @@ minetest.register_lbm({ label = "Fix grass palette indexes", -- This LBM fixes any incorrect grass palette indexes. name = "mcl_mapgen_core:fix_grass_palette_indexes", nodenames = affected_grass_blocks, - run_at_every_load = true, + run_at_every_load = false, action = function(pos, node) local reg_biome = mcl_util.get_registered_biome_from_pos(pos) if reg_biome and reg_biome._mcl_grass_palette_index and node.param2 ~= reg_biome._mcl_grass_palette_index then @@ -471,7 +438,7 @@ minetest.register_lbm({ label = "Fix foliage palette indexes", -- This LBM fixes any incorrect foliage palette indexes name = "mcl_mapgen_core:fix_foliage_palette_indexes", nodenames = {"group:foliage_palette", "group:foliage_palette_wallmounted"}, - run_at_every_load = true, + run_at_every_load = false, action = function(pos, node) local reg_biome = mcl_util.get_registered_biome_from_pos(pos) if reg_biome and reg_biome._mcl_foliage_palette_index and node.param2 ~= reg_biome._mcl_foliage_palette_index and node.name ~= "mcl_core:vine" then @@ -488,3 +455,26 @@ minetest.register_lbm({ end end, }) + +minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct palette indexes of foliage in brand new mapblocks. + local pos1, pos2 = vector.offset(minp, -16, -16, -16), vector.offset(maxp, 16, 16, 16) + local fnode + local foliage = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) + for _, fpos in pairs(foliage) do + fnode = minetest.get_node(fpos) + reg_biome = mcl_util.get_registered_biome_from_pos(fpos) + if reg_biome and reg_biome._mcl_foliage_palette_index and fnode.param2 ~= reg_biome._mcl_foliage_palette_index and fnode.name ~= "mcl_core:vine" then + fnode.param2 = reg_biome._mcl_foliage_palette_index + minetest.set_node(fpos, fnode) + elseif fnode.name == "mcl_core:vine" then + local biome_param2 = reg_biome._mcl_foliage_palette_index + local rotation_param2 = fnode.param2 + local final_param2 = (biome_param2 * 8) + rotation_param2 + if fnode.param2 ~= final_param2 and rotation_param2 < 6 then + fnode.param2 = final_param2 + minetest.set_node(fpos, fnode) + end + end + end +end +) From 7b7e213925fa0d8c3c93951725b3920492eed3f5 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Tue, 14 Feb 2023 08:12:55 +0000 Subject: [PATCH 39/54] Fix mcl_util.get_registered_biome_from_pos(pos) Adds something which was missing from the function. --- mods/CORE/mcl_util/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 8c12c1557..d4f83227f 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -1018,11 +1018,12 @@ function mcl_util.check_position_protection(position, player) end function mcl_util.get_registered_biome_from_pos(pos) + local mg_name = minetest.get_mapgen_setting("mg_name") if mg_name ~= "v6" and mg_name ~= "singlenode" then local biome_data = minetest.get_biome_data(pos) local biome = biome_data.biome local biome_name = minetest.get_biome_name(biome) local reg_biome = minetest.registered_biomes[biome_name] - return reg_biome + return reg_biome end end From f653f47f262f645e08366fa04286f6a1621439ac Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Tue, 14 Feb 2023 08:36:49 +0000 Subject: [PATCH 40/54] Improve the new code somewhat --- mods/MAPGEN/mcl_mapgen_core/init.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 407660ecb..2dc92da5d 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -458,11 +458,10 @@ minetest.register_lbm({ minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct palette indexes of foliage in brand new mapblocks. local pos1, pos2 = vector.offset(minp, -16, -16, -16), vector.offset(maxp, 16, 16, 16) - local fnode local foliage = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) for _, fpos in pairs(foliage) do - fnode = minetest.get_node(fpos) - reg_biome = mcl_util.get_registered_biome_from_pos(fpos) + local fnode = minetest.get_node(fpos) + local reg_biome = mcl_util.get_registered_biome_from_pos(fpos) if reg_biome and reg_biome._mcl_foliage_palette_index and fnode.param2 ~= reg_biome._mcl_foliage_palette_index and fnode.name ~= "mcl_core:vine" then fnode.param2 = reg_biome._mcl_foliage_palette_index minetest.set_node(fpos, fnode) From fee4ccf096d30f79fb07126cf000304d33d0a688 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Tue, 14 Feb 2023 11:20:00 +0000 Subject: [PATCH 41/54] Convert old player leaves into new system This commit adds a couple of lines to the `mcl_mapgen_core:fix_foliage_palette_indexes"` LBM, which ensures that player leaves which were placed before this update get converted into the new player leaves. I would have included mangrove leaves, but decided against it because of an issue where the `param2` of mangrove leaves was accidentally set to 1 (in the schematics?). This meant that if I included mangrove leaves, the LBM would have converted the natural leaves as well. This would have made it very tedious to clean up the leaves after chopping down a mangrove tree, since these would not rot by themselves. --- mods/MAPGEN/mcl_mapgen_core/init.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 2dc92da5d..15d89d6f9 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -435,13 +435,18 @@ minetest.register_lbm({ }) minetest.register_lbm({ - label = "Fix foliage palette indexes", -- This LBM fixes any incorrect foliage palette indexes + label = "Fix foliage palette indexes", -- Set correct palette indexes of foliage in old mapblocks. name = "mcl_mapgen_core:fix_foliage_palette_indexes", nodenames = {"group:foliage_palette", "group:foliage_palette_wallmounted"}, run_at_every_load = false, action = function(pos, node) local reg_biome = mcl_util.get_registered_biome_from_pos(pos) - if reg_biome and reg_biome._mcl_foliage_palette_index and node.param2 ~= reg_biome._mcl_foliage_palette_index and node.name ~= "mcl_core:vine" then + local noplconvert = {"mcl_mangrove:mangroveleaves", "mcl_core:vine"} -- These do not convert into player leaves. + if reg_biome and reg_biome._mcl_foliage_palette_index and node.param2 == 1 and node.name ~= noplconvert then -- Convert old player leaves into the new versions. + node.param2 = reg_biome._mcl_foliage_palette_index + minetest.remove_node(pos) -- Required, since otherwise this conversion won't work. + minetest.place_node(vector.offset(pos, 0, 1, 0), node) -- Offset required, since otherwise the leaves sink one node for some reason. + elseif reg_biome and reg_biome._mcl_foliage_palette_index and node.param2 ~= reg_biome._mcl_foliage_palette_index and node.name ~= "mcl_core:vine" then node.param2 = reg_biome._mcl_foliage_palette_index minetest.set_node(pos, node) elseif node.name == "mcl_core:vine" then @@ -456,7 +461,7 @@ minetest.register_lbm({ end, }) -minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct palette indexes of foliage in brand new mapblocks. +minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct palette indexes of foliage in new mapblocks. local pos1, pos2 = vector.offset(minp, -16, -16, -16), vector.offset(maxp, 16, 16, 16) local foliage = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) for _, fpos in pairs(foliage) do From 55478f6953e4a05ba83c0cfc2c61bb76e5cd701a Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Tue, 14 Feb 2023 14:01:14 +0000 Subject: [PATCH 42/54] Fix crash with mapgen v6 --- mods/CORE/mcl_util/init.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index d4f83227f..14949a7d7 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -1018,12 +1018,9 @@ function mcl_util.check_position_protection(position, player) end function mcl_util.get_registered_biome_from_pos(pos) - local mg_name = minetest.get_mapgen_setting("mg_name") - if mg_name ~= "v6" and mg_name ~= "singlenode" then - local biome_data = minetest.get_biome_data(pos) - local biome = biome_data.biome - local biome_name = minetest.get_biome_name(biome) - local reg_biome = minetest.registered_biomes[biome_name] - return reg_biome - end + local biome_data = minetest.get_biome_data(pos) + local biome = biome_data.biome + local biome_name = minetest.get_biome_name(biome) + local reg_biome = minetest.registered_biomes[biome_name] + return reg_biome end From fcaa2c4ce15a68cd575168125c383aea2514a1e5 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Tue, 14 Feb 2023 14:22:03 +0000 Subject: [PATCH 43/54] revert 55478f6953e4a05ba83c0cfc2c61bb76e5cd701a revert Fix crash with mapgen v6 --- mods/CORE/mcl_util/init.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 14949a7d7..d4f83227f 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -1018,9 +1018,12 @@ function mcl_util.check_position_protection(position, player) end function mcl_util.get_registered_biome_from_pos(pos) - local biome_data = minetest.get_biome_data(pos) - local biome = biome_data.biome - local biome_name = minetest.get_biome_name(biome) - local reg_biome = minetest.registered_biomes[biome_name] - return reg_biome + local mg_name = minetest.get_mapgen_setting("mg_name") + if mg_name ~= "v6" and mg_name ~= "singlenode" then + local biome_data = minetest.get_biome_data(pos) + local biome = biome_data.biome + local biome_name = minetest.get_biome_name(biome) + local reg_biome = minetest.registered_biomes[biome_name] + return reg_biome + end end From 8fd40eaf4636de3c4ca03776dd4523693b701f8d Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Tue, 14 Feb 2023 18:08:59 +0000 Subject: [PATCH 44/54] Replace get_registered_biome_from_pos with get_palette_indexes_from_pos --- mods/CORE/mcl_util/init.lua | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index d4f83227f..4889b7d0a 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -1017,13 +1017,18 @@ function mcl_util.check_position_protection(position, player) return false end -function mcl_util.get_registered_biome_from_pos(pos) - local mg_name = minetest.get_mapgen_setting("mg_name") - if mg_name ~= "v6" and mg_name ~= "singlenode" then - local biome_data = minetest.get_biome_data(pos) - local biome = biome_data.biome - local biome_name = minetest.get_biome_name(biome) - local reg_biome = minetest.registered_biomes[biome_name] - return reg_biome +function mcl_util.get_palette_indexes_from_pos(pos) + local palette_indexes = {grass_palette_index = 0, foliage_palette_index = 0} + local biome_data = minetest.get_biome_data(pos) + local biome = biome_data.biome + local biome_name = minetest.get_biome_name(biome) + local reg_biome = minetest.registered_biomes[biome_name] + if reg_biome then + local gpi = reg_biome._mcl_grass_palette_index + local fpi = reg_biome._mcl_foliage_palette_index + local palette_indexes = {grass_palette_index = gpi, foliage_palette_index = fpi} + return palette_indexes + else + return palette_indexes end end From bea9bbe212c5d97c33a54ed6b93ce6a0ebde5d70 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Tue, 14 Feb 2023 18:10:49 +0000 Subject: [PATCH 45/54] Improve certain functions --- mods/ITEMS/mcl_core/functions.lua | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index 1ea741382..7eecd2238 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -803,10 +803,8 @@ end local grass_spread_randomizer = PseudoRandom(minetest.get_mapgen_setting("seed")) function mcl_core.get_grass_palette_index(pos) - local reg_biome = mcl_util.get_registered_biome_from_pos(pos) - if reg_biome and reg_biome._mcl_grass_palette_index then - return reg_biome._mcl_grass_palette_index - end + local grass_palette_index = mcl_util.get_palette_indexes_from_pos(pos).grass_palette_index + return grass_palette_index end -- Return appropriate grass block node for pos @@ -815,10 +813,8 @@ function mcl_core.get_grass_block_type(pos) end function mcl_core.get_foliage_palette_index(pos) - local reg_biome = mcl_util.get_registered_biome_from_pos(pos) - if reg_biome and reg_biome._mcl_foliage_palette_index then - return reg_biome._mcl_foliage_palette_index - end + local foliage_palette_index = mcl_util.get_palette_indexes_from_pos(pos).foliage_palette_index + return foliage_palette_index end -- Return appropriate foliage block node for pos From 319beb91ce2bf65940dcf036f5ead3a54e4a22e9 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Tue, 14 Feb 2023 18:11:43 +0000 Subject: [PATCH 46/54] Improve vines code --- mods/ITEMS/mcl_core/nodes_climb.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_climb.lua b/mods/ITEMS/mcl_core/nodes_climb.lua index a47a533aa..33a34f899 100644 --- a/mods/ITEMS/mcl_core/nodes_climb.lua +++ b/mods/ITEMS/mcl_core/nodes_climb.lua @@ -159,9 +159,9 @@ minetest.register_node("mcl_core:vine", { on_construct = function(pos) local node = minetest.get_node(pos) - local reg_biome = mcl_util.get_registered_biome_from_pos(pos) - if node.name == "mcl_core:vine" and reg_biome and reg_biome._mcl_foliage_palette_index then - local biome_param2 = reg_biome._mcl_foliage_palette_index + local foliage_palette_index = mcl_util.get_palette_indexes_from_pos(pos).foliage_palette_index + if node.name == "mcl_core:vine" then + local biome_param2 = foliage_palette_index local rotation_param2 = node.param2 local final_param2 = (biome_param2 * 8) + rotation_param2 if node.param2 ~= final_param2 and rotation_param2 < 6 then From f919f73c24e0b339d86029668231f54ca88f2c27 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Tue, 14 Feb 2023 18:14:10 +0000 Subject: [PATCH 47/54] Improve some code --- mods/MAPGEN/mcl_mapgen_core/init.lua | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 15d89d6f9..f3e95bc81 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -426,9 +426,9 @@ minetest.register_lbm({ nodenames = affected_grass_blocks, run_at_every_load = false, action = function(pos, node) - local reg_biome = mcl_util.get_registered_biome_from_pos(pos) - if reg_biome and reg_biome._mcl_grass_palette_index and node.param2 ~= reg_biome._mcl_grass_palette_index then - node.param2 = reg_biome._mcl_grass_palette_index + local grass_palette_index = mcl_util.get_palette_indexes_from_pos(pos).grass_palette_index + if node.param2 ~= grass_palette_index then + node.param2 = grass_palette_index minetest.set_node(pos, node) end end, @@ -440,17 +440,17 @@ minetest.register_lbm({ nodenames = {"group:foliage_palette", "group:foliage_palette_wallmounted"}, run_at_every_load = false, action = function(pos, node) - local reg_biome = mcl_util.get_registered_biome_from_pos(pos) + local foliage_palette_index = mcl_util.get_palette_indexes_from_pos(pos).foliage_palette_index local noplconvert = {"mcl_mangrove:mangroveleaves", "mcl_core:vine"} -- These do not convert into player leaves. - if reg_biome and reg_biome._mcl_foliage_palette_index and node.param2 == 1 and node.name ~= noplconvert then -- Convert old player leaves into the new versions. - node.param2 = reg_biome._mcl_foliage_palette_index + if node.param2 == 1 and node.name ~= noplconvert then -- Convert old player leaves into the new versions. + node.param2 = foliage_palette_index minetest.remove_node(pos) -- Required, since otherwise this conversion won't work. minetest.place_node(vector.offset(pos, 0, 1, 0), node) -- Offset required, since otherwise the leaves sink one node for some reason. - elseif reg_biome and reg_biome._mcl_foliage_palette_index and node.param2 ~= reg_biome._mcl_foliage_palette_index and node.name ~= "mcl_core:vine" then - node.param2 = reg_biome._mcl_foliage_palette_index + elseif node.param2 ~= foliage_palette_index and node.name ~= "mcl_core:vine" then + node.param2 = foliage_palette_index minetest.set_node(pos, node) - elseif node.name == "mcl_core:vine" then - local biome_param2 = reg_biome._mcl_foliage_palette_index + elseif node.param2 ~= foliage_palette_index and node.name == "mcl_core:vine" then + local biome_param2 = foliage_palette_index local rotation_param2 = node.param2 local final_param2 = (biome_param2 * 8) + rotation_param2 if node.param2 ~= final_param2 and rotation_param2 < 6 then @@ -466,12 +466,12 @@ minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct pa local foliage = minetest.find_nodes_in_area(pos1, pos2, {"group:foliage_palette", "group:foliage_palette_wallmounted"}) for _, fpos in pairs(foliage) do local fnode = minetest.get_node(fpos) - local reg_biome = mcl_util.get_registered_biome_from_pos(fpos) - if reg_biome and reg_biome._mcl_foliage_palette_index and fnode.param2 ~= reg_biome._mcl_foliage_palette_index and fnode.name ~= "mcl_core:vine" then - fnode.param2 = reg_biome._mcl_foliage_palette_index + local foliage_palette_index = mcl_util.get_palette_indexes_from_pos(fpos).foliage_palette_index + if fnode.param2 ~= foliage_palette_index and fnode.name ~= "mcl_core:vine" then + fnode.param2 = foliage_palette_index minetest.set_node(fpos, fnode) - elseif fnode.name == "mcl_core:vine" then - local biome_param2 = reg_biome._mcl_foliage_palette_index + elseif fnode.param2 ~= foliage_palette_index and fnode.name == "mcl_core:vine" then + local biome_param2 = foliage_palette_index local rotation_param2 = fnode.param2 local final_param2 = (biome_param2 * 8) + rotation_param2 if fnode.param2 ~= final_param2 and rotation_param2 < 6 then From 3d9df5c797fbefd54c803e1deeef60896f779f8c Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Wed, 15 Feb 2023 12:20:15 +0000 Subject: [PATCH 48/54] Fix issue with vines in certain biomes This commit removes some excessive checks which caused vines to not get a biome colour in certain biomes at certain rotations. --- mods/MAPGEN/mcl_mapgen_core/init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index f3e95bc81..91d5114ee 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -431,7 +431,7 @@ minetest.register_lbm({ node.param2 = grass_palette_index minetest.set_node(pos, node) end - end, + end }) minetest.register_lbm({ @@ -449,7 +449,7 @@ minetest.register_lbm({ elseif node.param2 ~= foliage_palette_index and node.name ~= "mcl_core:vine" then node.param2 = foliage_palette_index minetest.set_node(pos, node) - elseif node.param2 ~= foliage_palette_index and node.name == "mcl_core:vine" then + elseif node.name == "mcl_core:vine" then local biome_param2 = foliage_palette_index local rotation_param2 = node.param2 local final_param2 = (biome_param2 * 8) + rotation_param2 @@ -470,7 +470,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct pa if fnode.param2 ~= foliage_palette_index and fnode.name ~= "mcl_core:vine" then fnode.param2 = foliage_palette_index minetest.set_node(fpos, fnode) - elseif fnode.param2 ~= foliage_palette_index and fnode.name == "mcl_core:vine" then + elseif fnode.name == "mcl_core:vine" then local biome_param2 = foliage_palette_index local rotation_param2 = fnode.param2 local final_param2 = (biome_param2 * 8) + rotation_param2 From 10d9eb29800c6afd700f274da7ae352716e24849 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Wed, 15 Feb 2023 12:23:58 +0000 Subject: [PATCH 49/54] Upload files to 'mods/MAPGEN/mcl_mapgen_core' --- mods/MAPGEN/mcl_mapgen_core/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 91d5114ee..158c269ff 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -458,7 +458,7 @@ minetest.register_lbm({ minetest.set_node(pos, node) end end - end, + end }) minetest.register_on_generated(function(minp, maxp, blockseed) -- Set correct palette indexes of foliage in new mapblocks. From 17fc7a3256c83230679865c7e5ed047b01263c98 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Wed, 15 Feb 2023 18:29:18 +0000 Subject: [PATCH 50/54] Use metadata method to make player leaves --- mods/ITEMS/mcl_core/nodes_trees.lua | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index a4413c17a..42810f1f7 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -28,8 +28,9 @@ function mcl_core.update_leaves(pos, oldnode) local leaves = minetest.find_nodes_in_area(pos1, pos2, "group:leaves") for _, lpos in pairs(leaves) do lnode = minetest.get_node(lpos) + lmeta = minetest.get_meta(lpos) -- skip already decaying leaf nodes and player leaves - if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 and minetest.get_item_group(lnode.name, "player_leaves") ~= 1 then + if minetest.get_item_group(lnode.name, "orphan_leaves") ~= 1 and lmeta:get_int("player_leaves") ~= 1 then if not minetest.find_node_near(lpos, 6, "group:tree") then local orphan_name = lnode.name .. "_orphan" local def = minetest.registered_nodes[orphan_name] @@ -45,11 +46,8 @@ function mcl_core.update_leaves(pos, oldnode) end function mcl_core.make_player_leaves(pos) - local node = minetest.get_node(pos) - if minetest.get_item_group(node.name, "player_leaves") ~= 1 then - local playerleafname = node.name .. "_player" - minetest.set_node(pos, {name = playerleafname}) - end + local meta = minetest.get_meta(pos) + meta:set_int("player_leaves", 1) end -- Register tree trunk (wood) and bark @@ -183,7 +181,7 @@ local function register_leaves(subname, description, longdesc, tiles, color, par return drop end - local pl_def = { + local l_def = { description = description, _doc_items_longdesc = longdesc, _doc_items_hidden = false, @@ -198,7 +196,7 @@ local function register_leaves(subname, description, longdesc, tiles, color, par groups = { handy = 1, hoey = 1, shearsy = 1, swordy = 1, dig_by_piston = 1, flammable = 2, fire_encouragement = 30, fire_flammability = 60, - leaves = 1, deco_block = 1, compostability = 30, foliage_palette = foliage_palette, player_leaves = 1, not_in_creative_inventory = 0, + leaves = 1, deco_block = 1, compostability = 30, foliage_palette = foliage_palette }, drop = get_drops(0), _mcl_shears_drop = true, @@ -221,22 +219,14 @@ local function register_leaves(subname, description, longdesc, tiles, color, par end, } - minetest.register_node("mcl_core:" .. subname .. "_player", pl_def) - - local l_def = table.copy(pl_def) - l_def.groups.player_leaves = nil - l_def.groups.not_in_creative_inventory = 1 - l_def._mcl_shears_drop = {"mcl_core:" .. subname .. "_player"} - l_def._mcl_silk_touch_drop = {"mcl_core:" .. subname .. "_player"} - minetest.register_node("mcl_core:" .. subname, l_def) local o_def = table.copy(l_def) o_def._doc_items_create_entry = false o_def.groups.not_in_creative_inventory = 1 o_def.groups.orphan_leaves = 1 - o_def._mcl_shears_drop = {"mcl_core:" .. subname .. "_player"} - o_def._mcl_silk_touch_drop = {"mcl_core:" .. subname .. "_player"} + o_def._mcl_shears_drop = {"mcl_core:" .. subname} + o_def._mcl_silk_touch_drop = {"mcl_core:" .. subname} minetest.register_node("mcl_core:" .. subname .. "_orphan", o_def) end From 8f8385e4a11d02f51336b16691acdc1e097bce00 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Wed, 15 Feb 2023 18:29:56 +0000 Subject: [PATCH 51/54] Use metadata method to make player mangrove leaves --- mods/ITEMS/mcl_mangrove/init.lua | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/mods/ITEMS/mcl_mangrove/init.lua b/mods/ITEMS/mcl_mangrove/init.lua index e7ac8090b..c007f55cf 100644 --- a/mods/ITEMS/mcl_mangrove/init.lua +++ b/mods/ITEMS/mcl_mangrove/init.lua @@ -86,7 +86,7 @@ minetest.register_node("mcl_mangrove:mangrove_wood", { _mcl_hardness = 2, }) -local pl_def = { +local l_def = { description = S("Mangrove Leaves"), _doc_items_longdesc = S("mangrove leaves are grown from mangrove trees."), _doc_items_hidden = false, @@ -100,7 +100,7 @@ local pl_def = { groups = { handy = 1, hoey = 1, shearsy = 1, swordy = 1, dig_by_piston = 1, flammable = 2, fire_encouragement = 30, fire_flammability = 60, - leaves = 1, deco_block = 1, compostability = 30, foliage_palette = 1, player_leaves = 1, not_in_creative_inventory = 0, + leaves = 1, deco_block = 1, compostability = 30, foliage_palette = 1 }, drop = get_drops(0), _mcl_shears_drop = true, @@ -123,22 +123,14 @@ local pl_def = { end, } -minetest.register_node("mcl_mangrove:mangroveleaves_player", pl_def) - -local l_def = table.copy(pl_def) -l_def.groups.player_leaves = nil -l_def.groups.not_in_creative_inventory = 1 -l_def._mcl_shears_drop = {"mcl_mangrove:mangroveleaves_player"} -l_def._mcl_silk_touch_drop = {"mcl_mangrove:mangroveleaves_player"} - minetest.register_node("mcl_mangrove:mangroveleaves", l_def) local o_def = table.copy(l_def) o_def._doc_items_create_entry = false o_def.groups.not_in_creative_inventory = 1 o_def.groups.orphan_leaves = 1 -o_def._mcl_shears_drop = {"mcl_mangrove:mangroveleaves_player"} -o_def._mcl_silk_touch_drop = {"mcl_mangrove:mangroveleaves_player"} +o_def._mcl_shears_drop = {"mcl_mangrove:mangroveleaves"} +o_def._mcl_silk_touch_drop = {"mcl_mangrove:mangroveleaves"} minetest.register_node("mcl_mangrove:mangroveleaves_orphan", o_def) From 406b27852b3e85b8989754dfb3b7d6c5b422ce78 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Thu, 16 Feb 2023 07:54:00 +0000 Subject: [PATCH 52/54] Improve the new function somewhat --- mods/CORE/mcl_util/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 4889b7d0a..3c755da22 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -1017,13 +1017,13 @@ function mcl_util.check_position_protection(position, player) return false end +local palette_indexes = {grass_palette_index = 0, foliage_palette_index = 0} function mcl_util.get_palette_indexes_from_pos(pos) - local palette_indexes = {grass_palette_index = 0, foliage_palette_index = 0} local biome_data = minetest.get_biome_data(pos) local biome = biome_data.biome local biome_name = minetest.get_biome_name(biome) local reg_biome = minetest.registered_biomes[biome_name] - if reg_biome then + if reg_biome and reg_biome._mcl_grass_palette_index and reg_biome._mcl_foliage_palette_index then local gpi = reg_biome._mcl_grass_palette_index local fpi = reg_biome._mcl_foliage_palette_index local palette_indexes = {grass_palette_index = gpi, foliage_palette_index = fpi} From 7d642c99292e5c10f38ae048c290b822bdaa6ec2 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Thu, 16 Feb 2023 17:25:21 +0000 Subject: [PATCH 53/54] Remove the tab before the curly bracket --- mods/ITEMS/mcl_mangrove/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_mangrove/init.lua b/mods/ITEMS/mcl_mangrove/init.lua index c007f55cf..aba844d24 100644 --- a/mods/ITEMS/mcl_mangrove/init.lua +++ b/mods/ITEMS/mcl_mangrove/init.lua @@ -121,7 +121,7 @@ local l_def = { after_place_node = function(pos) mcl_core.make_player_leaves(pos) -- Leaves placed by the player should always be player leaves. end, - } +} minetest.register_node("mcl_mangrove:mangroveleaves", l_def) From 68e6965dd02daefe87e91872792fb2f146d96afd Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Thu, 16 Feb 2023 18:09:39 +0000 Subject: [PATCH 54/54] Remove excessive functions and change the appropriate stuff --- mods/ITEMS/mcl_core/functions.lua | 14 ++------------ mods/ITEMS/mcl_core/nodes_cactuscane.lua | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index 7eecd2238..54cdcd32f 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -802,24 +802,14 @@ end local grass_spread_randomizer = PseudoRandom(minetest.get_mapgen_setting("seed")) -function mcl_core.get_grass_palette_index(pos) - local grass_palette_index = mcl_util.get_palette_indexes_from_pos(pos).grass_palette_index - return grass_palette_index -end - -- Return appropriate grass block node for pos function mcl_core.get_grass_block_type(pos) - return {name = "mcl_core:dirt_with_grass", param2 = mcl_core.get_grass_palette_index(pos)} -end - -function mcl_core.get_foliage_palette_index(pos) - local foliage_palette_index = mcl_util.get_palette_indexes_from_pos(pos).foliage_palette_index - return foliage_palette_index + return {name = minetest.get_node(pos).name, param2 = mcl_util.get_palette_indexes_from_pos(pos).grass_palette_index} end -- Return appropriate foliage block node for pos function mcl_core.get_foliage_block_type(pos) - return {name = minetest.get_node(pos).name, param2 = mcl_core.get_foliage_palette_index(pos)} + return {name = minetest.get_node(pos).name, param2 = mcl_util.get_palette_indexes_from_pos(pos).foliage_palette_index} end ------------------------------ diff --git a/mods/ITEMS/mcl_core/nodes_cactuscane.lua b/mods/ITEMS/mcl_core/nodes_cactuscane.lua index 62d5cc2b5..cb33a6f3e 100644 --- a/mods/ITEMS/mcl_core/nodes_cactuscane.lua +++ b/mods/ITEMS/mcl_core/nodes_cactuscane.lua @@ -127,7 +127,7 @@ minetest.register_node("mcl_core:reeds", { on_construct = function(pos) local node = minetest.get_node(pos) if node.param2 == 0 then - node.param2 = mcl_core.get_grass_palette_index(pos) + node.param2 = mcl_util.get_palette_indexes_from_pos(pos).grass_palette_index if node.param2 ~= 0 then minetest.set_node(pos, node) end