From f967aa3d51c2784ab1ff30a5bb5badd3e6ae5756 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sun, 18 Apr 2021 00:10:11 +0200 Subject: [PATCH 1/2] remove unuseful code --- mods/PLAYER/mcl_spawn/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/PLAYER/mcl_spawn/init.lua b/mods/PLAYER/mcl_spawn/init.lua index 441db28b7c..b8c746d1fd 100644 --- a/mods/PLAYER/mcl_spawn/init.lua +++ b/mods/PLAYER/mcl_spawn/init.lua @@ -397,9 +397,9 @@ end -- false otherwise. mcl_spawn.get_bed_spawn_pos = function(player) local spawn, custom_spawn = nil, false - if player ~= nil and player:is_player() then + if player and player:is_player() then local attr = player:get_meta():get_string("mcl_beds:spawn") - if attr ~= nil and attr ~= "" then + if attr and attr ~= "" then spawn = minetest.string_to_pos(attr) custom_spawn = true end From 4aa6421faf1bd3dabfaa53454ad06fbd21f596ec Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sun, 18 Apr 2021 00:27:51 +0200 Subject: [PATCH 2/2] performance optimisation --- mods/ITEMS/mcl_beds/functions.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index 86f6a68523..545b03be78 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -6,6 +6,8 @@ local player_in_bed = 0 local is_sp = minetest.is_singleplayer() local weather_mod = minetest.get_modpath("mcl_weather") ~= nil local explosions_mod = minetest.get_modpath("mcl_explosions") ~= nil +local spawn_mod = minetest.get_modpath("mcl_spawn") +local worlds_mod = minetest.get_modpath("mcl_worlds") -- Helper functions @@ -76,7 +78,7 @@ local function lay_down(player, pos, bed_pos, state, skip) bed_center = {x = bed_pos.x - dir.x/2, y = bed_pos.y + 0.1, z = bed_pos.z - dir.z/2} -- save respawn position when entering bed - if minetest.get_modpath("mcl_spawn") and mcl_spawn.set_spawn_pos(player, bed_pos, false) then + if spawn_mod and mcl_spawn.set_spawn_pos(player, bed_pos, nil) then minetest.chat_send_player(name, S("New respawn position set!")) end @@ -297,7 +299,7 @@ function mcl_beds.on_rightclick(pos, player, is_top) if player:get_meta():get_string("mcl_beds:sleeping") == "true" then return end - if minetest.get_modpath("mcl_worlds") then + if worlds_mod then local dim = mcl_worlds.pos_to_dimension(pos) if dim == "nether" or dim == "end" then -- Bed goes BOOM in the Nether or End.