Compare commits

...

2 Commits

2 changed files with 48 additions and 7 deletions

View File

@ -3,6 +3,9 @@ local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local NIGHT_VISION_RATIO = 0.45
-- Settings
local minimum_update_interval = { 250e3 }
-- Module state
local mods_loaded = false
@ -119,8 +122,29 @@ dofile(modpath.."/skycolor/water.lua")
dofile(modpath.."/skycolor/dimensions.lua")
dofile(modpath.."/skycolor/effects.lua")
local function get_skycolor_info(player)
local player_name = player:get_player_name()
local info = mcl_playerinfo[player_name] or {}
local skycolor_data = info.skycolor
if not skycolor_data then
skycolor_data = {}
info.skycolor = skycolor_data
end
return skycolor_data
end
local water_sky = skycolor.water_sky
function skycolor.update_player_sky_color(player)
-- Don't update more than once every 250 milliseconds
local skycolor_data = get_skycolor_info(player)
local last_update = skycolor_data.last_update or 0
local now_us = minetest.get_us_time()
if (now_us - last_update) < minimum_update_interval[1] then return end
skycolor_data.last_update = now_us
local sky_data = {
day_night_ratio = player._skycolor_day_night_ratio
}

View File

@ -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()