From a7e102426a49bf1c60381621e65cdaa9e87bb6d5 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 17 Apr 2021 21:01:09 +0200 Subject: [PATCH 1/8] Add time_of_day to get_light crash fix --- mods/ENTITIES/mcl_mobs/api.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 1b5715b2a..8aed37288 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -1029,10 +1029,10 @@ local node_ok = function(pos, fallback) return minetest.registered_nodes[fallback] end -local function get_light(pos) +local function get_light(pos, tod) if math.abs(pos.x) < 31000 and math.abs(pos.y) < 31000 and math.abs(pos.z) < 31000 then local lightfunc = minetest.get_natural_light or minetest.get_node_light - return lightfunc(pos) + return lightfunc(pos, tod) else return 0 end From dd69dcfd9f5fe5c8e481e275536f130853fc9e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Sat, 17 Apr 2021 23:03:57 +0200 Subject: [PATCH 2/8] Fix efficiency and unbreaking not working together This commit fixes an issue were tools enchanted with both efficiency and unbreaking would loose the effect of one of the enchantments in some conditions. --- mods/ITEMS/mcl_enchanting/enchantments.lua | 6 +++--- mods/ITEMS/mcl_enchanting/engine.lua | 1 + mods/ITEMS/mcl_enchanting/groupcaps.lua | 12 ++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index ca936c319..df6105d52 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -771,11 +771,11 @@ mcl_enchanting.enchantments.unbreaking = { curse = false, on_enchant = function(itemstack, level) local tool_capabilities = itemstack:get_tool_capabilities() - for group, capability in pairs(tool_capabilities.groupcaps) do - capability.uses = capability.uses * (1 + level) - end tool_capabilities.punch_attack_uses = tool_capabilities.punch_attack_uses * (1 + level) itemstack:get_meta():set_tool_capabilities(tool_capabilities) + + -- Unbreaking for groupcaps is handled in this function. + mcl_enchanting.update_groupcaps(itemstack) end, requires_tool = true, treasure = false, diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index ea69d1868..30e4a9a86 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -17,6 +17,7 @@ function mcl_enchanting.unload_enchantments(itemstack) local meta = itemstack:get_meta() if meta:get_string("name") == "" then meta:set_string("description", "") + meta:set_string("groupcaps_hash", "") end end diff --git a/mods/ITEMS/mcl_enchanting/groupcaps.lua b/mods/ITEMS/mcl_enchanting/groupcaps.lua index 375029547..1a4f8fd14 100644 --- a/mods/ITEMS/mcl_enchanting/groupcaps.lua +++ b/mods/ITEMS/mcl_enchanting/groupcaps.lua @@ -50,13 +50,21 @@ function mcl_enchanting.update_groupcaps(itemstack) end local name = itemstack:get_name() - local level = mcl_enchanting.get_enchantment(itemstack, "efficiency") - local groupcaps = get_efficiency_groupcaps(name, level) + local efficiency = mcl_enchanting.get_enchantment(itemstack, "efficiency") + local groupcaps = get_efficiency_groupcaps(name, efficiency) local hash = itemstack:get_meta():get_string("groupcaps_hash") if not hash or hash ~= groupcaps.hash then local tool_capabilities = itemstack:get_tool_capabilities() tool_capabilities.groupcaps = groupcaps.values + + -- Increase the number of uses depending on the unbreaking level + -- of the tool. + local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") + for group, capability in pairs(tool_capabilities.groupcaps) do + capability.uses = capability.uses * (1 + unbreaking) + end + itemstack:get_meta():set_tool_capabilities(tool_capabilities) itemstack:get_meta():set_string("groupcaps_hash", groupcaps.hash) end From 573b1dc44b4376bca3fe4bf4d3ed18f24210723b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Sat, 17 Apr 2021 23:40:19 +0200 Subject: [PATCH 3/8] Do not include unnecessary tool_capabilities This commit makes enchanted tools which have no use for tool_capabilities to not include it in their metadata. It does this by not including tool_capabilities in the metadata of an enchanted tool if at least one of two cases is true: (1) The tool is not enchanted with unbreaking or efficiency (2) The tool does not have tool_capabilities defined in its definition The first case covers situations like having a pickaxe only being enchanted with silk_touch. The second case covers situations like a piece of armor being enchanted with unbreaking. --- mods/ITEMS/mcl_enchanting/enchantments.lua | 5 +++++ mods/ITEMS/mcl_enchanting/engine.lua | 2 +- mods/ITEMS/mcl_enchanting/groupcaps.lua | 10 +++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index df6105d52..fa3bc3ed5 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -770,6 +770,11 @@ mcl_enchanting.enchantments.unbreaking = { description = S("Increases item durability."), curse = false, on_enchant = function(itemstack, level) + local name = itemstack:get_name() + if not minetest.registered_tools[name].tool_capabilities then + return + end + local tool_capabilities = itemstack:get_tool_capabilities() tool_capabilities.punch_attack_uses = tool_capabilities.punch_attack_uses * (1 + level) itemstack:get_meta():set_tool_capabilities(tool_capabilities) diff --git a/mods/ITEMS/mcl_enchanting/engine.lua b/mods/ITEMS/mcl_enchanting/engine.lua index 30e4a9a86..037134e4c 100644 --- a/mods/ITEMS/mcl_enchanting/engine.lua +++ b/mods/ITEMS/mcl_enchanting/engine.lua @@ -12,7 +12,7 @@ end function mcl_enchanting.unload_enchantments(itemstack) local itemdef = itemstack:get_definition() if itemdef.tool_capabilities then - itemstack:get_meta():set_tool_capabilities(itemdef.tool_capabilities) + itemstack:get_meta():set_tool_capabilities(nil) end local meta = itemstack:get_meta() if meta:get_string("name") == "" then diff --git a/mods/ITEMS/mcl_enchanting/groupcaps.lua b/mods/ITEMS/mcl_enchanting/groupcaps.lua index 1a4f8fd14..0bc1b8e24 100644 --- a/mods/ITEMS/mcl_enchanting/groupcaps.lua +++ b/mods/ITEMS/mcl_enchanting/groupcaps.lua @@ -45,12 +45,17 @@ end -- To make it more efficient it will first check a hash value to determine if -- the tool needs to be updated. function mcl_enchanting.update_groupcaps(itemstack) - if not itemstack:get_meta():get("tool_capabilities") then + local name = itemstack:get_name() + if not minetest.registered_tools[name].tool_capabilities then return end - local name = itemstack:get_name() local efficiency = mcl_enchanting.get_enchantment(itemstack, "efficiency") + local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") + if unbreaking == 0 and efficiency == 0 then + return + end + local groupcaps = get_efficiency_groupcaps(name, efficiency) local hash = itemstack:get_meta():get_string("groupcaps_hash") @@ -60,7 +65,6 @@ function mcl_enchanting.update_groupcaps(itemstack) -- Increase the number of uses depending on the unbreaking level -- of the tool. - local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking") for group, capability in pairs(tool_capabilities.groupcaps) do capability.uses = capability.uses * (1 + unbreaking) end From 5d9c3cd85bc5f5cd2650f5e982a9ae0626f4d385 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 18 Apr 2021 14:41:44 +0200 Subject: [PATCH 4/8] 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 5/8] 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 6/8] 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 7/8] 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 8/8] 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", {