From 5c953b1dc0ae25633f1401282c1a3bbd01d47444 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 17 Dec 2019 21:43:30 +0100 Subject: [PATCH] Add more node sounds for ocean plants --- mods/ITEMS/mcl_ocean/corals.lua | 4 ++++ mods/ITEMS/mcl_ocean/seagrass.lua | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_ocean/corals.lua b/mods/ITEMS/mcl_ocean/corals.lua index 56124db971..a1a029b7ec 100644 --- a/mods/ITEMS/mcl_ocean/corals.lua +++ b/mods/ITEMS/mcl_ocean/corals.lua @@ -56,6 +56,10 @@ local function coral_on_place(itemstack, placer, pointed_thing) node_under.param2 = node_under.param2 + 8 end minetest.set_node(pos_under, node_under) + local def_node = minetest.registered_nodes[node_under.name] + if def_node.sounds then + minetest.sound_play(def_node.sounds.place, { gain = 0.5, pos = pos_under }) + end if not (minetest.settings:get_bool("creative_mode")) then itemstack:take_item() end diff --git a/mods/ITEMS/mcl_ocean/seagrass.lua b/mods/ITEMS/mcl_ocean/seagrass.lua index 8a453901ee..adffac5f00 100644 --- a/mods/ITEMS/mcl_ocean/seagrass.lua +++ b/mods/ITEMS/mcl_ocean/seagrass.lua @@ -48,10 +48,17 @@ local function seagrass_on_place(itemstack, placer, pointed_thing) return itemstack end + -- Select a seagrass node if node_under.name == "mcl_core:dirt" then node_under.name = "mcl_ocean:seagrass_dirt" elseif node_under.name == "mcl_core:clay" then node_under.name = "mcl_ocean:seagrass_clay" + elseif node_under.name == "mcl_core:sand" then + node_under.name = "mcl_ocean:seagrass_sand" + elseif node_under.name == "mcl_core:redsand" then + node_under.name = "mcl_ocean:seagrass_redsand" + elseif node_under.name == "mcl_core:gravel" then + node_under.name = "mcl_ocean:seagrass_gravel" else return itemstack end @@ -60,6 +67,10 @@ local function seagrass_on_place(itemstack, placer, pointed_thing) -- Random horizontal displacement node_under.param2 = node_under.param2 + 8 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 minetest.set_node(pos_under, node_under) if not (minetest.settings:get_bool("creative_mode")) then itemstack:take_item() @@ -83,6 +94,11 @@ for s=1, #surfaces do 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:seagrass_"..surfaces[s][1], { drawtype = "plantlike_rooted", paramtype = "light", @@ -105,7 +121,7 @@ for s=1, #surfaces do }, }, groups = { dig_immediate = 3, deco_block = 1, plant = 1, seagrass = 1, falling_node = surfaces[s][3] }, - sounds = mcl_sounds.node_sound_leaves_defaults({footstep = mcl_sounds.node_sound_dirt_defaults().footstep}), + sounds = sounds, node_dig_prediction = surfaces[s][2], after_dig_node = function(pos) minetest.set_node(pos, {name=surfaces[s][2]})