Reads network format 0b_US--_LLLL where U = uses fancy brightness, S = uses lamp brightness, and L = brightness */ Into CC's native format 0b_SSSS_BBBB where S = lamp brightness and B = lava brightness */
| 544 | /* Reads network format 0b_US--_LLLL where U = uses fancy brightness, S = uses lamp brightness, and L = brightness */ |
| 545 | /* Into CC's native format 0b_SSSS_BBBB where S = lamp brightness and B = lava brightness */ |
| 546 | cc_uint8 Block_ReadBrightness(cc_uint8 fullBright) { |
| 547 | cc_bool useSun; |
| 548 | /* If the fullBright byte does not use the flag, we should interpret it as either completely dark or casting max block light */ |
| 549 | if ((fullBright & USE_MODERN_BRIGHTNESS_FLAG) == 0) { return fullBright > 0 ? FANCY_LIGHTING_MAX_LEVEL : 0; } |
| 550 | |
| 551 | useSun = fullBright & USE_LAMP_COLOR; |
| 552 | |
| 553 | /* Preserve only the least significant four bits. This gives us our raw brightness level for sun or block light. */ |
| 554 | fullBright &= BRIGHTNESS_MASK; |
| 555 | |
| 556 | /* Sun light is stored in the upper four bits */ |
| 557 | if (useSun) { fullBright <<= FANCY_LIGHTING_LAMP_SHIFT; } |
| 558 | return fullBright; |
| 559 | } |
| 560 | |
| 561 | /* Writes CC's native format 0b_SSSS_BBBB where S = lamp brightness and B = lava brightness */ |
| 562 | /* into network format 0b_US--_LLLL where U = uses fancy brightness, S = uses lamp brightness, and L = brightness */ |
no outgoing calls
no test coverage detected