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 cf63f98ba..2a103b8d0 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 000000000..85f75bad6 --- /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 zcmV-J0=)f+P)-)fQr5b170;q!BD)zZMo^Wg#gN;VeZ`+X#XP20_wU z*rZ5WNg!gAI#m!sQtcJDgkz88IBuWC-VB>?ySRJcYi8j6^X7m5{PUEEaQx#XVIXX7 z?DP25I{8(~ugh!ReSS_D2yfnh2Vk1z{QUO&241s>&5eDtMc?(gAKkHsr&$hw>lN_m z;V0rm0idEmpSsxF-s0_-)5^T=dc|hhy0^V$Z|Zu>F`cVFGh9!Tj*A{g3#y}GPMj#h zKo|{Yq@K2|q>ENY!<>%mX`Hp<7Iz_uv!-y-gn82m=A26$5||Ur%c_P!FEo zvlcB|*6%q|c3e81tJ{{IW;v?LqR(FUWs((cn`ChO@p37)Q&r%$L#v{)z%p$b$I;m? z=NCJy6h~*f?G8qRKIa!ZM1wwcGo!LOs|q{^Pq77V-_ ztu!#dv2lS(27s8~xC#Sl&7eFFS}`~{JW;D?Ab=bko&ZQ|4b0m3JO8(N@E5CG literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_1_off.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_1_off.png new file mode 100644 index 0000000000000000000000000000000000000000..24b648777c1a25b6f66506bf37ef39bccf7d098b GIT binary patch literal 422 zcmV;X0a^ZuP)LR!lEP{W)xvSzJ z{)r-jbZUkaDJe$?z3Xtvk<`2X0l($@;Jv%|zQ;$Tl$d;6Aq*rs?J>@-k053#zNWvp zf4W2%NZdZW0st~D@cHsx<5LvXX^+bh^q`63XkS0hxBvinOwps$N6Z%l06?OC3%hF2 z>*DVD-HKD6sln6-y{=aBnVI9xesXw>B3-H-lfr5e3(OY;VIYyjIZ{UTDrvDw5(~H< zqi`BZ#VaCl8br^-(Hlxm6)*YZ07*qoM6N<$f*ujCxc~qF 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 zcmV-L0=oT)P)gNjS%PDKmlrrdBrj+AhO%X7HCuQ`S$5@32(7D+gk@Z#JcHmC%j=EPtzO#$DPB& zdvA$i1%L|sUDlobogOdW4=VFk+nonx_x?`LbZWchnAY$r!*MN=$$ZA~g6epb6UBJlmEG)c^O%y8? z_#$4%R>@?xl-Kx525lG3V2RZqGq_GM8UV~Psm}o5&BuXS$3WeEv}p`dG>q4=rTD#* z$xN*p>bDH8Q_NjkgH?Yx1s@dgs>-6hC$~g*nq|V^!;eyItExa5vswkpw5ffLPxm-G z-{r5)@#$W(hhe|V+4(MEzstIvQ8}D;;?sxs*EXswFuckD%s!}HK-)Enm5FN=@H#et z1it9FnFdj;q>%=z`=Akn!=n?WH&PP@0?6Uf34k=#K;N~0rqzA$&;G{$zYl%^Ymnj> TxwW+}00000NkvXXu0mjfhqDq} literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_2_off.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_2_off.png new file mode 100644 index 0000000000000000000000000000000000000000..c0b34e8e925a70969e1d586e792fcff0501e38d9 GIT binary patch literal 430 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=DjSK$uZf!>a)($X?><>&pI^N1BI?$3yDPEd~ZgYfl%)5R21$gABb7J4n=)ds_C1 zwEIXNapbZpDSDw~@r3=z#lY!)P3JDH(`)KZ5R8$T8#|Tn(R=~XCBeo^JUlI(PRw#eoiFRV5D*5v!wLQsg|K!qPaU!LJyL7@B3m2FtXRx3aK`(w8`RyOiJ zwHLl`opkuDO!cR^O@&<*^WIB{hAj?AvQqvK)2iVkSiCB{vpaNAz@fA`hq9h(t?4+D zC1}f^9~V%xs^X;jZ};0)bFw1d@~+;NZFBx#%ghc@J{dk8mXiFU1a+q@2knL=#iFO1 z(pRo}m|eJFn#_c+RuTL7!*(`n%{Q65qW)6g(x7QtJ@R(FF}q(fPu^T#n{et_$o_n* Wm8`P97N3D3%i!ti=d#Wzp$Pz_wXHt@ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_3_anim.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_sea_pickle_3_anim.png new file mode 100644 index 0000000000000000000000000000000000000000..d484085e25058c6ec13d91c7f58398cab4ca8416 GIT binary patch literal 571 zcmV-B0>u4^P)5@59NeaP}JV+FyAdIlCgZ+doBsX#?x#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_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 zcmV;c0aX5pP)jLE!_O2b!Wio5;uvCa`fQM)_hAQ-fA1~{^@&XM zlRe@%!K$R_g_6Y+_7u@O#w#A=bgoVo?~axE!ymhtFVAX6#Fa-%mljF}WpuU#oGJEr zXOk3N@Y!+4@$dWgeBb+?&!y$}a%O>x>+=Qwd7alvcWGgaGk95kA*W?55RfR_9XPH8~l6RI%PZCzTbtDC~B){Vb)$*1N^MB#ZlAM~KbKzI^kk zZgj}=X(uLCE`NSYMLjafZuyswcFmd=i!#$fW_a^9hrE?yGj^H99=Oj-Vu{Agro$TP z!DsFWEj|-cS5(H74o5|3UL5b8ZPYG=!M|LzuzS)z4*}Q$iB}TOYLJ literal 0 HcmV?d00001