From 09a73482568afd17845512a2c80e1ef4578fd370 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Thu, 12 Jan 2023 00:33:26 +0000 Subject: [PATCH 01/22] Give an option for players to disable the in game music --- mods/PLAYER/mcl_music/init.lua | 26 ++++++++++++++++---------- settingtypes.txt | 3 +++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/mods/PLAYER/mcl_music/init.lua b/mods/PLAYER/mcl_music/init.lua index 05215059c..64114976d 100644 --- a/mods/PLAYER/mcl_music/init.lua +++ b/mods/PLAYER/mcl_music/init.lua @@ -1,6 +1,8 @@ local modname = minetest.get_current_modname() local modpath = minetest.get_modpath(modname) +local music_disabled = minetest.settings:get_bool("mcl_music_disable", false) + local pianowtune = "diminixed-pianowtune01" local end_tune = "diminixed-ambientwip" local nether_tune = "horizonchris96-traitor" @@ -99,15 +101,19 @@ local function play() minetest.after(7, play) end -minetest.after(15, play) +if not music_disabled then + minetest.log("action", "[mcl_music] Music is activated") + minetest.after(15, play) -minetest.register_on_joinplayer(function(player, last_login) - local player_name = player:get_player_name() - stop_music_for_listener_name(player_name) -end) - -minetest.register_on_respawnplayer(function(player) - local player_name = player:get_player_name() - stop_music_for_listener_name(player_name) -end) + minetest.register_on_joinplayer(function(player, last_login) + local player_name = player:get_player_name() + stop_music_for_listener_name(player_name) + end) + minetest.register_on_respawnplayer(function(player) + local player_name = player:get_player_name() + stop_music_for_listener_name(player_name) + end) +else + minetest.log("action", "[mcl_music] Music is deactivated") +end \ No newline at end of file diff --git a/settingtypes.txt b/settingtypes.txt index 25ac943ea..e7a42b351 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -139,6 +139,9 @@ mcl_mob_active_range (Active mob range) int 48 0 256 # Enable flame sound. flame_sound (Flame sound) bool true +# Disable the in game music. +mcl_music_disable (Disable in game music) bool false + [Graphics] # How many vertical animation frames the fire texture (fire_basic_flame_animated.png) has. # This may vary depending on the texture pack you use. From ce485e89cd5b7dab05f8d4ce86412ae9da1cccc9 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Thu, 12 Jan 2023 23:33:39 +0000 Subject: [PATCH 02/22] In game music review feedback fix --- mods/PLAYER/mcl_music/init.lua | 8 ++++---- settingtypes.txt | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mods/PLAYER/mcl_music/init.lua b/mods/PLAYER/mcl_music/init.lua index 64114976d..07e851f26 100644 --- a/mods/PLAYER/mcl_music/init.lua +++ b/mods/PLAYER/mcl_music/init.lua @@ -1,7 +1,7 @@ local modname = minetest.get_current_modname() local modpath = minetest.get_modpath(modname) -local music_disabled = minetest.settings:get_bool("mcl_music_disable", false) +local music_enabled = minetest.settings:get_bool("mcl_game_music", true) local pianowtune = "diminixed-pianowtune01" local end_tune = "diminixed-ambientwip" @@ -101,8 +101,8 @@ local function play() minetest.after(7, play) end -if not music_disabled then - minetest.log("action", "[mcl_music] Music is activated") +if music_enabled then + minetest.log("action", "[mcl_music] In game music is activated") minetest.after(15, play) minetest.register_on_joinplayer(function(player, last_login) @@ -115,5 +115,5 @@ if not music_disabled then stop_music_for_listener_name(player_name) end) else - minetest.log("action", "[mcl_music] Music is deactivated") + minetest.log("action", "[mcl_music] In game music is deactivated") end \ No newline at end of file diff --git a/settingtypes.txt b/settingtypes.txt index e7a42b351..58fad1dc3 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -139,8 +139,8 @@ mcl_mob_active_range (Active mob range) int 48 0 256 # Enable flame sound. flame_sound (Flame sound) bool true -# Disable the in game music. -mcl_music_disable (Disable in game music) bool false +# Enable the in game music. +mcl_game_music (Enable in game music) bool true [Graphics] # How many vertical animation frames the fire texture (fire_basic_flame_animated.png) has. From 871c4f24c2cc89127bea4a8139531a82033d8157 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Sat, 14 Jan 2023 10:20:30 +0000 Subject: [PATCH 03/22] Change some language stuff This adds correct hyphenation and also makes things more concise. --- settingtypes.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/settingtypes.txt b/settingtypes.txt index 58fad1dc3..d68b5793d 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -139,8 +139,8 @@ mcl_mob_active_range (Active mob range) int 48 0 256 # Enable flame sound. flame_sound (Flame sound) bool true -# Enable the in game music. -mcl_game_music (Enable in game music) bool true +# Enable the in-game music. +mcl_game_music (In-game music) bool true [Graphics] # How many vertical animation frames the fire texture (fire_basic_flame_animated.png) has. From 60b19b31ab3b1b0d032dc253164d7a586e83b689 Mon Sep 17 00:00:00 2001 From: FossFanatic Date: Sat, 14 Jan 2023 10:21:35 +0000 Subject: [PATCH 04/22] Add hyphenation This also adds hyphenation to `In-game`. --- mods/PLAYER/mcl_music/init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/PLAYER/mcl_music/init.lua b/mods/PLAYER/mcl_music/init.lua index 07e851f26..cd454593c 100644 --- a/mods/PLAYER/mcl_music/init.lua +++ b/mods/PLAYER/mcl_music/init.lua @@ -102,7 +102,7 @@ local function play() end if music_enabled then - minetest.log("action", "[mcl_music] In game music is activated") + minetest.log("action", "[mcl_music] In-game music is activated") minetest.after(15, play) minetest.register_on_joinplayer(function(player, last_login) @@ -115,5 +115,5 @@ if music_enabled then stop_music_for_listener_name(player_name) end) else - minetest.log("action", "[mcl_music] In game music is deactivated") -end \ No newline at end of file + minetest.log("action", "[mcl_music] In-game music is deactivated") +end From 4457432d325d7b4545640bc5ed83c3be271db886 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sun, 4 Dec 2022 18:34:15 +0100 Subject: [PATCH 05/22] Format file --- mods/ITEMS/mcl_core/nodes_misc.lua | 46 +++++++++++++++++++----------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 5f5b005e2..50c683232 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -8,7 +8,14 @@ if mod_screwdriver then on_rotate = screwdriver.rotate_3way end -local alldirs = {{x=0,y=0,z=1}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=-1,y=0,z=0}, {x=0,y=-1,z=0}, {x=0,y=1,z=0}} +local alldirs = { + {x = 0, y = 0, z = 1}, + {x = 1, y = 0, z = 0}, + {x = 0, y = 0, z = -1}, + {x = -1, y = 0, z = 0}, + {x = 0, y = -1, z = 0}, + {x = 0, y = 1, z = 0}, +} minetest.register_node("mcl_core:bone_block", { description = S("Bone Block"), @@ -17,7 +24,7 @@ minetest.register_node("mcl_core:bone_block", { is_ground_content = false, paramtype2 = "facedir", on_place = mcl_util.rotate_axis, - groups = {pickaxey=1, building_block=1, material_stone=1}, + groups = {pickaxey = 1, building_block = 1, material_stone = 1}, sounds = mcl_sounds.node_sound_stone_defaults(), on_rotate = on_rotate, _mcl_blast_resistance = 2, @@ -46,11 +53,11 @@ minetest.register_node("mcl_core:slimeblock", { -- According to Minecraft Wiki, bouncing off a slime block from a height off 255 blocks should result in a bounce height of 50 blocks -- bouncy=44 makes the player bounce up to 49.6. This value was chosen by experiment. -- bouncy=80 was chosen because it is higher than 66 (bounciness of bed) - groups = {dig_immediate=3, bouncy=80,fall_damage_add_percent=-100,deco_block=1}, + groups = {dig_immediate = 3, bouncy = 80, fall_damage_add_percent = -100, deco_block = 1}, sounds = { - dug = {name="slimenodes_dug", gain=0.6}, - place = {name="slimenodes_place", gain=0.6}, - footstep = {name="slimenodes_step", gain=0.3}, + dug = {name = "slimenodes_dug", gain = 0.6}, + place = {name = "slimenodes_place", gain = 0.6}, + footstep = {name = "slimenodes_step", gain = 0.3}, }, _mcl_blast_resistance = 0, _mcl_hardness = 0, @@ -74,7 +81,8 @@ minetest.register_node("mcl_core:slimeblock", { elseif name == "mesecons_pistons:piston_down_sticky_off" or name == "mesecons_pistons:piston_down_normal_off" then piston, piston_down = true, true end - if not( (piston_side and (n-1==neighbor_node.param2)) or (piston_up and (n==5)) or (piston_down and (n==6)) ) then + if not + ((piston_side and (n - 1 == neighbor_node.param2)) or (piston_up and (n == 5)) or (piston_down and (n == 6))) then if piston and piston_pos then if piston_pos.x == neighbor_pos.x and piston_pos.y == neighbor_pos.y and piston_pos.z == neighbor_pos.z then -- Loopback to the same piston! Preventing unwanted behavior: @@ -109,7 +117,8 @@ minetest.register_node("mcl_core:cobweb", { liquid_renewable = false, liquid_range = 0, walkable = false, - groups = {swordy_cobweb=1, shearsy_cobweb=1, fake_liquid=1, disable_jump=1, deco_block=1, dig_by_piston=1, dig_by_water=1,destroy_by_lava_flow=1,}, + groups = {swordy_cobweb = 1, shearsy_cobweb = 1, fake_liquid = 1, disable_jump = 1, deco_block = 1, dig_by_piston = 1, + dig_by_water = 1, destroy_by_lava_flow = 1,}, drop = "mcl_mobitems:string", _mcl_shears_drop = true, sounds = mcl_sounds.node_sound_leaves_defaults(), @@ -133,7 +142,8 @@ minetest.register_node("mcl_core:deadbush", { walkable = false, stack_max = 64, 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_water = 1, + destroy_by_lava_flow = 1, deco_block = 1, fire_encouragement = 60, fire_flammability = 100}, drop = { max_items = 1, items = { @@ -151,7 +161,7 @@ minetest.register_node("mcl_core:deadbush", { sounds = mcl_sounds.node_sound_leaves_defaults(), selection_box = { type = "fixed", - fixed = {-5/16, -8/16, -5/16, 5/16, 1/16, 5/16}, + fixed = {-5 / 16, -8 / 16, -5 / 16, 5 / 16, 1 / 16, 5 / 16}, }, _mcl_blast_resistance = 0, _mcl_hardness = 0, @@ -165,11 +175,11 @@ minetest.register_node("mcl_core:barrier", { paramtype = "light", inventory_image = "mcl_core_barrier.png", wield_image = "mcl_core_barrier.png", - tiles = { "blank.png" }, + tiles = {"blank.png"}, stack_max = 64, sunlight_propagates = true, is_ground_content = false, - groups = {creative_breakable=1, not_in_creative_inventory = 1, not_solid = 1 }, + groups = {creative_breakable = 1, not_in_creative_inventory = 1, not_solid = 1}, on_blast = function() end, drop = "", _mcl_blast_resistance = 36000008, @@ -222,14 +232,14 @@ minetest.register_node("mcl_core:realm_barrier", { paramtype = "light", inventory_image = "mcl_core_barrier.png^[colorize:#FF00FF:127^[transformFX", wield_image = "mcl_core_barrier.png^[colorize:#FF00FF:127^[transformFX", - tiles = { "blank.png" }, + tiles = {"blank.png"}, stack_max = 64, -- To avoid players getting stuck forever between realms damage_per_second = 8, sunlight_propagates = true, is_ground_content = false, pointable = false, - groups = {not_in_creative_inventory = 1, not_solid = 1 }, + groups = {not_in_creative_inventory = 1, not_solid = 1}, on_blast = function() end, drop = "", _mcl_blast_resistance = 36000008, @@ -237,7 +247,8 @@ minetest.register_node("mcl_core:realm_barrier", { -- Prevent placement to protect player from screwing up the world, because the node is not pointable and hard to get rid of. node_placement_prediction = "", on_place = function(pos, placer, itemstack, pointed_thing) - minetest.chat_send_player(placer:get_player_name(), minetest.colorize(mcl_colors.RED, "You can't just place a realm barrier by hand!")) + minetest.chat_send_player(placer:get_player_name(), + minetest.colorize(mcl_colors.RED, "You can't just place a realm barrier by hand!")) return end, }) @@ -262,12 +273,13 @@ minetest.register_node("mcl_core:void", { stack_max = 64, sunlight_propagates = true, is_ground_content = false, - groups = { not_in_creative_inventory = 1 }, + groups = {not_in_creative_inventory = 1}, on_blast = function() end, -- Prevent placement to protect player from screwing up the world, because the node is not pointable and hard to get rid of. node_placement_prediction = "", on_place = function(pos, placer, itemstack, pointed_thing) - minetest.chat_send_player(placer:get_player_name(), minetest.colorize(mcl_colors.RED, "You can't just place the void by hand!")) + minetest.chat_send_player(placer:get_player_name(), + minetest.colorize(mcl_colors.RED, "You can't just place the void by hand!")) return end, drop = "", From 1e31e383d4dac1cbe9d96ca1152922e91c61b453 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sun, 4 Dec 2022 18:36:54 +0100 Subject: [PATCH 06/22] Fix invalid function signature for `on_place` callbacks + handling of possible nil value --- mods/ITEMS/mcl_core/nodes_misc.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 50c683232..81a2fab32 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -246,9 +246,11 @@ minetest.register_node("mcl_core:realm_barrier", { _mcl_hardness = -1, -- Prevent placement to protect player from screwing up the world, because the node is not pointable and hard to get rid of. node_placement_prediction = "", - on_place = function(pos, placer, itemstack, pointed_thing) - minetest.chat_send_player(placer:get_player_name(), - minetest.colorize(mcl_colors.RED, "You can't just place a realm barrier by hand!")) + on_place = function(_, placer, _) + if placer then + minetest.chat_send_player(placer:get_player_name(), + minetest.colorize(mcl_colors.RED, "You can't just place a realm barrier by hand!")) + end return end, }) @@ -277,9 +279,11 @@ minetest.register_node("mcl_core:void", { on_blast = function() end, -- Prevent placement to protect player from screwing up the world, because the node is not pointable and hard to get rid of. node_placement_prediction = "", - on_place = function(pos, placer, itemstack, pointed_thing) - minetest.chat_send_player(placer:get_player_name(), - minetest.colorize(mcl_colors.RED, "You can't just place the void by hand!")) + on_place = function(_, placer, _) + if placer then + minetest.chat_send_player(placer:get_player_name(), + minetest.colorize(mcl_colors.RED, "You can't just place the void by hand!")) + end return end, drop = "", From 92261e5fb5e5929d1a112e99f95968aa6ed967f3 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sun, 4 Dec 2022 18:37:45 +0100 Subject: [PATCH 07/22] Remove `stack_max` fields duplicated with default value --- mods/ITEMS/mcl_core/nodes_misc.lua | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 81a2fab32..719f6efad 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -49,7 +49,6 @@ minetest.register_node("mcl_core:slimeblock", { }, tiles = {"mcl_core_slime.png"}, use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "blend" or true, - stack_max = 64, -- According to Minecraft Wiki, bouncing off a slime block from a height off 255 blocks should result in a bounce height of 50 blocks -- bouncy=44 makes the player bounce up to 49.6. This value was chosen by experiment. -- bouncy=80 was chosen because it is higher than 66 (bounciness of bed) @@ -106,7 +105,6 @@ minetest.register_node("mcl_core:cobweb", { drawtype = "plantlike", paramtype2 = "degrotate", visual_scale = 1.1, - stack_max = 64, tiles = {"mcl_core_web.png"}, inventory_image = "mcl_core_web.png", paramtype = "light", @@ -140,7 +138,6 @@ minetest.register_node("mcl_core:deadbush", { paramtype = "light", sunlight_propagates = true, walkable = false, - stack_max = 64, 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}, @@ -176,7 +173,6 @@ minetest.register_node("mcl_core:barrier", { inventory_image = "mcl_core_barrier.png", wield_image = "mcl_core_barrier.png", tiles = {"blank.png"}, - stack_max = 64, sunlight_propagates = true, is_ground_content = false, groups = {creative_breakable = 1, not_in_creative_inventory = 1, not_solid = 1}, @@ -233,7 +229,6 @@ minetest.register_node("mcl_core:realm_barrier", { inventory_image = "mcl_core_barrier.png^[colorize:#FF00FF:127^[transformFX", wield_image = "mcl_core_barrier.png^[colorize:#FF00FF:127^[transformFX", tiles = {"blank.png"}, - stack_max = 64, -- To avoid players getting stuck forever between realms damage_per_second = 8, sunlight_propagates = true, @@ -272,7 +267,6 @@ minetest.register_node("mcl_core:void", { buildable_to = false, inventory_image = "mcl_core_void.png", wield_image = "mcl_core_void.png", - stack_max = 64, sunlight_propagates = true, is_ground_content = false, groups = {not_in_creative_inventory = 1}, From bf25fca47d39820e48d18491729fe835850b7222 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sun, 4 Dec 2022 18:38:29 +0100 Subject: [PATCH 08/22] Remove support for `use_texture_alpha` bool values (mt 5.3) --- .vscode/settings.json | 5 +++++ mods/ITEMS/mcl_core/nodes_misc.lua | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..4fa2764d6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "Lua.format.defaultConfig": { + "keep_one_space_between_table_and_bracket": "false" + } +} diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 719f6efad..612ec5bdf 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -48,7 +48,7 @@ minetest.register_node("mcl_core:slimeblock", { type = "regular", }, tiles = {"mcl_core_slime.png"}, - use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "blend" or true, + use_texture_alpha = "blend", -- According to Minecraft Wiki, bouncing off a slime block from a height off 255 blocks should result in a bounce height of 50 blocks -- bouncy=44 makes the player bounce up to 49.6. This value was chosen by experiment. -- bouncy=80 was chosen because it is higher than 66 (bounciness of bed) From b9238b40696aa2d119ee1b4f083b15edb17ab32e Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sun, 4 Dec 2022 18:41:42 +0100 Subject: [PATCH 09/22] Use new vectors --- mods/ITEMS/mcl_core/nodes_misc.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 612ec5bdf..d6120f665 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -9,12 +9,12 @@ if mod_screwdriver then end local alldirs = { - {x = 0, y = 0, z = 1}, - {x = 1, y = 0, z = 0}, - {x = 0, y = 0, z = -1}, - {x = -1, y = 0, z = 0}, - {x = 0, y = -1, z = 0}, - {x = 0, y = 1, z = 0}, + vector.new(0, 0, 1), + vector.new(1, 0, 0), + vector.new(0, 0, -1), + vector.new(-1, 0, 0), + vector.new(0, -1, 0), + vector.new(0, 1, 0), } minetest.register_node("mcl_core:bone_block", { From 79876635af48a23a1f2383718a7355b467552828 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sun, 4 Dec 2022 18:45:05 +0100 Subject: [PATCH 10/22] Use `mcl_util.call_on_rightclick` in `on_place` callback for barrier block --- mods/ITEMS/mcl_core/nodes_misc.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index d6120f665..32f4a4f4d 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -199,11 +199,9 @@ minetest.register_node("mcl_core:barrier", { end -- Use pointed node's on_rightclick function first, if present - local node = minetest.get_node(pointed_thing.under) - 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 + local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) + if new_stack then + return new_stack end local name = placer:get_player_name() From 302970d22030020b3494d3c48258cbf7e4cb3c4a Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 6 Dec 2022 20:35:13 +0100 Subject: [PATCH 11/22] Basic light blocks --- mods/ITEMS/mcl_core/nodes_misc.lua | 27 ++++++++++++++++++ .../mcl_core/textures/mcl_core_light_0.png | Bin 0 -> 210 bytes .../mcl_core/textures/mcl_core_light_1.png | Bin 0 -> 220 bytes .../mcl_core/textures/mcl_core_light_10.png | Bin 0 -> 291 bytes .../mcl_core/textures/mcl_core_light_11.png | Bin 0 -> 287 bytes .../mcl_core/textures/mcl_core_light_12.png | Bin 0 -> 291 bytes .../mcl_core/textures/mcl_core_light_13.png | Bin 0 -> 267 bytes .../mcl_core/textures/mcl_core_light_14.png | Bin 0 -> 249 bytes .../mcl_core/textures/mcl_core_light_2.png | Bin 0 -> 211 bytes .../mcl_core/textures/mcl_core_light_3.png | Bin 0 -> 212 bytes .../mcl_core/textures/mcl_core_light_4.png | Bin 0 -> 214 bytes .../mcl_core/textures/mcl_core_light_5.png | Bin 0 -> 370 bytes .../mcl_core/textures/mcl_core_light_6.png | Bin 0 -> 354 bytes .../mcl_core/textures/mcl_core_light_7.png | Bin 0 -> 310 bytes .../mcl_core/textures/mcl_core_light_8.png | Bin 0 -> 310 bytes .../mcl_core/textures/mcl_core_light_9.png | Bin 0 -> 314 bytes 16 files changed, 27 insertions(+) create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_0.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_1.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_10.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_11.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_12.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_13.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_14.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_2.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_3.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_4.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_5.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_6.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_7.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_8.png create mode 100644 mods/ITEMS/mcl_core/textures/mcl_core_light_9.png diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 32f4a4f4d..270c3fb33 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -249,6 +249,33 @@ minetest.register_node("mcl_core:realm_barrier", { }) +--- Light blocks + +for i = 0, 14 do --minetest.LIGHT_MAX + minetest.register_node("mcl_core:light_" .. i, { + description = S("Light"), + _doc_items_longdesc = S("Lights are invisble blocks. They are used to light up adventure maps and the like."), + _doc_items_usagehelp = S("When you hold a light in hand, you reveal all placed lights in a short distance around you."), + drawtype = "airlike", + paramtype = "light", + light_source = i, + drop = "", + inventory_image = "mcl_core_light_" .. i .. ".png", + wield_image = "mcl_core_light_" .. i .. ".png", + sunlight_propagates = true, + is_ground_content = false, + groups = {creative_breakable = 1, not_solid = 1}, + on_blast = function() end, + on_use = function(itemstack, user, pointed_thing) + itemstack:set_name("mcl_core:light_" .. ((i == 14) and 0 or i + 1)) + return itemstack + end, + _mcl_blast_resistance = 36000008, + _mcl_hardness = -1, + }) +end + + -- The void below the bedrock. Void damage is handled in mcl_playerplus. diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_light_0.png b/mods/ITEMS/mcl_core/textures/mcl_core_light_0.png new file mode 100644 index 0000000000000000000000000000000000000000..ba7b78474f9de47cab2053ddc37b0b6f2ce17076 GIT binary patch literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Gd*1#Lo9lecWk=z#h&N)4UYfm z3Ze&09vLkt`gikxrg8oO!w&x~j0(IrbX*0Gr!utpM#Qk0Gek=~*fcky@)WPft9$() z{QS<L|elg|7mFgAJ*OCF=KF< zoXT+G>GLuC*cq!(-NIh6|4#dJA+UgQu&X J%Q~loCIDV&QO*DW literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_light_1.png b/mods/ITEMS/mcl_core/textures/mcl_core_light_1.png new file mode 100644 index 0000000000000000000000000000000000000000..9d3aed2166148741f237cec3a4c0ef74c93b771e GIT binary patch literal 220 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`i#=T&Lo7}wConW=pZ5L#`v%AV zbOrVXlgGvjivHdFpJ|+bz_6qLsz44~gGqw1h_lRW#)#ZQYW$y>b}8=2Q4gD!_`a#_ z|CAHPb7qThga^!={P};?(iimty}oklJMJVhhF!UPt?bpJyw*hS8<@ zhstu%8J`_ZB0GDNm>vAq>udd*FCy(dk8#0)&*jC;$(wi>Zu(8+c4)}C&B@5{ZFNU= U70WDUpmP~KUHx3vIVCg!0IP&m$^ZZW literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_light_10.png b/mods/ITEMS/mcl_core/textures/mcl_core_light_10.png new file mode 100644 index 0000000000000000000000000000000000000000..bdea1d56c673ff4337801f9894bb14e9c5b22c3f GIT binary patch literal 291 zcmV+;0o?wHP)*w%VHhTc7oaN!v5^h^dS&7NcZX}?7{teF2rdKOo}Tjm|Fxd~cUDA! z@r?yOn1)5rkvt|ItXWhVHgDu#-VFi2r|IAYsjLLkjwQ&2U5Zd4iq)e~%mKn!yI_f`r5Wect350CIYLQPKaT*jVxm00o}E pn;RIDWdO)_id+B!WZO;%002)}4_^%0nw0)k*0(3rJ08)&s0iFN#%EJHe4%fmlh>z6}Y%TyPetUY#|EI^MqhJg} z@EHKoaDQ(%9Ag*)b23a5I{)qZkpFL11;H`QAgo?N1|X-u+K~&^^mC;x9E12E@&Bib z@Ed@vxiTl`|FhMxU>d}KzsMSF2*DWoe>4)Tp}VaO>|_uP;{V?lNL&ic%1+M literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_light_12.png b/mods/ITEMS/mcl_core/textures/mcl_core_light_12.png new file mode 100644 index 0000000000000000000000000000000000000000..4b7bc671ff2304b60a4d6bb52dd5d4e70a5d9dfe GIT binary patch literal 291 zcmV+;0o?wHP)*w%VHhTc7vNG16MJ|6`2V*zccai)4Z-Dtx2LE4e|mBr1Rt9YrZEgb zHvq&2Dg1h6Az0J>z1?t(VFV<1qp}$`@G3B0Oa)gqN4vvv9aVC017;R pH#aaQ%K(t=6uAHd$hMsj003VF8ecFNnsxvH002ovPDHLkV1nO*fFu9_ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_light_13.png b/mods/ITEMS/mcl_core/textures/mcl_core_light_13.png new file mode 100644 index 0000000000000000000000000000000000000000..66c617e2acf9fc71a3a2caa34319aabcd11886df GIT binary patch literal 267 zcmV+m0rdWfP)*w%VHhTc7vNG16Z`P`F$TtJ2rd`AJw4_B)06Wc_}FwXjbR8r7l1U~ z-`fqx7>1zRh~a|uA^+d33W8&pL2qyF#veX^?kxQOYDX?u)7LGra17#u#Q&czB5VLm zb7fA>|7WWqG>HFxk@bI&Ji!?Hf3E!h&y}|SyW86Sf4#C0LIVu|i4)X}Y{=}{v%v;| zXp%G|8v=4ZS(>S00Lba}MMeLUVq?iO02FxsZf;;qmH{B!DRKb_kZn65003Oi7-1%^ R#V7y(002ovPDHLkV1h^&a;pFU literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_light_14.png b/mods/ITEMS/mcl_core/textures/mcl_core_light_14.png new file mode 100644 index 0000000000000000000000000000000000000000..47828a0d67772395808b50e7d841e4b90199bb5b GIT binary patch literal 249 zcmV*w%(Z%orkV1S0e0cpB17kG=*#KliKRvth|M``ja17#O7=q2YFfov( z`+K|L7{d^B8_^ATd!Y6Io4s{#jBE(rumLG}wIdg->FbtQ6q;xQV76E0K-PZR1>y?FInrO|)hRmKl`~Ua-C19E)%`ou)TsheJAev;&R51YL^!lQr z|4Fg2yjJgBCR_S00000NkvXXu0mjfBr$Aa literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_light_2.png b/mods/ITEMS/mcl_core/textures/mcl_core_light_2.png new file mode 100644 index 0000000000000000000000000000000000000000..692f7a5fa3a2b048f06aad2ae061657e33780e76 GIT binary patch literal 211 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`vpiiKLo7}wR~TIXV$bvY2FL$& z1@Q+)3lbk~{BJpT`U8n0$1il8W>w(5q2nxgJl)t%{P5GloeyqZ(%8c$Fe!b9(f!}{ zs-HBtw2F)V-JiAQpS+83E(6D%S*e_1SMFYGb2@yalS$#|=JfMy*$fv|GTWq?O6@w- zB8@|N7%cbhTk)bkC`YG~t%2$M{jL%(nKL*W+7*^CCv-V%6H4XS#c2QS$YWl9r%ychxBYk& z>fj-Fv~#MZ<^TVB!GHJ{Z9MsyrT+TNX3^5^TNhq1C|tzg@$t>g%?G6%Ogv{jY;%~) zzsU2Nk0`T)-+FzmU-Lzzz2`A5IPkf=m^pb955rBriQEniIk!0(8J0UvY5%u1Y9r90 N44$rjF6*2Ung9a$Qt|)* literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_light_5.png b/mods/ITEMS/mcl_core/textures/mcl_core_light_5.png new file mode 100644 index 0000000000000000000000000000000000000000..a1c8c9a2fb09c30f4af3763b8ca327b00e96baa8 GIT binary patch literal 370 zcmV-&0ge8NP)Fz1nY1++#cgn>=Fv1QK~a(BCQUx1BCUVm zE4AajS6qpWjRS{S&D=S2Zl-lMg729dA3|nOBneyRBI4U6bnmlxy_&_Noy8A>-x74} zWi%ZXzEwh4Jw#-e;M+%N8#72u@??nc%p!VZ6@jgQm{e>YP?pfNWIR|a=$qgr*yN(9 zehSYhBC4rWD4}t&1HV$nb7Q@KUvK^fh*btLBm`9zq@o~XCM=DDF* zhpl`bu`|j!bdC|yE;`nH^2Knsz}HY@8Q$eCXF?5Qck1uw#cO2%XTYLw7YbO*<S6ovZ^K8riSg-`?)L5Y7*6zwvr>P8UUb>nZ9T1@mAM3b1tQWOT6*D;9Y{%z-wZPSEcLeD6$iR3MM z-g5Gb@w}qf*ejQ5-yG;EB#`FZ-=CX@d2HJzZd~Ze<3jqsLUXFWMq@I)SObFbKA<_1 z4WOd$mP)J_3fTbac(eJu?o0sX{;ve8GP@_$7tme?VIA&ojQ{`u07*qoM6N<$g5Jrb AF8}}l literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_light_7.png b/mods/ITEMS/mcl_core/textures/mcl_core_light_7.png new file mode 100644 index 0000000000000000000000000000000000000000..2adfc272986560b6dd280f77b801c5b224c58762 GIT binary patch literal 310 zcmV-60m=S}P)L&PqgL_+Y|m@+}8geWXQ4A zO<*<%zuyx6pP&IBw}gTf|38%jra=b4Fo^$VYw~}*2K+x=16B;O{p})KIEESW|3oqV z@cMtMC3SHCN{3{C~1K4ot%g`LH#TaE$#w5(U=K z-PQ&+07QfM|MvzFAKm{C1pl8sd-ng&vlPJe|3hJ$ zzT_DIa(aDH(f_2_Sn>=21)jf~8yJ&i0LXTVTmS-O+fE1o0La$xy+WV%`v3p{07*qo IM6N<$f(Ve7Q2+n{ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_light_8.png b/mods/ITEMS/mcl_core/textures/mcl_core_light_8.png new file mode 100644 index 0000000000000000000000000000000000000000..bf11f8384414ba834b195842b9824e9d82eb6592 GIT binary patch literal 310 zcmV-60m=S}P)ON+jc?#0IKr>5r$l5UjP6A07*qo IM6N<$f_aRY3;+NC literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_core/textures/mcl_core_light_9.png b/mods/ITEMS/mcl_core/textures/mcl_core_light_9.png new file mode 100644 index 0000000000000000000000000000000000000000..12c4ee769d9f109b57955346c3b68169f8d1842e GIT binary patch literal 314 zcmV-A0mc4_P)C3SHCN{3{C~1K4ot%g`LH#TaE$#w z5(U=K-PQ&+07QfM|MvzFAKm{C1pl8sd-ng&vlPJe|3hJr0*iAg9+C75z_&jU~?jP~iEyxq&fR27qj*$ORxkw(W!f0Ng$Qs-4y)IRF3v M07*qoM6N<$g0*v(DF6Tf literal 0 HcmV?d00001 From cd70dd5b8867cb07bd23a5f5d255a24b185e82a2 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 6 Dec 2022 20:40:31 +0100 Subject: [PATCH 12/22] Spawn particle then placing light blocks --- mods/ITEMS/mcl_core/nodes_misc.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 270c3fb33..54c6b1ec2 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -266,10 +266,23 @@ for i = 0, 14 do --minetest.LIGHT_MAX is_ground_content = false, groups = {creative_breakable = 1, not_solid = 1}, on_blast = function() end, - on_use = function(itemstack, user, pointed_thing) + on_use = function(itemstack, _, _) itemstack:set_name("mcl_core:light_" .. ((i == 14) and 0 or i + 1)) return itemstack end, + after_place_node = function(pos, placer, _, _) + if placer == nil then + return + end + minetest.add_particle({ + pos = pos, + expirationtime = 1, + size = 8, + texture = "mcl_core_light_" .. i .. ".png", + glow = 14, + playername = placer:get_player_name() + }) + end, _mcl_blast_resistance = 36000008, _mcl_hardness = -1, }) From 7c20896d5eb71b6b4f6e77c332e9d13921f09e30 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 6 Dec 2022 20:46:51 +0100 Subject: [PATCH 13/22] Make light blocks not walkable --- mods/ITEMS/mcl_core/nodes_misc.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 54c6b1ec2..abe86879e 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -258,6 +258,7 @@ for i = 0, 14 do --minetest.LIGHT_MAX _doc_items_usagehelp = S("When you hold a light in hand, you reveal all placed lights in a short distance around you."), drawtype = "airlike", paramtype = "light", + walkable = false, light_source = i, drop = "", inventory_image = "mcl_core_light_" .. i .. ".png", From 7c497d960406968fd002331c7d0ed4d7b65dfdd0 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 6 Dec 2022 20:53:33 +0100 Subject: [PATCH 14/22] Remove config file --- .vscode/settings.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 4fa2764d6..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "Lua.format.defaultConfig": { - "keep_one_space_between_table_and_bracket": "false" - } -} From 33e2b79b2b6d8c7072235ed0f420d7bc89bfc4c3 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 6 Dec 2022 21:14:05 +0100 Subject: [PATCH 15/22] Make nearby light blocks spawn particles when player wield one --- mods/ITEMS/mcl_core/nodes_misc.lua | 3 ++- mods/PLAYER/mcl_playerplus/init.lua | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index abe86879e..ceee50004 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -250,6 +250,7 @@ minetest.register_node("mcl_core:realm_barrier", { --- Light blocks +--- TODO: make node only pointable when wielding it for i = 0, 14 do --minetest.LIGHT_MAX minetest.register_node("mcl_core:light_" .. i, { @@ -265,7 +266,7 @@ for i = 0, 14 do --minetest.LIGHT_MAX wield_image = "mcl_core_light_" .. i .. ".png", sunlight_propagates = true, is_ground_content = false, - groups = {creative_breakable = 1, not_solid = 1}, + groups = {creative_breakable = 1, not_solid = 1, light_block = i + 1}, on_blast = function() end, on_use = function(itemstack, _, _) itemstack:set_name("mcl_core:light_" .. ((i == 14) and 0 or i + 1)) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 0faa9c53f..28822d1bc 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -627,7 +627,7 @@ minetest.register_globalstep(function(dtime) -- Show positions of barriers when player is wielding a barrier local wi = player:get_wielded_item():get_name() - if wi == "mcl_core:barrier" or wi == "mcl_core:realm_barrier" then + if wi == "mcl_core:barrier" or wi == "mcl_core:realm_barrier" or minetest.get_item_group(wi, "light_block") ~= 0 then local pos = vector.round(player:get_pos()) local r = 8 local vm = get_voxel_manip() @@ -642,11 +642,15 @@ minetest.register_globalstep(function(dtime) for z=pos.z-r, pos.z+r do local vi = area:indexp({x=x, y=y, z=z}) local nodename = get_name_from_content_id(data[vi]) + local light_block_group = minetest.get_item_group(nodename, "light_block") + local tex if nodename == "mcl_core:barrier" then tex = "mcl_core_barrier.png" elseif nodename == "mcl_core:realm_barrier" then tex = "mcl_core_barrier.png^[colorize:#FF00FF:127^[transformFX" + elseif light_block_group ~= 0 then + tex = "mcl_core_light_" .. (light_block_group - 1) .. ".png" end if tex then add_particle({ From eb5f5678d6cac4f7765e44de40b753d89aa8c710 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 7 Dec 2022 19:01:44 +0100 Subject: [PATCH 16/22] Fix typo in barrier help text --- mods/ITEMS/mcl_core/locale/mcl_core.de.tr | 2 +- mods/ITEMS/mcl_core/locale/mcl_core.es.tr | 2 +- mods/ITEMS/mcl_core/locale/mcl_core.fr.tr | 2 +- mods/ITEMS/mcl_core/locale/mcl_core.pl.tr | 2 +- mods/ITEMS/mcl_core/locale/mcl_core.ru.tr | 2 +- mods/ITEMS/mcl_core/locale/mcl_core.zh_TW.tr | 2 +- mods/ITEMS/mcl_core/locale/template.txt | 2 +- mods/ITEMS/mcl_core/nodes_misc.lua | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.de.tr b/mods/ITEMS/mcl_core/locale/mcl_core.de.tr index f8a441fdc..4f9071825 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.de.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.de.tr @@ -24,7 +24,7 @@ Andesite is an igneous rock.=Andesit ist ein magmatisches Gestein. Apple=Apfel Apples are food items which can be eaten.=Äpfel sind essbare Gegenstände. Barrier=Barriere -Barriers are invisble walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=Barrieren sind unsichtbare feste Blöcke. Sie sind nützlich, um Grenzen für Abenteuerkarten und ähnliches zu bauen. Monster und Tiere werden auf Barrieren nicht auftauchen, und Zäune verbinden sich nicht mit Barrieren. Andere Blöcke können an Barrieren gebaut werden, wie bei allen anderen Blöcken. +Barriers are invisible walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=Barrieren sind unsichtbare feste Blöcke. Sie sind nützlich, um Grenzen für Abenteuerkarten und ähnliches zu bauen. Monster und Tiere werden auf Barrieren nicht auftauchen, und Zäune verbinden sich nicht mit Barrieren. Andere Blöcke können an Barrieren gebaut werden, wie bei allen anderen Blöcken. Bedrock=Grundgestein Bedrock is a very hard type of rock. It can not be broken, destroyed, collected or moved by normal means, unless in Creative Mode.=Grundgestein ist ein sehr harter Gesteinstyp. Er kann unter normalen Umständen nicht abgebaut, zerstört, aufgesammelt oder verschoben werden, außer im Kreativmodus. Birch Bark=Birkenrinde diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.es.tr b/mods/ITEMS/mcl_core/locale/mcl_core.es.tr index 0f8656520..cf16e5bda 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.es.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.es.tr @@ -24,7 +24,7 @@ Andesite is an igneous rock.=La andesita es una roca ígnea. Apple=Manzana Apples are food items which can be eaten.=Las manzanas son alimentos que se pueden comer. Barrier=Barrera -Barriers are invisble walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=Las barreras son bloques transitables invisibles. Se utilizan para crear límites de mapas de aventura y similares. Los monstruos y los animales no aparecerán en las barreras, y las cercas no se conectan a las barreras. Otros bloques pueden construirse sobre barreras como en cualquier otro bloque. +Barriers are invisible walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=Las barreras son bloques transitables invisibles. Se utilizan para crear límites de mapas de aventura y similares. Los monstruos y los animales no aparecerán en las barreras, y las cercas no se conectan a las barreras. Otros bloques pueden construirse sobre barreras como en cualquier otro bloque. Bedrock=Lecho de roca Bedrock is a very hard type of rock. It can not be broken, destroyed, collected or moved by normal means, unless in Creative Mode.=El lecho de roca es un tipo de roca muy duro. No se puede romper, destruir, recoger o mover por medios normales, a menos que esté en modo creativo. Birch Bark=Madera de abedul sin corteza diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr b/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr index ad6c09b08..c6a4d84ad 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr @@ -24,7 +24,7 @@ Andesite is an igneous rock.=L'andésite est une roche ignée. Apple=Pomme Apples are food items which can be eaten.=Les pommes sont des aliments qui peuvent être consommés. Barrier=Barrière invisible -Barriers are invisble walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=Les barrières sont des blocs accessibles à pied. Ils sont utilisés pour créer des limites de cartes d'aventure et similaires. Les monstres et les animaux n'apparaissent pas sur les barrières, et les clôtures ne se connectent pas aux barrières. D'autres blocs peuvent être construits sur des barrières comme sur n'importe quel autre bloc. +Barriers are invisible walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=Les barrières sont des blocs accessibles à pied. Ils sont utilisés pour créer des limites de cartes d'aventure et similaires. Les monstres et les animaux n'apparaissent pas sur les barrières, et les clôtures ne se connectent pas aux barrières. D'autres blocs peuvent être construits sur des barrières comme sur n'importe quel autre bloc. Bedrock=Bedrock Bedrock is a very hard type of rock. It can not be broken, destroyed, collected or moved by normal means, unless in Creative Mode.=Le bedrock est un type de roche très dur. Il ne peut pas être brisé, détruit, collecté ou déplacé par des moyens normaux, sauf en mode créatif. Birch Bark=Bois de Bouleau diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.pl.tr b/mods/ITEMS/mcl_core/locale/mcl_core.pl.tr index 8e9d7cf8f..669e4bc9b 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.pl.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.pl.tr @@ -24,7 +24,7 @@ Andesite is an igneous rock.=Andezyt jest skałą pochodzenia wulkanicznego. Apple=Jabłko Apples are food items which can be eaten.=Jabłka to przedmioty które można zjeść. Barrier=Bariera -Barriers are invisble walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=Bariery to niewidzialne bloki po których można chodzić. Są użyteczne do tworzenia ograniczeń na mapach przygodowych i im podobnych. Potwory i zwierzęta nie pojawiają się na barierach, a płoty się z nimi nie łączą. Inne bloki mogą być na nich budowane podobnie jak na innych blokach. +Barriers are invisible walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=Bariery to niewidzialne bloki po których można chodzić. Są użyteczne do tworzenia ograniczeń na mapach przygodowych i im podobnych. Potwory i zwierzęta nie pojawiają się na barierach, a płoty się z nimi nie łączą. Inne bloki mogą być na nich budowane podobnie jak na innych blokach. Bedrock=Skała macierzysta Bedrock is a very hard type of rock. It can not be broken, destroyed, collected or moved by normal means, unless in Creative Mode.=Skała macierzysta jest rodzajem bardzo twardej skały. Nie może być ona zniszczona, zebrana lub przesunięta normalnymi metodami, jeśli nie jesteś w trybie kreatywnym. Birch Bark=Brzozowa kora diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.ru.tr b/mods/ITEMS/mcl_core/locale/mcl_core.ru.tr index 831795792..bf8ce9e4f 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.ru.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.ru.tr @@ -24,7 +24,7 @@ Andesite is an igneous rock.=Андезит это камень вулканич Apple=Яблоко Apples are food items which can be eaten.=Яблоки относятся к продуктовым предметам, которые можно есть. Barrier=Барьер -Barriers are invisble walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=Барьеры это невидимые блоки-препятствия. Они могут использоваться, например, для создания границ карты. Монстры и животные не будут появляться на барьерах. Заборы с барьерами визуально не связываются. Другие блоки могут строиться на барьерах, как на любых других блоках. +Barriers are invisible walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=Барьеры это невидимые блоки-препятствия. Они могут использоваться, например, для создания границ карты. Монстры и животные не будут появляться на барьерах. Заборы с барьерами визуально не связываются. Другие блоки могут строиться на барьерах, как на любых других блоках. Bedrock=Бедрок Bedrock is a very hard type of rock. It can not be broken, destroyed, collected or moved by normal means, unless in Creative Mode.=Бедрок это очень твёрдый камень. Его невозможно сломать, выкопать или сдвинуть обычным способом, за исключением творческого режима. Birch Bark=Кора берёзы diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.zh_TW.tr b/mods/ITEMS/mcl_core/locale/mcl_core.zh_TW.tr index 0e8280c6e..74f3297a1 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.zh_TW.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.zh_TW.tr @@ -23,7 +23,7 @@ Andesite is an igneous rock.=安山岩是一種火成岩。 Apple=蘋果 Apples are food items which can be eaten.=蘋果是一種可以被食用的食物 Barrier=屏障 -Barriers are invisble walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=屏障是看不見但可行走的方塊。它們通常被用來創建冒險地圖的邊界。怪物和動物不會出現在屏障上,柵欄也不會連接到屏障上。其他方塊可以像在其他方塊上一樣被放置在屏障上。 +Barriers are invisible walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.=屏障是看不見但可行走的方塊。它們通常被用來創建冒險地圖的邊界。怪物和動物不會出現在屏障上,柵欄也不會連接到屏障上。其他方塊可以像在其他方塊上一樣被放置在屏障上。 Bedrock=基岩 Bedrock is a very hard type of rock. It can not be broken, destroyed, collected or moved by normal means, unless in Creative Mode.=基岩是一種堅實無比的石頭。除了創造模式的玩家,沒有人可以以正常方式破壞、銷毀、收集或移動它。 Birch Bark=白樺樹皮 diff --git a/mods/ITEMS/mcl_core/locale/template.txt b/mods/ITEMS/mcl_core/locale/template.txt index a7798b9cd..69ca8b77f 100644 --- a/mods/ITEMS/mcl_core/locale/template.txt +++ b/mods/ITEMS/mcl_core/locale/template.txt @@ -24,7 +24,7 @@ Andesite is an igneous rock.= Apple= Apples are food items which can be eaten.= Barrier= -Barriers are invisble walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.= +Barriers are invisible walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block.= Bedrock= Bedrock is a very hard type of rock. It can not be broken, destroyed, collected or moved by normal means, unless in Creative Mode.= Birch Bark= diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index ceee50004..6225bd611 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -166,7 +166,7 @@ minetest.register_node("mcl_core:deadbush", { minetest.register_node("mcl_core:barrier", { description = S("Barrier"), - _doc_items_longdesc = S("Barriers are invisble walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block."), + _doc_items_longdesc = S("Barriers are invisible walkable blocks. They are used to create boundaries of adventure maps and the like. Monsters and animals won't appear on barriers, and fences do not connect to barriers. Other blocks can be built on barriers like on any other block."), _doc_items_usagehelp = S("When you hold a barrier in hand, you reveal all placed barriers in a short distance around you."), drawtype = "airlike", paramtype = "light", @@ -255,7 +255,7 @@ minetest.register_node("mcl_core:realm_barrier", { for i = 0, 14 do --minetest.LIGHT_MAX minetest.register_node("mcl_core:light_" .. i, { description = S("Light"), - _doc_items_longdesc = S("Lights are invisble blocks. They are used to light up adventure maps and the like."), + _doc_items_longdesc = S("Lights are invisible blocks. They are used to light up adventure maps and the like."), _doc_items_usagehelp = S("When you hold a light in hand, you reveal all placed lights in a short distance around you."), drawtype = "airlike", paramtype = "light", From 515204d296189f97decb0e650ad12ff7f60e40fc Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 7 Dec 2022 19:07:35 +0100 Subject: [PATCH 17/22] Update translation template and add french translation --- mods/ITEMS/mcl_core/locale/mcl_core.fr.tr | 3 +++ mods/ITEMS/mcl_core/locale/template.txt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr b/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr index c6a4d84ad..7dbe3b55a 100644 --- a/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr +++ b/mods/ITEMS/mcl_core/locale/mcl_core.fr.tr @@ -286,3 +286,6 @@ Stackable=Empilable Crying Obsidian=Obsidienne pleureuse Crying obsidian is a luminous obsidian that can generate as part of ruined portals.=L'obsidienne pleureuse est une obsidienne luminause qui peut être générée dans les portails en ruine. Enchanted Golden Apple=Pomme dorée enchantée +Light=Lumière +Lights are invisible blocks. They are used to light up adventure maps and the like.=Les lumières sont des blocs invisibles. Ils sont utilisés pour éclairer les cartes d'aventure. +When you hold a light in hand, you reveal all placed lights in a short distance around you.=Lorsque vous tenez une lumière en main, vous révélez toutes les lumières placées à une courte distance autour de vous. diff --git a/mods/ITEMS/mcl_core/locale/template.txt b/mods/ITEMS/mcl_core/locale/template.txt index 69ca8b77f..911746699 100644 --- a/mods/ITEMS/mcl_core/locale/template.txt +++ b/mods/ITEMS/mcl_core/locale/template.txt @@ -286,3 +286,6 @@ Stackable= Crying Obsidian= Crying obsidian is a luminous obsidian that can generate as part of ruined portals.= Enchanted Golden Apple= +Light= +Lights are invisible blocks. They are used to light up adventure maps and the like.= +When you hold a light in hand, you reveal all placed lights in a short distance around you.= From 726358da4bf105e3061d81a078dd6b2f10ca3e86 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 6 Jan 2023 16:37:35 +0100 Subject: [PATCH 18/22] Rename callbacks parameters to match Minetest documentation --- mods/ITEMS/mcl_core/nodes_misc.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 6225bd611..5b589332b 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -176,7 +176,7 @@ minetest.register_node("mcl_core:barrier", { sunlight_propagates = true, is_ground_content = false, groups = {creative_breakable = 1, not_in_creative_inventory = 1, not_solid = 1}, - on_blast = function() end, + on_blast = function(pos, intensity) end, drop = "", _mcl_blast_resistance = 36000008, _mcl_hardness = -1, @@ -233,13 +233,13 @@ minetest.register_node("mcl_core:realm_barrier", { is_ground_content = false, pointable = false, groups = {not_in_creative_inventory = 1, not_solid = 1}, - on_blast = function() end, + on_blast = function(pos, intensity) end, drop = "", _mcl_blast_resistance = 36000008, _mcl_hardness = -1, -- Prevent placement to protect player from screwing up the world, because the node is not pointable and hard to get rid of. node_placement_prediction = "", - on_place = function(_, placer, _) + on_place = function(itemstack, placer, pointed_thing) if placer then minetest.chat_send_player(placer:get_player_name(), minetest.colorize(mcl_colors.RED, "You can't just place a realm barrier by hand!")) @@ -267,12 +267,12 @@ for i = 0, 14 do --minetest.LIGHT_MAX sunlight_propagates = true, is_ground_content = false, groups = {creative_breakable = 1, not_solid = 1, light_block = i + 1}, - on_blast = function() end, - on_use = function(itemstack, _, _) + on_blast = function(pos, intensity) end, + on_use = function(itemstack, user, pointed_thing) itemstack:set_name("mcl_core:light_" .. ((i == 14) and 0 or i + 1)) return itemstack end, - after_place_node = function(pos, placer, _, _) + after_place_node = function(pos, placer, itemstack, pointed_thing) if placer == nil then return end @@ -310,10 +310,10 @@ minetest.register_node("mcl_core:void", { sunlight_propagates = true, is_ground_content = false, groups = {not_in_creative_inventory = 1}, - on_blast = function() end, + on_blast = function(pos, intensity) end, -- Prevent placement to protect player from screwing up the world, because the node is not pointable and hard to get rid of. node_placement_prediction = "", - on_place = function(_, placer, _) + on_place = function(itemstack, placer, pointed_thing) if placer then minetest.chat_send_player(placer:get_player_name(), minetest.colorize(mcl_colors.RED, "You can't just place the void by hand!")) From fb8262bf57d636684a688f0959066a04586a7911 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 6 Jan 2023 23:27:15 +0100 Subject: [PATCH 19/22] Make light blocks `buildable_to` --- mods/CORE/mcl_util/init.lua | 362 ++++++++++++++++++++++++----- mods/ITEMS/mcl_core/nodes_misc.lua | 5 + 2 files changed, 305 insertions(+), 62 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index a79c970cd..f37b34444 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -2,8 +2,8 @@ mcl_util = {} -- Updates all values in t using values from to*. function table.update(t, ...) - for _, to in ipairs{...} do - for k,v in pairs(to) do + for _, to in ipairs {...} do + for k, v in pairs(to) do t[k] = v end end @@ -12,8 +12,8 @@ end -- Updates nil values in t using values from to*. function table.update_nil(t, ...) - for _, to in ipairs{...} do - for k,v in pairs(to) do + for _, to in ipairs {...} do + for k, v in pairs(to) do if t[k] == nil then t[k] = v end @@ -22,9 +22,9 @@ function table.update_nil(t, ...) return t end -local LOGGING_ON = minetest.settings:get_bool("mcl_logging_default",false) +local LOGGING_ON = minetest.settings:get_bool("mcl_logging_default", false) local LOG_MODULE = "[MCL2]" -function mcl_util.mcl_log (message, module, bypass_default_logger) +function mcl_util.mcl_log(message, module, bypass_default_logger) local selected_module = LOG_MODULE if module then selected_module = module @@ -34,7 +34,6 @@ function mcl_util.mcl_log (message, module, bypass_default_logger) end end - function mcl_util.file_exists(name) if type(name) ~= "string" then return end local f = io.open(name) @@ -69,7 +68,7 @@ function mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, infini local undef = minetest.registered_nodes[unode.name] if undef and undef.on_rightclick then undef.on_rightclick(pointed_thing.under, unode, placer, - itemstack, pointed_thing) + itemstack, pointed_thing) return end local fdir = minetest.dir_to_facedir(placer:get_look_dir()) @@ -151,23 +150,23 @@ end function mcl_util.get_double_container_neighbor_pos(pos, param2, side) if side == "right" then if param2 == 0 then - return {x=pos.x-1, y=pos.y, z=pos.z} + return {x = pos.x - 1, y = pos.y, z = pos.z} elseif param2 == 1 then - return {x=pos.x, y=pos.y, z=pos.z+1} + return {x = pos.x, y = pos.y, z = pos.z + 1} elseif param2 == 2 then - return {x=pos.x+1, y=pos.y, z=pos.z} + return {x = pos.x + 1, y = pos.y, z = pos.z} elseif param2 == 3 then - return {x=pos.x, y=pos.y, z=pos.z-1} + return {x = pos.x, y = pos.y, z = pos.z - 1} end else if param2 == 0 then - return {x=pos.x+1, y=pos.y, z=pos.z} + return {x = pos.x + 1, y = pos.y, z = pos.z} elseif param2 == 1 then - return {x=pos.x, y=pos.y, z=pos.z-1} + return {x = pos.x, y = pos.y, z = pos.z - 1} elseif param2 == 2 then - return {x=pos.x-1, y=pos.y, z=pos.z} + return {x = pos.x - 1, y = pos.y, z = pos.z} elseif param2 == 3 then - return {x=pos.x, y=pos.y, z=pos.z+1} + return {x = pos.x, y = pos.y, z = pos.z + 1} end end end @@ -185,7 +184,7 @@ end function mcl_util.get_eligible_transfer_item_slot(src_inventory, src_list, dst_inventory, dst_list, condition) local size = src_inventory:get_size(src_list) local stack - for i=1, size do + for i = 1, size do stack = src_inventory:get_stack(src_list, i) if not stack:is_empty() and (condition == nil or condition(stack, src_inventory, src_list, dst_inventory, dst_list)) then return i @@ -288,10 +287,10 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list, -- Main inventory for most container types if sctype == 2 or sctype == 3 or sctype == 5 or sctype == 6 or sctype == 7 then source_list = "main" - -- Furnace: output + -- Furnace: output elseif sctype == 4 then source_list = "dst" - -- Unknown source container type. Bail out + -- Unknown source container type. Bail out else return false end @@ -344,7 +343,7 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list, -- Main inventory for most container types if dctype == 2 or dctype == 3 or dctype == 5 or dctype == 6 or dctype == 7 then destination_list = "main" - -- Furnace source slot + -- Furnace source slot elseif dctype == 4 then destination_list = "src" end @@ -409,7 +408,7 @@ end -- Returns true if item (itemstring or ItemStack) can be used as a furnace fuel. -- Returns false otherwise function mcl_util.is_fuel(item) - return minetest.get_craft_result({method="fuel", width=1, items={item}}).time ~= 0 + return minetest.get_craft_result({method = "fuel", width = 1, items = {item}}).time ~= 0 end -- Returns a on_place function for plants @@ -456,7 +455,7 @@ function mcl_util.generate_on_place_plant_function(condition) if success then if idef.sounds and idef.sounds.place then - minetest.sound_play(idef.sounds.place, {pos=pointed_thing.above, gain=1}, true) + minetest.sound_play(idef.sounds.place, {pos = pointed_thing.above, gain = 1}, true) end end itemstack = new_itemstack @@ -643,78 +642,80 @@ end local function roundN(n, d) if type(n) ~= "number" then return n end - local m = 10^d - return math.floor(n * m + 0.5) / m + local m = 10 ^ d + return math.floor(n * m + 0.5) / m end -local function close_enough(a,b) - local rt=true +local function close_enough(a, b) + local rt = true if type(a) == "table" and type(b) == "table" then - for k,v in pairs(a) do - if roundN(v,2) ~= roundN(b[k],2) then - rt=false + for k, v in pairs(a) do + if roundN(v, 2) ~= roundN(b[k], 2) then + rt = false break end end else - rt = roundN(a,2) == roundN(b,2) + rt = roundN(a, 2) == roundN(b, 2) end return rt end -local function props_changed(props,oldprops) - local changed=false - local p={} - for k,v in pairs(props) do - if not close_enough(v,oldprops[k]) then - p[k]=v - changed=true +local function props_changed(props, oldprops) + local changed = false + local p = {} + for k, v in pairs(props) do + if not close_enough(v, oldprops[k]) then + p[k] = v + changed = true end end - return changed,p + return changed, p end --tests for roundN -local test_round1=15 -local test_round2=15.00199999999 -local test_round3=15.00111111 -local test_round4=15.00999999 +local test_round1 = 15 +local test_round2 = 15.00199999999 +local test_round3 = 15.00111111 +local test_round4 = 15.00999999 -assert(roundN(test_round1,2)==roundN(test_round1,2)) -assert(roundN(test_round1,2)==roundN(test_round2,2)) -assert(roundN(test_round1,2)==roundN(test_round3,2)) -assert(roundN(test_round1,2)~=roundN(test_round4,2)) +assert(roundN(test_round1, 2) == roundN(test_round1, 2)) +assert(roundN(test_round1, 2) == roundN(test_round2, 2)) +assert(roundN(test_round1, 2) == roundN(test_round3, 2)) +assert(roundN(test_round1, 2) ~= roundN(test_round4, 2)) -- tests for close_enough -local test_cb = {-0.35,0,-0.35,0.35,0.8,0.35} --collisionboxes -local test_cb_close = {-0.351213,0,-0.35,0.35,0.8,0.351212} -local test_cb_diff = {-0.35,0,-1.35,0.35,0.8,0.35} +local test_cb = {-0.35, 0, -0.35, 0.35, 0.8, 0.35} --collisionboxes +local test_cb_close = {-0.351213, 0, -0.35, 0.35, 0.8, 0.351212} +local test_cb_diff = {-0.35, 0, -1.35, 0.35, 0.8, 0.35} local test_eh = 1.65 --eye height local test_eh_close = 1.65123123 local test_eh_diff = 1.35 -local test_nt = { r = 225, b = 225, a = 225, g = 225 } --nametag -local test_nt_diff = { r = 225, b = 225, a = 0, g = 225 } +local test_nt = {r = 225, b = 225, a = 225, g = 225} --nametag +local test_nt_diff = {r = 225, b = 225, a = 0, g = 225} -assert(close_enough(test_cb,test_cb_close)) -assert(not close_enough(test_cb,test_cb_diff)) -assert(close_enough(test_eh,test_eh_close)) -assert(not close_enough(test_eh,test_eh_diff)) -assert(not close_enough(test_nt,test_nt_diff)) --no floats involved here +assert(close_enough(test_cb, test_cb_close)) +assert(not close_enough(test_cb, test_cb_diff)) +assert(close_enough(test_eh, test_eh_close)) +assert(not close_enough(test_eh, test_eh_diff)) +assert(not close_enough(test_nt, test_nt_diff)) --no floats involved here --tests for properties_changed -local test_properties_set1={collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 0.65, nametag_color = { r = 225, b = 225, a = 225, g = 225 }} -local test_properties_set2={collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 1.35, nametag_color = { r = 225, b = 225, a = 225, g = 225 }} +local test_properties_set1 = {collisionbox = {-0.35, 0, -0.35, 0.35, 0.8, 0.35}, eye_height = 0.65, + nametag_color = {r = 225, b = 225, a = 225, g = 225}} +local test_properties_set2 = {collisionbox = {-0.35, 0, -0.35, 0.35, 0.8, 0.35}, eye_height = 1.35, + nametag_color = {r = 225, b = 225, a = 225, g = 225}} -local test_p1,_=props_changed(test_properties_set1,test_properties_set1) -local test_p2,_=props_changed(test_properties_set1,test_properties_set2) +local test_p1, _ = props_changed(test_properties_set1, test_properties_set1) +local test_p2, _ = props_changed(test_properties_set1, test_properties_set2) assert(not test_p1) assert(test_p2) -function mcl_util.set_properties(obj,props) - local changed,p=props_changed(props,obj:get_properties()) +function mcl_util.set_properties(obj, props) + local changed, p = props_changed(props, obj:get_properties()) if changed then obj:set_properties(p) end @@ -729,6 +730,243 @@ function mcl_util.set_bone_position(obj, bone, pos, rot) end end +---Return a function to use in `on_place`. +--- +---Allow to bypass the `buildable_to` node field in a `on_place` callback. +--- +---You have to make sure that the nodes you return true for have `buildable_to = true`. +---@param func fun(node_name: string): boolean Return `true` if node must not replace the buildable_to node which have `node_name` +---@return fun(itemstack: ItemStack, placer: ObjectRef, pointed_thing: pointed_thing, param2: integer): ItemStack? +function mcl_util.bypass_buildable_to(func) + -------------------------- + -- MINETEST CODE: UTILS -- + -------------------------- + + local function copy_pointed_thing(pointed_thing) + return { + type = pointed_thing.type, + above = pointed_thing.above and vector.copy(pointed_thing.above), + under = pointed_thing.under and vector.copy(pointed_thing.under), + ref = pointed_thing.ref, + } + end + + local function user_name(user) + return user and user:get_player_name() or "" + end + + -- Returns a logging function. For empty names, does not log. + local function make_log(name) + return name ~= "" and minetest.log or function() end + end + + local function check_attached_node(p, n, group_rating) + local def = core.registered_nodes[n.name] + local d = vector.zero() + if group_rating == 3 then + -- always attach to floor + d.y = -1 + elseif group_rating == 4 then + -- always attach to ceiling + d.y = 1 + elseif group_rating == 2 then + -- attach to facedir or 4dir direction + if (def.paramtype2 == "facedir" or + def.paramtype2 == "colorfacedir") then + -- Attach to whatever facedir is "mounted to". + -- For facedir, this is where tile no. 5 point at. + + -- The fallback vector here is in case 'facedir to dir' is nil due + -- to voxelmanip placing a wallmounted node without resetting a + -- pre-existing param2 value that is out-of-range for facedir. + -- The fallback vector corresponds to param2 = 0. + d = core.facedir_to_dir(n.param2) or vector.new(0, 0, 1) + elseif (def.paramtype2 == "4dir" or + def.paramtype2 == "color4dir") then + -- Similar to facedir handling + d = core.fourdir_to_dir(n.param2) or vector.new(0, 0, 1) + end + elseif def.paramtype2 == "wallmounted" or + def.paramtype2 == "colorwallmounted" then + -- Attach to whatever this node is "mounted to". + -- This where tile no. 2 points at. + + -- The fallback vector here is used for the same reason as + -- for facedir nodes. + d = core.wallmounted_to_dir(n.param2) or vector.new(0, 1, 0) + else + d.y = -1 + end + local p2 = vector.add(p, d) + local nn = core.get_node(p2).name + local def2 = core.registered_nodes[nn] + if def2 and not def2.walkable then + return false + end + return true + end + + return function(itemstack, placer, pointed_thing, param2) + ------------------- + -- MINETEST CODE -- + ------------------- + local def = itemstack:get_definition() + if def.type ~= "node" or pointed_thing.type ~= "node" then + return itemstack + end + + local under = pointed_thing.under + local oldnode_under = minetest.get_node_or_nil(under) + local above = pointed_thing.above + local oldnode_above = minetest.get_node_or_nil(above) + local playername = user_name(placer) + local log = make_log(playername) + + if not oldnode_under or not oldnode_above then + log("info", playername .. " tried to place" + .. " node in unloaded position " .. minetest.pos_to_string(above)) + return itemstack + end + + local olddef_under = minetest.registered_nodes[oldnode_under.name] + olddef_under = olddef_under or minetest.nodedef_default + local olddef_above = minetest.registered_nodes[oldnode_above.name] + olddef_above = olddef_above or minetest.nodedef_default + + if not olddef_above.buildable_to and not olddef_under.buildable_to then + log("info", playername .. " tried to place" + .. " node in invalid position " .. minetest.pos_to_string(above) + .. ", replacing " .. oldnode_above.name) + return itemstack + end + + --------------------- + -- CUSTOMIZED CODE -- + --------------------- + + -- Place above pointed node + local place_to = vector.copy(above) + + -- If node under is buildable_to, check for callback result and place into it instead + if olddef_under.buildable_to and not func(oldnode_under.name) then + log("info", "node under is buildable to") + place_to = vector.copy(under) + end + + ------------------- + -- MINETEST CODE -- + ------------------- + + if minetest.is_protected(place_to, playername) then + log("action", playername + .. " tried to place " .. def.name + .. " at protected position " + .. minetest.pos_to_string(place_to)) + minetest.record_protection_violation(place_to, playername) + return itemstack + end + + local oldnode = minetest.get_node(place_to) + local newnode = {name = def.name, param1 = 0, param2 = param2 or 0} + + -- Calculate direction for wall mounted stuff like torches and signs + if def.place_param2 ~= nil then + newnode.param2 = def.place_param2 + elseif (def.paramtype2 == "wallmounted" or + def.paramtype2 == "colorwallmounted") and not param2 then + local dir = vector.subtract(under, above) + newnode.param2 = minetest.dir_to_wallmounted(dir) + -- Calculate the direction for furnaces and chests and stuff + elseif (def.paramtype2 == "facedir" or + def.paramtype2 == "colorfacedir" or + def.paramtype2 == "4dir" or + def.paramtype2 == "color4dir") and not param2 then + local placer_pos = placer and placer:get_pos() + if placer_pos then + local dir = vector.subtract(above, placer_pos) + newnode.param2 = minetest.dir_to_facedir(dir) + log("info", "facedir: " .. newnode.param2) + end + end + + local metatable = itemstack:get_meta():to_table().fields + + -- Transfer color information + if metatable.palette_index and not def.place_param2 then + local color_divisor = nil + if def.paramtype2 == "color" then + color_divisor = 1 + elseif def.paramtype2 == "colorwallmounted" then + color_divisor = 8 + elseif def.paramtype2 == "colorfacedir" then + color_divisor = 32 + elseif def.paramtype2 == "color4dir" then + color_divisor = 4 + elseif def.paramtype2 == "colordegrotate" then + color_divisor = 32 + end + if color_divisor then + local color = math.floor(metatable.palette_index / color_divisor) + local other = newnode.param2 % color_divisor + newnode.param2 = color * color_divisor + other + end + end + + -- Check if the node is attached and if it can be placed there + local an = minetest.get_item_group(def.name, "attached_node") + if an ~= 0 and + not check_attached_node(place_to, newnode, an) then + log("action", "attached node " .. def.name .. + " cannot be placed at " .. minetest.pos_to_string(place_to)) + return itemstack + end + + log("action", playername .. " places node " + .. def.name .. " at " .. minetest.pos_to_string(place_to)) + + -- Add node and update + minetest.add_node(place_to, newnode) + + -- Play sound if it was done by a player + if playername ~= "" and def.sounds and def.sounds.place then + minetest.sound_play(def.sounds.place, { + pos = place_to, + exclude_player = playername, + }, true) + end + + local take_item = true + + -- Run callback + if def.after_place_node then + -- Deepcopy place_to and pointed_thing because callback can modify it + local place_to_copy = vector.copy(place_to) + local pointed_thing_copy = copy_pointed_thing(pointed_thing) + if def.after_place_node(place_to_copy, placer, itemstack, + pointed_thing_copy) then + take_item = false + end + end + + -- Run script hook + for _, callback in ipairs(minetest.registered_on_placenodes) do + -- Deepcopy pos, node and pointed_thing because callback can modify them + local place_to_copy = vector.copy(place_to) + local newnode_copy = {name = newnode.name, param1 = newnode.param1, param2 = newnode.param2} + local oldnode_copy = {name = oldnode.name, param1 = oldnode.param1, param2 = oldnode.param2} + local pointed_thing_copy = copy_pointed_thing(pointed_thing) + if callback(place_to_copy, newnode_copy, placer, oldnode_copy, itemstack, pointed_thing_copy) then + take_item = false + end + end + + if take_item then + itemstack:take_item() + end + return itemstack + end +end + --[[Check for a protection violation in a given area. -- -- Applies is_protected() to a 3D lattice of points in the defined volume. The points are spaced diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 5b589332b..bf5300510 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -262,6 +262,8 @@ for i = 0, 14 do --minetest.LIGHT_MAX walkable = false, light_source = i, drop = "", + buildable_to = true, + node_placement_prediction = "", inventory_image = "mcl_core_light_" .. i .. ".png", wield_image = "mcl_core_light_" .. i .. ".png", sunlight_propagates = true, @@ -272,6 +274,9 @@ for i = 0, 14 do --minetest.LIGHT_MAX itemstack:set_name("mcl_core:light_" .. ((i == 14) and 0 or i + 1)) return itemstack end, + on_place = mcl_util.bypass_buildable_to(function(node_name) + return string.match(node_name, "^mcl_core:light_(%d+)$") + end), after_place_node = function(pos, placer, itemstack, pointed_thing) if placer == nil then return From e9c9f151de8d922f20c77e7fbfd2cc978c6f6512 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 14 Jan 2023 09:56:24 +0100 Subject: [PATCH 20/22] Let user dig light blocks when wielding a light block --- mods/ITEMS/mcl_core/nodes_misc.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index bf5300510..679810a5e 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -252,6 +252,9 @@ minetest.register_node("mcl_core:realm_barrier", { --- Light blocks --- TODO: make node only pointable when wielding it +local light_block_pattern = "^mcl_core:light_(%d+)$" + + for i = 0, 14 do --minetest.LIGHT_MAX minetest.register_node("mcl_core:light_" .. i, { description = S("Light"), @@ -271,11 +274,15 @@ for i = 0, 14 do --minetest.LIGHT_MAX groups = {creative_breakable = 1, not_solid = 1, light_block = i + 1}, on_blast = function(pos, intensity) end, on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type == "node" and string.match(minetest.get_node(pointed_thing.under).name, light_block_pattern) and not user:get_player_control().sneak then + minetest.dig_node(pointed_thing.under) + return + end itemstack:set_name("mcl_core:light_" .. ((i == 14) and 0 or i + 1)) return itemstack end, on_place = mcl_util.bypass_buildable_to(function(node_name) - return string.match(node_name, "^mcl_core:light_(%d+)$") + return string.match(node_name, light_block_pattern) end), after_place_node = function(pos, placer, itemstack, pointed_thing) if placer == nil then From 302796531486d12f6f2d19486793108e276e08ca Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 14 Jan 2023 10:06:23 +0100 Subject: [PATCH 21/22] Add comment --- mods/ITEMS/mcl_core/nodes_misc.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_core/nodes_misc.lua b/mods/ITEMS/mcl_core/nodes_misc.lua index 679810a5e..47949057c 100644 --- a/mods/ITEMS/mcl_core/nodes_misc.lua +++ b/mods/ITEMS/mcl_core/nodes_misc.lua @@ -274,6 +274,7 @@ for i = 0, 14 do --minetest.LIGHT_MAX groups = {creative_breakable = 1, not_solid = 1, light_block = i + 1}, on_blast = function(pos, intensity) end, on_use = function(itemstack, user, pointed_thing) + -- user:get_player_control() returns {} for non players, so we don't need user:is_player() if pointed_thing.type == "node" and string.match(minetest.get_node(pointed_thing.under).name, light_block_pattern) and not user:get_player_control().sneak then minetest.dig_node(pointed_thing.under) return @@ -285,7 +286,7 @@ for i = 0, 14 do --minetest.LIGHT_MAX return string.match(node_name, light_block_pattern) end), after_place_node = function(pos, placer, itemstack, pointed_thing) - if placer == nil then + if not placer then return end minetest.add_particle({ From a7fac7c550e3a9f8554cf1e464cbde07cb6a3bcb Mon Sep 17 00:00:00 2001 From: b3nderman Date: Sat, 14 Jan 2023 19:32:32 -0700 Subject: [PATCH 22/22] Fix tamed ocelot textures not being set correctly --- mods/ENTITIES/mobs_mc/ocelot.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/ocelot.lua b/mods/ENTITIES/mobs_mc/ocelot.lua index 8a7ea7545..65181a581 100644 --- a/mods/ENTITIES/mobs_mc/ocelot.lua +++ b/mods/ENTITIES/mobs_mc/ocelot.lua @@ -164,7 +164,7 @@ cat.on_spawn = function(self) if not self._texture then self._texture = cat.textures[math.random(#cat.textures)] end - self.object:set_properties({textures = {self._texture}}) + self.object:set_properties({textures = self._texture}) end mcl_mobs.register_mob("mobs_mc:cat", cat)