## Update lighting
# Clear current light level
data merge entity @s {brightness:{sky:0,block:0}}
# vb.dummy1 stores the highest neighbouring light level found
scoreboard players set @s vb.dummy1 0
# Check all neighbouring block spaces (block light)
execute positioned ~ ~1 ~ run function vb:tick_entity/custom_block/check_light
execute positioned ~ ~-1 ~ run function vb:tick_entity/custom_block/check_light
execute positioned ~1 ~ ~ run function vb:tick_entity/custom_block/check_light
execute positioned ~-1 ~ ~ run function vb:tick_entity/custom_block/check_light
execute positioned ~ ~ ~-1 run function vb:tick_entity/custom_block/check_light
# Block brightness
execute if score @s vb.dummy1 matches 1.. run scoreboard players remove @s vb.dummy1 1
execute store result entity @s brightness.block int 1 run scoreboard players get @s vb.dummy1
# Check sky light
execute if predicate {condition:"minecraft:entity_properties",entity:"this",predicate:{location:{can_see_sky:1b}}} run data modify entity @s brightness.sky set value 15

## Specific tick function
execute if entity @s[tag=vb.custom_block.bartering_station] run function vb:tick_entity/custom_block/bartering_station/main
execute if entity @s[tag=vb.custom_block.ender_output] run function vb:tick_entity/custom_block/ender_output/main
execute if entity @s[tag=vb.custom_block.copper_fan] run function vb:tick_entity/custom_block/copper_fan/main
execute if entity @s[tag=vb.custom_block.subwoofer] run function vb:tick_entity/custom_block/subwoofer/main
execute if entity @s[tag=vb.custom_block.coin_press] run function vb:tick_entity/custom_block/coin_press/main
execute if entity @s[tag=vb.custom_block.esky] run function vb:tick_entity/custom_block/esky/main
execute if entity @s[tag=vb.custom_block.fish_trap] run function vb:tick_entity/custom_block/fish_trap/main
execute if entity @s[tag=vb.custom_block.trial_gate] run function vb:tick_entity/custom_block/trial_gate/main
execute if entity @s[tag=vb.custom_block.void_core] run function vb:tick_entity/custom_block/void_core/main
