forked from VoxeLibre/VoxeLibre
Merge pull request 'better water visuals' (#2960) from better_visuals_water into master
Reviewed-on: MineClone2/MineClone2#2960 Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
commit
661424ad23
|
@ -1,7 +1,11 @@
|
|||
local mods_loaded = false
|
||||
local NIGHT_VISION_RATIO = 0.45
|
||||
|
||||
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 = {
|
||||
|
@ -16,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,
|
||||
|
@ -96,6 +110,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 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,
|
||||
})
|
||||
end
|
||||
if dim == "overworld" then
|
||||
if (mcl_weather.state == "none") then
|
||||
-- Clear weather
|
||||
|
@ -108,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,
|
||||
|
@ -127,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,
|
||||
|
@ -178,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",
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
@ -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 = 32, y = 16},
|
||||
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.
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
Loading…
Reference in New Issue