From 11b66e83a26fa22ceb580d33ddfc5285faaa5dd3 Mon Sep 17 00:00:00 2001 From: kay27 Date: Sun, 18 Apr 2021 04:28:14 +0400 Subject: [PATCH 1/6] [mcl_portals] Better NP search, no more teleports on the roof, fix https://git.minetest.land/MineClone2/MineClone2/issues/1560 --- mods/ITEMS/mcl_portals/portal_nether.lua | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index 1d9fe2efb..a121f719c 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -27,9 +27,8 @@ local DELAY = 3 -- seconds before teleporting in Nether portal in Survival mo local DISTANCE_MAX = 128 local PORTAL = "mcl_portals:portal" local OBSIDIAN = "mcl_core:obsidian" -local O_Y_MIN, O_Y_MAX = max(mcl_vars.mg_overworld_min, -31), min(mcl_vars.mg_overworld_max_official, 2048) -local N_Y_MIN, N_Y_MAX = mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_top_max - H_MIN -local O_DY, N_DY = O_Y_MAX - O_Y_MIN + 1, N_Y_MAX - N_Y_MIN + 1 +local O_Y_MIN, O_Y_MAX = max(mcl_vars.mg_overworld_min, -31), min(mcl_vars.mg_overworld_max, 2048) +local N_Y_MIN, N_Y_MAX = mcl_vars.mg_bedrock_nether_bottom_min, mcl_vars.mg_bedrock_nether_top_min - H_MIN -- Alpha and particles local node_particles_allowed = minetest.settings:get("mcl_node_particles") or "none" @@ -78,6 +77,8 @@ local pos_to_string = minetest.pos_to_string local is_area_protected = minetest.is_area_protected local get_us_time = minetest.get_us_time +local dimension_to_teleport = { nether = "overworld", overworld = "nether" } + local limits = { nether = { pmin = {x=LIM_MIN, y = N_Y_MIN, z = LIM_MIN}, @@ -181,10 +182,10 @@ local function get_target(p) x, o1 = ping_pong(x, TRAVEL_X, LIM_MIN, LIM_MAX) z, o2 = ping_pong(z, TRAVEL_Z, LIM_MIN, LIM_MAX) y = floor(y * TRAVEL_Y + (o1+o2) / 16 * LIM_MAX) - y = min(max(y + mcl_vars.mg_overworld_min, mcl_vars.mg_overworld_min), mcl_vars.mg_overworld_max) + y = min(max(y + O_Y_MIN, O_Y_MIN), O_Y_MAX) elseif d=="overworld" then x, y, z = floor(x / TRAVEL_X + 0.5), floor(y / TRAVEL_Y + 0.5), floor(z / TRAVEL_Z + 0.5) - y = min(max(y + mcl_vars.mg_nether_min, mcl_vars.mg_nether_min), mcl_vars.mg_nether_max) + y = min(max(y + N_Y_MIN, N_Y_MIN), N_Y_MAX) end return {x=x, y=y, z=z}, d end @@ -457,8 +458,8 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param) local nodes = find_nodes_in_area_under_air(pos1, pos2, {"group:building_block"}) if nodes then local nc = #nodes + log("action", "[mcl_portals] Area for destination Nether portal emerged! Found " .. tostring(nc) .. " nodes under the air around "..pos_to_string(pos)) if nc > 0 then - log("action", "[mcl_portals] Area for destination Nether portal emerged! Found " .. tostring(nc) .. " nodes under the air around "..pos_to_string(pos)) for i=1,nc do local node = nodes[i] local node1 = {x=node.x, y=node.y+1, z=node.z } @@ -474,7 +475,7 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param) return end if not distance or (distance0 < distance) or (distance0 < distance-1 and node.y > lava and pos0.y < lava) then - log("action", "[mcl_portals] found distance "..tostring(distance0).." at pos "..pos_to_string(node)) + log("verbose", "[mcl_portals] found distance "..tostring(distance0).." at pos "..pos_to_string(node)) distance = distance0 pos0 = {x=node1.x, y=node1.y, z=node1.z} end @@ -626,7 +627,7 @@ end -- Pos can be any of the inner part. -- The frame MUST be filled only with air or any fire, which will be replaced with Nether portal blocks. -- If no Nether portal can be lit, nothing happens. --- Returns number of portals created (0, 1 or 2) +-- Returns true if portal created function mcl_portals.light_nether_portal(pos) -- Only allow to make portals in Overworld and Nether local dim = mcl_worlds.pos_to_dimension(pos) @@ -636,11 +637,6 @@ function mcl_portals.light_nether_portal(pos) local orientation = random(0, 1) for orientation_iteration = 1, 2 do if check_and_light_shape(pos, orientation) then - minetest.after(0.2, function(pos) -- generate target map chunk - local pos1 = add(mul(mcl_vars.pos_to_chunk(pos), mcl_vars.chunk_size_in_nodes), mcl_vars.central_chunk_offset_in_nodes) - local pos2 = add(pos1, mcl_vars.chunk_size_in_nodes - 1) - minetest.emerge_area(pos1, pos2) - end, vector.new(pos)) return true end orientation = 1 - orientation @@ -672,6 +668,7 @@ local function teleport_no_delay(obj, pos) if exit then finalize_teleport(obj, exit) else + dim = dimension_to_teleport[dim] -- need to create arrival portal create_portal(target, limits[dim].pmin, limits[dim].pmax, name, obj) end From 5d9c3cd85bc5f5cd2650f5e982a9ae0626f4d385 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 18 Apr 2021 14:41:44 +0200 Subject: [PATCH 2/6] Fix #1572 --- mods/PLAYER/mcl_playerplus/init.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 360f4fe5d..f7c430509 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -150,13 +150,6 @@ minetest.register_globalstep(function(dtime) for _,player in pairs(get_connected_players()) do - local c_x, c_y = unpack(player_collision(player)) - - if player:get_velocity().x + player:get_velocity().y < .5 and c_x + c_y > 0 then - --minetest.chat_send_player(player:get_player_name(), "pushed at " .. c_x + c_y .. " parsecs.") - player:add_velocity({x=c_x, y=0, z=c_y}) - end - --[[ _ _ _ __ _ _ __ (_)_ __ ___ __ _| |_(_) ___ _ __ ___ @@ -173,6 +166,14 @@ minetest.register_globalstep(function(dtime) local wielded = player:get_wielded_item() local player_velocity = player:get_velocity() or player:get_player_velocity() + local c_x, c_y = unpack(player_collision(player)) + + if player_velocity.x + player_velocity.y < .5 and c_x + c_y > 0 then + local add_velocity = player.add_player_velocity or player.add_velocity + add_velocity(player, {x = c_x, y = 0, z = c_y}) + player_velocity = player:get_velocity() or player:get_player_velocity() + end + -- control head bone local pitch = - degrees(player:get_look_vertical()) local yaw = degrees(player:get_look_horizontal()) From 9bc2f2d8669b63225de22114d17ad9ced8aefe19 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 18 Apr 2021 17:18:27 +0000 Subject: [PATCH 3/6] Fix lying trunks that stand upright again after debarking --- mods/ITEMS/mcl_tools/init.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index 3aebafb7b..cdc981b2a 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -375,22 +375,22 @@ local make_stripped_trunk = function(itemstack, placer, pointed_thing) return itemstack end if node_name == "mcl_core:tree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:darktree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:acaciatree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:birchtree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:sprucetree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:jungletree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle"}) + minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle", param2=node.param2}) make_stripped_trunk_add_wear(itemstack, placer) elseif node_name == "mcl_core:tree_bark" then minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak_bark"}) From 3668b2dee68daf57aa81b5a30941ee48ef5673b9 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 18 Apr 2021 18:02:37 +0000 Subject: [PATCH 4/6] Summarize all debarked types of wood --- mods/ITEMS/mcl_core/nodes_trees.lua | 204 +++++++--------------------- 1 file changed, 46 insertions(+), 158 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_trees.lua b/mods/ITEMS/mcl_core/nodes_trees.lua index 4af3eef34..d2c5443d3 100644 --- a/mods/ITEMS/mcl_core/nodes_trees.lua +++ b/mods/ITEMS/mcl_core/nodes_trees.lua @@ -48,165 +48,46 @@ local register_tree_trunk = function(subname, description_trunk, description_bar }) end --- Register stripped trunk -minetest.register_node("mcl_core:stripped_oak", { - description = "Stripped Oak Log", - _doc_items_longdesc = "Stripped Oak Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_acacia", { - description = "Stripped Acacia Log", - _doc_items_longdesc = "Stripped Acacia Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_dark_oak", { - description = "Stripped Dark Oak Log", - _doc_items_longdesc = "Stripped Dark Oak Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_dark_oak_top.png", "mcl_core_stripped_dark_oak_top.png", "mcl_core_stripped_dark_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_birch", { - description = "Stripped Birch Log", - _doc_items_longdesc = "Stripped Birch Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_birch_top.png", "mcl_core_stripped_birch_top.png", "mcl_core_stripped_birch_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_spruce", { - description = "Stripped Spruce Log", - _doc_items_longdesc = "Stripped Spruce Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_spruce_top.png", "mcl_core_stripped_spruce_top.png", "mcl_core_stripped_spruce_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_jungle", { - description = "Stripped Jungle Log", - _doc_items_longdesc = "Stripped Jungle Log is a log that has been stripped of it's bark.", - tiles = {"mcl_core_stripped_jungle_top.png", "mcl_core_stripped_jungle_top.png", "mcl_core_stripped_jungle_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5, tree=1}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - - --- Register stripped bark -minetest.register_node("mcl_core:stripped_oak_bark", { - description = "Stripped Oak Bark", - _doc_items_longdesc = "Stripped Oak Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_acacia_bark", { - description = "Stripped Acacia Bark", - _doc_items_longdesc = "Stripped Acacia Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_acacia_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_dark_oak_bark", { - description = "Stripped Dark Oak Bark", - _doc_items_longdesc = "Stripped Dark Oak Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_dark_oak_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_birch_bark", { - description = "Stripped Birch Bark", - _doc_items_longdesc = "Stripped Birch Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_birch_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_spruce_bark", { - description = "Stripped Spruce Bark", - _doc_items_longdesc = "Stripped Spruce Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_spruce_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) - -minetest.register_node("mcl_core:stripped_jungle_bark", { - description = "Stripped Jungle Bark", - _doc_items_longdesc = "Stripped Jungles Bark is a bark that has been stripped.", - tiles = {"mcl_core_stripped_jungle_side.png"}, - is_ground_content = false, - paramtype2 = "facedir", - on_place = mcl_util.rotate_axis, - groups = {handy=1,axey=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, - sounds = mcl_sounds.node_sound_wood_defaults(), - _mcl_blast_resistance = 10, - _mcl_hardness = 2, -}) +-- Register stripped trunk and stripped wood +local register_stripped_trunk = function(subname, description_stripped_trunk, description_stripped_bark, longdesc, tile_stripped_inner, tile_stripped_bark) + minetest.register_node("mcl_core:"..subname, { + description = description_stripped_trunk, + _doc_items_longdesc = longdesc, + _doc_items_hidden = false, + tiles = {tile_stripped_inner, tile_stripped_inner, tile_stripped_bark}, + paramtype2 = "facedir", + on_place = mcl_util.rotate_axis, + stack_max = 64, + groups = {handy=1,axey=1, tree=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, + sounds = mcl_sounds.node_sound_wood_defaults(), + on_rotate = on_rotate, + _mcl_blast_resistance = 2, + _mcl_hardness = 2, + }) + minetest.register_node("mcl_core:"..subname.."_bark", { + description = description_stripped_bark, + _doc_items_longdesc = S("This is a decorative block."), + tiles = {tile_stripped_bark}, + paramtype2 = "facedir", + on_place = mcl_util.rotate_axis, + stack_max = 64, + groups = {handy=1,axey=1, bark=1, flammable=2, building_block=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, + sounds = mcl_sounds.node_sound_wood_defaults(), + is_ground_content = false, + on_rotate = on_rotate, + _mcl_blast_resistance = 2, + _mcl_hardness = 2, + }) + + minetest.register_craft({ + output = "mcl_core:"..subname.."_bark 3", + recipe = { + { "mcl_core:"..subname, "mcl_core:"..subname }, + { "mcl_core:"..subname, "mcl_core:"..subname }, + } + }) +end local register_wooden_planks = function(subname, description, tiles) minetest.register_node("mcl_core:"..subname, { @@ -340,6 +221,13 @@ register_tree_trunk("sprucetree", S("Spruce Wood"), S("Spruce Bark"), S("The tru register_tree_trunk("birchtree", S("Birch Wood"), S("Birch Bark"), S("The trunk of a birch tree."), "mcl_core_log_birch_top.png", "mcl_core_log_birch.png") register_tree_trunk("jungletree", S("Jungle Wood"), S("Jungle Bark"), S("The trunk of a jungle tree."), "default_jungletree_top.png", "default_jungletree.png") +register_stripped_trunk("stripped_oak", S("Stripped Oak Log"), S("Stripped Oak Wood"), S("The stripped trunk of an oak tree."), "mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_side.png") +register_stripped_trunk("stripped_acacia", S("Stripped Acacia Log"), S("Stripped Acacia Wood"), S("The stripped trunk of an acacia tree."), "mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_side.png") +register_stripped_trunk("stripped_dark_oak", S("Stripped Dark Oak Log"), S("Stripped Dark Oak Wood"), S("The stripped trunk of an dark oak tree."), "mcl_core_stripped_dark_oak_top.png", "mcl_core_stripped_dark_oak_side.png") +register_stripped_trunk("stripped_birch", S("Stripped Birch Log"), S("Stripped Birch Wood"), S("The stripped trunk of an birch tree."), "mcl_core_stripped_birch_top.png", "mcl_core_stripped_birch_side.png") +register_stripped_trunk("stripped_spruce", S("Stripped Spruce Log"), S("Stripped Spruce Wood"), S("The stripped trunk of an spruce tree."), "mcl_core_stripped_spruce_top.png", "mcl_core_stripped_spruce_side.png") +register_stripped_trunk("stripped_jungle", S("Stripped Jungle Log"), S("Stripped Jungle Wood"), S("The stripped trunk of an jungle tree."),"mcl_core_stripped_jungle_top.png", "mcl_core_stripped_jungle_side.png") + register_wooden_planks("wood", S("Oak Wood Planks"), {"default_wood.png"}) register_wooden_planks("darkwood", S("Dark Oak Wood Planks"), {"mcl_core_planks_big_oak.png"}) register_wooden_planks("junglewood", S("Jungle Wood Planks"), {"default_junglewood.png"}) From 49f6ccaa4adf1cd36bbc56f93968d26fedc5ba6e Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 18 Apr 2021 18:02:41 +0000 Subject: [PATCH 5/6] Remove old crafting recipes --- mods/ITEMS/mcl_core/crafting.lua | 50 -------------------------------- 1 file changed, 50 deletions(-) diff --git a/mods/ITEMS/mcl_core/crafting.lua b/mods/ITEMS/mcl_core/crafting.lua index 7a2b6a5c8..a0ad38a77 100644 --- a/mods/ITEMS/mcl_core/crafting.lua +++ b/mods/ITEMS/mcl_core/crafting.lua @@ -46,56 +46,6 @@ minetest.register_craft({ } }) --- Stripped Bark -minetest.register_craft({ - output = "mcl_core:stripped_oak_bark 3", - recipe = { - { "mcl_core:stripped_oak", "mcl_core:stripped_oak" }, - { "mcl_core:stripped_oak", "mcl_core:stripped_oak" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_acacia_bark 3", - recipe = { - { "mcl_core:stripped_acacia", "mcl_core:stripped_acacia" }, - { "mcl_core:stripped_acacia", "mcl_core:stripped_acacia" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_dark_oak_bark 3", - recipe = { - { "mcl_core:stripped_dark_oak", "mcl_core:stripped_dark_oak" }, - { "mcl_core:stripped_dark_oak", "mcl_core:stripped_dark_oak" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_birch_bark 3", - recipe = { - { "mcl_core:stripped_birch", "mcl_core:stripped_birch" }, - { "mcl_core:stripped_birch", "mcl_core:stripped_birch" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_spruce_bark 3", - recipe = { - { "mcl_core:stripped_spruce", "mcl_core:stripped_spruce" }, - { "mcl_core:stripped_spruce", "mcl_core:stripped_spruce" }, - } -}) - -minetest.register_craft({ - output = "mcl_core:stripped_jungle_bark 3", - recipe = { - { "mcl_core:stripped_jungle", "mcl_core:stripped_jungle" }, - { "mcl_core:stripped_jungle", "mcl_core:stripped_jungle" }, - } -}) - - minetest.register_craft({ type = 'shapeless', output = 'mcl_core:mossycobble', From aa533edda230403ca1a7daf9a097927fc2c2ac5b Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 18 Apr 2021 18:28:39 +0000 Subject: [PATCH 6/6] Simplify debarking --- mods/ITEMS/mcl_tools/init.lua | 88 ++++++++++++++--------------------- 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index cdc981b2a..bb9a4873c 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -360,59 +360,43 @@ local make_stripped_trunk_add_wear = function(itemstack, placer) itemstack:add_wear(wear) end end + +local stripped_table = { + {"mcl_core:tree", "mcl_core:stripped_oak"}, + {"mcl_core:darktree", "mcl_core:stripped_dark_oak"}, + {"mcl_core:acaciatree", "mcl_core:stripped_acacia"}, + {"mcl_core:birchtree", "mcl_core:stripped_birch"}, + {"mcl_core:sprucetree", "mcl_core:stripped_spruce"}, + {"mcl_core:jungletree", "mcl_core:stripped_jungle"}, + {"mcl_core:tree_bark", "mcl_core:stripped_oak_bark"}, + {"mcl_core:darktree_bark", "mcl_core:stripped_dark_oak_bark"}, + {"mcl_core:acaciatree_bark", "mcl_core:stripped_acacia_bark"}, + {"mcl_core:birchtree_bark", "mcl_core:stripped_birch_bark"}, + {"mcl_core:sprucetree_bark", "mcl_core:stripped_spruce_bark"}, + {"mcl_core:jungletree_bark", "mcl_core:stripped_jungle_bark"}, +} + local make_stripped_trunk = function(itemstack, placer, pointed_thing) - if pointed_thing.type == "node" then - local pos = minetest.get_pointed_thing_position(pointed_thing) - local node = minetest.get_node(pos) - local node_name = node.name - if placer and not placer:get_player_control().sneak then - if minetest.registered_nodes[node_name] and minetest.registered_nodes[node_name].on_rightclick then - return minetest.registered_nodes[node_name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack - end - end - if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then - minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) - return itemstack - end - if node_name == "mcl_core:tree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:darktree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:acaciatree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:birchtree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:sprucetree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:jungletree" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle", param2=node.param2}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:tree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_oak_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:darktree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_dark_oak_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:acaciatree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_acacia_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:birchtree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_birch_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:sprucetree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_spruce_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - elseif node_name == "mcl_core:jungletree_bark" then - minetest.swap_node(pointed_thing.under, {name="mcl_core:stripped_jungle_bark"}) - make_stripped_trunk_add_wear(itemstack, placer) - end - end - return itemstack + if pointed_thing.type ~= "node" then return end + + local node = minetest.get_node(pointed_thing.under) + local noddef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] + + if not placer:get_player_control().sneak and noddef.on_rightclick then + return minetest.item_place(itemstack, placer, pointed_thing) + end + if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then + minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) + return itemstack + end + + for _, st in pairs(stripped_table) do + if noddef.name == st[1] then + minetest.swap_node(pointed_thing.under, {name=st[2], param2=node.param2}) + make_stripped_trunk_add_wear(itemstack, placer) + end + end + return itemstack end minetest.register_tool("mcl_tools:axe_wood", {