import { world, BlockPermutation } from "@minecraft/server";

world.beforeEvents.worldInitialize.subscribe(initEvent => {
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:heated_netherrack_active_random_active", {
    onRandomTick: eventData => {
      const block = eventData.block;
      if (block.permutation.matches("nicothekid:heated_netherrack")) {
        let randomChance = Math.random();
        if (randomChance <= 0.5) {
          block.setPermutation(BlockPermutation.resolve("nicothekid:heated_netherrack_active", { "nicothekid:heated_netherrack_active_lighten": false }));
          return;
        }
        else return;
      }
      else return;
    }
  });
});