# entity:unregister_cycle
# called by: entity:unregister, entity:unregister_cycle

function magical_addons:entity/unregister_tick with storage magical_addons:temp data.tick[-1]

data remove storage magical_addons:temp data.tick[-1]

scoreboard players remove #magical_addons:entity_count maddons.tick 1

execute if score #magical_addons:entity_count maddons.tick matches 1.. run function magical_addons:entity/unregister_cycle