From 40e681a5665d4646d5e1cc553019f06984d30792 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 17 Dec 2019 22:43:35 +0100 Subject: [PATCH] Add kelp and related items --- mods/ITEMS/mcl_ocean/corals.lua | 2 +- mods/ITEMS/mcl_ocean/depends.txt | 1 + mods/ITEMS/mcl_ocean/init.lua | 3 + mods/ITEMS/mcl_ocean/kelp.lua | 185 ++++++++++++++++++ mods/ITEMS/mcl_ocean/seagrass.lua | 2 +- .../textures/mcl_ocean_dried_kelp.png | Bin 0 -> 414 bytes .../textures/mcl_ocean_dried_kelp_bottom.png | Bin 0 -> 364 bytes .../textures/mcl_ocean_dried_kelp_side.png | Bin 0 -> 360 bytes .../textures/mcl_ocean_dried_kelp_top.png | Bin 0 -> 364 bytes .../textures/mcl_ocean_kelp_item.png | Bin 0 -> 396 bytes .../textures/mcl_ocean_kelp_plant.png | Bin 0 -> 2291 bytes 11 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 mods/ITEMS/mcl_ocean/kelp.lua create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp_bottom.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp_side.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp_top.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_kelp_item.png create mode 100644 mods/ITEMS/mcl_ocean/textures/mcl_ocean_kelp_plant.png diff --git a/mods/ITEMS/mcl_ocean/corals.lua b/mods/ITEMS/mcl_ocean/corals.lua index a1a029b7e..14546b4b6 100644 --- a/mods/ITEMS/mcl_ocean/corals.lua +++ b/mods/ITEMS/mcl_ocean/corals.lua @@ -50,7 +50,7 @@ local function coral_on_place(itemstack, placer, pointed_thing) end node_under.name = itemstack:get_name() - node_under.param2 = minetest.registered_items[itemstack:get_name()].place_param2 or 1 + node_under.param2 = minetest.registered_items[node_under.name].place_param2 or 1 if node_under.param2 < 8 and math.random(1,2) == 1 then -- Random horizontal displacement node_under.param2 = node_under.param2 + 8 diff --git a/mods/ITEMS/mcl_ocean/depends.txt b/mods/ITEMS/mcl_ocean/depends.txt index b214a2f9d..d950d6079 100644 --- a/mods/ITEMS/mcl_ocean/depends.txt +++ b/mods/ITEMS/mcl_ocean/depends.txt @@ -2,3 +2,4 @@ mcl_core mcl_sounds mcl_dye doc_items +screwdriver? diff --git a/mods/ITEMS/mcl_ocean/init.lua b/mods/ITEMS/mcl_ocean/init.lua index aee7ead16..cf63f98ba 100644 --- a/mods/ITEMS/mcl_ocean/init.lua +++ b/mods/ITEMS/mcl_ocean/init.lua @@ -6,3 +6,6 @@ dofile(minetest.get_modpath(minetest.get_current_modname()).."/corals.lua") -- Seagrass dofile(minetest.get_modpath(minetest.get_current_modname()).."/seagrass.lua") + +-- Kelp +dofile(minetest.get_modpath(minetest.get_current_modname()).."/kelp.lua") diff --git a/mods/ITEMS/mcl_ocean/kelp.lua b/mods/ITEMS/mcl_ocean/kelp.lua new file mode 100644 index 000000000..4404d907a --- /dev/null +++ b/mods/ITEMS/mcl_ocean/kelp.lua @@ -0,0 +1,185 @@ +local S = minetest.get_translator("mcl_ocean") + +-- List of supported surfaces for seagrass and kelp +local surfaces = { + { "dirt", "mcl_core:dirt" }, + { "clay", "mcl_core:clay" }, + { "sand", "mcl_core:sand", 1 }, + { "redsand", "mcl_core:redsand", 1 }, + { "gravel", "mcl_core:gravel", 1 }, +} + +local function kelp_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 pos_under.y >= pos_above.y then + return itemstack + end + + -- Placement rules: + -- Seagrass can only be placed on top of dirt inside water + local g_above_water = minetest.get_item_group(node_above.name, "water") + if not (g_above_water ~= 0 and def_above.liquidtype == "source") then + return 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 + + -- Select a kelp node + if node_under.name == "mcl_core:dirt" then + node_under.name = "mcl_ocean:kelp_dirt" + elseif node_under.name == "mcl_core:clay" then + node_under.name = "mcl_ocean:kelp_clay" + elseif node_under.name == "mcl_core:sand" then + node_under.name = "mcl_ocean:kelp_sand" + elseif node_under.name == "mcl_core:redsand" then + node_under.name = "mcl_ocean:kelp_redsand" + elseif node_under.name == "mcl_core:gravel" then + node_under.name = "mcl_ocean:kelp_gravel" + else + return itemstack + end + local def_node = minetest.registered_items[node_under.name] + if def_node.sounds then + minetest.sound_play(def_node.sounds.place, { gain = 0.5, pos = pos_under }) + end + node_under.param2 = minetest.registered_items[node_under.name].place_param2 or 16 + minetest.set_node(pos_under, node_under) + if not (minetest.settings:get_bool("creative_mode")) then + itemstack:take_item() + end + + return itemstack +end + +minetest.register_craftitem("mcl_ocean:kelp", { + description = S("Kelp"), + inventory_image = "mcl_ocean_kelp_item.png", + wield_image = "mcl_ocean_kelp_item.png", + on_place = kelp_on_place, +}) + +-- Kelp nodes: kelp on a surface node + +for s=1, #surfaces do + local def = minetest.registered_nodes[surfaces[s][2]] + local alt + if surfaces[s][3] == 1 then + alt = surfaces[s][2] + end + local sounds = table.copy(def.sounds) + local leaf_sounds = mcl_sounds.node_sound_leaves_defaults() + sounds.dig = leaf_sounds.dig + sounds.dug = leaf_sounds.dug + sounds.place = leaf_sounds.place + minetest.register_node("mcl_ocean:kelp_"..surfaces[s][1], { + drawtype = "plantlike_rooted", + paramtype = "light", + paramtype2 = "leveled", + place_param2 = 16, + tiles = def.tiles, + special_tiles = { + { + image = "mcl_ocean_kelp_plant.png", + animation = {type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}, + tileable_vertical = true, + } + }, + inventory_image = "("..def.tiles[1]..")^mcl_ocean_kelp_item.png", + wield_image = "mcl_ocean_kelp_item.png", + selection_box = { + type = "fixed", + fixed = { + { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }, + { -0.5, 0.5, -0.5, 0.5, 1.5, 0.5 }, + }, + }, + groups = { dig_immediate = 3, deco_block = 1, plant = 1, kelp = 1, falling_node = surfaces[s][3] }, + sounds = sounds, + node_dig_prediction = surfaces[s][2], + after_dig_node = function(pos) + minetest.set_node(pos, {name=surfaces[s][2]}) + end, + drop = "mcl_ocean:kelp", + _mcl_falling_node_alternative = alt, + _mcl_hardness = 0, + _mcl_blast_resistance = 0, + }) +end + + +-- Dried kelp stuff + +-- TODO: This is supposed to be eaten very fast +minetest.register_craftitem("mcl_ocean:dried_kelp", { + description = S("Dried Kelp"), + inventory_image = "mcl_ocean_dried_kelp.png", + wield_image = "mcl_ocean_dried_kelp.png", + groups = { food = 2, eatable = 1 }, + on_place = minetest.item_eat(1), + on_secondary_use = minetest.item_eat(1), + groups = { food = 2, eatable = 1 }, + _mcl_saturation = 0.6, +}) + +local mod_screwdriver = minetest.get_modpath("screwdriver") ~= nil +local on_rotate +if mod_screwdriver then + on_rotate = screwdriver.rotate_3way +end + + +minetest.register_node("mcl_ocean:dried_kelp_block", { + description = S("Dried Kelp Block"), + tiles = { "mcl_ocean_dried_kelp_top.png", "mcl_ocean_dried_kelp_bottom.png", "mcl_ocean_dried_kelp_side.png" }, + groups = { handy = 1, building_block = 1, flammable = 2 }, + sounds = mcl_sounds.node_sound_leaves_defaults(), + paramtype2 = "facedir", + on_place = mcl_util.rotate_axis, + on_rotate = on_rotate, + _mcl_hardness = 0.5, + _mcl_blast_resistance = 12.5, +}) + +minetest.register_craft({ + type = "cooking", + recipe = "mcl_ocean:kelp", + output = "mcl_ocean:dried_kelp", + cooktime = 10, +}) +minetest.register_craft({ + recipe = { + { "mcl_ocean:dried_kelp","mcl_ocean:dried_kelp","mcl_ocean:dried_kelp" }, + { "mcl_ocean:dried_kelp","mcl_ocean:dried_kelp","mcl_ocean:dried_kelp" }, + { "mcl_ocean:dried_kelp","mcl_ocean:dried_kelp","mcl_ocean:dried_kelp" }, + }, + output = "mcl_ocean:dried_kelp_block", +}) +minetest.register_craft({ + type = "fuel", + recipe = "mcl_ocean:dried_kelp_block", + burntime = 200, +}) diff --git a/mods/ITEMS/mcl_ocean/seagrass.lua b/mods/ITEMS/mcl_ocean/seagrass.lua index adffac5f0..74546be2b 100644 --- a/mods/ITEMS/mcl_ocean/seagrass.lua +++ b/mods/ITEMS/mcl_ocean/seagrass.lua @@ -62,7 +62,7 @@ local function seagrass_on_place(itemstack, placer, pointed_thing) else return itemstack end - node_under.param2 = minetest.registered_items[itemstack:get_name()].place_param2 or 3 + node_under.param2 = minetest.registered_items[node_under.name].place_param2 or 3 if node_under.param2 < 8 and math.random(1,2) == 1 then -- Random horizontal displacement node_under.param2 = node_under.param2 + 8 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp.png new file mode 100644 index 0000000000000000000000000000000000000000..2d7879200d038ff90bbdc717d24890037a28a63b GIT binary patch literal 414 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkErdA3vpBHx%reQ|qJVtzpN_@PN~1e(I;RrV10bNUv+F0vH5XCJEeiQt(bRzFRz_ z-BadX(-p2D?JILX{@a*#Am!Wv`)luf^S`a1sGj(K^#+%_lIKg+@>%k(2kvN9*m~%# zRo61}I8m;=!j9Mf|FHvI#MgPyY{|5o;61aJ3LiKRjoFQ!pA9%yhHjeI zuDNZy=n2nC^*ZUw+R2VOCtS7(*qa?Ye(`bFNy~{JS=RQhxw1ASARQFUp00i_>zopr E0FD%>0ssI2 literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp_bottom.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..148ecfd3535223665e8ef08a8416a93c34fcf4c6 GIT binary patch literal 364 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt3( zJ<}BT2#_^*JzX3_Ec|^Zd2=y2^0@pq+9l{BFhx>i=G`@E&;PD}#H~MtcjL+>c6S4h zZ(9HT{NvI+njgPb-rhG`SG3FW%>!oH)?fqSzlIH`8=P+0O`K@ulVs01ThzHByin@b zea5YZ48d0oH$JtAJ@-{*g7W7B_rzq2Pj%coD51S_=J^HtmhOCh#Gz8r^-+z#Lc>HA4jSz{2j0@KA`0*}Vl4&X-6Z!v=iC^Ykt=tI5_YU^e&o~&?7H?v! zwI~%3^psq+iB~XCuURkqh2ZyiW!nS#rz*cqjQaMK{bK2kp9&h>kAWU#@O1TaS?83{ F1OSddiPr!C literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp_side.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp_side.png new file mode 100644 index 0000000000000000000000000000000000000000..71d1cb2ad6ab9d0a74fec78e813f508d34658882 GIT binary patch literal 360 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt3( zJ<}BT2#_^5JzX3_Ec|mPIdUB`5OJxNWYz3Y3K3blqxk7L=_=Opd5$(s?jNU$FWbmf zIOES5@4BSfcPsb5-2Jpnbg`92md3eTmY1KE*v_epmAmz#9q=&rSlTFM7F zpCvIZU<{Ip7CNw7Omu=g!?%JU=6P|+$_Mlr+WuZ((2FcLS%3WP-#zZ?mov_Y3w&N} z`1I13hD&aJ^R`U!sSH!QBj<18?-}y`aD-01O!kU~EW>~H2RIxSv7O=3t(?bP0l+XkKI7xzJ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp_top.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_dried_kelp_top.png new file mode 100644 index 0000000000000000000000000000000000000000..148ecfd3535223665e8ef08a8416a93c34fcf4c6 GIT binary patch literal 364 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt3( zJ<}BT2#_^*JzX3_Ec|^Zd2=y2^0@pq+9l{BFhx>i=G`@E&;PD}#H~MtcjL+>c6S4h zZ(9HT{NvI+njgPb-rhG`SG3FW%>!oH)?fqSzlIH`8=P+0O`K@ulVs01ThzHByin@b zea5YZ48d0oH$JtAJ@-{*g7W7B_rzq2Pj%coD51S_=J^HtmhOCh#Gz8r^-+z#Lc>HA4jSz{2j0@KA`0*}Vl4&X-6Z!v=iC^Ykt=tI5_YU^e&o~&?7H?v! zwI~%3^psq+iB~XCuURkqh2ZyiW!nS#rz*cqjQaMK{bK2kp9&h>kAWU#@O1TaS?83{ F1OSddiPr!C literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_ocean/textures/mcl_ocean_kelp_item.png b/mods/ITEMS/mcl_ocean/textures/mcl_ocean_kelp_item.png new file mode 100644 index 0000000000000000000000000000000000000000..396f8b3efbe9409a097966bd185d76c43a263186 GIT binary patch literal 396 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkEUD{gefxFIv#pF7<5HgbW?9;ba!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