From 0e1a2cbc1e1d02df545f645f073e1a351d4545d1 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 19 Jun 2024 06:54:44 -0500 Subject: [PATCH] Correct conditions for water-air transition forced skycolor update --- mods/PLAYER/mcl_playerplus/init.lua | 31 ++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index ad1143c9d..b4fa23945 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -407,13 +407,30 @@ minetest.register_globalstep(function(dtime) set_bone_pos(player,"Body_Control", nil, vector.new(0, -player_vel_yaw + yaw, 0)) end - local underwater - if get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 and underwater ~= true then - mcl_weather.skycolor.update_sky_color() - local underwater = true - elseif get_item_group(mcl_playerinfo[name].node_head, "water") == 0 and underwater == true then - mcl_weather.skycolor.update_sky_color() - local underwater = false + local playerinfo = mcl_playerinfo[name] or {} + local plusinfo = playerinfo.mcl_playerplus + if not plusinfo then + plusinfo = {} + playerinfo.mcl_playerplus = plusinfo + end + + -- Only process if node_head changed + if plusinfo.old_node_head ~= playerinfo.node_head then + local node_head = playerinfo.node_head or "" + local old_node_head = plusinfo.old_node_head or "" + plusinfo.old_node_head = playerinfo.node_head + + minetest.log(dump({ + node_head = node_head, + old_node_head = old_node_head, + new_group = get_item_group(node_head, "water"), + old_group = get_item_group(old_node_head, "water"), + })) + + -- Update skycolor if moving in or out of water + if (get_item_group(node_head, "water") == 0) ~= (get_item_group(old_node_head, "water") == 0) then + mcl_weather.skycolor.update_sky_color() + end end elytra.last_yaw = player:get_look_horizontal()