diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index 87952845b..b815e79aa 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -152,8 +152,7 @@ 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)) - local checkname = minetest.get_node(vector.new(pos.x,pos.y+1.5,pos.z)).name - if minetest.get_item_group(checkname, "water") ~= 0 then + if mcl_player.is_head_in_water(player) then local biome_index = minetest.get_biome_data(player:get_pos()).biome local biome_name = minetest.get_biome_name(biome_index) local biome = minetest.registered_biomes[biome_name] diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index 23dade636..48c70ae5d 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -557,7 +557,10 @@ local function do_breath_tick(player, dtime) local breath_max = hb.settings.breath_max local player_name = player:get_player_name() local node_head = mcl_playerinfo[player_name].node_head - local in_water = node_head and minetest.get_item_group(node_head, "water") > 0 + minetest.debug(mcl_playerinfo[player_name].node_head, + mcl_playerinfo[player_name].ndef_head.param2 and + bit.band(mcl_playerinfo[player_name].ndef_head.param2, 7)) + local in_water = mcl_player.is_head_in_water(player) local current_breath = hb.get_breath(player) local helmet = player:get_inventory():get_stack("armor", 2) diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index 164e0083b..2c41b588b 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -187,6 +187,11 @@ function mcl_player.player_set_animation(player, anim_name, speed) player:set_animation(anim, speed or model.animation_speed, animation_blend) end + +function mcl_player.is_head_in_water(player) + return minetest.get_item_group(mcl_playerinfo[player:get_player_name()].node_head, "water") ~= 0 +end + -- Update appearance when the player joins minetest.register_on_joinplayer(function(player) local name = player:get_player_name() @@ -237,7 +242,7 @@ minetest.register_globalstep(function(dtime) end -- ask if player is swiming - local head_in_water = minetest.get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 + local head_in_water = mcl_player.is_head_in_water(player) -- ask if player is sprinting local is_sprinting = mcl_sprint.is_sprinting(name) diff --git a/mods/PLAYER/mcl_playerinfo/init.lua b/mods/PLAYER/mcl_playerinfo/init.lua index 1f1b84749..d520a3a4d 100644 --- a/mods/PLAYER/mcl_playerinfo/init.lua +++ b/mods/PLAYER/mcl_playerinfo/init.lua @@ -6,7 +6,7 @@ mcl_playerinfo = {} -- Get node but use fallback for nil or unknown local function node_ok(pos, fallback) - fallback = fallback or "air" + fallback = fallback or {name="air", param1=0, param2=0} local node = minetest.get_node_or_nil(pos) @@ -15,7 +15,7 @@ local function node_ok(pos, fallback) end if minetest.registered_nodes[node.name] then - return node.name + return node end return fallback @@ -24,23 +24,30 @@ end local time = 0 local function get_player_nodes(player_pos) + local infotable = {} local work_pos = table.copy(player_pos) -- what is around me? work_pos.y = work_pos.y - 0.1 -- standing on - local node_stand = node_ok(work_pos) - local node_stand_below = node_ok({x=work_pos.x, y=work_pos.y-1, z=work_pos.z}) + infotable.ndef_stand = node_ok(work_pos) + infotable.node_stand = infotable.ndef_stand.name + + infotable.ndef_stand_below = node_ok({x=work_pos.x, y=work_pos.y-1, z=work_pos.z}) + infotable.node_stand_below = infotable.ndef_stand_below.name work_pos.y = work_pos.y + 1.5 -- head level - local node_head = node_ok(work_pos) + infotable.ndef_head = node_ok(work_pos) + infotable.node_head = infotable.ndef_head.name work_pos.y = work_pos.y + 0.5 -- top of head level, at collision box height - local node_head_top = node_ok(work_pos) + infotable.ndef_head_top = node_ok(work_pos) + infotable.node_head_top = infotable.ndef_head_top.name work_pos.y = work_pos.y - 0.5 work_pos.y = work_pos.y - 1.2 -- feet level - local node_feet = node_ok(work_pos) + infotable.ndef_feet = node_ok(work_pos) + infotable.node_feet = infotable.ndef_feet.name - return node_stand, node_stand_below, node_head, node_feet, node_head_top + return infotable end minetest.register_globalstep(function(dtime) @@ -65,13 +72,7 @@ minetest.register_globalstep(function(dtime) local pos = player:get_pos() -- what is around me? - local node_stand, node_stand_below, node_head, node_feet, node_head_top = get_player_nodes(pos) - mcl_playerinfo[name].node_stand = node_stand - mcl_playerinfo[name].node_stand_below = node_stand_below - mcl_playerinfo[name].node_head = node_head - mcl_playerinfo[name].node_feet = node_feet - mcl_playerinfo[name].node_head_top = node_head_top - + mcl_playerinfo[name] = get_player_nodes(pos) end end) @@ -86,6 +87,11 @@ minetest.register_on_joinplayer(function(player) node_stand = "", node_stand_below = "", node_head_top = "", + ndef_head = "", + ndef_feet = "", + ndef_stand = "", + ndef_stand_below = "", + ndef_head_top = "", } end) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 646030202..5da9e3f2b 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -586,7 +586,7 @@ minetest.register_globalstep(function(dtime) end -- Underwater: Spawn bubble particles - if get_item_group(node_head, "water") ~= 0 then + if mcl_player.is_head_in_water(player) then add_particlespawner({ amount = 10, time = 0.15,