@@ -1389,10 +1389,14 @@ void hurtEntity (int entity_id, int attacker_id, uint8_t damage_type, uint8_t da
1389
1389
strcpy ((char * )recv_buffer + player_name_len , " was slain by " );
1390
1390
strcpy ((char * )recv_buffer + player_name_len + 14 , attacker -> name );
1391
1391
recv_buffer [player_name_len + 14 + strlen (attacker -> name )] = '\0' ;
1392
+ } else if (damage_type == D_cactus ) {
1393
+ // Killed by being near a cactus
1394
+ strcpy ((char * )recv_buffer + player_name_len , " was pricked to death" );
1395
+ recv_buffer [player_name_len + 21 ] = '\0' ;
1392
1396
} else {
1393
1397
// Unknown death reason
1394
1398
strcpy ((char * )recv_buffer + player_name_len , " died" );
1395
- recv_buffer [player_name_len + 4 ] = '\0' ;
1399
+ recv_buffer [player_name_len + 5 ] = '\0' ;
1396
1400
}
1397
1401
1398
1402
} else player -> health -= effective_damage ;
@@ -1502,6 +1506,15 @@ void handleServerTick (int64_t time_since_last_tick) {
1502
1506
if (block >= B_lava && block < B_lava + 4 ) {
1503
1507
hurtEntity (player -> client_fd , -1 , D_lava , 8 );
1504
1508
}
1509
+ #ifdef ENABLE_CACTUS_DAMAGE
1510
+ // Tick damage from a cactus block if one is under/inside or around the player.
1511
+ if (block == B_cactus ||
1512
+ getBlockAt (player -> x + 1 , player -> y , player -> z ) == B_cactus ||
1513
+ getBlockAt (player -> x - 1 , player -> y , player -> z ) == B_cactus ||
1514
+ getBlockAt (player -> x , player -> y , player -> z + 1 ) == B_cactus ||
1515
+ getBlockAt (player -> x , player -> y , player -> z - 1 ) == B_cactus
1516
+ ) hurtEntity (player -> client_fd , -1 , D_cactus , 4 );
1517
+ #endif
1505
1518
// Heal from saturation if player is able and has enough food
1506
1519
if (player -> health >= 20 || player -> health == 0 ) continue ;
1507
1520
if (player -> hunger < 18 ) continue ;
0 commit comments