@@ -2242,15 +2242,19 @@ void ClientEnvironment::step(float dtime)
22422242 v3s16 p = floatToInt (pf + v3f (0 , BS*1.6 , 0 ), BS);
22432243 MapNode n = m_map->getNodeNoEx (p);
22442244 ContentFeatures c = m_gamedef->ndef ()->get (n);
2245-
2246- if (c.isLiquid () && c.drowning ){
2247- if (lplayer->breath > 10 )
2248- lplayer->breath = 11 ;
2249- if (lplayer->breath > 0 )
2250- lplayer->breath -= 1 ;
2245+ if (c.isLiquid () && c.drowning && lplayer->hp > 0 ){
2246+ u16 breath = lplayer->getBreath ();
2247+ if (breath > 10 ){
2248+ breath = 11 ;
2249+ }
2250+ if (breath > 0 ){
2251+ breath -= 1 ;
2252+ }
2253+ lplayer->setBreath (breath);
2254+ updateLocalPlayerBreath (breath);
22512255 }
22522256
2253- if (lplayer->breath == 0 ){
2257+ if (lplayer->getBreath () == 0 ){
22542258 damageLocalPlayer (1 , true );
22552259 }
22562260 }
@@ -2262,10 +2266,16 @@ void ClientEnvironment::step(float dtime)
22622266 v3s16 p = floatToInt (pf + v3f (0 , BS*1.6 , 0 ), BS);
22632267 MapNode n = m_map->getNodeNoEx (p);
22642268 ContentFeatures c = m_gamedef->ndef ()->get (n);
2265-
2266- if (!c.isLiquid () || !c.drowning ){
2267- if (lplayer->breath <= 10 )
2268- lplayer->breath += 1 ;
2269+ if (!lplayer->hp ){
2270+ lplayer->setBreath (11 );
2271+ }
2272+ else if (!c.isLiquid () || !c.drowning ){
2273+ u16 breath = lplayer->getBreath ();
2274+ if (breath <= 10 ){
2275+ breath += 1 ;
2276+ lplayer->setBreath (breath);
2277+ updateLocalPlayerBreath (breath);
2278+ }
22692279 }
22702280 }
22712281
@@ -2528,6 +2538,14 @@ void ClientEnvironment::damageLocalPlayer(u8 damage, bool handle_hp)
25282538 m_client_event_queue.push_back (event);
25292539}
25302540
2541+ void ClientEnvironment::updateLocalPlayerBreath (u16 breath)
2542+ {
2543+ ClientEnvEvent event;
2544+ event.type = CEE_PLAYER_BREATH;
2545+ event.player_breath .amount = breath;
2546+ m_client_event_queue.push_back (event);
2547+ }
2548+
25312549/*
25322550 Client likes to call these
25332551*/
0 commit comments