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

world.beforeEvents.worldInitialize.subscribe(initEvent => {
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:jellyfish_slime_block_on_step_on", {
    onStepOn: eventData => {
      const block = eventData.block;
      if (block.permutation.matches("nicothekid:jellyfish_slime_block_pink", { "nicothekid:jellyfish_slime_block_lighten": false })) {
        block.setPermutation(BlockPermutation.resolve("nicothekid:jellyfish_slime_block_pink", { "nicothekid:jellyfish_slime_block_lighten": true }));
        return;
      }
      else return;
    }
  });
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:jellyfish_slime_block_on_step_off", {
    onStepOff: eventData => {
      const block = eventData.block;
      if (block.permutation.matches("nicothekid:jellyfish_slime_block_pink", { "nicothekid:jellyfish_slime_block_lighten": true })) {
        block.setPermutation(BlockPermutation.resolve("nicothekid:jellyfish_slime_block_pink", { "nicothekid:jellyfish_slime_block_lighten": false }));
        return;
      }
      else return;
    }
  });
})