From b81396c03f012a5aa05a02f85c1375112b1f2281 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 17 Dec 2019 21:24:57 +0100 Subject: [PATCH] Add falling node variants of seagrass --- API.md | 1 + mods/ENTITIES/mcl_falling_nodes/init.lua | 8 ++++++-- mods/ITEMS/mcl_ocean/corals.lua | 8 ++++---- mods/ITEMS/mcl_ocean/seagrass.lua | 17 +++++++++++------ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/API.md b/API.md index 7611ce44..344414b7 100644 --- a/API.md +++ b/API.md @@ -21,6 +21,7 @@ All nodes can have these fields: * `_mcl_hardness`: Hardness of the block, ranges from 0 to infinity (represented by -1). Determines digging times. Default: 0 * `_mcl_blast_resistance`: How well this block blocks and resists explosions. Default: 0 +* `_mcl_falling_node_alternative`: If set to an itemstring, the node will turn into this node before it starts to fall. * `_mcl_after_falling(pos)`: Called after a falling node finished falling and turned into a node. Use the `mcl_sounds` mod for the sounds. diff --git a/mods/ENTITIES/mcl_falling_nodes/init.lua b/mods/ENTITIES/mcl_falling_nodes/init.lua index d5dd6c47..71478bfe 100644 --- a/mods/ENTITIES/mcl_falling_nodes/init.lua +++ b/mods/ENTITIES/mcl_falling_nodes/init.lua @@ -79,10 +79,14 @@ minetest.register_entity(":__builtin:falling_node", { meta = {}, set_node = function(self, node, meta) + local def = core.registered_nodes[node.name] + -- Change falling node if definition tells us to + if def and def._mcl_falling_node_alternative then + node.name = def._mcl_falling_node_alternative + end + local glow self.node = node self.meta = meta or {} - local def = core.registered_nodes[node.name] - local glow -- Set correct entity yaw if def and node.param2 ~= 0 then if (def.paramtype2 == "facedir" or def.paramtype2 == "colorfacedir") then diff --git a/mods/ITEMS/mcl_ocean/corals.lua b/mods/ITEMS/mcl_ocean/corals.lua index 8e6ff422..56124db9 100644 --- a/mods/ITEMS/mcl_ocean/corals.lua +++ b/mods/ITEMS/mcl_ocean/corals.lua @@ -110,7 +110,7 @@ for c=1, #corals do node_placement_prediction = "", node_dig_prediction = "mcl_ocean:"..id.."_coral_block", on_place = coral_on_place, - after_destruct = function(pos) + after_dig_node = function(pos) local node = minetest.get_node(pos) if minetest.get_item_group(node.name, "coral") == 0 then minetest.set_node(pos, {name="mcl_ocean:"..id.."_coral_block"}) @@ -140,7 +140,7 @@ for c=1, #corals do node_placement_prediction = "", node_dig_prediction = "mcl_ocean:dead_"..id.."_coral_block", on_place = coral_on_place, - after_destruct = function(pos) + after_dig_node = function(pos) local node = minetest.get_node(pos) if minetest.get_item_group(node.name, "coral") == 0 then minetest.set_node(pos, {name="mcl_ocean:dead_"..id.."_coral_block"}) @@ -173,7 +173,7 @@ for c=1, #corals do node_placement_prediction = "", node_dig_prediction = "mcl_ocean:"..id.."_coral_block", on_place = coral_on_place, - after_destruct = function(pos) + after_dig_node = function(pos) local node = minetest.get_node(pos) if minetest.get_item_group(node.name, "coral") == 0 then minetest.set_node(pos, {name="mcl_ocean:"..id.."_coral_block"}) @@ -203,7 +203,7 @@ for c=1, #corals do node_placement_prediction = "", node_dig_prediction = "mcl_ocean:dead_"..id.."_coral_block", on_place = coral_on_place, - after_destruct = function(pos) + after_dig_node = function(pos) local node = minetest.get_node(pos) if minetest.get_item_group(node.name, "coral") == 0 then minetest.set_node(pos, {name="mcl_ocean:dead_"..id.."_coral_block"}) diff --git a/mods/ITEMS/mcl_ocean/seagrass.lua b/mods/ITEMS/mcl_ocean/seagrass.lua index 984c545c..8a453901 100644 --- a/mods/ITEMS/mcl_ocean/seagrass.lua +++ b/mods/ITEMS/mcl_ocean/seagrass.lua @@ -4,6 +4,9 @@ local S = minetest.get_translator("mcl_ocean") 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 seagrass_on_place(itemstack, placer, pointed_thing) @@ -76,6 +79,10 @@ minetest.register_craftitem("mcl_ocean:seagrass", { 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 minetest.register_node("mcl_ocean:seagrass_"..surfaces[s][1], { drawtype = "plantlike_rooted", paramtype = "light", @@ -97,16 +104,14 @@ for s=1, #surfaces do { -0.5, 0.5, -0.5, 0.5, 1.3, 0.5 }, }, }, - groups = { dig_immediate = 3, deco_block = 1, plant = 1, seagrass = 1, }, + 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}), node_dig_prediction = surfaces[s][2], - after_destruct = function(pos) - local node = minetest.get_node(pos) - if minetest.get_item_group(node.name, "seagrass") == 0 then - minetest.set_node(pos, {name=surfaces[s][2]}) - end + after_dig_node = function(pos) + minetest.set_node(pos, {name=surfaces[s][2]}) end, drop = "", + _mcl_falling_node_alternative = alt, _mcl_shears_drop = true, _mcl_hardness = 0, _mcl_blast_resistance = 0,