From 24006e78326807ff2809d233b28c6e260db66e47 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 14 Mar 2017 18:45:21 +0100 Subject: [PATCH] Add peony and large plant support --- mods/ITEMS/mcl_flowers/init.lua | 132 ++++++++++-------- ...cl_flowers_double_plant_paeonia_bottom.png | Bin 0 -> 1057 bytes .../mcl_flowers_double_plant_paeonia_top.png | Bin 0 -> 1270 bytes mods/MISC/mcl_wip/init.lua | 1 - 4 files changed, 74 insertions(+), 59 deletions(-) create mode 100644 mods/ITEMS/mcl_flowers/textures/mcl_flowers_double_plant_paeonia_bottom.png create mode 100644 mods/ITEMS/mcl_flowers/textures/mcl_flowers_double_plant_paeonia_top.png diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index 3fb516b798..f7af8aa800 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -38,7 +38,6 @@ add_simple_flower("tulip_pink", "Pink Tulip", "mcl_flowers_tulip_pink", box_tuli add_simple_flower("tulip_red", "Red Tulip", "mcl_flowers_tulip_red", box_tulip) add_simple_flower("tulip_white", "White Tulip", "mcl_flowers_tulip_white", box_tulip) add_simple_flower("allium", "Allium", "mcl_flowers_allium", { -0.2, -0.5, -0.2, 0.2, 6/16, 0.2 }) -add_simple_flower("peony", "Peony", "mcl_flowers_peony", { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 }) add_simple_flower("azure_bluet", "Azure Bluet", "mcl_flowers_azure_bluet", { -3/16, -0.5, -3/16, 3/16, 2/16, 3/16 }) add_simple_flower("blue_orchid", "Blue Orchid", "mcl_flowers_blue_orchid", { -5/16, -0.5, -5/16, 5/16, 6/16, 5/16 }) @@ -72,66 +71,83 @@ minetest.register_node("mcl_flowers:fern", { }, }) -function register_large(name, desc, inv_img, bot_img, colr) --change in function - minetest.register_node("mcl_flowers:"..name.."_bottom", { - description = desc.." Bottom", - drawtype = "plantlike", - tiles = { "double_plant_"..name.."_bottom.png" }, - inventory_image = "flowers_"..inv_img..".png", - wield_image = "flowers_"..inv_img..".png", - sunlight_propagates = true, - paramtype = "light", - walkable = false, - buildable_to = true, - --[[ - on_place = function(itemstack, placer, pointed_thing) - pointed_thing.under = pointed_thing.under-1 - local name = minetest.get_node({x=pointed_thing.under, y=pointed_thing.under-1, z=pointed_thing.under}).name - if minetest.get_item_group(name, "soil") ~= 0 then - pointed_thing.under = pointed_thing.under+1 - local height = 0 - while minetest.get_node(pointed_thing.under).name == "mcl_flowers:"..name.."_bottom" and height < 2 do - height = height+1 - pointed_thing.under = pointed_thing.under+1 - end - if height <2 then - if minetest.get_node(pointed_thing.under).name == "air" then - minetest.set_node(pointed_thing.under, {name="mcl_flowers:"..name.."_top"}) - end - end - end - end, - ]] - drop = "mcl_flowers:"..name, - groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,colr=1, dig_by_water=1, double_bottom =1,deco_block=1,deco_block=1}, - sounds = mcl_sounds.node_sound_leaves_defaults(), - selection_box = { - type = "fixed", - fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 }, - }, - }) +local function add_large_flower(name, desc, longdesc, inv_img, bottom_img, top_img) + minetest.register_node("mcl_flowers:"..name, { + description = desc, + _doc_items_longdesc = longdesc, + drawtype = "plantlike", + tiles = { bottom_img }, + inventory_image = inv_img, + wield_image = inv_img, + sunlight_propagates = true, + paramtype = "light", + walkable = false, + node_placement_prediction = "", + on_place = function(itemstack, placer, pointed_thing) + -- We can only place on nodes + if pointed_thing.type ~= "node" then + --return + end + -- Check for a floor and a space of 1×2×1 + local ptu_node = minetest.get_node(pointed_thing.under) + local bottom + if minetest.registered_nodes[ptu_node.name].buildable_to then + bottom = pointed_thing.under + else + bottom = pointed_thing.above + end + local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } + local bottom_buildable = minetest.registered_nodes[minetest.get_node(bottom).name].buildable_to + local top_buildable = minetest.registered_nodes[minetest.get_node(top).name].buildable_to + local floorname = minetest.get_node({x=bottom.x, y=bottom.y-1, z=bottom.z}).name + if minetest.registered_nodes[floorname].walkable and bottom_buildable and top_buildable then + -- Success! We can now place the flower + minetest.sound_play(minetest.registered_nodes["mcl_flowers:"..name].sounds.place, {pos = bottom, gain=1}) + minetest.set_node(bottom, {name="mcl_flowers:"..name}) + minetest.set_node(top, {name="mcl_flowers:"..name.."_top"}) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + end + end + return itemstack + end, + after_destruct = function(pos, oldnode) + -- Remove top half of flower (if it exists) + local bottom = pos + local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } + if minetest.get_node(top).name == "mcl_flowers:"..name.."_top" then + minetest.remove_node(top) + end + end, + groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1, dig_by_water=1, double_plant=1,deco_block=1}, + sounds = mcl_sounds.node_sound_leaves_defaults(), + }) - -- Top - minetest.register_node("mcl_flowers:"..name.."_top", { - description = desc.." Top", - drawtype = "plantlike", - tiles = { "double_plant_"..name.."_top.png" }, - inventory_image = "double_plant_"..inv_img.."_top.png", - wield_image = "double_plant_"..inv_img.."_top.png", - sunlight_propagates = true, - paramtype = "light", - walkable = false, - buildable_to = true, - drop = "mcl_flowers:"..name, - groups = {dig_immediate=3,flammable=2,flower=1,attached_node=1,colr=1, dig_by_water=1, not_in_creative_inventory = 1, double_top =1}, - sounds = mcl_sounds.node_sound_leaves_defaults(), - selection_box = { - type = "fixed", - fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 }, - }, - }) + -- Top + minetest.register_node("mcl_flowers:"..name.."_top", { + description = desc.." (Top Part)", + _doc_items_create_entry = false, + drawtype = "plantlike", + tiles = { top_img }, + sunlight_propagates = true, + paramtype = "light", + walkable = false, + drop = "", + after_destruct = function(pos, oldnode) + -- "Dig" bottom half of flower (if it exists) + local top = pos + local bottom = { x = top.x, y = top.y - 1, z = top.z } + if minetest.get_node(bottom).name == "mcl_flowers:"..name then + minetest.dig_node(bottom) + end + end, + groups = {dig_immediate=3,flammable=2,flower=1, dig_by_water=1, not_in_creative_inventory = 1, double_plant=2}, + sounds = mcl_sounds.node_sound_leaves_defaults(), + }) end +add_large_flower("peony", "Peony", nil, "mcl_flowers_double_plant_paeonia_top.png", "mcl_flowers_double_plant_paeonia_bottom.png", "mcl_flowers_double_plant_paeonia_top.png") + -- Lily Pad minetest.register_node("mcl_flowers:waterlily", { diff --git a/mods/ITEMS/mcl_flowers/textures/mcl_flowers_double_plant_paeonia_bottom.png b/mods/ITEMS/mcl_flowers/textures/mcl_flowers_double_plant_paeonia_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..6aaeb31a725a7488cfbfb1351c77eaf77f7a35db GIT binary patch literal 1057 zcmZ9JYfPJE6vrP1Y=r^tVw_pVfVR)`ye$yg(he*#2ehSk+R_$S!u^(U35FJjki{WN z!8w`WP#FUWH+O*`gNS1SGA3r7qB9Ioxle8zV=C@tj#^*hC;f2F|6KArCpo7=qmFcU zJ?IJmaFY2gGn@E|Jr% zq>ltKA_*TcMtaOo5zJpB`Gz2*Vtb1bL(XEV2&iPyfsTa? z7)P<0YDkwsCbdOL(3Oxb!9EH^9c|#*;V-CrJD7FqXmD(CB4ayAQACPBxwEH~N?cx* z#+d-vy?@&rKyBTNRB@MCrV{U(bM)97a5zHLDzo0KIQQgEIg>e? zWi2j$n9R;;p;z^cY)sP56q>u=%Pq_(&i-?nw%4u1EuKd%oR;3+G+wHv71gx7aBPuh zYX-`pe%sXt@-j>=&J2PH-d*o(Cm!G=K1@yVr z3FGToRt=%as}YHGJq^!gMx6Lk*|PG(zL#P)MlG6z-olmNrHQ@ayrNG3{PVV_+2bW? z+Pm7dvlkTaUhHbhxG^?xYN_MH;vU<&V~9s?&qAr?tZ~s=o9OWE_jIrJtMY5-D;r|7 zI$Z9Rx9P@H2Q#1GhJntej%O0vK1=-IkTvFh_Kmp8>k`>zn%mC!{!?v(IrY`+zd3{y z9pUXbnjaB*bW*fxU%s`PmcvL&GChtf3Gkc{aj&d~@qgLb|5x3G!5YJ;V6W83Q~SvOsVR4Ysd5_Ua#QQ?`&P!5nBmL^x#otg3xp>%T)v4aGv^D-}-R2 zxvQ*==ecERHp&C7aWQsrl)Y03L@MeG2xl$gMXLxNg`(nA25qOP zwN-27r~(3tR;hx5C>jI_DBwX28XzGDA%_x@2(BPCeVKl0KkPoU`^;~@>{AdeKF4~EAIhfjEv=_`hFxn48^`O2C+FH;yzzfNQ z;w%_i;N?RwJqEKJ^v$5X2AV5i>;%Jo7?yycdBWWMmL~Xw97dyEhjl`ppg*b_an;w9s4oIO?pLmu<0je4x@u_$;4HMER5j5p_P*ee)fKg*<-cc-O zoG%uKVSGA8gpq|5QaDD5!ia}P&)jvJ$bv(bNEnNPhM%WR4;vzQ9Q32(Vm>j<-oa1$ z1|gRZrpo~p|NbGdbjk`7aGlgM=D2$;S;MLDB$&U$IKkq8&XMCTIWEET^BS^5jbGf# zpF{WPJ1eR?L`hL(wieb?6ybptDb|4u$KWQyu)4}D=?Zs&znXeO-?b|DAt-Y7$|UZ@ zQsvjlwb%AoOWq`RtZUj*Bx&4`7oMDaDm^=KoqKa)wnK<+rU$~TqX#Vre$>Yp2`chBseQZ4_!t~KOwx%wD+#&vu$#=}*rEuc78w44+Fl(_s6COuju zGLBg}wwe0+)FY<@vnO50XWfr9y-Z{u>pD`ZZAo+GeY#(*sVcwtOLxkhv{?6H~!`y4ZqCi=Z`A{$s1H!*9|`mD|Djk`7zg1i|_mM6o< zlj$pFvegP{{R`=H*HDV^FP3s#r9$R3oQJW literal 0 HcmV?d00001 diff --git a/mods/MISC/mcl_wip/init.lua b/mods/MISC/mcl_wip/init.lua index db2e8d1efb..0fcd992279 100644 --- a/mods/MISC/mcl_wip/init.lua +++ b/mods/MISC/mcl_wip/init.lua @@ -18,7 +18,6 @@ local wip_items = { "mcl_end:chorus_fruit", "mcl_end:chorus_flower", "mcl_end:chorus_flower_dead", - "mcl_flowers:peony", "mcl_fishing:fishing_rod", "mcl_fishing:pufferfish_raw", "mcl_maps:filled_map",