From d87d8e51f5c1dc4beb7dbd8c49d9063311e46bb3 Mon Sep 17 00:00:00 2001 From: Oversword Date: Mon, 7 Jun 2021 17:04:31 +0000 Subject: [PATCH 1/2] Fixes bug with stalactite placement --- cavestuff/nodes.lua | 101 +++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 43 deletions(-) diff --git a/cavestuff/nodes.lua b/cavestuff/nodes.lua index e6ae02c..654ceeb 100644 --- a/cavestuff/nodes.lua +++ b/cavestuff/nodes.lua @@ -12,65 +12,65 @@ minetest.register_node("cavestuff:pebble_1",{ description = S("Pebble"), drawtype = "mesh", mesh = "cavestuff_pebble.obj", - tiles = {"undergrowth_pebble.png"}, - paramtype = "light", + tiles = {"undergrowth_pebble.png"}, + paramtype = "light", paramtype2 = "facedir", - groups = {cracky=3, stone=1}, - selection_box = cbox, - collision_box = cbox, - on_place = function(itemstack, placer, pointed_thing) + groups = {cracky=3, stone=1}, + selection_box = cbox, + collision_box = cbox, + on_place = function(itemstack, placer, pointed_thing) -- place a random pebble node local stack = ItemStack("cavestuff:pebble_"..math.random(1,2)) local ret = minetest.item_place(stack, placer, pointed_thing) return ItemStack("cavestuff:pebble_1 "..itemstack:get_count()-(1-ret:get_count())) end, - sounds = default.node_sound_stone_defaults(), + sounds = default.node_sound_stone_defaults(), }) minetest.register_node("cavestuff:pebble_2",{ drawtype = "mesh", mesh = "cavestuff_pebble.obj", - tiles = {"undergrowth_pebble.png"}, + tiles = {"undergrowth_pebble.png"}, drop = "cavestuff:pebble_1", - tiles = {"undergrowth_pebble.png"}, - paramtype = "light", + tiles = {"undergrowth_pebble.png"}, + paramtype = "light", paramtype2 = "facedir", - groups = {cracky=3, stone=1, not_in_creative_inventory=1}, + groups = {cracky=3, stone=1, not_in_creative_inventory=1}, selection_box = cbox, collision_box = cbox, - sounds = default.node_sound_stone_defaults(), + sounds = default.node_sound_stone_defaults(), }) minetest.register_node("cavestuff:desert_pebble_1",{ description = S("Desert Pebble"), drawtype = "mesh", mesh = "cavestuff_pebble.obj", - tiles = {"default_desert_stone.png"}, - paramtype = "light", + tiles = {"default_desert_stone.png"}, + paramtype = "light", paramtype2 = "facedir", - groups = {cracky=3, stone=1}, + groups = {cracky=3, stone=1}, selection_box = cbox, collision_box = cbox, - on_place = function(itemstack, placer, pointed_thing) + on_place = function(itemstack, placer, pointed_thing) -- place a random pebble node local stack = ItemStack("cavestuff:desert_pebble_"..math.random(1,2)) local ret = minetest.item_place(stack, placer, pointed_thing) return ItemStack("cavestuff:desert_pebble_1 "..itemstack:get_count()-(1-ret:get_count())) end, - sounds = default.node_sound_stone_defaults(), + sounds = default.node_sound_stone_defaults(), }) minetest.register_node("cavestuff:desert_pebble_2",{ drawtype = "mesh", mesh = "cavestuff_pebble.obj", drop = "cavestuff:desert_pebble_1", - tiles = {"default_desert_stone.png"}, - paramtype = "light", + tiles = {"default_desert_stone.png"}, + paramtype = "light", paramtype2 = "facedir", - groups = {cracky=3, stone=1, not_in_creative_inventory=1}, + groups = {cracky=3, stone=1, not_in_creative_inventory=1}, selection_box = cbox, collision_box = cbox, - sounds = default.node_sound_stone_defaults(), + sounds = default.node_sound_stone_defaults(), }) --Staclactites @@ -85,19 +85,34 @@ minetest.register_node("cavestuff:stalactite_1",{ node_box = { type = "fixed", fixed = { - {-0.187500,0.425000,-0.150003,0.162500,0.500000,0.162500}, - {-0.112500,0.162500,-0.100000,0.087500,0.475000,0.087500}, - {-0.062500,-0.275000,-0.062500,0.062500,0.500000,0.062500}, - {-0.037500,-0.837500,0.037500,0.037500,0.500000,-0.025000}, + {-0.187500,-0.425000,-0.150003,0.162500,-0.500000,0.162500}, + {-0.112500,-0.162500,-0.100000,0.087500,-0.475000,0.087500}, + {-0.062500,0.275000,-0.062500,0.062500,-0.500000,0.062500}, + {-0.037500,0.837500,0.037500,0.037500,-0.500000,-0.025000}, } }, - on_place = function(itemstack, placer, pointed_thing) - local pt = pointed_thing - if minetest.get_node(pt.under).name=="default:stone" - and minetest.get_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}).name=="air" - and minetest.get_node({x=pt.under.x, y=pt.under.y-2, z=pt.under.z}).name=="air" then - minetest.swap_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}, {name="cavestuff:stalactite_"..math.random(1,3)}) + local dir = vector.subtract(pointed_thing.above, pointed_thing.under) + local base = pointed_thing.under + local place = vector.add(base, dir) + local above = vector.add(place, dir) + + if not placer then return end + local playername = placer:get_player_name() + if minetest.is_protected(place, playername) + or minetest.is_protected(above, playername) then + minetest.record_protection_violation(place, playername) + return + end + + if minetest.get_node(base).name == "default:stone" + and minetest.get_node(place).name == "air" + and minetest.get_node(above).name == "air" + then + minetest.swap_node(place, { + name = "cavestuff:stalactite_"..math.random(1,3), + param2 = minetest.dir_to_wallmounted(vector.multiply(dir, -1)) + }) if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end @@ -116,10 +131,10 @@ minetest.register_node("cavestuff:stalactite_2",{ node_box = { type = "fixed", fixed = { - {-0.187500,0.387500,-0.150003,0.162500,0.500000,0.162500}, - {-0.112500,0.112500,-0.100000,0.087500,0.475000,0.087500}, - {-0.062500,-0.675000,-0.062500,0.062500,0.500000,0.062500}, - {-0.037500,-0.975000,0.037500,0.037500,0.500000,-0.025000}, + {-0.187500,-0.387500,-0.150003,0.162500,-0.500000,0.162500}, + {-0.112500,-0.112500,-0.100000,0.087500,-0.475000,0.087500}, + {-0.062500,0.675000,-0.062500,0.062500,-0.500000,0.062500}, + {-0.037500,0.975000,0.037500,0.037500,-0.500000,-0.025000}, } }, }) @@ -132,14 +147,14 @@ minetest.register_node("cavestuff:stalactite_3",{ paramtype = "light", paramtype2 = "wallmounted", node_box = { - type = "fixed", - fixed = { - {-0.187500,0.387500,-0.150003,0.162500,0.500000,0.162500}, - {-0.112500,0.037500,-0.100000,0.087500,0.475000,0.087500}, - {-0.062500,-0.437500,-0.062500,0.062500,0.500000,0.062500}, - {-0.037500,-1.237500,0.037500,0.037500,0.500000,-0.025000}, - } - }, + type = "fixed", + fixed = { + {-0.187500,-0.387500,-0.150003,0.162500,-0.500000,0.162500}, + {-0.112500,-0.037500,-0.100000,0.087500,-0.475000,0.087500}, + {-0.062500,0.437500,-0.062500,0.062500,-0.500000,0.062500}, + {-0.037500,1.237500,0.037500,0.037500,-0.500000,-0.025000}, + } + }, }) --Stalagmites From 7b4f54ead08eacdee32a93113cc0df1d401a9b32 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Sat, 19 Jun 2021 20:34:22 -0400 Subject: [PATCH 2/2] make youngtrees, bushes fall on dig, make moss fall when the node holding it is dug, and make trunk roots decay (exploiting the standard leafdecay function) --- bushes/init.lua | 8 +++++--- trunks/nodes.lua | 12 +++++++++--- youngtrees/init.lua | 8 ++++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/bushes/init.lua b/bushes/init.lua index 4be5a61..64a9adf 100644 --- a/bushes/init.lua +++ b/bushes/init.lua @@ -26,7 +26,7 @@ node_box = { {-0.0612,-0.500000,-0.500000,0.0612,0.500000,-0.375000}, --NodeBox 1 } }, - groups = {snappy=3,flammable=2}, + groups = {snappy=3,flammable=2,attached_node=1}, sounds = default.node_sound_leaves_defaults(), drop = 'default:stick' }) @@ -61,7 +61,8 @@ for i in pairs(BushBranchCenter) do -- tree=1, -- MM: disabled because some recipes use group:tree for trunks snappy=3, flammable=2, - leaves=1 + leaves=1, + attached_node=1 }, sounds = default.node_sound_leaves_defaults(), drop = 'default:stick 4' @@ -104,7 +105,8 @@ for i in pairs(BushBranchSide) do -- tree=1, -- MM: disabled because some recipes use group:tree for trunks snappy=3, flammable=2, - leaves=1 + leaves=1, + attached_node=1 }, sounds = default.node_sound_leaves_defaults(), drop = 'default:stick 3' diff --git a/trunks/nodes.lua b/trunks/nodes.lua index f60281b..5f3906f 100644 --- a/trunks/nodes.lua +++ b/trunks/nodes.lua @@ -79,7 +79,7 @@ minetest.register_node("trunks:moss", { walkable = false, node_box = {type = "fixed", fixed = flat_moss}, selection_box = {type = "fixed", fixed = flat_stick},--{type = "wallmounted"}, - groups = {snappy = 3, flammable = 3 }, + groups = {snappy = 3, flammable = 3, attached_node=1 }, sounds = default.node_sound_leaves_defaults(), }) @@ -98,7 +98,7 @@ minetest.register_node("trunks:moss_fungus", { walkable = false, node_box = {type = "fixed", fixed = flat_moss}, selection_box = {type = "fixed", fixed = flat_stick},--{type = "wallmounted"}, - groups = {snappy = 3, flammable = 3 }, + groups = {snappy = 3, flammable = 3, attached_node=1 }, sounds = default.node_sound_leaves_defaults(), }) @@ -361,13 +361,19 @@ for i in pairs(TRuNKS) do snappy=1, choppy=2, oddly_breakable_by_hand=1, - flammable=2--, + flammable=2, --not_in_creative_inventory=1 -- atm in inv for testing }, --drop = "trunks:twig_1", -- not sure about this yet sounds = default.node_sound_wood_defaults(), }) + default.register_leafdecay({ + trunks = { MoD..":"..TRuNK }, + leaves = { "trunks:"..TRuNK.."root" }, + radius = 1, + }) + else minetest.log("error", string.format("[Trunks] warning: tree type '%s:%s' not found", MoD, TRuNK)) end diff --git a/youngtrees/init.lua b/youngtrees/init.lua index 50d11ff..ca74de1 100644 --- a/youngtrees/init.lua +++ b/youngtrees/init.lua @@ -40,7 +40,7 @@ minetest.register_node("youngtrees:youngtree2_middle",{ {-0.500000,0.125000,-0.500000,0.500000,0.500000,0.500000}, --NodeBox 3 } }, - groups = {snappy=3,flammable=2}, + groups = {snappy=3,flammable=2,attached_node=1}, sounds = default.node_sound_leaves_defaults(), drop = 'trunks:twig_1' }) @@ -58,7 +58,7 @@ minetest.register_node("youngtrees:youngtree_top", { type = "fixed", fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3} }, - groups = {snappy=3,flammable=2}, + groups = {snappy=3,flammable=2,attached_node=1}, sounds = default.node_sound_leaves_defaults(), drop = 'trunks:twig_1' }) @@ -77,7 +77,7 @@ minetest.register_node("youngtrees:youngtree_middle", { type = "fixed", fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3} }, - groups = {snappy=3,flammable=2}, + groups = {snappy=3,flammable=2,attached_node=1}, sounds = default.node_sound_leaves_defaults(), drop = 'trunks:twig_1' }) @@ -97,7 +97,7 @@ minetest.register_node("youngtrees:youngtree_bottom", { type = "fixed", fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3} }, - groups = {snappy=3,flammable=2}, + groups = {snappy=3,flammable=2,attached_node=1}, sounds = default.node_sound_leaves_defaults(), drop = 'trunks:twig_1' })