@@ -2242,15 +2242,19 @@ void ClientEnvironment::step(float dtime)
2242
2242
v3s16 p = floatToInt (pf + v3f (0 , BS*1.6 , 0 ), BS);
2243
2243
MapNode n = m_map->getNodeNoEx (p);
2244
2244
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);
2251
2255
}
2252
2256
2253
- if (lplayer->breath == 0 ){
2257
+ if (lplayer->getBreath () == 0 ){
2254
2258
damageLocalPlayer (1 , true );
2255
2259
}
2256
2260
}
@@ -2262,10 +2266,16 @@ void ClientEnvironment::step(float dtime)
2262
2266
v3s16 p = floatToInt (pf + v3f (0 , BS*1.6 , 0 ), BS);
2263
2267
MapNode n = m_map->getNodeNoEx (p);
2264
2268
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
+ }
2269
2279
}
2270
2280
}
2271
2281
@@ -2528,6 +2538,14 @@ void ClientEnvironment::damageLocalPlayer(u8 damage, bool handle_hp)
2528
2538
m_client_event_queue.push_back (event);
2529
2539
}
2530
2540
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
+
2531
2549
/*
2532
2550
Client likes to call these
2533
2551
*/
0 commit comments