@@ -1389,10 +1389,14 @@ void hurtEntity (int entity_id, int attacker_id, uint8_t damage_type, uint8_t da
13891389 strcpy ((char * )recv_buffer + player_name_len , " was slain by " );
13901390 strcpy ((char * )recv_buffer + player_name_len + 14 , attacker -> name );
13911391 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' ;
13921396 } else {
13931397 // Unknown death reason
13941398 strcpy ((char * )recv_buffer + player_name_len , " died" );
1395- recv_buffer [player_name_len + 4 ] = '\0' ;
1399+ recv_buffer [player_name_len + 5 ] = '\0' ;
13961400 }
13971401
13981402 } else player -> health -= effective_damage ;
@@ -1502,6 +1506,15 @@ void handleServerTick (int64_t time_since_last_tick) {
15021506 if (block >= B_lava && block < B_lava + 4 ) {
15031507 hurtEntity (player -> client_fd , -1 , D_lava , 8 );
15041508 }
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
15051518 // Heal from saturation if player is able and has enough food
15061519 if (player -> health >= 20 || player -> health == 0 ) continue ;
15071520 if (player -> hunger < 18 ) continue ;
0 commit comments