From f2eca64e42364bc6f597d1fd552352e4818501cf Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sun, 18 Jun 2023 20:59:37 +0200 Subject: [PATCH 01/15] Blocks with dig_by_piston no longer fill up the push limit Fix for broken nodes (e.g. sugar cane) not updating and leaving floating bits Short-term fix for minetest.dig_node not always working (checking for group dig_immediate = 3) --- mods/ITEMS/REDSTONE/mesecons_mvps/init.lua | 61 +++++++++++++++------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua index 58e5afd92..d85943e45 100644 --- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua @@ -117,7 +117,7 @@ local function is_available(pos) return false, n end if minetest.registered_nodes[name] then - return minetest.registered_nodes[name].buildable_to, n or false, n + return minetest.registered_nodes[name].buildable_to or minetest.get_item_group(name, "dig_by_piston") == 1, n or false, n end return false, n end @@ -126,6 +126,7 @@ end function mesecon.mvps_get_stack(pos, dir, maximum, piston_pos) -- determine the number of nodes to be pushed local nodes = {} + local dig_nodes = {} local frontiers = {pos} while #frontiers > 0 do @@ -141,8 +142,13 @@ function mesecon.mvps_get_stack(pos, dir, maximum, piston_pos) end if not node_replaceable(nn.name) then - if #nodes >= maximum then return nil, false end - table.insert(nodes, {node = nn, pos = {x=np.x, y=np.y, z=np.z}}) + if minetest.get_item_group(nn.name, "dig_by_piston") == 1 then + -- if we want the node to drop, e.g. sugar cane, do not count towards push limit + table.insert(dig_nodes, {node = nn, pos = {x=np.x, y=np.y, z=np.z}}) + else + table.insert(nodes, {node = nn, pos = {x=np.x, y=np.y, z=np.z}}) + if #nodes > maximum then return nil, nil, false, true end + end -- add connected nodes to frontiers, connected is a vector list -- the vectors must be absolute positions @@ -152,10 +158,9 @@ function mesecon.mvps_get_stack(pos, dir, maximum, piston_pos) and minetest.registered_nodes[nn.name].mvps_sticky then connected, has_loop = minetest.registered_nodes[nn.name].mvps_sticky(np, nn, piston_pos) if has_loop then - return {}, true + return {}, {}, true, false end end - table.insert(connected, vector.add(np, dir)) -- Make sure there are no duplicates in frontiers / nodes before @@ -172,7 +177,7 @@ function mesecon.mvps_get_stack(pos, dir, maximum, piston_pos) duplicate = true end end - if not duplicate and not mesecon.is_mvps_stopper(minetest.get_node(cp)) then + if not duplicate and not mesecon.is_mvps_stopper(minetest.get_node(cp)) and minetest.get_item_group(nn.name, "dig_by_piston") == 0 then table.insert(frontiers, cp) end end @@ -180,7 +185,7 @@ function mesecon.mvps_get_stack(pos, dir, maximum, piston_pos) table.remove(frontiers, 1) end - return nodes, false + return nodes, dig_nodes, false, false end function mesecon.mvps_set_owner(pos, placer) @@ -222,14 +227,14 @@ end -- movedir: direction of actual movement -- maximum: maximum nodes to be pushed function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name, piston_pos) - local nodes, has_loop = mesecon.mvps_get_stack(pos, movedir, maximum, piston_pos) + local nodes, dig_nodes, has_loop, too_many = mesecon.mvps_get_stack(pos, movedir, maximum, piston_pos) - if has_loop then + if has_loop or too_many then return false end if not nodes then return end - + local newpos={} -- check node availability to push/pull into, and fill newpos[i] for i in ipairs(nodes) do @@ -253,18 +258,36 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name, end end - if are_protected(nodes, player_name) then + local all_nodes = nodes + if dig_nodes and #dig_nodes > 0 then all_nodes = mesecon.mergetable(dig_nodes, nodes) end + if are_protected(all_nodes, player_name) then return end local first_dropper = nil -- remove all nodes - for id, n in ipairs(nodes) do + for id, n in ipairs(all_nodes) do n.meta = minetest.get_meta(n.pos):to_table() - local is_dropper = mesecon.is_mvps_dropper(n.node, movedir, nodes, id) + local is_dropper = mesecon.is_mvps_dropper(n.node, movedir, all_nodes, id) if is_dropper then - --local drops = minetest.get_node_drops(n.node.name, "") - minetest.dig_node(n.pos) + -- minetest.dig_node has been shown to be buggy (https://git.minetest.land/MineClone2/MineClone2/issues/3547) + if minetest.get_item_group(n.node.name, "dig_immediate") == 3 then + -- should dig as normal + minetest.dig_node(n.pos) + else + -- simulate dig_node because nothing drops otherwise + local drops = minetest.get_node_drops(n.node.name, "") + minetest.remove_node(n.pos) + for _, callback in pairs(minetest.registered_on_dignodes) do + callback(n.pos, n) + end + for _, item in ipairs(drops) do + if type(item) ~= "string" then + item = item:get_name() .. item:get_count() + end + minetest.add_item(n.pos, item) + end + end else minetest.remove_node(n.pos) local node_timer = minetest.get_node_timer(n.pos) @@ -273,13 +296,13 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name, end end if is_dropper then - first_dropper = id - break + -- get id of the first dropper, but we still let everything else drop, so don't break here + if not first_dropper then first_dropper = id end end end -- update mesecons for removed nodes ( has to be done after all nodes have been removed ) - for id, n in ipairs(nodes) do + for id, n in ipairs(all_nodes) do if first_dropper and id >= first_dropper then break end @@ -287,7 +310,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name, end -- add nodes - for id, n in ipairs(nodes) do + for id, n in ipairs(all_nodes) do if first_dropper and id >= first_dropper then break end From af206ed8b33ed4bb34b04ae9b0c264255b339d74 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sun, 18 Jun 2023 21:14:43 +0200 Subject: [PATCH 02/15] All bamboo plant tiles can be broken with pistons --- mods/ITEMS/mcl_bamboo/bamboo_base.lua | 8 ++++---- mods/ITEMS/mcl_bamboo/globals.lua | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_bamboo/bamboo_base.lua b/mods/ITEMS/mcl_bamboo/bamboo_base.lua index 1c7e99a61..0cbea4361 100644 --- a/mods/ITEMS/mcl_bamboo/bamboo_base.lua +++ b/mods/ITEMS/mcl_bamboo/bamboo_base.lua @@ -251,7 +251,7 @@ local bamboo_def = { minetest.register_node(BAMBOO, bamboo_def) local bamboo_top = table.copy(bamboo_def) -bamboo_top.groups = {not_in_creative_inventory = 1, handy = 1, axey = 1, choppy = 1, flammable = 3} +bamboo_top.groups = {not_in_creative_inventory = 1, handy = 1, axey = 1, choppy = 1, dig_by_piston = 1, plant = 1, non_mycelium_plant = 1, flammable = 3} bamboo_top.tiles = {"mcl_bamboo_endcap.png"} bamboo_top.drawtype = "plantlike_rooted" --"plantlike" --bamboo_top.paramtype2 = "meshoptions" @@ -361,7 +361,7 @@ bamboo_one_def.selection_box = { {-0.05, -0.5, 0.285, -0.275, 0.5, 0.06}, } } -bamboo_one_def.groups = {not_in_creative_inventory = 1, handy = 1, axey = 1, choppy = 1, flammable = 3} +bamboo_one_def.groups = {not_in_creative_inventory = 1, handy = 1, axey = 1, choppy = 1, dig_by_piston = 1, plant = 1, non_mycelium_plant = 1, flammable = 3} mcl_bamboo.mcl_log(dump(mcl_bamboo.bamboo_index)) minetest.register_node(mcl_bamboo.bamboo_index[2], bamboo_one_def) local bamboo_two_def = table.copy(bamboo_def) @@ -385,7 +385,7 @@ bamboo_two_def.selection_box = { {0.25, -0.5, 0.325, 0.025, 0.5, 0.100}, } } -bamboo_two_def.groups = {not_in_creative_inventory = 1, handy = 1, axey = 1, choppy = 1, flammable = 3} +bamboo_two_def.groups = {not_in_creative_inventory = 1, handy = 1, axey = 1, choppy = 1, dig_by_piston = 1, plant = 1, non_mycelium_plant = 1, flammable = 3} minetest.register_node(mcl_bamboo.bamboo_index[3], bamboo_two_def) local bamboo_three_def = table.copy(bamboo_def) @@ -408,5 +408,5 @@ bamboo_three_def.selection_box = { {-0.125, -0.5, 0.125, -0.3125, 0.5, 0.3125}, } } -bamboo_three_def.groups = {not_in_creative_inventory = 1, handy = 1, axey = 1, choppy = 1, flammable = 3} +bamboo_three_def.groups = {not_in_creative_inventory = 1, handy = 1, axey = 1, choppy = 1, dig_by_piston = 1, plant = 1, non_mycelium_plant = 1, flammable = 3} minetest.register_node(mcl_bamboo.bamboo_index[4], bamboo_three_def) diff --git a/mods/ITEMS/mcl_bamboo/globals.lua b/mods/ITEMS/mcl_bamboo/globals.lua index f96395228..37fafc2fd 100644 --- a/mods/ITEMS/mcl_bamboo/globals.lua +++ b/mods/ITEMS/mcl_bamboo/globals.lua @@ -67,7 +67,7 @@ end local BAMBOO_ENDCAP_NAME = "mcl_bamboo:bamboo_endcap" --- For when I learn more about the pistons... +-- check if supporting block is broken. pistons now break the bamboo plant. function mcl_bamboo.break_orphaned(pos) mcl_bamboo.mcl_log("Break_Orphaned called.") local node_below = minetest.get_node(vector.offset(pos, 0, -1, 0)) From 918b8eee38f9474415470e6c3394f76999dba04d Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Tue, 20 Jun 2023 17:33:45 +0200 Subject: [PATCH 03/15] Fix unsticky defs for shulker_box_small names (some did not exist) --- mods/ITEMS/REDSTONE/mesecons_mvps/init.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua index d85943e45..814c5d80d 100644 --- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua @@ -930,16 +930,16 @@ mesecon.register_mvps_unsticky("mcl_chests:black_shulker_box_small") mesecon.register_mvps_unsticky("mcl_chests:blue_shulker_box_small") mesecon.register_mvps_unsticky("mcl_chests:brown_shulker_box_small") mesecon.register_mvps_unsticky("mcl_chests:cyan_shulker_box_small") +mesecon.register_mvps_unsticky("mcl_chests:dark_green_shulker_box_small") +mesecon.register_mvps_unsticky("mcl_chests:dark_grey_shulker_box_small") +mesecon.register_mvps_unsticky("mcl_chests:lightblue_shulker_box_small") mesecon.register_mvps_unsticky("mcl_chests:green_shulker_box_small") -mesecon.register_mvps_unsticky("mcl_chests:grey_shulker_box_small") -mesecon.register_mvps_unsticky("mcl_chests:light_blue_shulker_box_small") -mesecon.register_mvps_unsticky("mcl_chests:lime_shulker_box_small") mesecon.register_mvps_unsticky("mcl_chests:orange_shulker_box_small") mesecon.register_mvps_unsticky("mcl_chests:magenta_shulker_box_small") mesecon.register_mvps_unsticky("mcl_chests:pink_shulker_box_small") -mesecon.register_mvps_unsticky("mcl_chests:purple_shulker_box_small") +mesecon.register_mvps_unsticky("mcl_chests:violet_shulker_box_small") mesecon.register_mvps_unsticky("mcl_chests:red_shulker_box_small") -mesecon.register_mvps_unsticky("mcl_chests:silver_shulker_box_small") +mesecon.register_mvps_unsticky("mcl_chests:grey_shulker_box_small") mesecon.register_mvps_unsticky("mcl_chests:white_shulker_box_small") mesecon.register_mvps_unsticky("mcl_chests:yellow_shulker_box_small") -- Snow From 058684f17f8ae824dda9ced84224fc3002b824d6 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sun, 2 Jul 2023 13:08:59 +0200 Subject: [PATCH 04/15] Improve dig_node simulation and fix duplication --- mods/ITEMS/REDSTONE/mesecons/util.lua | 9 +++++++++ mods/ITEMS/REDSTONE/mesecons_mvps/init.lua | 17 ++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/util.lua b/mods/ITEMS/REDSTONE/mesecons/util.lua index b6602526a..12dbc0240 100644 --- a/mods/ITEMS/REDSTONE/mesecons/util.lua +++ b/mods/ITEMS/REDSTONE/mesecons/util.lua @@ -246,6 +246,15 @@ function mesecon.mergetable(source, dest) return rval end +-- +function mesecon.join_table(t1, t2) + local rval = mesecon.tablecopy(t2) + for i, v in ipairs(t1) do + table.insert(rval, mesecon.tablecopy(v)) + end + return rval +end + function mesecon.register_node(name, spec_common, spec_off, spec_on) spec_common.drop = spec_common.drop or name .. "_off" spec_common.on_blast = spec_common.on_blast or mesecon.on_blastnode diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua index 814c5d80d..f282f4dca 100644 --- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua @@ -234,7 +234,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name, end if not nodes then return end - + local newpos={} -- check node availability to push/pull into, and fill newpos[i] for i in ipairs(nodes) do @@ -259,7 +259,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name, end local all_nodes = nodes - if dig_nodes and #dig_nodes > 0 then all_nodes = mesecon.mergetable(dig_nodes, nodes) end + if dig_nodes and #dig_nodes > 0 then all_nodes = mesecon.join_table(dig_nodes, nodes) end if are_protected(all_nodes, player_name) then return end @@ -270,13 +270,11 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name, n.meta = minetest.get_meta(n.pos):to_table() local is_dropper = mesecon.is_mvps_dropper(n.node, movedir, all_nodes, id) if is_dropper then - -- minetest.dig_node has been shown to be buggy (https://git.minetest.land/MineClone2/MineClone2/issues/3547) - if minetest.get_item_group(n.node.name, "dig_immediate") == 3 then - -- should dig as normal - minetest.dig_node(n.pos) - else - -- simulate dig_node because nothing drops otherwise + -- if current node has already been destroyed (e.g. chain reaction of sugar cane breaking), skip it + if minetest.get_node(n.pos).name == n.node.name then + -- simulate dig_node using handle_node_drops local drops = minetest.get_node_drops(n.node.name, "") + local counted_drops = {} minetest.remove_node(n.pos) for _, callback in pairs(minetest.registered_on_dignodes) do callback(n.pos, n) @@ -285,8 +283,9 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name, if type(item) ~= "string" then item = item:get_name() .. item:get_count() end - minetest.add_item(n.pos, item) + table.insert(counted_drops, item) end + minetest.handle_node_drops(n.pos, counted_drops) end else minetest.remove_node(n.pos) From 5d8688dbebfccf31c27ce7dca500236cedceffd3 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sun, 2 Jul 2023 14:30:36 +0200 Subject: [PATCH 05/15] Change tall flowers to `buildable_to = false` --- mods/ITEMS/mcl_flowers/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index e89d01b65..24b07428a 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -252,7 +252,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im paramtype2 = paramtype2, palette = palette, walkable = false, - buildable_to = true, + buildable_to = false, drop = drop_bottom, _mcl_shears_drop = shears_drop, _mcl_fortune_drop = fortune_drop, @@ -354,7 +354,7 @@ local function add_large_plant(name, desc, longdesc, bottom_img, top_img, inv_im paramtype2 = paramtype2, palette = palette, walkable = false, - buildable_to = true, + buildable_to = false, selection_box = { type = "fixed", fixed = { -selbox_radius, -0.5, -selbox_radius, selbox_radius, selbox_top_height, selbox_radius }, From 089e3d46f18b1f09dc03a2b35ea152b996b7f110 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sun, 2 Jul 2023 16:54:56 +0200 Subject: [PATCH 06/15] Several more blocks comply with MC piston mechanics. --- mods/ITEMS/mcl_bells/init.lua | 2 +- mods/ITEMS/mcl_lanterns/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_bells/init.lua b/mods/ITEMS/mcl_bells/init.lua index 32bdfe3d7..46b8b9f89 100644 --- a/mods/ITEMS/mcl_bells/init.lua +++ b/mods/ITEMS/mcl_bells/init.lua @@ -33,7 +33,7 @@ minetest.register_node("mcl_bells:bell", { "mcl_bells_bell_side.png", }, is_ground_content = false, - groups = {pickaxey=2, deco_block=1 }, + groups = {pickaxey=2, deco_block=1, dig_by_piston=1 }, sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 5, _mcl_hardness = 5, diff --git a/mods/ITEMS/mcl_lanterns/init.lua b/mods/ITEMS/mcl_lanterns/init.lua index 5be325e48..f978358b7 100644 --- a/mods/ITEMS/mcl_lanterns/init.lua +++ b/mods/ITEMS/mcl_lanterns/init.lua @@ -118,7 +118,7 @@ function mcl_lanterns.register_lantern(name, def) node_placement_prediction = "", sunlight_propagates = true, light_source = def.light_level, - groups = {pickaxey = 1, attached_node = 1, deco_block = 1, lantern = 1}, + groups = {pickaxey = 1, attached_node = 1, deco_block = 1, lantern = 1, dig_by_piston=1}, selection_box = { type = "fixed", fixed = { From e5829f719d10d4c8376bcce3b603f42261ecb8e3 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Sun, 2 Jul 2023 17:08:44 +0200 Subject: [PATCH 07/15] All signs are mvps_stopper upon registration All buttons are mvps_unsticky upon registration Add some missing unmovable nodes Bamboo trapdoor is now sticky --- mods/ITEMS/REDSTONE/mesecons_button/init.lua | 5 +++ mods/ITEMS/REDSTONE/mesecons_mvps/init.lua | 36 +++++--------------- mods/ITEMS/mcl_signs/signs_api.lua | 34 ++++++++++++++++++ 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_button/init.lua b/mods/ITEMS/REDSTONE/mesecons_button/init.lua index 275cac2e2..b812ea956 100644 --- a/mods/ITEMS/REDSTONE/mesecons_button/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_button/init.lua @@ -211,6 +211,11 @@ function mesecon.register_button(basename, description, texture, recipeitem, sou output = "mesecons_button:button_"..basename.."_off", recipe = {{ recipeitem }}, }) + + if minetest.get_modpath("mesecons_mvps") then + mesecon.register_mvps_unsticky("mesecons_button:button_"..basename.."_off") + mesecon.register_mvps_unsticky("mesecons_button:button_"..basename.."_on") + end end mesecon.register_button( diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua index f282f4dca..12bfd0ca8 100644 --- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua @@ -433,10 +433,8 @@ mesecon.register_mvps_stopper("mesecons_solarpanel:solar_panel_inverted_on") mesecon.register_mvps_stopper("mesecons_solarpanel:solar_panel_inverted_off") mesecon.register_mvps_stopper("mcl_banners:hanging_banner") mesecon.register_mvps_stopper("mcl_banners:standing_banner") -mesecon.register_mvps_stopper("mcl_campfires:campfire") -mesecon.register_mvps_stopper("mcl_campfires:campfire_lit") -mesecon.register_mvps_stopper("mcl_campfires:soul_campfire") -mesecon.register_mvps_stopper("mcl_campfires:soul_campfire_lit") +mesecon.register_mvps_stopper("mcl_beehives:bee_nest") +mesecon.register_mvps_stopper("mcl_beehives:beehive") -- Unmovable by technical restrictions. -- Open formspec would screw up if node is destroyed (minor problem) @@ -467,13 +465,14 @@ mesecon.register_mvps_stopper("mcl_chests:trapped_chest") mesecon.register_mvps_stopper("mcl_chests:trapped_chest_small") mesecon.register_mvps_stopper("mcl_chests:trapped_chest_left") mesecon.register_mvps_stopper("mcl_chests:trapped_chest_right") -mesecon.register_mvps_stopper("mcl_signs:wall_sign") -mesecon.register_mvps_stopper("mcl_signs:standing_sign") -mesecon.register_mvps_stopper("mcl_signs:standing_sign22_5") -mesecon.register_mvps_stopper("mcl_signs:standing_sign45") -mesecon.register_mvps_stopper("mcl_signs:standing_sign67_5") mesecon.register_mvps_stopper("mcl_barrels:barrel_open") mesecon.register_mvps_stopper("mcl_barrels:barrel_closed") +mesecon.register_mvps_stopper("mcl_campfires:campfire") +mesecon.register_mvps_stopper("mcl_campfires:campfire_lit") +mesecon.register_mvps_stopper("mcl_campfires:soul_campfire") +mesecon.register_mvps_stopper("mcl_campfires:soul_campfire_lit") +mesecon.register_mvps_stopper("mcl_lectern:lectern") +mesecon.register_mvps_stopper("mcl_grindstone:grindstone") -- Unmovable by design: objects @@ -517,8 +516,6 @@ mesecon.register_mvps_unsticky("mcl_bamboo:bamboo_2") mesecon.register_mvps_unsticky("mcl_bamboo:bamboo_3") mesecon.register_mvps_unsticky("mcl_bamboo:bamboo_door") -mesecon.register_mvps_unsticky("mcl_bamboo:bamboo_trapdoor") -mesecon.register_mvps_unsticky("mcl_signs:wall_sign_bamboo") mesecon.register_mvps_unsticky("mcl_bamboo:scaffolding") -- Beds @@ -554,21 +551,6 @@ mesecon.register_mvps_unsticky("mcl_beds:bed_white_top") mesecon.register_mvps_unsticky("mcl_beds:bed_white_bottom") mesecon.register_mvps_unsticky("mcl_beds:bed_yellow_top") mesecon.register_mvps_unsticky("mcl_beds:bed_yellow_bottom") --- Buttons -mesecon.register_mvps_unsticky("mesecons_button:button_stone_off") -mesecon.register_mvps_unsticky("mesecons_button:button_stone_on") -mesecon.register_mvps_unsticky("mesecons_button:button_wood_off") -mesecon.register_mvps_unsticky("mesecons_button:button_wood_on") -mesecon.register_mvps_unsticky("mesecons_button:button_acaciawood_off") -mesecon.register_mvps_unsticky("mesecons_button:button_acaciawood_on") -mesecon.register_mvps_unsticky("mesecons_button:button_birchwood_off") -mesecon.register_mvps_unsticky("mesecons_button:button_birchwood_on") -mesecon.register_mvps_unsticky("mesecons_button:button_darkwood_off") -mesecon.register_mvps_unsticky("mesecons_button:button_darkwood_on") -mesecon.register_mvps_unsticky("mesecons_button:button_sprucewood_off") -mesecon.register_mvps_unsticky("mesecons_button:button_sprucewood_on") -mesecon.register_mvps_unsticky("mesecons_button:button_junglewood_off") -mesecon.register_mvps_unsticky("mesecons_button:button_junglewood_on") -- Cactus, Sugarcane & Vines mesecon.register_mvps_unsticky("mcl_core:cactus") mesecon.register_mvps_unsticky("mcl_core:reeds") @@ -581,7 +563,7 @@ mesecon.register_mvps_unsticky("mcl_cake:cake_4") mesecon.register_mvps_unsticky("mcl_cake:cake_5") mesecon.register_mvps_unsticky("mcl_cake:cake_6") mesecon.register_mvps_unsticky("mcl_cake:cake") --- Carpet +-- Carpet - pullable in MC but breaks when pulled downwards. At the moment, it just cannot be pulled. mesecon.register_mvps_unsticky("mcl_wool:black_carpet") mesecon.register_mvps_unsticky("mcl_wool:blue_carpet") mesecon.register_mvps_unsticky("mcl_wool:brown_carpet") diff --git a/mods/ITEMS/mcl_signs/signs_api.lua b/mods/ITEMS/mcl_signs/signs_api.lua index 7ada6a646..52bb7bbbf 100644 --- a/mods/ITEMS/mcl_signs/signs_api.lua +++ b/mods/ITEMS/mcl_signs/signs_api.lua @@ -764,6 +764,15 @@ function mcl_signs.register_sign (modname, color, _name, ttsign) table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign22_5" .. _name, 1 }) table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign45" .. _name, 2 }) table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign67_5" .. _name, 3 }) + + -- register as unpushable + if minetest.get_modpath("mesecons_mvps") then + mesecon.register_mvps_stopper("mcl_signs:wall_sign" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign22_5" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign45" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign67_5" .. _name) + end end --- The same as register_sign, except caller defines the textures. Note, there is a greyscale version of the sign, @@ -1002,6 +1011,14 @@ function mcl_signs.register_sign_custom (modname, _name, tiles, color, inventory table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign45" .. _name, 2 }) table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign67_5" .. _name, 3 }) + -- register as unpushable + if minetest.get_modpath("mesecons_mvps") then + mesecon.register_mvps_stopper("mcl_signs:wall_sign" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign22_5" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign45" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign67_5" .. _name) + end end --- Override an existing sign, tint the textures, and gives it an unique node name. Creates both wall and standing signs. @@ -1234,6 +1251,15 @@ function mcl_signs.reregister_sign (modname, color, _name, ttsign) table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign22_5" .. _name, 1 }) table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign45" .. _name, 2 }) table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign67_5" .. _name, 3 }) + + -- register as unpushable + if minetest.get_modpath("mesecons_mvps") then + mesecon.register_mvps_stopper("mcl_signs:wall_sign" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign22_5" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign45" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign67_5" .. _name) + end end --- The same as reregister_sign, except caller defines the textures. Note, there is a greyscale version of the sign, @@ -1469,6 +1495,14 @@ function mcl_signs.reregister_sign_custom (modname, _name, tiles, color, invento table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign45" .. _name, 2 }) table.insert(mcl_signs.standing_rotation_levels, { "mcl_signs:standing_sign67_5" .. _name, 3 }) + -- register as unpushable + if minetest.get_modpath("mesecons_mvps") then + mesecon.register_mvps_stopper("mcl_signs:wall_sign" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign22_5" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign45" .. _name) + mesecon.register_mvps_stopper("mcl_signs:standing_sign67_5" .. _name) + end end --- Usage: Call this with the mod's name, the wood's item string (for the planks), and with the sign's suffix. From 98cf3b7f7a27733f5672d1349c37d3a02621e625 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Tue, 4 Jul 2023 18:22:05 +0200 Subject: [PATCH 08/15] Check node_replaceable after dig_by_piston Allows tallgrass, nether vines etc to drop --- mods/ITEMS/REDSTONE/mesecons_mvps/init.lua | 65 +++++++++++----------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua index 12bfd0ca8..b36721e78 100644 --- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua @@ -141,44 +141,43 @@ function mesecon.mvps_get_stack(pos, dir, maximum, piston_pos) return end - if not node_replaceable(nn.name) then - if minetest.get_item_group(nn.name, "dig_by_piston") == 1 then - -- if we want the node to drop, e.g. sugar cane, do not count towards push limit - table.insert(dig_nodes, {node = nn, pos = {x=np.x, y=np.y, z=np.z}}) - else + if minetest.get_item_group(nn.name, "dig_by_piston") == 1 then + -- if we want the node to drop, e.g. sugar cane, do not count towards push limit + table.insert(dig_nodes, {node = nn, pos = {x=np.x, y=np.y, z=np.z}}) + else + if not node_replaceable(nn.name) then table.insert(nodes, {node = nn, pos = {x=np.x, y=np.y, z=np.z}}) if #nodes > maximum then return nil, nil, false, true end - end - - -- add connected nodes to frontiers, connected is a vector list - -- the vectors must be absolute positions - local connected = {} - local has_loop - if minetest.registered_nodes[nn.name] - and minetest.registered_nodes[nn.name].mvps_sticky then - connected, has_loop = minetest.registered_nodes[nn.name].mvps_sticky(np, nn, piston_pos) - if has_loop then - return {}, {}, true, false - end - end - table.insert(connected, vector.add(np, dir)) - - -- Make sure there are no duplicates in frontiers / nodes before - -- adding nodes in "connected" to frontiers - for _, cp in ipairs(connected) do - local duplicate = false - for _, rp in ipairs(nodes) do - if vector.equals(cp, rp.pos) then - duplicate = true + + -- add connected nodes to frontiers, connected is a vector list + -- the vectors must be absolute positions + local connected = {} + local has_loop + if minetest.registered_nodes[nn.name] and minetest.registered_nodes[nn.name].mvps_sticky then + connected, has_loop = minetest.registered_nodes[nn.name].mvps_sticky(np, nn, piston_pos) + if has_loop then + return {}, {}, true, false end end - for _, fp in ipairs(frontiers) do - if vector.equals(cp, fp) then - duplicate = true + table.insert(connected, vector.add(np, dir)) + + -- Make sure there are no duplicates in frontiers / nodes before + -- adding nodes in "connected" to frontiers + for _, cp in ipairs(connected) do + local duplicate = false + for _, rp in ipairs(nodes) do + if vector.equals(cp, rp.pos) then + duplicate = true + end + end + for _, fp in ipairs(frontiers) do + if vector.equals(cp, fp) then + duplicate = true + end + end + if not duplicate and not mesecon.is_mvps_stopper(minetest.get_node(cp)) and minetest.get_item_group(nn.name, "dig_by_piston") == 0 then + table.insert(frontiers, cp) end - end - if not duplicate and not mesecon.is_mvps_stopper(minetest.get_node(cp)) and minetest.get_item_group(nn.name, "dig_by_piston") == 0 then - table.insert(frontiers, cp) end end end From 0580b14310fac1113d9684eb3c9f4f80d058cea8 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Thu, 6 Jul 2023 14:17:54 +0200 Subject: [PATCH 09/15] Vertical pistons now save owner meta --- mods/ITEMS/REDSTONE/mesecons_pistons/init.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua b/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua index 93b8df96d..262ac6eb5 100644 --- a/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua @@ -138,14 +138,12 @@ local function piston_off(pos, node) end local function piston_orientate(pos, placer) - mesecon.mvps_set_owner(pos, placer) - -- not placed by player if not placer then return end - + -- placer pitch in degrees local pitch = placer:get_look_vertical() * (180 / math.pi) - + local node = minetest.get_node(pos) local pistonspec = minetest.registered_nodes[node.name].mesecons_piston if pitch > 55 then @@ -153,6 +151,9 @@ local function piston_orientate(pos, placer) elseif pitch < -55 then minetest.add_node(pos, {name=pistonspec.piston_down}) end + + -- set owner meta after setting node, or it will not keep + mesecon.mvps_set_owner(pos, placer) end From 0637182697739f57ebcee109071a29024910a449 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Thu, 6 Jul 2023 15:34:49 +0200 Subject: [PATCH 10/15] Tallgrass and dead bush added to dig_by_piston --- mods/ITEMS/mcl_core/nodes_misc.lua | 4 ++-- mods/ITEMS/mcl_flowers/init.lua | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index d830cc310..9986eaf2d 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -139,8 +139,8 @@ minetest.register_node("mcl_core:deadbush", { sunlight_propagates = true, walkable = false, buildable_to = true, - groups = {handy = 1, shearsy = 1, flammable = 3, attached_node = 1, plant = 1, non_mycelium_plant = 1, dig_by_water = 1, - destroy_by_lava_flow = 1, deco_block = 1, fire_encouragement = 60, fire_flammability = 100}, + groups = {handy = 1, shearsy = 1, flammable = 3, attached_node = 1, plant = 1, non_mycelium_plant = 1, dig_by_piston = 1, + dig_by_water = 1, destroy_by_lava_flow = 1, deco_block = 1, fire_encouragement = 60, fire_flammability = 100}, drop = { max_items = 1, items = { diff --git a/mods/ITEMS/mcl_flowers/init.lua b/mods/ITEMS/mcl_flowers/init.lua index 24b07428a..10189240b 100644 --- a/mods/ITEMS/mcl_flowers/init.lua +++ b/mods/ITEMS/mcl_flowers/init.lua @@ -128,8 +128,6 @@ local fortune_wheat_seed_drop = { overwrite = true, } --- CHECKME: How does tall grass behave when pushed by a piston? - --- Tall Grass --- local def_tallgrass = { description = S("Tall Grass"), @@ -155,7 +153,7 @@ local def_tallgrass = { groups = { handy = 1, shearsy = 1, attached_node = 1, deco_block = 1, plant = 1, place_flowerlike = 2, non_mycelium_plant = 1, - flammable = 3, fire_encouragement = 60, fire_flammability = 100, + flammable = 3, fire_encouragement = 60, fire_flammability = 10, dig_by_piston = 1, dig_by_water = 1, destroy_by_lava_flow = 1, compostability = 30, grass_palette = 1 }, sounds = mcl_sounds.node_sound_leaves_defaults(), From 3e12b3c7006aaae64c232834ab78b68980271060 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Thu, 6 Jul 2023 15:41:41 +0200 Subject: [PATCH 11/15] Check protection of certain nodes before push/pull - The node directly in front of a piston (including air) - The 'final' position of any connected nodes --- mods/ITEMS/REDSTONE/mesecons_mvps/init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua index b36721e78..d1a1171e8 100644 --- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua @@ -207,6 +207,11 @@ local function are_protected(nodes, player_name) end function mesecon.mvps_push(pos, dir, maximum, player_name, piston_pos) + -- check if the node in front of the piston is protected against player_name (to prevent replacing air) + if minetest.is_protected(pos, player_name) then + return false + end + return mesecon.mvps_push_or_pull(pos, dir, dir, maximum, player_name, piston_pos) end @@ -241,6 +246,9 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, player_name, if (newpos[i].x == piston_pos.x) and (newpos[i].y == piston_pos.y) and (newpos[i].z == piston_pos.z) then return end + if minetest.is_protected(newpos[i], player_name) then + return + end if not is_available(newpos[i]) then local available = false for j in ipairs(nodes) do From 378df76e5f122f354289d16c1fe3c07c4be222dc Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Mon, 16 Oct 2023 22:06:52 +0200 Subject: [PATCH 12/15] Prevent signs from being replaced by pushed/pulled blocks --- mods/ITEMS/mcl_signs/signs_api.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_signs/signs_api.lua b/mods/ITEMS/mcl_signs/signs_api.lua index 52bb7bbbf..2c0908124 100644 --- a/mods/ITEMS/mcl_signs/signs_api.lua +++ b/mods/ITEMS/mcl_signs/signs_api.lua @@ -85,7 +85,7 @@ end mcl_signs = {} -- GLOBALS -mcl_signs.sign_groups = { handy = 1, axey = 1, deco_block = 1, material_wood = 1, attached_node = 1, dig_by_piston = 1, flammable = -1 } +mcl_signs.sign_groups = { handy = 1, axey = 1, deco_block = 1, material_wood = 1, attached_node = 1, flammable = -1 } --- colors used for wools. mcl_signs.mcl_wool_colors = { unicolor_white = "#FFFFFF", From 520fd773fbc06d896f4e13dce419aff03fce4456 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Mon, 16 Oct 2023 22:07:52 +0200 Subject: [PATCH 13/15] Fix random crash when piston breaks node with no player --- mods/HUD/mcl_inventory/creative.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index bb2f226a2..5dfc2b7ae 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -741,12 +741,14 @@ if minetest.is_creative_enabled("") then for _, item in ipairs(drops) do minetest.add_item(pos, item) end - end - local inv = digger:get_inventory() - if inv then - for _, item in ipairs(drops) do - if not inv:contains_item("main", item, true) then - inv:add_item("main", item) + else + -- If there is a player + local inv = digger:get_inventory() + if inv then + for _, item in ipairs(drops) do + if not inv:contains_item("main", item, true) then + inv:add_item("main", item) + end end end end From c37da143dacc0e64f019dce3ab6217fb03781cc8 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Mon, 16 Oct 2023 22:08:17 +0200 Subject: [PATCH 14/15] Add crying obsidian and lodestone to mvps_stoppers --- mods/ITEMS/REDSTONE/mesecons_mvps/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua index d1a1171e8..9534d66c9 100644 --- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua @@ -423,6 +423,7 @@ mesecon.register_mvps_stopper("mcl_core:realm_barrier") mesecon.register_mvps_stopper("mcl_core:void") mesecon.register_mvps_stopper("mcl_core:bedrock") mesecon.register_mvps_stopper("mcl_core:obsidian") +mesecon.register_mvps_stopper("mcl_core:crying_obsidian") mesecon.register_mvps_stopper("mcl_chests:ender_chest") mesecon.register_mvps_stopper("mcl_chests:ender_chest_small") mesecon.register_mvps_stopper("mcl_mobspawners:spawner") @@ -442,6 +443,7 @@ mesecon.register_mvps_stopper("mcl_banners:hanging_banner") mesecon.register_mvps_stopper("mcl_banners:standing_banner") mesecon.register_mvps_stopper("mcl_beehives:bee_nest") mesecon.register_mvps_stopper("mcl_beehives:beehive") +mesecon.register_mvps_stopper("mcl_compass:lodestone") -- Unmovable by technical restrictions. -- Open formspec would screw up if node is destroyed (minor problem) From 00cfca5947d28c824a6973a512d1f1bb1b3f7c99 Mon Sep 17 00:00:00 2001 From: seventeenthShulker Date: Mon, 23 Oct 2023 12:13:12 +0200 Subject: [PATCH 15/15] Make carpet sticky again --- mods/ITEMS/REDSTONE/mesecons_mvps/init.lua | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua index 9534d66c9..88ca9d30e 100644 --- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua @@ -572,23 +572,6 @@ mesecon.register_mvps_unsticky("mcl_cake:cake_4") mesecon.register_mvps_unsticky("mcl_cake:cake_5") mesecon.register_mvps_unsticky("mcl_cake:cake_6") mesecon.register_mvps_unsticky("mcl_cake:cake") --- Carpet - pullable in MC but breaks when pulled downwards. At the moment, it just cannot be pulled. -mesecon.register_mvps_unsticky("mcl_wool:black_carpet") -mesecon.register_mvps_unsticky("mcl_wool:blue_carpet") -mesecon.register_mvps_unsticky("mcl_wool:brown_carpet") -mesecon.register_mvps_unsticky("mcl_wool:cyan_carpet") -mesecon.register_mvps_unsticky("mcl_wool:green_carpet") -mesecon.register_mvps_unsticky("mcl_wool:grey_carpet") -mesecon.register_mvps_unsticky("mcl_wool:light_blue_carpet") -mesecon.register_mvps_unsticky("mcl_wool:lime_carpet") -mesecon.register_mvps_unsticky("mcl_wool:orange_carpet") -mesecon.register_mvps_unsticky("mcl_wool:magenta_carpet") -mesecon.register_mvps_unsticky("mcl_wool:pink_carpet") -mesecon.register_mvps_unsticky("mcl_wool:purple_carpet") -mesecon.register_mvps_unsticky("mcl_wool:red_carpet") -mesecon.register_mvps_unsticky("mcl_wool:silver_carpet") -mesecon.register_mvps_unsticky("mcl_wool:white_carpet") -mesecon.register_mvps_unsticky("mcl_wool:yellow_carpet") -- Carved & Jack O'Lantern Pumpkins, Pumpkin & Melon mesecon.register_mvps_unsticky("mcl_farming:pumpkin_face") mesecon.register_mvps_unsticky("mcl_farming:pumpkin_face_light")