From b77307b7ac73e5c00417180f36e7ce2829425553 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 27 Dec 2019 15:24:59 +0100 Subject: [PATCH] Add sea pickles --- mods/ITEMS/mcl_ocean/init.lua | 3 + mods/ITEMS/mcl_ocean/sea_pickle.lua | 200 ++++++++++++++++++ .../textures/mcl_ocean_sea_pickle_1_anim.png | Bin 0 -> 579 bytes .../textures/mcl_ocean_sea_pickle_1_off.png | Bin 0 -> 422 bytes .../textures/mcl_ocean_sea_pickle_2_anim.png | Bin 0 -> 581 bytes .../textures/mcl_ocean_sea_pickle_2_off.png | Bin 0 -> 430 bytes .../textures/mcl_ocean_sea_pickle_3_anim.png | Bin 0 -> 571 bytes .../textures/mcl_ocean_sea_pickle_3_off.png | Bin 0 -> 440 bytes .../textures/mcl_ocean_sea_pickle_4_anim.png | Bin 0 -> 529 bytes .../textures/mcl_ocean_sea_pickle_4_off.png | Bin 0 -> 427 bytes .../textures/mcl_ocean_sea_pickle_item.png | Bin 0 -> 456 bytes 11 files changed, 203 insertions(+) create mode 100644 mods/ITEMS/mcl_ocean/sea_pickle.lua create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_1_anim.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_1_off.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_2_anim.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_2_off.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_3_anim.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_3_off.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_4_anim.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_4_off.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_item.png diff --git a/mods/ITEMS/mcl_ocean/init.lua b/mods/ITEMS/mcl_ocean/init.lua index cf63f98b..2a103b8d 100644 --- a/mods/ITEMS/mcl_ocean/init.lua +++ b/mods/ITEMS/mcl_ocean/init.lua @@ -9,3 +9,6 @@ dofile(minetest.get_modpath(minetest.get_current_modname()).."/seagrass.lua") -- Kelp dofile(minetest.get_modpath(minetest.get_current_modname()).."/kelp.lua") + +-- Sea Pickle +dofile(minetest.get_modpath(minetest.get_current_modname()).."/sea_pickle.lua") diff --git a/mods/ITEMS/mcl_ocean/sea_pickle.lua b/mods/ITEMS/mcl_ocean/sea_pickle.lua new file mode 100644 index 00000000..85f75bad --- /dev/null +++ b/mods/ITEMS/mcl_ocean/sea_pickle.lua @@ -0,0 +1,200 @@ +local S = minetest.get_translator("mcl_ocean") +local mod_doc = minetest.get_modpath("doc") ~= nil + +local function sea_pickle_on_place(itemstack, placer, pointed_thing) + if pointed_thing.type ~= "node" or not placer then + return itemstack + end + + local player_name = placer:get_player_name() + local pos_under = pointed_thing.under + local pos_above = pointed_thing.above + local node_under = minetest.get_node(pos_under) + local node_above = minetest.get_node(pos_above) + local def_under = minetest.registered_nodes[node_under.name] + local def_above = minetest.registered_nodes[node_above.name] + + if def_under and def_under.on_rightclick and not placer:get_player_control().sneak then + return def_under.on_rightclick(pos_under, node_under, + placer, itemstack, pointed_thing) or itemstack + end + + if minetest.is_protected(pos_under, player_name) or + minetest.is_protected(pos_above, player_name) then + minetest.log("action", player_name + .. " tried to place " .. itemstack:get_name() + .. " at protected position " + .. minetest.pos_to_string(pos_under)) + minetest.record_protection_violation(pos_under, player_name) + return itemstack + end + + local submerged = false + if minetest.get_item_group(node_above.name, "water") ~= 0 then + submerged = true + end + -- Place + if node_under.name == "mcl_ocean:dead_brain_coral_block" then + -- Place on suitable coral block + if submerged then + node_under.name = "mcl_ocean:sea_pickle_1_dead_brain_coral_block" + else + node_under.name = "mcl_ocean:sea_pickle_1_off_dead_brain_coral_block" + end + minetest.set_node(pos_under, node_under) + elseif minetest.get_item_group(node_under.name, "sea_pickle") ~= 0 then + -- Grow by 1 stage + local def = minetest.registered_nodes[node_under.name] + if def and def._mcl_sea_pickle_next then + node_under.name = def._mcl_sea_pickle_next + minetest.set_node(pos_under, node_under) + else + return itemstack + end + else + return itemstack + end + if not (minetest.settings:get_bool("creative_mode")) then + itemstack:take_item() + end + return itemstack +end + +-- Sea Pickle on brain coral + +local sounds_coral_plant = mcl_sounds.node_sound_leaves_defaults({footstep = mcl_sounds.node_sound_dirt_defaults().footstep}) +local ontop = "dead_brain_coral_block" + +for s=1,4 do + local desc, doc_desc, doc_use, doc_create, nici, img, img_off, on_place + if s == 1 then + desc = S("Sea Pickle") + doc_desc = S("Sea pickles grow on dead brain coral blocks and provide light when underwater. They come in 4 sizes that vary in brightness.") + doc_use = S("It can only be placed on top of dead brain coral blocks. Placing a sea pickle on another sea pickle will make it grow and brighter.") + img = "mcl_ocean_sea_pickle_item.png" + on_place = sea_pickle_on_place + else + doc_create = false + nici = 1 + img = "mcl_ocean_"..ontop..".png^(mcl_ocean_sea_pickle_"..s.."_anim.png^[verticalframe:2:1)" + end + img_off = "mcl_ocean_"..ontop..".png^mcl_ocean_sea_pickle_"..s.."_off.png" + local next_on, next_off + if s < 4 then + next_on = "mcl_ocean:sea_pickle_"..tostring(s+1).."_"..ontop + next_off = "mcl_ocean:sea_pickle_"..tostring(s+1).."_off_"..ontop + end + + minetest.register_node("mcl_ocean:sea_pickle_"..s.."_"..ontop, { + description = desc, + _doc_items_create_entry = doc_create, + _doc_items_longdesc = doc_desc, + _doc_items_usagehelp = doc_use, + drawtype = "plantlike_rooted", + paramtype = "light", + paramtype2 = "meshoptions", + tiles = { "mcl_ocean_"..ontop..".png" }, + special_tiles = { + { + image = "mcl_ocean_sea_pickle_"..s.."_anim.png", + animation = {type="vertical_frames", aspect_w=16, aspect_h=16, length=1.7}, + } + }, + inventory_image = img, + wield_image = img, + groups = { dig_immediate = 3, deco_block = 1, sea_pickle=1, not_in_creative_inventory=nici }, + -- Light level: 6 at size 1, +3 for each additional stage + light_source = math.min(6 + (s-1)*3, minetest.LIGHT_MAX), + selection_box = { + type = "fixed", + fixed = { + { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }, + { -0.15, 0.5, -0.15, 0.15, 0.5+2/16+(2/16)*s, 0.15 }, + } + }, + sounds = sounds_coral_plant, + node_placement_prediction = "", + node_dig_prediction = "mcl_ocean:"..ontop, + after_dig_node = function(pos) + local node = minetest.get_node(pos) + if minetest.get_item_group(node.name, "sea_pickle") == 0 then + minetest.set_node(pos, {name="mcl_ocean:"..ontop}) + end + end, + on_place = on_place, + _mcl_sea_pickle_off = "mcl_ocean:sea_pickle_"..s.."_off_"..ontop, + _mcl_sea_pickle_next = next_on, + _mcl_hardness = 0, + _mcl_blast_resistance = 0, + }) + + minetest.register_node("mcl_ocean:sea_pickle_"..s.."_off_"..ontop, { + drawtype = "plantlike_rooted", + paramtype = "light", + paramtype2 = "meshoptions", + tiles = { "mcl_ocean_"..ontop..".png" }, + special_tiles = { "mcl_ocean_sea_pickle_"..s.."_off.png", }, + groups = { dig_immediate = 3, deco_block = 1, sea_pickle=2, not_in_creative_inventory=1 }, + selection_box = { + type = "fixed", + fixed = { + { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }, + { -0.15, 0.5, -0.15, 0.15, 0.5+2/16+(2/16)*s, 0.15 }, + } + }, + inventory_image = img_off, + wield_image = img_off, + sounds = sounds_coral_plant, + node_placement_prediction = "", + node_dig_prediction = "mcl_ocean:"..ontop, + after_dig_node = function(pos) + local node = minetest.get_node(pos) + if minetest.get_item_group(node.name, "sea_pickle") == 0 then + minetest.set_node(pos, {name="mcl_ocean:"..ontop}) + end + end, + _mcl_sea_pickle_on = "mcl_ocean:sea_pickle_"..s.."_"..ontop, + _mcl_sea_pickle_next = next_off, + _mcl_hardness = 0, + _mcl_blast_resistance = 0, + }) + + if mod_doc then + if s == 1 then + doc.add_entry_alias("nodes", "mcl_ocean:sea_pickle_1_dead_brain_coral_block", "nodes", "mcl_ocean:sea_pickle_1_off_"..ontop) + else + doc.add_entry_alias("nodes", "mcl_ocean:sea_pickle_1_dead_brain_coral_block", "nodes", "mcl_ocean:sea_pickle_"..s.."_off_"..ontop) + doc.add_entry_alias("nodes", "mcl_ocean:sea_pickle_1_dead_brain_coral_block", "nodes", "mcl_ocean:sea_pickle_"..s.."_"..ontop) + end + end +end + +minetest.register_abm({ + label = "Sea pickle update", + nodenames = { "group:sea_pickle" }, + interval = 17, + chance = 5, + catch_up = false, + action = function(pos, node, active_object_count, active_object_count_wider) + -- Check if it's lit + local state = minetest.get_item_group(node.name, "sea_pickle") + -- Check for water + local checknode = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}) + local def = minetest.registered_nodes[node.name] + if minetest.get_item_group(checknode.name, "water") ~= 0 then + -- Sea pickle is unlit + if state == 2 then + node.name = def._mcl_sea_pickle_on + minetest.set_node(pos, node) + return + end + else + -- Sea pickle is lit + if state == 1 then + node.name = def._mcl_sea_pickle_off + minetest.set_node(pos, node) + return + end + end + end, +}) diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_1_anim.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_1_anim.png new file mode 100644 index 0000000000000000000000000000000000000000..5c4f0064c6771018151598a3cecd0ab48b3daafd GIT binary patch literal 579 zcmeAS@N?(olHy`uVBq!ia0y~yU=UznU{K&-V_;yA?)-6vfq{W7$=lt9;Xep2*t>i( z0|NtRfk$L90|Vb75M~tB@M>USU|=ut^mS!_%p=XiDpC-w?$5x$c)`=fF~sBe-YJF| zB90<$`)BUmptC(@<5jVw#A3~$$R&b0N&Cgbl2R2lg&yj-2Hoap;$U;U6nSHbN0g^R z(qyYp0mq=XqT5@N`=46m%|CjNXLiBv9n}xA(;oc&{H*@}pU+b|3jRD+O;pIqd-M6n zRjZ$&r`Dg&zE@l4C&7__ubw?&*3& zR`;bo_%3tl;~%$s540sqY&n=GS_G~-^J>1Nk5Py4(nAg`0iS1XNjsp$!@u0Jr}oLBjTRE`z@bav)yxXYnNubQsc#&EFU+E`^#O8Tk<-Nal_{Y zg^bB!#{5#^AFBIO6TYoAG1$Mcu+fvPVaEL(T+Eqg7ufJe8CqD_1g_3dXpoVa$Ka98 jd*;>;>;Ky;KZx&N^_a_kS-=bi1_lOCS3j3^P6H=O_QyQZJZvJ-WhFff42;H}E{-7 zs4e&8bnkLr#`EYwP`e*rEKB>p28*uA!Rib9l-|Bl+99ITRDWRS>PHIyI+dDAvf4y6 zHQhP(zAiX9@yhOhjQgMdez14<_kG9RmrR*a6QjtZV)fSW+`4{+G|hd>_V1|Q_08|WkKiTjClKVI~W)$d@e4&?0!a^g~4G_9ry063$Gu& z`+2u3c>c(w_xS#TWdGeF5I@MF5%R%5b2Ct XtL|=?yWg9Efq}u()z4*}Q$iB}9ucp( literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_2_anim.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_2_anim.png new file mode 100644 index 0000000000000000000000000000000000000000..ce063765f80eb3529f1f914743f0ae13290cb7d7 GIT binary patch literal 581 zcmeAS@N?(olHy`uVBq!ia0y~yU=UznU{K&-V_;yA?)-6vfq{W7$=lt9;Xep2*t>i( z0|NtRfk$L90|Vb75M~tB@M>USU|=ut^mS!_%p=Xi$}07meJ=w8<0VfQ#}JR>N2eHO zTuBf)ULRki+QMy~a!P^E)uP>xFP5dfxWBo1aZ^b~Yw@&mdQA_K1eZK`@Zi$Ib(fmE zyr28Iaz9;mr@*mqNhtrMTl^CsVdfx&Fh8Em!<(Lg!U^;~jp6QVeH|R-R{gaQ1j()NzNqwOcZI zf=qg@Z(RCg@8pv{Yo%Uo=UEqgCN{b`wBCYMUgYDdQ;YVhZ+9u5m3rvG;r^hU)vFvN zH%GCa+Oo2?&;PrH_5G*o&wYFux4AuW|LL1Q^%D1=-ZeMSa!%Q!%kAHH=O_QyQZJZwB3Qg3cC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dfkU>7WT@#KPQ!3+5SclTH;PAl)&SQhbvN;@p9c5BHVsdoyQ;P-Yy zke3&SVkMuaT&8cA?4GB6yWiif{eD+CDtlg>|BCA-XWjanH_I++JbnCk%j(_AuT0PW z{A$dwPyFMzAExcoRj%cHxg@YNFm?OhJh|U-EDdXuDysiadlaBKN(oy~d6k3Oy4 zzd=u1i|{x~b2~N|!&>H>}O)Z0>5B+5XX$N9TUG z&p{stqt6!v?AbV&bvJ$epT40&*1EXW-f+Xr^Xtzf7|wqtCfTt_|CZIgOD~rgT=*hy pSG+MSu-PU}+w{a`wexihjuV&IXFT!HWME)m@O1TaS?83{1OS8*wY~rV literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_4_anim.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_4_anim.png new file mode 100644 index 0000000000000000000000000000000000000000..6d3e56675234d221354c03e5dbbc26684d1145a2 GIT binary patch literal 529 zcmeAS@N?(olHy`uVBq!ia0y~yU=UznU{K&-V_;yA?)-6vfq{W7$=lt9;Xep2*t>i( z0|NtRfk$L90|Vb75M~tB@M>USU|=ut^mS!_%p=XiBK`9}_k0Eh#(ADDjv*e$--Z}^ z91aku{l8tcMXcRN@`z)LRY}ncC5tPze0+Uemlle?ih1=)sYFn>iGz<%kFRvCn3mpL z>rSqv!PZMWI$H#0y`S)BLYvBjt``q<%m4f@`u^_eeZgZA@8VUBKJy@5?C zF5a%7Xd`!I(u!-*3=GcOKh*rTYhGTUGe7%-K#69vX{z9+BN1EgH7$&0U~t^>@YFHO zwqzy-1uxZZjn$&uZ+>j@J@hU!YD=?1ytbIc`YB?~h9@2GwmbX(pk2T=ORzVx7ijNbeD$XYxf0+My^Zw%sUpmFU zg-NV8F_pY^J-_irN<@=F+D0LkOyS$J<{ItVE3_~5tY76m{;6JKcjG!Wr|K*!bIT~M zdG>v~d1T1K3oOn1EI0EfsSCJtZJsSA+1F{kZ)2VEefIG3ejByo%mcMKZ2xLMBB@0(FFfcH9y85}Sb4q9e0I4n7d;kCd literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_4_off.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_4_off.png new file mode 100644 index 0000000000000000000000000000000000000000..d2df9310946fa229ab2ae86198bad271802062c3 GIT binary patch literal 427 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7*pj^6T^Rm@;DWu&Co?cG za29w(7BevL9RguSQ4OyK1_lQ95>H=O_QyQZJgjC*tz>KfW$+<0|?0-U=;8^IbQ3uYG;&NXLrwCepIT|Bs_XBW#5ui? zYkBa74VQ$LJD1cJes1DQKBsMS)B4VpXEV}Dugj#~o255xNnV;-lt_il55WsNJsW3p zu4JFZC{mg~<6&cG{?`L<)~{J`Z++E&f5yyTiynTQwra+-oriuryxdhfTkOV^wObB6 d>(#AeT&_RA@`C)FGzJC+22WQ%mvv4FO#rU1xVQiS literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_item.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_item.png new file mode 100644 index 0000000000000000000000000000000000000000..88a4669add5ac6882e248df4298a5369fb811d83 GIT binary patch literal 456 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7*pj^6T^PXNr}OT51_lPs z0*}aI1_r)EAj~ML;nl#vz`$PO>Fdh=m`6~I!NkMQl!1YPG1Sw=F~s8Z*&svj!ww?< z-dz&v6Pf5Id&F^qRY}ncC5tEQDWZ3bS3Jn+T%9c59V_#PKXx%+p4EWKt9Iu3qiAzItU_q{g~jFN zUoIz@q^$_`^u4!c{i2T9O{>+c&ZW9*ax(m=V!eG%Dl2qR*zIupSxSqocZ+*T7Wci5 z5Sy2M`Q}sI=#b~rPE4v?{`{7TdSsH_@-H9lnl&vJWu}G9@aAm}c`L@tfzaG#gN z5{;Qnhc(iJ&)gAOd?uu>s_v|c`+9G?+c$3qJbRHA8pd;}ymwjrnv66d{lJ9IH(pP7 zdN^u!28RX+9|-*7R?lu#zmnbRUplL6Owxb BwBrB( literal 0 HcmV?d00001