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

world.beforeEvents.worldInitialize.subscribe(initEvent => {
  const sporePots = [
    "nicothekid:spore_pot_amethyst",
    "nicothekid:spore_pot_blaze",
    "nicothekid:spore_pot_charcoal",
    "nicothekid:spore_pot_cocoa",
    "nicothekid:spore_pot_diamond",
    "nicothekid:spore_pot_emerald",
    "nicothekid:spore_pot_enchanted",
    "nicothekid:spore_pot_glowstone",
    "nicothekid:spore_pot_gold",
    "nicothekid:spore_pot_gunpowder",
    "nicothekid:spore_pot_iron",
    "nicothekid:spore_pot_lapis_lazuli",
    "nicothekid:spore_pot_netherite",
    "nicothekid:spore_pot_redstone",
    "nicothekid:spore_pot_sugar",
    "nicothekid:spore_pot"
  ]
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:spore_pot_interaction", {
    onPlayerInteract: eventData => {
      const player = eventData.player;
      const block = eventData.block;
      const blockLocation = block.location;
      const playerLocation = block.location; // It's same location of block for now, currently bugged when item spawn at player location it doesn't add immediately in player's inventory.
      const playerEquippable = player.getComponent("equippable");
      const itemUsed = playerEquippable.getEquipment("Mainhand");
      function decreaseItem () {
        system.run(() => {
          if (!player.matches({ gameMode: GameMode.creative })) {
            const decrementItem = itemUsed.amount == 1 ? undefined : (itemUsed.amount--, itemUsed);
            playerEquippable.setEquipment("Mainhand", decrementItem)
          }
        });
      }
      if (player.isSneaking) return;
      if (sporePots.includes(block.typeId)) {
        if (block.typeId === "nicothekid:spore_pot") {
          const validInputs = [
            "minecraft:blaze_powder",
            "minecraft:glowstone_dust",
            "minecraft:gunpowder",
            "minecraft:redstone",
            "minecraft:sugar",
            "nicothekid:amethyst_powder",
            "nicothekid:charcoal_powder",
            "nicothekid:cocoa_powder",
            "nicothekid:diamond_powder",
            "nicothekid:emerald_powder",
            "nicothekid:enchanted_dust",
            "nicothekid:gold_powder",
            "nicothekid:iron_powder",
            "nicothekid:lapis_lazuli_powder",
            "nicothekid:netherite_powder"
          ]
          if (itemUsed === undefined) {
            player.playSound("game.player.attack.nodamage", { pitch: 1.1, location: player.location, volume: 1.0 });
            player.runCommandAsync(`tellraw @p {\"rawtext\":[{\"text\":\"§eUse any type of powder or dust to active the Spore Pot.§r\"}]}`);
            return;
          }
          else if (validInputs.includes(itemUsed.typeId)) {
            decreaseItem ();
            block.dimension.playSound("item.bone_meal.use", blockLocation, { pitch: 1.0, volume: 0.8 });
            if (itemUsed.typeId === "minecraft:blaze_powder") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_blaze"));
            }
            if (itemUsed.typeId === "minecraft:glowstone_dust") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_glowstone"));
            }
            if (itemUsed.typeId === "minecraft:gunpowder") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_gunpowder"));
            }
            if (itemUsed.typeId === "minecraft:redstone") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_redstone"));
            }
            if (itemUsed.typeId === "minecraft:sugar") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_sugar"));
            }
            if (itemUsed.typeId === "nicothekid:amethyst_powder") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_amethyst"));
            }
            if (itemUsed.typeId === "nicothekid:charcoal_powder") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_charcoal"));
            }
            if (itemUsed.typeId === "nicothekid:cocoa_powder") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_cocoa"));
            }
            if (itemUsed.typeId === "nicothekid:diamond_powder") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_diamond"));
            }
            if (itemUsed.typeId === "nicothekid:emerald_powder") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_emerald"));
            }
            if (itemUsed.typeId === "nicothekid:enchanted_dust") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_enchanted"));
            }
            if (itemUsed.typeId === "nicothekid:gold_powder") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_gold"));
            }
            if (itemUsed.typeId === "nicothekid:iron_powder") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_iron"));
            }
            if (itemUsed.typeId === "nicothekid:lapis_lazuli_powder") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_lapis_lazuli"));
            }
            if (itemUsed.typeId === "nicothekid:netherite_powder") {
              block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot_netherite"));
            }
          }
          else return;
        }
        else {
          if (itemUsed === undefined) return;
          if (itemUsed.typeId === "nicothekid:salt") {
            decreaseItem ();
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 0.8 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"));
          }
          else return;
        }
      }
      else return;
    }
  });
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:spore_pot_ticks", {
    onTick: eventData => {
      const block = eventData.block;
      const blockLocation = block.location;
      if (sporePots.includes(block.typeId)) {
        if (block.permutation.matches("nicothekid:spore_pot_amethyst")) {
          block.dimension.spawnParticle("nicothekid:spore_amethyst_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_blaze")) {
          block.dimension.spawnParticle("nicothekid:spore_blaze_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_charcoal")) {
          block.dimension.spawnParticle("nicothekid:spore_charcoal_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_cocoa")) {
          block.dimension.spawnParticle("nicothekid:spore_cocoa_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_diamond")) {
          block.dimension.spawnParticle("nicothekid:spore_diamond_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_diamond")) {
          block.dimension.spawnParticle("nicothekid:spore_diamond_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_emerald")) {
          block.dimension.spawnParticle("nicothekid:spore_emerald_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_enchanted")) {
          block.dimension.spawnParticle("nicothekid:spore_enchanted_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_glowstone")) {
          block.dimension.spawnParticle("nicothekid:spore_glowstone_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_gold")) {
          block.dimension.spawnParticle("nicothekid:spore_gold_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_gunpowder")) {
          block.dimension.spawnParticle("nicothekid:spore_gunpowder_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_iron")) {
          block.dimension.spawnParticle("nicothekid:spore_iron_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_lapis_lazuli")) {
          block.dimension.spawnParticle("nicothekid:spore_lapis_lazuli_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_netherite")) {
          block.dimension.spawnParticle("nicothekid:spore_netherite_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_redstone")) {
          block.dimension.spawnParticle("nicothekid:spore_redstone_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
        if (block.permutation.matches("nicothekid:spore_pot_sugar")) {
          block.dimension.spawnParticle("nicothekid:spore_sugar_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
        }
      }
      else return;
    }
  });
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:spore_pot_random_ticks", {
    onRandomTick: eventData => {
      const block = eventData.block;
      const blockLocation = block.location;
      if (sporePots.includes(block.typeId)) {
        if (block.permutation.matches("nicothekid:spore_pot_amethyst")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("nicothekid:amethyst_powder", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_amethyst_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_blaze")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("minecraft:blaze_powder", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_blaze_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_charcoal")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("nicothekid:charcoal_powder", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_charcoal_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_cocoa")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("nicothekid:cocoa_powder", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_cocoa_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_diamond")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("nicothekid:diamond_powder", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_diamond_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_emerald")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("nicothekid:emerald_powder", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_emerald_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_enchanted")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.05) {
            const spawnPowder = new ItemStack ("nicothekid:enchanted_dust", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else if (randomChance <= 0.2) {
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnEntity("minecraft:xp_orb", { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.dimension.spawnEntity("minecraft:xp_orb", { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.dimension.spawnEntity("minecraft:xp_orb", { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.dimension.spawnEntity("minecraft:xp_orb", { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.dimension.spawnEntity("minecraft:xp_orb", { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.dimension.spawnEntity("minecraft:xp_orb", { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.dimension.spawnEntity("minecraft:xp_orb", { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.dimension.spawnEntity("minecraft:xp_orb", { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.dimension.spawnEntity("minecraft:xp_orb", { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.dimension.spawnEntity("minecraft:xp_orb", { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_enchanted_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_glowstone")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("minecraft:glowstone_dust", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_glowstone_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_gold")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("nicothekid:gold_powder", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_gold_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_gunpowder")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("minecraft:gunpowder", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_gunpowder_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_iron")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("nicothekid:iron_powder", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_iron_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_lapis_lazuli")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("nicothekid:lapis_lazuli_powder", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_lapis_lazuli_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_netherite")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("nicothekid:netherite_powder", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_netherite_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_redstone")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("minecraft:redstone", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_redstone_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
        if (block.permutation.matches("nicothekid:spore_pot_sugar")) {
          let randomChance = Math.random();
          if (randomChance <= 0.01) {
            block.dimension.playSound("block.composter.fill", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:spore_pot"))
          }
          else if (randomChance <= 0.15) {
            const spawnPowder = new ItemStack ("minecraft:sugar", 1);
            block.dimension.playSound("block.composter.ready", blockLocation, { pitch: 1.0, volume: 1.0 });
            block.dimension.spawnItem(spawnPowder, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          }
          else {
            block.dimension.spawnParticle("nicothekid:spore_sugar_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            return;
          }
        }
      }
      else return;
    }
  });
});