From ce724ee926170d24367a2ca6c8bd96c406bf9e69 Mon Sep 17 00:00:00 2001 From: epCode Date: Mon, 14 Nov 2022 14:42:33 -0800 Subject: [PATCH 1/4] make sky color change when submerged --- mods/ENVIRONMENT/mcl_weather/skycolor.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index a4108598f..66f5c9363 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -1,6 +1,8 @@ local mods_loaded = false local NIGHT_VISION_RATIO = 0.45 +water_color = "#0b4880" + function mcl_weather.set_sky_box_clear(player) player:set_sky({ type = "regular", @@ -96,7 +98,19 @@ mcl_weather.skycolor = { local pos = player:get_pos() local dim = mcl_worlds.pos_to_dimension(pos) local has_weather = (mcl_worlds.has_weather(pos) and (mcl_weather.state == "snow" or mcl_weather.state =="rain" or mcl_weather.state == "thunder") and mcl_weather.has_snow(pos)) or ((mcl_weather.state =="rain" or mcl_weather.state == "thunder") and mcl_weather.has_rain(pos)) - if dim == "overworld" then + if minetest.get_item_group(minetest.get_node(vector.new(pos.x,pos.y+1.5,pos.z)).name, "water") ~= 0 then + player:set_sky({ type = "regular", + sky_color = { + day_sky = water_color, + day_horizon = water_color, + dawn_sky = water_color, + dawn_horizon = water_color, + night_sky = water_color, + night_horizon = water_color, + }, + clouds = true, + }) + elseif dim == "overworld" then if (mcl_weather.state == "none") then -- Clear weather mcl_weather.set_sky_box_clear(player) From a5eb1d240ed369a374616b7c15ebde2b5bd704f8 Mon Sep 17 00:00:00 2001 From: epCode Date: Mon, 14 Nov 2022 14:43:13 -0800 Subject: [PATCH 2/4] add deeper = darker --- mods/ITEMS/mcl_core/nodes_liquid.lua | 4 +- mods/PLAYER/mcl_playerplus/init.lua | 57 ++++++++++++++++++++++++---- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_liquid.lua b/mods/ITEMS/mcl_core/nodes_liquid.lua index 68ae4a829..081f1978a 100644 --- a/mods/ITEMS/mcl_core/nodes_liquid.lua +++ b/mods/ITEMS/mcl_core/nodes_liquid.lua @@ -50,7 +50,7 @@ minetest.register_node("mcl_core:water_flowing", { liquid_viscosity = WATER_VISC, liquid_range = 7, waving = 3, - post_effect_color = {a=209, r=0x03, g=0x3C, b=0x5C}, + post_effect_color = {a=20, r=0x03, g=0x3C, b=0x5C}, groups = { water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1, freezes=1, melt_around=1, dig_by_piston=1}, _mcl_blast_resistance = 100, -- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode @@ -95,7 +95,7 @@ S("• When water is directly below lava, the water turns into stone."), liquid_alternative_source = "mcl_core:water_source", liquid_viscosity = WATER_VISC, liquid_range = 7, - post_effect_color = {a=209, r=0x03, g=0x3C, b=0x5C}, + post_effect_color = {a=60, r=0x03, g=0x3C, b=0x5C}, stack_max = 64, groups = { water=3, liquid=3, puts_out_fire=1, freezes=1, not_in_creative_inventory=1, dig_by_piston=1}, _mcl_blast_resistance = 100, diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 3d3e5f129..47edacdec 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -3,6 +3,8 @@ mcl_playerplus = { is_pressing_jump = {}, } +local hud_water = {} + local get_connected_players = minetest.get_connected_players local dir_to_yaw = minetest.dir_to_yaw local get_item_group = minetest.get_item_group @@ -25,6 +27,26 @@ local mcl_playerplus_internal = {} local time = 0 local look_pitch = 0 + +local function calculate_water_depth(pos) + for i=1, 50 do + if get_item_group(minetest.get_node(vector.new(pos.x,pos.y+i,pos.z)).name, "water") == 0 then + return i + end + end + return 50 +end + +local function remove_water_hud(player) + if hud_water[player] then + mcl_weather.skycolor.update_sky_color() + for i=1, #hud_water[player] do + player:hud_remove(hud_water[player][i]) + end + hud_water[player] = nil + end +end + local function player_collision(player) local pos = player:get_pos() @@ -349,16 +371,16 @@ minetest.register_globalstep(function(dtime) -- set head pitch and yaw when flying local head_rot = vector.new(pitch - degrees(dir_to_pitch(player_velocity)) + 50, player_vel_yaw - yaw, 0) set_bone_pos(player,"Head_Control", nil, head_rot) - + -- sets eye height, and nametag color accordingly set_properties(player, player_props_elytra) - + -- control body bone when flying local body_rot = vector.new((75 - degrees(dir_to_pitch(player_velocity))), -player_vel_yaw + yaw, 0) set_bone_pos(player, "Body_Control", nil, body_rot) elseif parent then set_properties(player, player_props_riding) - + local parent_yaw = degrees(parent:get_yaw()) local head_rot = vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0) set_bone_pos(player, "Head_Control", nil, head_rot) @@ -367,10 +389,10 @@ minetest.register_globalstep(function(dtime) -- controls head pitch when sneaking local head_rot = vector.new(pitch, player_vel_yaw - yaw, player_vel_yaw - yaw) set_bone_pos(player, "Head_Control", nil, head_rot) - + -- sets eye height, and nametag color accordingly set_properties(player, player_props_sneaking) - + -- sneaking body conrols set_bone_pos(player, "Body_Control", nil, vector.new(0, -player_vel_yaw + yaw, 0)) elseif get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 and is_sprinting(name) == true then @@ -378,10 +400,10 @@ minetest.register_globalstep(function(dtime) is_swimming = true local head_rot = vector.new(pitch - degrees(dir_to_pitch(player_velocity)) + 20, player_vel_yaw - yaw, 0) set_bone_pos(player, "Head_Control", nil, head_rot) - + -- sets eye height, and nametag color accordingly set_properties(player, player_props_swimming) - + -- control body bone when swimming local body_rot = vector.new((75 + degrees(dir_to_pitch(player_velocity))), player_vel_yaw - yaw, 180) set_bone_pos(player,"Body_Control", nil, body_rot) @@ -395,6 +417,25 @@ minetest.register_globalstep(function(dtime) set_bone_pos(player,"Body_Control", nil, vector.new(0, -player_vel_yaw + yaw, 0)) end + if get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 then + if not hud_water[player] or hud_water[player] and calculate_water_depth(player:get_pos()) ~= #hud_water[player] then + remove_water_hud(player) + hud_water[player] = {} + for i=1, calculate_water_depth(player:get_pos()) do + table.insert(hud_water[player], player:hud_add({ + hud_elem_type = "image", + text = "mcl_playerplus_water.png", + position = {x = 0.5, y = 0.5}, + scale = {x = 8, y = 4}, + offset = {x = 0, y = 0}, + z_index = -1002, + })) + end + end + else + remove_water_hud(player) + end + elytra.last_yaw = player:get_look_horizontal() -- Update jump status immediately since we need this info in real time. -- WARNING: This section is HACKY as hell since it is all just based on heuristics. @@ -639,7 +680,7 @@ minetest.register_on_joinplayer(function(player) jump_cooldown = -1, -- Cooldown timer for jumping, we need this to prevent the jump exhaustion to increase rapidly } mcl_playerplus.elytra[player] = {active = false, rocketing = 0, speed = 0} - + -- Minetest bug: get_bone_position() returns all zeros vectors. -- Workaround: call set_bone_position() one time first. player:set_bone_position("Head_Control", vector.new(0, 6.75, 0)) From 3f8f6f8e44861be896437dee5400a3cf5db91c83 Mon Sep 17 00:00:00 2001 From: epCode Date: Mon, 14 Nov 2022 14:47:02 -0800 Subject: [PATCH 3/4] deeper-darker image --- mods/PLAYER/mcl_playerplus/init.lua | 2 +- .../textures/mcl_playerplus_water.png | Bin 0 -> 9421 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 mods/PLAYER/mcl_playerplus/textures/mcl_playerplus_water.png diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 47edacdec..0faa9c53f 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -426,7 +426,7 @@ minetest.register_globalstep(function(dtime) hud_elem_type = "image", text = "mcl_playerplus_water.png", position = {x = 0.5, y = 0.5}, - scale = {x = 8, y = 4}, + scale = {x = 32, y = 16}, offset = {x = 0, y = 0}, z_index = -1002, })) diff --git a/mods/PLAYER/mcl_playerplus/textures/mcl_playerplus_water.png b/mods/PLAYER/mcl_playerplus/textures/mcl_playerplus_water.png new file mode 100644 index 0000000000000000000000000000000000000000..0524ce8d692852c626f5818d9160d069f0e86b2d GIT binary patch literal 9421 zcmV;;Br@BHP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O1e?a>ghQ{Ld-&2q50a!C+VI4d(dUEn&xBl9`>U znmDmRU|ZcS2^@F+@!!k+2R~AycPZCadMO@1si!UjjppsA>pA$OXZ^W{(EqTzXFymvpaeO?I&jG|%{{d(JUDs;YbsD;n3K%Ur zqP)A=;XRmmfbyuf6&w|R8SSb^$I<-o6XGmC{efeK9t5gfE~K!+2v<1uI>UsENlvM_ zicE=WYq3g~8BHe~;X-2cxMG8nQ%)Bn%<}jW^u1l*H$%glSHM&Wcvw*R|KxCgHTX{s zcU_Yd1>YX7;FmCR;RcoC8M7crxVCOt3BHdlzkkIKLKO;TrMUs%@P|F($l)utqUszm zFXL)i5nNsS0iX!)&Ts}Pkb*BE=1_vKA~gi?*dWk==Yrfgpg_o37Mv7hMiEz~3Ez!- zYS6ior3lTaO%Ni-5-YUnaX_q;GUBJEh8P+-=9F_Tx#s3_&!fbWN-m|;!Xh_ntf}T& zYOSsII$CV0Q;SwX0v_QEjXG zHZDn9HjfH+b^muu5(irvn(X1J|g?T61;HI z#zJWV%it30$pOUd;fnxbHgTXe@oT6!-LfgI_b_Nwr8r z1BD%9$iY*s0@pAdkEpmEW~7KO*1QH^g$K;ZT5>e-*orD#cCZgMjBO z#Ay~hIe>$hP*Do9eeLmr1en0rr*uk$@Z^O$s4x;5+1Fkf`Q<3iCW+fP(xPIMJ=8cIj+%8$IYA;4!yTc=jq25P>f}&) zP-S&B89EOIit+%Qm>w@2A25*Hpw6*ktF3DbTjRxL@Qf@T%00s>Y$x?v`n=-`5N$G` zZ85M$F_Z9pfo&(bR|UrM_|~z6{PaZm5wj+6d3E(lPO zJX8SH!-@$KSYdHU+juRiEfz?xlHAz7l)*J7NqCDbYZ<4GiTC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tue, 15 Nov 2022 14:33:33 -0800 Subject: [PATCH 4/4] localize var/fix weather not changing brightness while underwater. --- mods/ENVIRONMENT/mcl_weather/skycolor.lua | 25 ++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index 66f5c9363..6fb8ab56c 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -1,9 +1,11 @@ local mods_loaded = false local NIGHT_VISION_RATIO = 0.45 -water_color = "#0b4880" +local water_color = "#0b4880" function mcl_weather.set_sky_box_clear(player) + local pos = player:get_pos() + if minetest.get_item_group(minetest.get_node(vector.new(pos.x,pos.y+1.5,pos.z)).name, "water") ~= 0 then return end player:set_sky({ type = "regular", sky_color = { @@ -18,6 +20,16 @@ function mcl_weather.set_sky_box_clear(player) }) end +function mcl_weather.set_sky_color(player, def) + local pos = player:get_pos() + if minetest.get_item_group(minetest.get_node(vector.new(pos.x,pos.y+1.5,pos.z)).name, "water") ~= 0 then return end + player:set_sky({ + type = def.type, + sky_color = def.sky_color, + clouds = def.clouds, + }) +end + mcl_weather.skycolor = { -- Should be activated before do any effect. active = true, @@ -110,7 +122,8 @@ mcl_weather.skycolor = { }, clouds = true, }) - elseif dim == "overworld" then + end + if dim == "overworld" then if (mcl_weather.state == "none") then -- Clear weather mcl_weather.set_sky_box_clear(player) @@ -122,7 +135,8 @@ mcl_weather.skycolor = { local day_color = mcl_weather.skycolor.get_sky_layer_color(0.15) local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.27) local night_color = mcl_weather.skycolor.get_sky_layer_color(0.1) - player:set_sky({ type = "regular", + mcl_weather.set_sky_color(player, { + type = "regular", sky_color = { day_sky = day_color, day_horizon = day_color, @@ -141,7 +155,8 @@ mcl_weather.skycolor = { local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5) local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.75) local night_color = mcl_weather.skycolor.get_sky_layer_color(0) - player:set_sky({ type = "regular", + mcl_weather.set_sky_color(player, { + type = "regular", sky_color = { day_sky = day_color, day_horizon = day_color, @@ -192,7 +207,7 @@ mcl_weather.skycolor = { } local biometint = nether_sky[minetest.get_biome_name(minetest.get_biome_data(player:get_pos()).biome)] - player:set_sky({ + mcl_weather.set_sky_color(player, { type = "regular", sky_color = { day_sky = "#300808",