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

system.beforeEvents.watchdogTerminate.subscribe(data => {
    data.cancel = true;
});
world.beforeEvents.worldInitialize.subscribe(initEvent => {
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:artifacture_table_activation", {
    onPlayerInteract: eventData => {
      const player = eventData.player;
      const block = eventData.block;
      const blockLocation = block.location;
      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 (block.permutation.matches("nicothekid:artifacture_table", { "nicothekid:artifacture_table_active": false })) {
        if (itemUsed === undefined) {
          player.playSound("game.player.attack.nodamage", { pitch: 1.1, location: player.location, volume: 1.0 });
          player.runCommandAsync(`tellraw @p {\"rawtext\":[{\"text\":\"§eYou must have an Amethyst Shard in your hand to activate the Artifacture Table.§r\"}]}`);
          return;
        }
        else if (itemUsed.typeId === "minecraft:amethyst_shard") {
          decreaseItem ();
          block.dimension.playSound("respawn_anchor.charge", blockLocation, { pitch: 1.1, volume: 1.0 });
          block.dimension.spawnParticle("nicothekid:artifacture_table_particle", { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:artifacture_table", { "nicothekid:artifacture_table_active": true }));
          return;
        }
        else return;
      }
      else return;
    }
  });
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:artifacture_table_deactivation", {
    onTick: eventData => {
      const block = eventData.block;
      const blockLocation = block.location;
      if (block.permutation.matches("nicothekid:artifacture_table", { "nicothekid:artifacture_table_active": true })) {
        block.dimension.playSound("break.amethyst_block", blockLocation, { pitch: 1.1, volume: 1.0 });
        block.setPermutation(BlockPermutation.resolve("nicothekid:artifacture_table", { "nicothekid:artifacture_table_active": false }));
        return;
      }
      else return;
    }
  });
});
world.beforeEvents.worldInitialize.subscribe(initEvent => {
  const copperEvaporator = [
    "nicothekid:evaporator_copper_blue_ice",
    "nicothekid:evaporator_copper_cheese",
    "nicothekid:evaporator_copper_ice",
    "nicothekid:evaporator_copper_lava",
    "nicothekid:evaporator_copper_leather_scrap_1",
    "nicothekid:evaporator_copper_leather_scrap_2",
    "nicothekid:evaporator_copper_leather_scrap_3",
    "nicothekid:evaporator_copper_milk",
    "nicothekid:evaporator_copper_obsidian",
    "nicothekid:evaporator_copper_packed_ice",
    "nicothekid:evaporator_copper_rotten_flesh_1",
    "nicothekid:evaporator_copper_rotten_flesh_2",
    "nicothekid:evaporator_copper_rotten_flesh_3",
    "nicothekid:evaporator_copper_salt",
    "nicothekid:evaporator_copper_snow",
    "nicothekid:evaporator_copper_water",
    "nicothekid:evaporator_copper_empty"
  ]
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:copper_evaporator_interaction", {
    onPlayerInteract: eventData => {
      const player = eventData.player;
      const block = eventData.block;
      const blockLocation = block.location;
      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)
          }
        });
      }
      function giveEmptyBucket () {
        const emptyBucket = new ItemStack ("minecraft:bucket", 1);
        playerEquippable.setEquipment("Mainhand", emptyBucket)
      }
      if (player.isSneaking) return;
      if (copperEvaporator.includes(block.typeId)) {
        if (block.typeId === "nicothekid:evaporator_copper_empty") {
          const validInputs = [
            "minecraft:blue_ice",
            "minecraft:ice",
            "minecraft:lava_bucket",
            "minecraft:milk_bucket",
            "minecraft:packed_ice",
            "minecraft:rotten_flesh",
            "minecraft:snow",
            "minecraft:water_bucket",
            "nicothekid:jar_water_full"
          ]
          if (itemUsed === undefined || !validInputs.includes(itemUsed.typeId)) return;
          if (itemUsed.typeId === "minecraft:blue_ice") {
            decreaseItem ();
            block.dimension.playSound("dig.stone", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_blue_ice"));
          }
          if (itemUsed.typeId === "minecraft:ice") {
            decreaseItem ();
            block.dimension.playSound("dig.stone", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_ice"));
          }
          if (itemUsed.typeId === "minecraft:lava_bucket") {
            giveEmptyBucket ();
            block.dimension.playSound("bucket.empty_lava", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_lava"));
          }
          if (itemUsed.typeId === "minecraft:milk_bucket") {
            giveEmptyBucket ();
            block.dimension.playSound("bucket.empty_water", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_milk"));
          }
          if (itemUsed.typeId === "minecraft:packed_ice") {
            decreaseItem ();
            block.dimension.playSound("dig.stone", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_packed_ice"));
          }
          if (itemUsed.typeId === "minecraft:rotten_flesh") {
            decreaseItem ();
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_rotten_flesh_1"));
            return;
          }
          if (itemUsed.typeId === "minecraft:snow") {
            decreaseItem ();
            block.dimension.playSound("use.snow", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_snow"));
          }
          if (itemUsed.typeId === "minecraft:water_bucket") {
            giveEmptyBucket ();
            block.dimension.playSound("bucket.empty_water", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_water"));
          }
          if (itemUsed.typeId === "nicothekid:jar_water_full") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:jar_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_water"));
          }
        }
        if (block.typeId === "nicothekid:evaporator_copper_blue_ice") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:blue_ice") {
            const spawnBlueIce = new ItemStack ("minecraft:blue_ice", 1);
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnBlueIce, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
          }
          else if (itemUsed.typeId === "minecraft:blue_ice") {
            block.dimension.playSound("block.click.fail", blockLocation, { pitch: 1.0, volume: 0.7 });
          }
        }
        if (block.typeId === "nicothekid:evaporator_copper_cheese") {
          const setCount = Math.random() * (4 - 3) + 3;
          const spawnCheese = new ItemStack ("nicothekid:cheese", setCount);
          block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnCheese, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_copper_ice") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:ice") {
            const spawnIce = new ItemStack ("minecraft:ice", 1);
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnIce, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
          }
          else if (itemUsed.typeId === "minecraft:blue_ice") {
            block.dimension.playSound("block.click.fail", blockLocation, { pitch: 1.0, volume: 0.7 });
          }
        }
        if (block.typeId === "nicothekid:evaporator_copper_lava") {
          if (itemUsed === undefined) return;
          if (itemUsed.typeId === "minecraft:bucket") {
            decreaseItem ();
            block.dimension.playSound("bucket.fill_lava", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:lava_bucket 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
          }
        }
        if (block.typeId === "nicothekid:evaporator_copper_leather_scrap_1") {
          const setCount = Math.random() * (4 - 3) + 3;
          const spawnLeatherScrap = new ItemStack ("nicothekid:leather_scrap", setCount);
          block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnLeatherScrap, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_copper_leather_scrap_2") {
          const setCount = Math.random() * (7 - 6) + 6;
          const spawnLeatherScrap = new ItemStack ("nicothekid:leather_scrap", setCount);
          block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnLeatherScrap, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_copper_leather_scrap_3") {
          const setCount = Math.random() * (10 - 9) + 9;
          const spawnLeatherScrap = new ItemStack ("nicothekid:leather_scrap", setCount);
          block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnLeatherScrap, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_copper_milk") {
          if (itemUsed === undefined) return;
          if (itemUsed.typeId === "minecraft:bucket") {
            decreaseItem ();
            block.dimension.playSound("bucket.fill_water", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:milk_bucket 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
          }
        }
        if (block.typeId === "nicothekid:evaporator_copper_obsidian") {
          const spawnObsidian = new ItemStack ("minecraft:obsidian", 1);
          block.dimension.playSound("dig.stone", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnObsidian, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_copper_packed_ice") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:packed_ice") {
            const spawnPackedIce = new ItemStack ("minecraft:packed_ice", 1);
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnPackedIce, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
          }
          else if (itemUsed.typeId === "minecraft:packed_ice") {
            block.dimension.playSound("block.click.fail", blockLocation, { pitch: 1.0, volume: 0.7 });
          }
        }
        if (block.typeId === "nicothekid:evaporator_copper_rotten_flesh_1") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:rotten_flesh") {
            const spawnRottenFlesh = new ItemStack ("minecraft:rotten_flesh", 1);
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnRottenFlesh, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
          }
          else if (itemUsed.typeId === "minecraft:rotten_flesh") {
            decreaseItem ();
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_rotten_flesh_2"));
            return;
          }
        }
        if (block.typeId === "nicothekid:evaporator_copper_rotten_flesh_2") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:rotten_flesh") {
            const spawnRottenFlesh = new ItemStack ("minecraft:rotten_flesh", 2);
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnRottenFlesh, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
          }
          else if (itemUsed.typeId === "minecraft:rotten_flesh") {
            decreaseItem ();
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_rotten_flesh_3"));
            return;
          }
        }
        if (block.typeId === "nicothekid:evaporator_copper_rotten_flesh_3") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:rotten_flesh") {
            const spawnRottenFlesh = new ItemStack ("minecraft:rotten_flesh", 3);
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnRottenFlesh, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
          }
          else if (itemUsed.typeId === "minecraft:rotten_flesh") {
            block.dimension.playSound("block.click.fail", blockLocation, { pitch: 1.0, volume: 0.7 });
          }
        }
        if (block.typeId === "nicothekid:evaporator_copper_salt") {
          const setCount = Math.random() * (4 - 3) + 3;
          const spawnSalt = new ItemStack ("nicothekid:salt", setCount);
          block.dimension.playSound("dig.sand", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnSalt, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_copper_snow") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:snow") {
            const spawnSnow = new ItemStack ("minecraft:snow", 1);
            block.dimension.playSound("dig.snow", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnSnow, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
          }
          else if (itemUsed.typeId === "minecraft:snow") {
            block.dimension.playSound("block.click.fail", blockLocation, { pitch: 1.0, volume: 0.7 });
          }
        }
        if (block.typeId === "nicothekid:evaporator_copper_water") {
          if (itemUsed === undefined) return;
          if (itemUsed.typeId === "minecraft:bucket") {
            decreaseItem ();
            block.dimension.playSound("bucket.fill_water", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:water_bucket 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
            return;
          }
          if (itemUsed.typeId === "nicothekid:jar_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:jar_water_full 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_empty"));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_water 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            return;
          }
        }
      }
    }
  });
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:copper_evaporator_ticks", {
    onTick: eventData => {
      const block = eventData.block;
      const blockLocation = block.location;
      if (copperEvaporator.includes(block.typeId)) {
        if (block.permutation.matches("nicothekid:evaporator_copper_blue_ice")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_packed_ice"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_copper_ice")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_water"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_copper_lava")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_obsidian"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_copper_milk")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_cheese"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_copper_packed_ice")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_ice"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_copper_rotten_flesh_1")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_leather_scrap_1"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_copper_rotten_flesh_2")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_leather_scrap_2"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_copper_rotten_flesh_3")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_leather_scrap_3"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_copper_snow")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_water"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_copper_water")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_copper_salt"));
          return
        }
      }
    }
  });
});
world.beforeEvents.worldInitialize.subscribe(initEvent => {
  const ironEvaporator = [
    "nicothekid:evaporator_iron_blue_ice",
    "nicothekid:evaporator_iron_cheese",
    "nicothekid:evaporator_iron_ice",
    "nicothekid:evaporator_iron_lava",
    "nicothekid:evaporator_iron_leather_scrap_1",
    "nicothekid:evaporator_iron_leather_scrap_2",
    "nicothekid:evaporator_iron_leather_scrap_3",
    "nicothekid:evaporator_iron_milk",
    "nicothekid:evaporator_iron_obsidian",
    "nicothekid:evaporator_iron_packed_ice",
    "nicothekid:evaporator_iron_rotten_flesh_1",
    "nicothekid:evaporator_iron_rotten_flesh_2",
    "nicothekid:evaporator_iron_rotten_flesh_3",
    "nicothekid:evaporator_iron_salt",
    "nicothekid:evaporator_iron_snow",
    "nicothekid:evaporator_iron_water",
    "nicothekid:evaporator_iron_empty"
  ]
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:iron_evaporator_interaction", {
    onPlayerInteract: eventData => {
      const player = eventData.player;
      const block = eventData.block;
      const blockLocation = block.location;
      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)
          }
        });
      }
      function giveEmptyBucket () {
        const emptyBucket = new ItemStack ("minecraft:bucket", 1);
        playerEquippable.setEquipment("Mainhand", emptyBucket)
      }
      if (player.isSneaking) return;
      if (ironEvaporator.includes(block.typeId)) {
        if (block.typeId === "nicothekid:evaporator_iron_empty") {
          const validInputs = [
            "minecraft:blue_ice",
            "minecraft:ice",
            "minecraft:lava_bucket",
            "minecraft:milk_bucket",
            "minecraft:packed_ice",
            "minecraft:rotten_flesh",
            "minecraft:snow",
            "minecraft:water_bucket",
            "nicothekid:jar_water_full"
          ]
          if (itemUsed === undefined || !validInputs.includes(itemUsed.typeId)) return;
          if (itemUsed.typeId === "minecraft:blue_ice") {
            decreaseItem ();
            block.dimension.playSound("dig.stone", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_blue_ice"));
          }
          if (itemUsed.typeId === "minecraft:ice") {
            decreaseItem ();
            block.dimension.playSound("dig.stone", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_ice"));
          }
          if (itemUsed.typeId === "minecraft:lava_bucket") {
            giveEmptyBucket ();
            block.dimension.playSound("bucket.empty_lava", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_lava"));
          }
          if (itemUsed.typeId === "minecraft:milk_bucket") {
            giveEmptyBucket ();
            block.dimension.playSound("bucket.empty_water", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_milk"));
          }
          if (itemUsed.typeId === "minecraft:packed_ice") {
            decreaseItem ();
            block.dimension.playSound("dig.stone", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_packed_ice"));
          }
          if (itemUsed.typeId === "minecraft:rotten_flesh") {
            decreaseItem ();
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_rotten_flesh_1"));
            return;
          }
          if (itemUsed.typeId === "minecraft:snow") {
            decreaseItem ();
            block.dimension.playSound("use.snow", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_snow"));
          }
          if (itemUsed.typeId === "minecraft:water_bucket") {
            giveEmptyBucket ();
            block.dimension.playSound("bucket.empty_water", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_water"));
          }
          if (itemUsed.typeId === "nicothekid:jar_water_full") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:jar_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_water"));
          }
        }
        if (block.typeId === "nicothekid:evaporator_iron_blue_ice") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:blue_ice") {
            const spawnBlueIce = new ItemStack ("minecraft:blue_ice", 1);
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnBlueIce, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
          }
          else if (itemUsed.typeId === "minecraft:blue_ice") {
            block.dimension.playSound("block.click.fail", blockLocation, { pitch: 1.0, volume: 0.7 });
          }
        }
        if (block.typeId === "nicothekid:evaporator_iron_cheese") {
          const setCount = Math.random() * (4 - 3) + 3;
          const spawnCheese = new ItemStack ("nicothekid:cheese", setCount);
          block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnCheese, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_iron_ice") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:ice") {
            const spawnIce = new ItemStack ("minecraft:ice", 1);
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnIce, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
          }
          else if (itemUsed.typeId === "minecraft:blue_ice") {
            block.dimension.playSound("block.click.fail", blockLocation, { pitch: 1.0, volume: 0.7 });
          }
        }
        if (block.typeId === "nicothekid:evaporator_iron_lava") {
          if (itemUsed === undefined) return;
          if (itemUsed.typeId === "minecraft:bucket") {
            decreaseItem ();
            block.dimension.playSound("bucket.fill_lava", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:lava_bucket 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
          }
        }
        if (block.typeId === "nicothekid:evaporator_iron_leather_scrap_1") {
          const setCount = Math.random() * (4 - 3) + 3;
          const spawnLeatherScrap = new ItemStack ("nicothekid:leather_scrap", setCount);
          block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnLeatherScrap, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_iron_leather_scrap_2") {
          const setCount = Math.random() * (7 - 6) + 6;
          const spawnLeatherScrap = new ItemStack ("nicothekid:leather_scrap", setCount);
          block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnLeatherScrap, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_iron_leather_scrap_3") {
          const setCount = Math.random() * (10 - 9) + 9;
          const spawnLeatherScrap = new ItemStack ("nicothekid:leather_scrap", setCount);
          block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnLeatherScrap, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_iron_milk") {
          if (itemUsed === undefined) return;
          if (itemUsed.typeId === "minecraft:bucket") {
            decreaseItem ();
            block.dimension.playSound("bucket.fill_water", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:milk_bucket 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
          }
        }
        if (block.typeId === "nicothekid:evaporator_iron_obsidian") {
          const spawnObsidian = new ItemStack ("minecraft:obsidian", 1);
          block.dimension.playSound("dig.stone", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnObsidian, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_iron_packed_ice") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:packed_ice") {
            const spawnPackedIce = new ItemStack ("minecraft:packed_ice", 1);
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnPackedIce, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
          }
          else if (itemUsed.typeId === "minecraft:packed_ice") {
            block.dimension.playSound("block.click.fail", blockLocation, { pitch: 1.0, volume: 0.7 });
          }
        }
        if (block.typeId === "nicothekid:evaporator_iron_rotten_flesh_1") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:rotten_flesh") {
            const spawnRottenFlesh = new ItemStack ("minecraft:rotten_flesh", 1);
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnRottenFlesh, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
          }
          else if (itemUsed.typeId === "minecraft:rotten_flesh") {
            decreaseItem ();
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_rotten_flesh_2"));
            return;
          }
        }
        if (block.typeId === "nicothekid:evaporator_iron_rotten_flesh_2") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:rotten_flesh") {
            const spawnRottenFlesh = new ItemStack ("minecraft:rotten_flesh", 2);
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnRottenFlesh, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
          }
          else if (itemUsed.typeId === "minecraft:rotten_flesh") {
            decreaseItem ();
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_rotten_flesh_3"));
            return;
          }
        }
        if (block.typeId === "nicothekid:evaporator_iron_rotten_flesh_3") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:rotten_flesh") {
            const spawnRottenFlesh = new ItemStack ("minecraft:rotten_flesh", 3);
            block.dimension.playSound("cake.add_candle", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnRottenFlesh, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
          }
          else if (itemUsed.typeId === "minecraft:rotten_flesh") {
            block.dimension.playSound("block.click.fail", blockLocation, { pitch: 1.0, volume: 0.7 });
          }
        }
        if (block.typeId === "nicothekid:evaporator_iron_salt") {
          const setCount = Math.random() * (4 - 3) + 3;
          const spawnSalt = new ItemStack ("nicothekid:salt", setCount);
          block.dimension.playSound("dig.sand", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.dimension.spawnItem(spawnSalt, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
        }
        if (block.typeId === "nicothekid:evaporator_iron_snow") {
          if (itemUsed === undefined || itemUsed.typeId !== "minecraft:snow") {
            const spawnSnow = new ItemStack ("minecraft:snow", 1);
            block.dimension.playSound("dig.snow", blockLocation, { pitch: 1.0, volume: 0.7 });
            block.dimension.spawnItem(spawnSnow, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
          }
          else if (itemUsed.typeId === "minecraft:snow") {
            block.dimension.playSound("block.click.fail", blockLocation, { pitch: 1.0, volume: 0.7 });
          }
        }
        if (block.typeId === "nicothekid:evaporator_iron_water") {
          if (itemUsed === undefined) return;
          if (itemUsed.typeId === "minecraft:bucket") {
            decreaseItem ();
            block.dimension.playSound("bucket.fill_water", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:water_bucket 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
            return;
          }
          if (itemUsed.typeId === "nicothekid:jar_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:jar_water_full 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_empty"));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_water 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            return;
          }
        }
      }
    }
  });
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:iron_evaporator_ticks", {
    onTick: eventData => {
      const block = eventData.block;
      const blockLocation = block.location;
      if (ironEvaporator.includes(block.typeId)) {
        if (block.permutation.matches("nicothekid:evaporator_iron_blue_ice")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_packed_ice"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_iron_ice")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 0.7 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_water"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_iron_lava")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_obsidian"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_iron_milk")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_cheese"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_iron_packed_ice")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 0.5 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_ice"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_iron_rotten_flesh_1")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_leather_scrap_1"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_iron_rotten_flesh_2")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_leather_scrap_2"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_iron_rotten_flesh_3")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_leather_scrap_3"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_iron_snow")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_water"));
          return
        }
        if (block.permutation.matches("nicothekid:evaporator_iron_water")) {
          block.dimension.playSound("step.powder_snow", blockLocation, { pitch: 1.0, volume: 1.0 });
          block.setPermutation(BlockPermutation.resolve("nicothekid:evaporator_iron_salt"));
          return
        }
      }
    }
  });
});
world.beforeEvents.worldInitialize.subscribe(initEvent => {
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:jar_of_cookies_interaction", {
    onPlayerInteract: eventData => {
      const player = eventData.player;
      const block = eventData.block;
      const blockLocation = block.location;
      const playerEquippable = player.getComponent("equippable");
      const itemUsed = playerEquippable.getEquipment("Mainhand");
      const blockState = block.permutation.getState("minecraft:cardinal_direction");
      const blockAllState = block.permutation.getAllStates();
      function damageDurability () {
        if (!player.matches({ gameMode: GameMode.creative })) {
          const itemEnchantable = itemUsed.getComponent("enchantable");
          const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
          const breakChance = 100 / (unbreakingLevel + 1);
          const randomizeChance = Math.random() * 100;
          if (breakChance < randomizeChance) return;
          const itemDurability = itemUsed.getComponent("durability");
          if (!itemDurability) return;
          const itemMaxDurability = itemDurability.maxDurability;
          const itemDurabilityDamage = itemDurability.damage;
          const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
          let damageAmount = 1;
          const currentDurability = durabilityCalculation - damageAmount;
          if (currentDurability <= 0) {
            player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
            playerEquippable.setEquipment("Mainhand", null);
          }
          else {
            itemDurability.damage += damageAmount;
            playerEquippable.setEquipment("Mainhand", itemUsed)
          }
        }
      }
      function decreaseItem () {
        system.run(() => {
          if (!player.matches({ gameMode: GameMode.creative })) {
            const decrementItem = itemUsed.amount == 1 ? undefined : (itemUsed.amount--, itemUsed);
            playerEquippable.setEquipment("Mainhand", decrementItem)
          }
        });
      }
      const cookieJars = [
        "nicothekid:block_jar_empty",
        "nicothekid:block_jar_cookies_01",
        "nicothekid:block_jar_cookies_02",
        "nicothekid:block_jar_cookies_03",
        "nicothekid:block_jar_cookies_04",
        "nicothekid:block_jar_cookies_05",
        "nicothekid:block_jar_cookies_06",
        "nicothekid:block_jar_cookies_07",
        "nicothekid:block_jar_cookies_08",
        "nicothekid:block_jar_glow_berry_cookies_01",
        "nicothekid:block_jar_glow_berry_cookies_02",
        "nicothekid:block_jar_glow_berry_cookies_03",
        "nicothekid:block_jar_glow_berry_cookies_04",
        "nicothekid:block_jar_glow_berry_cookies_05",
        "nicothekid:block_jar_glow_berry_cookies_06",
        "nicothekid:block_jar_glow_berry_cookies_07",
        "nicothekid:block_jar_glow_berry_cookies_08",
        "nicothekid:block_jar_moss_berry_cookies_01",
        "nicothekid:block_jar_moss_berry_cookies_02",
        "nicothekid:block_jar_moss_berry_cookies_03",
        "nicothekid:block_jar_moss_berry_cookies_04",
        "nicothekid:block_jar_moss_berry_cookies_05",
        "nicothekid:block_jar_moss_berry_cookies_06",
        "nicothekid:block_jar_moss_berry_cookies_07",
        "nicothekid:block_jar_moss_berry_cookies_08",
        "nicothekid:block_jar_sweet_berry_cookies_01",
        "nicothekid:block_jar_sweet_berry_cookies_02",
        "nicothekid:block_jar_sweet_berry_cookies_03",
        "nicothekid:block_jar_sweet_berry_cookies_04",
        "nicothekid:block_jar_sweet_berry_cookies_05",
        "nicothekid:block_jar_sweet_berry_cookies_06",
        "nicothekid:block_jar_sweet_berry_cookies_07",
        "nicothekid:block_jar_sweet_berry_cookies_08"
      ]
      if (player.isSneaking) return;
      if (cookieJars.includes(block.typeId)) {
        if (itemUsed === undefined) {
          const fullCookieJars = [
            "nicothekid:block_jar_cookies_08",
            "nicothekid:block_jar_glow_berry_cookies_08",
            "nicothekid:block_jar_moss_berry_cookies_08",
            "nicothekid:block_jar_sweet_berry_cookies_08"
          ]
          if (fullCookieJars.includes(block.typeId)) {
            player.playSound("game.player.attack.nodamage", { pitch: 1.1, location: blockLocation, volume: 1.0 });
            player.runCommandAsync(`tellraw @p {\"rawtext\":[{\"text\":\"§eUse the Jar Opener to take out one of the cookies.§r\"}]}`);
          }
          else return;
        }
        else if (itemUsed !== undefined) {
          const validCookies = [
            "minecraft:cookie",
            "nicothekid:glow_berry_cookie",
            "nicothekid:moss_berry_cookie",
            "nicothekid:sweet_berry_cookie"
          ]
          if (itemUsed.typeId === "nicothekid:jar_opener") {
            if (block.hasTag("jar_cookies_block")) {
              damageDurability ();
              block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.5 });
              const spawnCookie = new ItemStack ("minecraft:cookie", 1);
              block.dimension.spawnItem(spawnCookie, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
              if (block.permutation.matches("nicothekid:block_jar_cookies_01")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_02")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_01", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_03")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_02", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_04")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_03", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_05")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_04", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_06")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_05", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_07")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_06", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_08")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_07", blockAllState ));
                return;
              }
            }
            if (block.hasTag("jar_glow_berry_cookies_block")) {
              damageDurability ();
              block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.5 });
              const spawnGlowBerryCookie = new ItemStack ("nicothekid:glow_berry_cookie", 1);
              block.dimension.spawnItem(spawnGlowBerryCookie, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_01")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_02")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_01", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_03")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_02", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_04")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_03", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_05")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_04", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_06")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_05", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_07")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_06", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_08")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_07", blockAllState ));
                return;
              }
            }
            if (block.hasTag("jar_moss_berry_cookies_block")) {
              damageDurability ();
              block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.5 });
              const spawnMossBerryCookie = new ItemStack ("nicothekid:moss_berry_cookie", 1);
              block.dimension.spawnItem(spawnMossBerryCookie, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_01")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_02")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_01", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_03")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_02", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_04")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_03", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_05")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_04", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_06")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_05", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_07")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_06", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_08")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_07", blockAllState ));
                return;
              }
            }
            if (block.hasTag("jar_sweet_berry_cookies_block")) {
              damageDurability ();
              block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 1.0, volume: 0.5 });
              const spawnSweetBerryCookie = new ItemStack ("nicothekid:sweet_berry_cookie", 1);
              block.dimension.spawnItem(spawnSweetBerryCookie, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_01")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_02")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_01", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_03")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_02", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_04")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_03", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_05")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_04", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_06")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_05", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_07")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_06", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_08")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_07", blockAllState ));
                return;
              }
            }
          }
          else if (validCookies.includes(itemUsed.typeId)) {
            if (itemUsed.typeId === "minecraft:cookie") {
              const inputableJars = [
                "nicothekid:block_jar_empty",
                "nicothekid:block_jar_cookies_01",
                "nicothekid:block_jar_cookies_02",
                "nicothekid:block_jar_cookies_03",
                "nicothekid:block_jar_cookies_04",
                "nicothekid:block_jar_cookies_05",
                "nicothekid:block_jar_cookies_06",
                "nicothekid:block_jar_cookies_07"
              ];
              if (!inputableJars.includes(block.typeId)) return;
              decreaseItem ();
              block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 1.0, volume: 0.5 });
              if (block.permutation.matches("nicothekid:block_jar_empty")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_01", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_01")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_02", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_02")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_03", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_03")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_04", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_04")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_05", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_05")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_06", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_06")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_07", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_cookies_07")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_cookies_08", blockAllState ));
                return;
              }
            }
            if (itemUsed.typeId === "nicothekid:glow_berry_cookie") {
              const inputableJars = [
                "nicothekid:block_jar_empty",
                "nicothekid:block_jar_glow_berry_cookies_01",
                "nicothekid:block_jar_glow_berry_cookies_02",
                "nicothekid:block_jar_glow_berry_cookies_03",
                "nicothekid:block_jar_glow_berry_cookies_04",
                "nicothekid:block_jar_glow_berry_cookies_05",
                "nicothekid:block_jar_glow_berry_cookies_06",
                "nicothekid:block_jar_glow_berry_cookies_07"
              ];
              if (!inputableJars.includes(block.typeId)) return;
              decreaseItem ();
              block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 1.0, volume: 0.5 });
              if (block.permutation.matches("nicothekid:block_jar_empty")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_01", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_01")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_02", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_02")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_03", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_03")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_04", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_04")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_05", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_05")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_06", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_06")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_07", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_glow_berry_cookies_07")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_cookies_08", blockAllState ));
                return;
              }
            }
            if (itemUsed.typeId === "nicothekid:moss_berry_cookie") {
              const inputableJars = [
                "nicothekid:block_jar_empty",
                "nicothekid:block_jar_moss_berry_cookies_01",
                "nicothekid:block_jar_moss_berry_cookies_02",
                "nicothekid:block_jar_moss_berry_cookies_03",
                "nicothekid:block_jar_moss_berry_cookies_04",
                "nicothekid:block_jar_moss_berry_cookies_05",
                "nicothekid:block_jar_moss_berry_cookies_06",
                "nicothekid:block_jar_moss_berry_cookies_07"
              ];
              if (!inputableJars.includes(block.typeId)) return;
              decreaseItem ();
              block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 1.0, volume: 0.5 });
              if (block.permutation.matches("nicothekid:block_jar_empty")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_01", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_01")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_02", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_02")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_03", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_03")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_04", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_04")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_05", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_05")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_06", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_06")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_07", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_moss_berry_cookies_07")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_moss_berry_cookies_08", blockAllState ));
                return;
              }
            }
            if (itemUsed.typeId === "nicothekid:sweet_berry_cookie") {
              const inputableJars = [
                "nicothekid:block_jar_empty",
                "nicothekid:block_jar_sweet_berry_cookies_01",
                "nicothekid:block_jar_sweet_berry_cookies_02",
                "nicothekid:block_jar_sweet_berry_cookies_03",
                "nicothekid:block_jar_sweet_berry_cookies_04",
                "nicothekid:block_jar_sweet_berry_cookies_05",
                "nicothekid:block_jar_sweet_berry_cookies_06",
                "nicothekid:block_jar_sweet_berry_cookies_07"
              ];
              if (!inputableJars.includes(block.typeId)) return;
              decreaseItem ();
              block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 1.0, volume: 0.5 });
              if (block.permutation.matches("nicothekid:block_jar_empty")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_01", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_01")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_02", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_02")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_03", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_03")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_04", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_04")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_05", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_05")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_06", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_06")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_07", blockAllState ));
                return;
              }
              if (block.permutation.matches("nicothekid:block_jar_sweet_berry_cookies_07")) {
                block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_cookies_08", blockAllState ));
                return;
              }
            }
          }
          else return;
        }
      }
      else return;
    }
  });
});
world.beforeEvents.worldInitialize.subscribe(initEvent => {
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:jar_of_drinks_interaction", {
    onPlayerInteract: eventData => {
      const player = eventData.player;
      const block = eventData.block;
      const blockFacing = eventData.face;
      const blockLocation = block.location;
      const playerEquippable = player.getComponent("equippable");
      const itemUsed = playerEquippable.getEquipment("Mainhand");
      const blockAllState = block.permutation.getAllStates();
      function damageDurability () {
        if (!player.matches({ gameMode: GameMode.creative })) {
          const itemEnchantable = itemUsed.getComponent("enchantable");
          const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
          const breakChance = 100 / (unbreakingLevel + 1);
          const randomizeChance = Math.random() * 100;
          if (breakChance < randomizeChance) return;
          const itemDurability = itemUsed.getComponent("durability");
          if (!itemDurability) return;
          const itemMaxDurability = itemDurability.maxDurability;
          const itemDurabilityDamage = itemDurability.damage;
          const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
          let damageAmount = 1;
          const currentDurability = durabilityCalculation - damageAmount;
          if (currentDurability <= 0) {
            player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
            playerEquippable.setEquipment("Mainhand", null);
          }
          else {
            itemDurability.damage += damageAmount;
            playerEquippable.setEquipment("Mainhand", itemUsed)
          }
        }
      }
      function decreaseItem () {
        system.run(() => {
          if (!player.matches({ gameMode: GameMode.creative })) {
            const decrementItem = itemUsed.amount == 1 ? undefined : (itemUsed.amount--, itemUsed);
            playerEquippable.setEquipment("Mainhand", decrementItem)
          }
        });
      }
      const drinkJars = [
        "nicothekid:block_jar_empty",
        "nicothekid:block_jar_chocolate_full",
        "nicothekid:block_jar_chocolate_half",
        "nicothekid:block_jar_glow_berry_juice_full",
        "nicothekid:block_jar_glow_berry_juice_half",
        "nicothekid:block_jar_honey_full",
        "nicothekid:block_jar_honey_half",
        "nicothekid:block_jar_milk_full",
        "nicothekid:block_jar_milk_half",
        "nicothekid:block_jar_sweet_berry_juice_full",
        "nicothekid:block_jar_sweet_berry_juice_half",
        "nicothekid:block_jar_water_full",
        "nicothekid:block_jar_water_half"
      ];
      const validLiquids = [
        "minecraft:bucket",
        "minecraft:milk_bucket",
        "minecraft:glass_bottle",
        "minecraft:honey_bottle",
        "minecraft:potion",
        "nicothekid:bamboo_tumbler_empty",
        "nicothekid:bamboo_tumbler_chocolate",
        "nicothekid:bamboo_tumbler_glow_berry",
        "nicothekid:bamboo_tumbler_milk",
        "nicothekid:bamboo_tumbler_sweet_berry",
        "nicothekid:bamboo_tumbler_water"
      ];
      if (player.isSneaking || itemUsed === undefined || blockFacing === "Up") return;
      if (drinkJars.includes(block.typeId) && validLiquids.includes(itemUsed.typeId)) {
        if (block.permutation.matches("nicothekid:block_jar_empty")) {
          if (itemUsed.typeId === "minecraft:milk_bucket") {
            decreaseItem ();
            block.dimension.playSound("bucket.empty_water", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:bucket 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_milk_full", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "minecraft:honey_bottle") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:glass_bottle 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_honey_half", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "minecraft:potion") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:glass_bottle 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_water_half", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_chocolate") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_chocolate_half", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_glow_berry") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });        
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_juice_half", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_milk") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_milk_half", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_sweet_berry") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_juice_half", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_water") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_water_half", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_chocolate_half")) {
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_chocolate 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_chocolate") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_chocolate_full", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_chocolate_full")) {
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_chocolate 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_chocolate_half", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_glow_berry_juice_half")) {
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_glow_berry 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_glow_berry") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_juice_full", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_glow_berry_juice_full")) {
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_glow_berry 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_glow_berry_juice_half", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_honey_half")) {
          if (itemUsed.typeId === "minecraft:glass_bottle") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:honey_bottle 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "minecraft:honey_bottle") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:glass_bottle 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_honey_full", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_honey_full")) {
          if (itemUsed.typeId === "minecraft:glass_bottle") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:honey_bottle 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_honey_half", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_milk_half")) {
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_milk 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_milk") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_milk_full", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_milk_full")) {
          if (itemUsed.typeId === "minecraft:bucket") {
            decreaseItem ();
            block.dimension.playSound("bucket.fill_water", blockLocation, { pitch: 1.0, volume: 0.7 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:milk_bucket 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_milk 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_milk_half", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_sweet_berry_juice_half")) {
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_sweet_berry 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_sweet_berry") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_juice_full", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_sweet_berry_juice_full")) {
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_sweet_berry 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_sweet_berry_juice_half", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_water_half")) {
          if (itemUsed.typeId === "minecraft:glass_bottle") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:potion 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "minecraft:potion") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:glass_bottle 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_water_full", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_water 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_empty", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_water") {
            decreaseItem ();
            block.dimension.playSound("bottle.empty", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_empty 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_water_full", blockAllState ));
            return;
          }
        }
        if (block.permutation.matches("nicothekid:block_jar_water_full")) {
          if (itemUsed.typeId === "minecraft:glass_bottle") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s minecraft:potion 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_water_half", blockAllState ));
            return;
          }
          if (itemUsed.typeId === "nicothekid:bamboo_tumbler_empty") {
            decreaseItem ();
            block.dimension.playSound("bottle.fill", blockLocation, { pitch: 1.0, volume: 0.5 });
            player.runCommandAsync(`gamerule sendcommandfeedback false`);
            player.runCommandAsync(`give @s nicothekid:bamboo_tumbler_water 1`);
            player.runCommandAsync(`gamerule sendcommandfeedback true`);
            block.setPermutation(BlockPermutation.resolve("nicothekid:block_jar_water_half", blockAllState ));
            return;
          }
        }
      }
      else return;
    }
  });
});
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;
    }
  });
});
world.beforeEvents.itemUseOn.subscribe(eventData => {
  const player = eventData.source;
  const itemUsed = eventData.itemStack;
  const block = eventData.block;
  const blockLocation = block.location;
  const playerEquippable = player.getComponent("equippable");
  const statePillarAxis = block.permutation.getState("pillar_axis");
  const stateAll = block.permutation.getAllStates();
  const strippedWoods = [
    "minecraft:stripped_acacia_log",
    "minecraft:stripped_acacia_wood",
    "minecraft:stripped_bamboo_block",
    "minecraft:stripped_birch_log",
    "minecraft:stripped_birch_wood",
    "minecraft:stripped_cherry_log",
    "minecraft:stripped_cherry_wood",
    "minecraft:stripped_crimson_hyphae",
    "minecraft:stripped_crimson_stem",
    "minecraft:stripped_dark_oak_log",
    "minecraft:stripped_dark_oak_wood",
    "minecraft:stripped_jungle_log",
    "minecraft:stripped_jungle_wood",
    "minecraft:stripped_mangrove_log",
    "minecraft:stripped_mangrove_wood",
    "minecraft:stripped_oak_log",
    "minecraft:stripped_oak_wood",
    "minecraft:stripped_spruce_log",
    "minecraft:stripped_spruce_wood",
    "minecraft:stripped_warped_hyphae",
    "minecraft:stripped_warped_stem"
  ]
  function decreaseItem () {
    if (!player.matches({ gameMode: GameMode.creative })) {
      const decrementItem = itemUsed.amount == 1 ? undefined : (itemUsed.amount--, itemUsed);
      playerEquippable.setEquipment("Mainhand", decrementItem)
    }
  }
  if (itemUsed === undefined) return;
  if (strippedWoods.includes(block.typeId)) {
    if (itemUsed.typeId === "minecraft:bone_meal") {
      system.run(() => {
        decreaseItem ();
        block.dimension.playSound("item.bone_meal.use", blockLocation, { pitch: 1.0, volume: 1.0 });
        block.dimension.spawnParticle("nicothekid:barked_2_particle", { x: blockLocation.x, y: blockLocation.y, z: blockLocation.z });
        if (block.permutation.matches("minecraft:stripped_acacia_log")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:acacia_log", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_acacia_wood")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:acacia_wood", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_bamboo_block")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:bamboo_block", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_birch_log")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:birch_log", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_birch_wood")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:birch_wood", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_cherry_log")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:cherry_log", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_cherry_wood")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:cherry_wood", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_crimson_stem")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:crimson_stem", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_crimson_hyphae")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:crimson_hyphae", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_dark_oak_log")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:dark_oak_log", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_dark_oak_wood")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:dark_oak_wood", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_jungle_log")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:jungle_log", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_jungle_wood")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:jungle_wood", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_mangrove_log")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:mangrove_log", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_mangrove_wood")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:mangrove_wood", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_oak_log")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:oak_log", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_oak_wood")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:oak_wood", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_spruce_log")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:spruce_log", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_spruce_wood")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:spruce_wood", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_warped_stem")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:warped_stem", { "pillar_axis": statePillarAxis } ));
          return;
        }
        if (block.permutation.matches("minecraft:stripped_warped_hyphae")) {
          block.setPermutation(BlockPermutation.resolve("minecraft:warped_hyphae", { "pillar_axis": statePillarAxis } ));
          return;
        }
      });
    }
    else return;
  }
  else return;
});
world.beforeEvents.itemUseOn.subscribe(eventData => {
  const player = eventData.source;
  const itemUsed = eventData.itemStack;
  const block = eventData.block;
  const blockLocation = block.location;
  const playerEquippable = player.getComponent("equippable");
  const stateAll = block.permutation.getAllStates();
  const customAxes = [
    "nicothekid:copper_axe"
  ]
  const customHoes = [
    "nicothekid:copper_hoe"
  ]
  const customShovels = [
    "nicothekid:copper_shovel"
  ]
  function damageDurability () {
    if (!player.matches({ gameMode: GameMode.creative })) {
      const itemEnchantable = itemUsed.getComponent("minecraft:enchantable");
      const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
      const breakChance = 100 / (unbreakingLevel + 1);
      const randomizeChance = Math.random() * 100;
      if (breakChance < randomizeChance) return;
      const itemDurability = itemUsed.getComponent("durability");
      if (!itemDurability) return;
      const itemMaxDurability = itemDurability.maxDurability;
      const itemDurabilityDamage = itemDurability.damage;
      const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
      let damageAmount = 1;
      const currentDurability = durabilityCalculation - damageAmount;
      if (currentDurability <= 0) {
        player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
        playerEquippable.setEquipment("Mainhand", null);
      }
      else {
        itemDurability.damage += damageAmount;
        playerEquippable.setEquipment("Mainhand", itemUsed)
      }
    }
  }
  if (itemUsed === undefined) return;
  if (customAxes.includes(itemUsed.typeId) || customHoes.includes(itemUsed.typeId) || customShovels.includes(itemUsed.typeId)) {
    if (customAxes.includes(itemUsed.typeId)) {
      const vanillaWoods = [
        "minecraft:oak_log",
        "minecraft:oak_wood",
        "minecraft:spruce_log",
        "minecraft:spruce_wood",
        "minecraft:birch_log",
        "minecraft:birch_wood",
        "minecraft:jungle_log",
        "minecraft:jungle_wood",
        "minecraft:acacia_log",
        "minecraft:acacia_wood",
        "minecraft:dark_oak_log",
        "minecraft:dark_oak_wood",
        "minecraft:mangrove_log",
        "minecraft:mangrove_wood",
        "minecraft:cherry_log",
        "minecraft:cherry_wood",
        "minecraft:bamboo_block",
        "minecraft:crimson_stem",
        "minecraft:crimson_hyphae",
        "minecraft:warped_stem",
        "minecraft:warped_hyphae"
      ];
      const vanillaCopper = [
        "minecraft:exposed_chiseled_copper",
        "minecraft:exposed_copper",
        "minecraft:exposed_copper_bulb",
        "minecraft:exposed_copper_door",
        "minecraft:exposed_copper_grate",
        "minecraft:exposed_copper_trapdoor",
        "minecraft:exposed_cut_copper",
        "minecraft:exposed_cut_copper_stairs",
        "minecraft:exposed_cut_copper_slab",
        "minecraft:exposed_double_cut_copper_slab",
        "minecraft:weathered_chiseled_copper",
        "minecraft:weathered_copper",
        "minecraft:weathered_copper_bulb",
        "minecraft:weathered_copper_door",
        "minecraft:weathered_copper_grate",
        "minecraft:weathered_copper_trapdoor",
        "minecraft:weathered_cut_copper",
        "minecraft:weathered_cut_copper_stairs",
        "minecraft:weathered_cut_copper_slab",
        "minecraft:weathered_double_cut_copper_slab",
        "minecraft:oxidized_chiseled_copper",
        "minecraft:oxidized_copper",
        "minecraft:oxidized_copper_bulb",
        "minecraft:oxidized_copper_door",
        "minecraft:oxidized_copper_grate",
        "minecraft:oxidized_copper_trapdoor",
        "minecraft:oxidized_cut_copper",
        "minecraft:oxidized_cut_copper_stairs",
        "minecraft:oxidized_cut_copper_slab",
        "minecraft:oxidized_double_cut_copper_slab"
      ];
      const vanillaWaxedCopper = [
        "minecraft:waxed_copper",
        "minecraft:waxed_chiseled_copper",
        "minecraft:waxed_copper_bulb",
        "minecraft:waxed_copper_door",
        "minecraft:waxed_copper_grate",
        "minecraft:waxed_copper_trapdoor",
        "minecraft:waxed_cut_copper",
        "minecraft:waxed_cut_copper_stairs",
        "minecraft:waxed_cut_copper_slab",
        "minecraft:waxed_double_cut_copper_slab",
        
        "minecraft:waxed_exposed_copper",
        "minecraft:waxed_exposed_chiseled_copper",
        "minecraft:waxed_exposed_copper_bulb",
        "minecraft:waxed_exposed_copper_door",
        "minecraft:waxed_exposed_copper_grate",
        "minecraft:waxed_exposed_copper_trapdoor",
        "minecraft:waxed_exposed_cut_copper",
        "minecraft:waxed_exposed_cut_copper_stairs",
        "minecraft:waxed_exposed_cut_copper_slab",
        "minecraft:waxed_exposed_double_cut_copper_slab",
        
        "minecraft:waxed_weathered_copper",
        "minecraft:waxed_weathered_chiseled_copper",
        "minecraft:waxed_weathered_copper_bulb",
        "minecraft:waxed_weathered_copper_door",
        "minecraft:waxed_weathered_copper_grate",
        "minecraft:waxed_weathered_copper_trapdoor",
        "minecraft:waxed_weathered_cut_copper",
        "minecraft:waxed_weathered_cut_copper_stairs",
        "minecraft:waxed_weathered_cut_copper_slab",
        "minecraft:waxed_weathered_double_cut_copper_slab",
        
        "minecraft:waxed_oxidized_copper",
        "minecraft:waxed_oxidized_chiseled_copper",
        "minecraft:waxed_oxidized_copper_bulb",
        "minecraft:waxed_oxidized_copper_door",
        "minecraft:waxed_oxidized_copper_grate",
        "minecraft:waxed_oxidized_copper_trapdoor",
        "minecraft:waxed_oxidized_cut_copper",
        "minecraft:waxed_oxidized_cut_copper_stairs",
        "minecraft:waxed_oxidized_cut_copper_slab",
        "minecraft:waxed_oxidized_double_cut_copper_slab"
      ];
      if (vanillaWoods.includes(block.typeId)) {
        system.run(() => {
          const statePillarAxis = block.permutation.getState("pillar_axis");
          damageDurability ();
          if (block.permutation.matches("minecraft:oak_log")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_oak_log", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:oak_wood")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_oak_wood", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:spruce_log")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_spruce_log", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:spruce_wood")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_spruce_wood", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:birch_log")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_birch_log", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:birch_wood")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_birch_wood", { "pillar_axis": statePillarAxis } ));            
          }
          if (block.permutation.matches("minecraft:jungle_log")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_jungle_log", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:jungle_wood")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_jungle_wood", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:acacia_log")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_acacia_log", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:acacia_wood")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_acacia_wood", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:dark_oak_log")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_dark_oak_log", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:dark_oak_wood")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_dark_oak_wood", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:mangrove_log")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_mangrove_log", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:mangrove_wood")) {
            block.dimension.playSound("use.wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_mangrove_wood", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:cherry_log")) {
            block.dimension.playSound("step.cherry_wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_cherry_log", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:cherry_wood")) {
            block.dimension.playSound("step.cherry_wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_cherry_wood", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:crimson_stem")) {
            block.dimension.playSound("use.stem", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_crimson_stem", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:crimson_hyphae")) {
            block.dimension.playSound("use.stem", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_crimson_hyphae", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:warped_stem")) {
            block.dimension.playSound("use.stem", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_warped_stem", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:warped_hyphae")) {
            block.dimension.playSound("use.stem", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_warped_hyphae", { "pillar_axis": statePillarAxis } ));
          }
          if (block.permutation.matches("minecraft:bamboo_block")) {
            block.dimension.playSound("step.bamboo_wood", blockLocation, { pitch: 0.8, volume: 1.0 });
            //block.setPermutation(BlockPermutation.resolve("minecraft:stripped_bamboo_block", { "pillar_axis": statePillarAxis } ));
          }
        });
      }
      /*if (vanillaCopper.includes(block.typeId)) {
        const pitchRange = Math.random() * (1.2 - 0.8) + 0.8;
        const vanillaCopperDoors = [
          "minecraft:exposed_copper_door",
          "minecraft:exposed_copper_trapdoor",
          "minecraft:weathered_copper_door",
          "minecraft:weathered_copper_trapdoor",
          "minecraft:oxidized_copper_door",
          "minecraft:oxidized_copper_trapdoor"
        ];
        if (vanillaCopperDoors.includes(block.typeId)) {
          system.run(() => {
            if (!player.isSneaking) return;
            damageDurability ();
            block.dimension.playSound("scrape", blockLocation, { pitch: pitchRange, volume: 1.0 });
            block.dimension.spawnParticle("nicothekid:copper_scrape_particle", { x: blockLocation.x, y: blockLocation.y, z: blockLocation.z });
            if (block.permutation.matches("minecraft:exposed_copper_door", { "upper_block_bit": false })) {
              const blockAbove = block.above();
              const blockAboveAllState = blockAbove.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_door", stateAll ));
              blockAbove.setPermutation(BlockPermutation.resolve("minecraft:copper_door", blockAboveAllState ));
            }
            if (block.permutation.matches("minecraft:exposed_copper_door", { "upper_block_bit": true })) {
              const blockBelow = block.below();
              const blockBelowAllState = blockBelow.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_door", stateAll ));
              blockBelow.setPermutation(BlockPermutation.resolve("minecraft:copper_door", blockBelowAllState ));
            }
            if (block.permutation.matches("minecraft:exposed_copper_trapdoor")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_trapdoor", stateAll ));
            }
            if (block.permutation.matches("minecraft:weathered_copper_door", { "upper_block_bit": false })) {
              const blockAbove = block.above();
              const blockAboveAllState = blockAbove.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_door", stateAll ));
              blockAbove.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_door", blockAboveAllState ));
            }
            if (block.permutation.matches("minecraft:weathered_copper_door", { "upper_block_bit": true })) {
              const blockBelow = block.below();
              const blockBelowAllState = blockBelow.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_door", stateAll ));
              blockBelow.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_door", blockBelowAllState ));
            }
            if (block.permutation.matches("minecraft:weathered_copper_trapdoor")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_trapdoor", stateAll ));
            }
            if (block.permutation.matches("minecraft:oxidized_copper_door", { "upper_block_bit": false })) {
              const blockAbove = block.above();
              const blockAboveAllState = blockAbove.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_door", stateAll ));
              blockAbove.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_door", blockAboveAllState ));
            }
            if (block.permutation.matches("minecraft:oxidized_copper_door", { "upper_block_bit": true })) {
              const blockBelow = block.below();
              const blockBelowAllState = blockBelow.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_door", stateAll ));
              blockBelow.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_door", blockBelowAllState ));
            }
            if (block.permutation.matches("minecraft:oxidized_copper_trapdoor")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_trapdoor", stateAll ));
            }
          });
        }
        else {
          system.run(() => {
            damageDurability ();
            block.dimension.playSound("scrape", blockLocation, { pitch: pitchRange, volume: 1.0 });
            block.dimension.spawnParticle("nicothekid:copper_scrape_particle", { x: blockLocation.x, y: blockLocation.y, z: blockLocation.z });
            if (block.permutation.matches("minecraft:exposed_chiseled_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:chiseled_copper"));
            }
            if (block.permutation.matches("minecraft:exposed_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_block"));
            }
            if (block.permutation.matches("minecraft:exposed_copper_bulb")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_bulb", stateAll ));
            }
            if (block.permutation.matches("minecraft:exposed_copper_grate")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_grate"));
            }
            if (block.permutation.matches("minecraft:exposed_cut_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:cut_copper"));
            }
            if (block.permutation.matches("minecraft:exposed_cut_copper_stairs")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:cut_copper_stairs", stateAll ));
            }
            if (block.permutation.matches("minecraft:exposed_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:cut_copper_slab", stateAll ));
            }
            if (block.permutation.matches("minecraft:exposed_double_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:double_cut_copper_slab"));
            }
            if (block.permutation.matches("minecraft:weathered_chiseled_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_chiseled_copper"));
            }
            if (block.permutation.matches("minecraft:weathered_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper"));
            }
            if (block.permutation.matches("minecraft:weathered_copper_bulb")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_bulb", stateAll ));
            }
            if (block.permutation.matches("minecraft:weathered_copper_grate")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_grate"));
            }
            if (block.permutation.matches("minecraft:weathered_cut_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_cut_copper"));
            }
            if (block.permutation.matches("minecraft:weathered_cut_copper_stairs")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_cut_copper_stairs", stateAll ));
            }
            if (block.permutation.matches("minecraft:weathered_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_cut_copper_slab", stateAll ));
            }
            if (block.permutation.matches("minecraft:weathered_double_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_double_cut_copper_slab"));
            }
            if (block.permutation.matches("minecraft:oxidized_chiseled_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_chiseled_copper"));
            }
            if (block.permutation.matches("minecraft:oxidized_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper"));
            }
            if (block.permutation.matches("minecraft:oxidized_copper_bulb")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_bulb", stateAll ));
            }
            if (block.permutation.matches("minecraft:oxidized_copper_grate")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_grate"));
            }
            if (block.permutation.matches("minecraft:oxidized_cut_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_cut_copper"));
            }
            if (block.permutation.matches("minecraft:oxidized_cut_copper_stairs")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_cut_copper_stairs", stateAll ));
            }
            if (block.permutation.matches("minecraft:oxidized_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_cut_copper_slab", stateAll ));
            }
            if (block.permutation.matches("minecraft:oxidized_double_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_double_cut_copper_slab"));
            }
          });
        }
      }
      if (vanillaWaxedCopper.includes(block.typeId)) {
        const pitchRange = Math.random() * (1.2 - 0.8) + 0.8;
        const vanillaWaxedCopperDoors = [
          "minecraft:waxed_copper_door",
          "minecraft:waxed_copper_trapdoor",
          "minecraft:waxed_exposed_copper_door",
          "minecraft:waxed_exposed_copper_trapdoor",
          "minecraft:waxed_weathered_copper_door",
          "minecraft:waxed_weathered_copper_trapdoor",
          "minecraft:waxed_oxidized_copper_door",
          "minecraft:waxed_oxidized_copper_trapdoor"
        ];
        if (vanillaWaxedCopperDoors.includes(block.typeId)) {
          system.run(() => {
            if (!player.isSneaking) return;
            damageDurability ();
            block.dimension.playSound("copper.wax.off", blockLocation, { pitch: pitchRange, volume: 1.0 });
            block.dimension.spawnParticle("nicothekid:copper_wax_off_particle", { x: blockLocation.x, y: blockLocation.y, z: blockLocation.z });
            if (block.permutation.matches("minecraft:waxed_copper_door", { "upper_block_bit": false })) {
              const blockAbove = block.above();
              const blockAboveAllState = blockAbove.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_door", stateAll ));
              blockAbove.setPermutation(BlockPermutation.resolve("minecraft:copper_door", blockAboveAllState ));
            }
            if (block.permutation.matches("minecraft:waxed_copper_door", { "upper_block_bit": true })) {
              const blockBelow = block.below();
              const blockBelowAllState = blockBelow.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_door", stateAll ));
              blockBelow.setPermutation(BlockPermutation.resolve("minecraft:copper_door", blockBelowAllState ));
            }
            if (block.permutation.matches("minecraft:waxed_copper_trapdoor")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_trapdoor", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_exposed_copper_door", { "upper_block_bit": false })) {
              const blockAbove = block.above();
              const blockAboveAllState = blockAbove.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_door", stateAll ));
              blockAbove.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_door", blockAboveAllState ));
            }
            if (block.permutation.matches("minecraft:waxed_exposed_copper_door", { "upper_block_bit": true })) {
              const blockBelow = block.below();
              const blockBelowAllState = blockBelow.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_door", stateAll ));
              blockBelow.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_door", blockBelowAllState ));
            }
            if (block.permutation.matches("minecraft:waxed_exposed_copper_trapdoor")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_trapdoor", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_weathered_copper_door", { "upper_block_bit": false })) {
              const blockAbove = block.above();
              const blockAboveAllState = blockAbove.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_door", stateAll ));
              blockAbove.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_door", blockAboveAllState ));
            }
            if (block.permutation.matches("minecraft:waxed_weathered_copper_door", { "upper_block_bit": true })) {
              const blockBelow = block.below();
              const blockBelowAllState = blockBelow.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_door", stateAll ));
              blockBelow.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_door", blockBelowAllState ));
            }
            if (block.permutation.matches("minecraft:waxed_weathered_copper_trapdoor")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_trapdoor", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_oxidized_copper_door", { "upper_block_bit": false })) {
              const blockAbove = block.above();
              const blockAboveAllState = blockAbove.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:oxidized_copper_door", stateAll ));
              blockAbove.setPermutation(BlockPermutation.resolve("minecraft:oxidized_copper_door", blockAboveAllState ));
            }
            if (block.permutation.matches("minecraft:waxed_oxidized_copper_door", { "upper_block_bit": true })) {
              const blockBelow = block.below();
              const blockBelowAllState = blockBelow.permutation.getAllStates();
              block.setPermutation(BlockPermutation.resolve("minecraft:oxidized_copper_door", stateAll ));
              blockBelow.setPermutation(BlockPermutation.resolve("minecraft:oxidized_copper_door", blockBelowAllState ));
            }
            if (block.permutation.matches("minecraft:waxed_oxidized_copper_trapdoor")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:oxidized_copper_trapdoor", stateAll ));
            }
          });
        }
        else {
          system.run(() => {
            damageDurability ();
            block.dimension.playSound("copper.wax.off", blockLocation, { pitch: pitchRange, volume: 1.0 });
            block.dimension.spawnParticle("nicothekid:copper_wax_off_particle", { x: blockLocation.x, y: blockLocation.y, z: blockLocation.z });
            if (block.permutation.matches("minecraft:waxed_chiseled_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:chiseled_copper"));
            }
            if (block.permutation.matches("minecraft:waxed_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_block"));
            }
            if (block.permutation.matches("minecraft:waxed_copper_bulb")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_bulb", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_copper_grate")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:copper_grate"));
            }
            if (block.permutation.matches("minecraft:waxed_cut_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:cut_copper"));
            }
            if (block.permutation.matches("minecraft:waxed_cut_copper_stairs")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:cut_copper_stairs", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:cut_copper_slab", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_double_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:double_cut_copper_slab"));
            }
            if (block.permutation.matches("minecraft:waxed_exposed_chiseled_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_chiseled_copper"));
            }
            if (block.permutation.matches("minecraft:waxed_exposed_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper"));
            }
            if (block.permutation.matches("minecraft:waxed_exposed_copper_bulb")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_bulb", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_exposed_copper_grate")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_copper_grate"));
            }
            if (block.permutation.matches("minecraft:waxed_exposed_cut_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_cut_copper"));
            }
            if (block.permutation.matches("minecraft:waxed_exposed_cut_copper_stairs")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_cut_copper_stairs", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_exposed_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_cut_copper_slab", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_exposed_double_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:exposed_double_cut_copper_slab"));
            }
            if (block.permutation.matches("minecraft:waxed_weathered_chiseled_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_chiseled_copper"));
            }
            if (block.permutation.matches("minecraft:waxed_weathered_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper"));
            }
            if (block.permutation.matches("minecraft:waxed_weathered_copper_bulb")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_bulb", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_weathered_copper_grate")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_copper_grate"));
            }
            if (block.permutation.matches("minecraft:waxed_weathered_cut_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_cut_copper"));
            }
            if (block.permutation.matches("minecraft:waxed_weathered_cut_copper_stairs")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_cut_copper_stairs", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_weathered_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_cut_copper_slab", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_weathered_double_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:weathered_double_cut_copper_slab"));
            }
            if (block.permutation.matches("minecraft:waxed_oxidized_chiseled_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:oxidized_chiseled_copper"));
            }
            if (block.permutation.matches("minecraft:waxed_oxidized_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:oxidized_copper"));
            }
            if (block.permutation.matches("minecraft:waxed_oxidized_copper_bulb")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:oxidized_copper_bulb", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_oxidized_copper_grate")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:oxidized_copper_grate"));
            }
            if (block.permutation.matches("minecraft:waxed_oxidized_cut_copper")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:oxidized_cut_copper"));
            }
            if (block.permutation.matches("minecraft:waxed_oxidized_cut_copper_stairs")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:oxidized_cut_copper_stairs", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_oxidized_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:oxidized_cut_copper_slab", stateAll ));
            }
            if (block.permutation.matches("minecraft:waxed_oxidized_double_cut_copper_slab")) {
              block.setPermutation(BlockPermutation.resolve("minecraft:oxidized_double_cut_copper_slab"));
            }
          });
        }
      }*/
    }
    if (customHoes.includes(itemUsed.typeId)) {
      const vanillaFarmSoil = [
        "minecraft:coarse_dirt",
        "minecraft:dirt",
        "minecraft:dirt_with_roots",
        "minecraft:grass_block",
        "minecraft:grass_path"
      ];
      if (vanillaFarmSoil.includes(block.typeId)) {
        system.run(() => {
          const blockAbove = block.dimension.getBlock(blockLocation).above(1);
          if (!blockAbove.isAir) return;
          damageDurability ();
          block.dimension.playSound("use.gravel", blockLocation, { pitch: 0.8, volume: 1.0 });
          /*if (block.permutation.matches("minecraft:dirt", { dirt_type: "normal" })) {
            block.setPermutation(BlockPermutation.resolve("minecraft:farmland"));
          }
          if (block.permutation.matches("minecraft:dirt", { dirt_type: "coarse" })) {
            block.setPermutation(BlockPermutation.resolve("minecraft:dirt", { dirt_type: "normal" }));
          }
          if (block.permutation.matches("minecraft:dirt_with_roots")) {
            const spawnHangingRoots = new ItemStack("minecraft:hanging_roots", 1);
            block.dimension.spawnItem(spawnHangingRoots, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("minecraft:dirt", { dirt_type: "normal" }));
          }
          if (block.permutation.matches("minecraft:grass_block")) {
            block.setPermutation(BlockPermutation.resolve("minecraft:farmland"));
          }
          if (block.permutation.matches("minecraft:grass_path")) {
            block.setPermutation(BlockPermutation.resolve("minecraft:farmland"));
          }*/
        });
      }
    }
    if (customShovels.includes(itemUsed.typeId)) {
      const vanillaCampfire = [
        "minecraft:campfire",
        "minecraft:soul_campfire"
      ];
      const vanillaPathSoil = [
        "minecraft:coarse_dirt",
        "minecraft:dirt",
        "minecraft:dirt_with_roots",
        "minecraft:grass_block",
        "minecraft:mycelium",
        "minecraft:podzol"
      ];
      if (vanillaCampfire.includes(block.typeId)) {
        system.run(() => {
          const blockState = block.permutation.getState("minecraft:cardinal_direction");
          const pitchRange = Math.random() * (2.4 - 1.8) + 1.8;
          damageDurability ();
          block.dimension.playSound("random.fizz", blockLocation, { pitch: pitchRange, volume: 0.5 });
          if (block.permutation.matches("minecraft:campfire", { "extinguished": false, "minecraft:cardinal_direction": blockState })) {
            block.setPermutation(BlockPermutation.resolve("minecraft:campfire", { "extinguished": true, "minecraft:cardinal_direction": blockState }));
          }
          if (block.permutation.matches("minecraft:soul_campfire", { "extinguished": false, "minecraft:cardinal_direction": blockState })) {
            block.setPermutation(BlockPermutation.resolve("minecraft:soul_campfire", { "extinguished": true, "minecraft:cardinal_direction": blockState }));
          }
        });
      }
      if (vanillaPathSoil.includes(block.typeId)) {
        system.run(() => {
          const blockAbove = block.dimension.getBlock(blockLocation).above(1);
          if (!blockAbove.isAir) return;
          damageDurability ();
          block.dimension.playSound("use.grass", blockLocation, { pitch: 0.8, volume: 1.0 });
          if (block.permutation.matches("minecraft:dirt", { dirt_type: "normal" })) {
            block.setPermutation(BlockPermutation.resolve("minecraft:grass_path"));
          }
          if (block.permutation.matches("minecraft:dirt", { dirt_type: "coarse" })) {
            block.setPermutation(BlockPermutation.resolve("minecraft:grass_path"));
          }
          if (block.permutation.matches("minecraft:dirt_with_roots")) {
            block.setPermutation(BlockPermutation.resolve("minecraft:grass_path"));
          }
          /*if (block.permutation.matches("minecraft:grass_block")) {
            block.setPermutation(BlockPermutation.resolve("minecraft:grass_path"));
          }*/
          if (block.permutation.matches("minecraft:mycelium")) {
            block.setPermutation(BlockPermutation.resolve("minecraft:grass_path"));
          }
          if (block.permutation.matches("minecraft:podzol")) {
            block.setPermutation(BlockPermutation.resolve("minecraft:grass_path"));
          }
        });
      }
      if (block.typeId === "minecraft:snow_layer") {
        system.run(() => {
          const pitchRange = Math.random() * (1.0 - 0.8) + 0.8;
          damageDurability ();
          block.dimension.playSound("dig.snow", blockLocation, { pitch: pitchRange, volume: 1.0 });
          if (block.permutation.matches("minecraft:snow_layer", { height: 0 })) {
            const spawnSnowball = new ItemStack("minecraft:snowball", 1);
            block.dimension.spawnItem(spawnSnowball, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("minecraft:air"));
          }
          if (block.permutation.matches("minecraft:snow_layer", { height: 1 })) {
            const spawnSnowball = new ItemStack("minecraft:snowball", 1);
            block.dimension.spawnItem(spawnSnowball, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("minecraft:air"));
          }
          if (block.permutation.matches("minecraft:snow_layer", { height: 2 })) {
            const spawnSnowball = new ItemStack("minecraft:snowball", 1);
            block.dimension.spawnItem(spawnSnowball, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("minecraft:air"));
          }
          if (block.permutation.matches("minecraft:snow_layer", { height: 3 })) {
            const spawnSnowball = new ItemStack("minecraft:snowball", 2);
            block.dimension.spawnItem(spawnSnowball, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("minecraft:air"));
          }
          if (block.permutation.matches("minecraft:snow_layer", { height: 4 })) {
            const spawnSnowball = new ItemStack("minecraft:snowball", 2);
            block.dimension.spawnItem(spawnSnowball, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("minecraft:air"));
          }
          if (block.permutation.matches("minecraft:snow_layer", { height: 5 })) {
            const spawnSnowball = new ItemStack("minecraft:snowball", 3);
            block.dimension.spawnItem(spawnSnowball, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("minecraft:air"));
          }
          if (block.permutation.matches("minecraft:snow_layer", { height: 6 })) {
            const spawnSnowball = new ItemStack("minecraft:snowball", 3);
            block.dimension.spawnItem(spawnSnowball, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("minecraft:air"));
          }
          if (block.permutation.matches("minecraft:snow_layer", { height: 7 })) {
            const spawnSnowball = new ItemStack("minecraft:snowball", 4);
            block.dimension.spawnItem(spawnSnowball, { x: blockLocation.x + 0.5, y: blockLocation.y + 0.5, z: blockLocation.z + 0.5 });
            block.setPermutation(BlockPermutation.resolve("minecraft:air"));
          }
        });
      }
    }
  }
  else return;
});
world.afterEvents.itemUse.subscribe(eventData => {
  const player = eventData.source;
  const itemUsed = eventData.itemStack;
  const playerEquippable = player.getComponent("equippable");
  const customStaff = [
    "nicothekid:blazing_staff",
    "nicothekid:powder_staff",
    "nicothekid:staff_of_the_sea"
  ]
  function damageDurability () {
    if (!player.matches({ gameMode: GameMode.creative })) {
      const itemEnchantable = itemUsed.getComponent("minecraft:enchantable");
      const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
      const breakChance = 100 / (unbreakingLevel + 1);
      const randomizeChance = Math.random() * 100;
      if (breakChance < randomizeChance) return;
      const itemDurability = itemUsed.getComponent("durability");
      if (!itemDurability) return;
      const itemMaxDurability = itemDurability.maxDurability;
      const itemDurabilityDamage = itemDurability.damage;
      const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
      let damageAmount = 1;
      const currentDurability = durabilityCalculation - damageAmount;
      if (currentDurability <= 0) {
        player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
        playerEquippable.setEquipment("Mainhand", null);
      }
      else {
        itemDurability.damage += damageAmount;
        playerEquippable.setEquipment("Mainhand", itemUsed)
      }
    }
  }
  if (itemUsed === undefined) return;
  if (customStaff.includes(itemUsed.typeId)) {    
    if (itemUsed.typeId === "nicothekid:blazing_staff") {
      const cooldown = itemUsed.getComponent("cooldown").getCooldownTicksRemaining(player);
      if (cooldown == 47) {
        let projectileEntity = player.dimension.spawnEntity("nicothekid:projectile_blazing_missile", {
          x: player.location.x + (player.getViewDirection().x),
          y: player.location.y + 1.5 + (player.getViewDirection().y),
          z: player.location.z + (player.getViewDirection().z)
        });
        let projectileComponent = projectileEntity.getComponent("minecraft:projectile");
        let velocity = { x: player.getViewDirection().x, y: player.getViewDirection().y, z: player.getViewDirection().z };
        projectileComponent.owner = player;
        projectileComponent.shoot( velocity );
        player.playSound("mob.ghast.fireball", { pitch: 2.0, location: player.location, volume: 1.0 });
        player.playAnimation("attack");
        damageDurability ();
      }
    }
    if (itemUsed.typeId === "nicothekid:powder_staff") {
      const cooldown = itemUsed.getComponent("cooldown").getCooldownTicksRemaining(player);
      const offhandItem = playerEquippable.getEquipment("Offhand");
      const customPowder = [
        "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 (offhandItem === undefined || !customPowder.includes(offhandItem.typeId)) {
        if (cooldown == 43) {
          player.playSound("game.player.attack.nodamage", { pitch: 1.1, location: player.location, volume: 1.0 });
          player.runCommandAsync(`tellraw @p {\"rawtext\":[{\"text\":\"§eYou don't have any powder materials in your off-hand to use as a projectile.§r\"}]}`);
          system.runTimeout(() => {
            player.startItemCooldown("powder_staff", 0 );
            return;
          }, 5);
        }
        else return;
      }
      else if (customPowder.includes(offhandItem.typeId)) {
        if (cooldown == 43) {
          player.playSound("mob.shulker.shoot", { pitch: 1.5, location: player.location, volume: 1.0 });
          player.playAnimation("attack");
        }
        else return;
      }
      else return;
    }
    if (itemUsed.typeId === "nicothekid:staff_of_the_sea") {
      const cooldown = itemUsed.getComponent("cooldown").getCooldownTicksRemaining(player);
      const playerOnBlock = player.dimension.getBlock({ x: player.location.x, y: player.location.y + 0.5, z: player.location.z });
      const validWater = [
        "minecraft:flowing_water",
        "minecraft:water"
      ]
      if (!validWater.includes(playerOnBlock.typeId)) {
        if (cooldown == 799) {
          player.playSound("game.player.attack.nodamage", { pitch: 1.1, location: player.location, volume: 1.0 });
          player.runCommandAsync(`tellraw @p {\"rawtext\":[{\"text\":\"§eYou have to be in water to activate the staff's effect§r\"}]}`);
          system.runTimeout(() => {
            player.startItemCooldown("staff_of_the_sea", 0 );
            return;
          }, 10);
        }
        else return;
      }
      else if (validWater.includes(playerOnBlock.typeId) && cooldown == 799) {
        if (cooldown == 799) {
          player.addEffect("conduit_power", 1800, {amplifier: 0, showParticles: false })
          player.playSound("conduit.activate", { pitch: 1.1, location: player.location, volume: 1.0 });
          player.playAnimation("attack");
          player.dimension.spawnParticle("nicothekid:staff_of_the_sea_activation_particle", { x: player.location.x, y: player.location.y + 0.5, z: player.location.z });
          damageDurability ();
        }
        else return;
      }
      else return;
    }
  }
  else return;
});
world.afterEvents.itemCompleteUse.subscribe(eventData => {
  const player = eventData.source;
  const itemUsed = eventData.itemStack;
	const customFoods = [
    "nicothekid:amethyst_apple",
    "nicothekid:apple_pie",
    "nicothekid:bamboo_tumbler_chocolate",
    "nicothekid:bamboo_tumbler_glow_berry",
    "nicothekid:bamboo_tumbler_milk",
    "nicothekid:bamboo_tumbler_sweet_berry",
    "nicothekid:blazing_apple",
    "nicothekid:cactus_stew",
    "nicothekid:carrot_soup",
    "nicothekid:cheese",
    "nicothekid:cheese_bread",
    "nicothekid:chocolate_bar",
    "nicothekid:crimson_stew",
    "nicothekid:diamond_apple",
    "nicothekid:egg_sandwich",
    "nicothekid:emerald_apple",
    "nicothekid:glow_berry_cookie",
    "nicothekid:glow_berry_pie",
    "nicothekid:glow_lichen_stew",
    "nicothekid:iron_apple",
    "nicothekid:jar_chocolate_full",
    "nicothekid:jar_chocolate_half",
    "nicothekid:jar_glow_berry_juice_full",
    "nicothekid:jar_glow_berry_juice_half",
    "nicothekid:jar_honey_full",
    "nicothekid:jar_honey_half",
    "nicothekid:jar_milk_full",
    "nicothekid:jar_milk_half",
    "nicothekid:jar_sweet_berry_juice_full",
    "nicothekid:jar_sweet_berry_juice_half",
    "nicothekid:lapis_lazuli_apple",
    "nicothekid:netherite_apple",
    "nicothekid:pea_stew",
    "nicothekid:potato_soup",
    "nicothekid:pumpkin_slice",
    "nicothekid:seagrass_stew",
    "nicothekid:soup",
    "nicothekid:sweet_berry_cookie",
    "nicothekid:sweet_berry_pie",
    "nicothekid:warped_stew"
  ]
	if (customFoods.includes(itemUsed.typeId)) {
    if (itemUsed.typeId === "nicothekid:amethyst_apple") {
      player.addEffect("night_vision", 1200, {amplifier: 0, showParticles: true })
      player.addEffect("regeneration", 100, {amplifier: 1, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:apple_pie") {
      player.addEffect("instant_health", 200, {amplifier: 1, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:bamboo_tumbler_chocolate") {
      player.removeEffect("slowness")
    }
    if (itemUsed.typeId === "nicothekid:bamboo_tumbler_glow_berry") {
      player.removeEffect("blindness")
    }
    if (itemUsed.typeId === "nicothekid:bamboo_tumbler_milk") {
      player.removeEffect("nausea")
      player.removeEffect("fatal_poison")
      player.removeEffect("levitation")
      player.removeEffect("poison")
      player.removeEffect("weakness")
    }
    if (itemUsed.typeId === "nicothekid:bamboo_tumbler_sweet_berry") {
      player.removeEffect("hunger")
    }
    if (itemUsed.typeId === "nicothekid:blazing_apple") {
      player.addEffect("fire_resistance", 1200, {amplifier: 0, showParticles: true })
      player.addEffect("regeneration", 100, {amplifier: 1, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:cactus_stew") {
      let nauseaChance = Math.random();
      if (nauseaChance <= 0.5) {
        player.addEffect("nausea", 300, {amplifier: 0, showParticles: true })
      }
    }
    if (itemUsed.typeId === "nicothekid:carrot_soup") {
      player.removeEffect("hunger")
      player.removeEffect("nausea")
    }
    if (itemUsed.typeId === "nicothekid:cheese") {
      let nauseaChance = Math.random();
      if (nauseaChance <= 0.1) {
        player.addEffect("nausea", 300, {amplifier: 0, showParticles: true })
      }
    }
    if (itemUsed.typeId === "nicothekid:cheese_bread") {
      let regenerationChance = Math.random();
      if (regenerationChance <= 0.05) {
        player.addEffect("regeneration", 200, {amplifier: 0, showParticles: true })
      }
    }
    if (itemUsed.typeId === "nicothekid:chocolate_bar") {
      let speedChance = Math.random();
      if (speedChance <= 0.5) {
        player.addEffect("speed", 400, {amplifier: 0, showParticles: true })
      }
    }
    if (itemUsed.typeId === "nicothekid:crimson_stew") {
      let nauseaChance = Math.random();
      let poisonChance = Math.random();
      if (nauseaChance <= 0.25) {
        player.addEffect("nausea", 300, {amplifier: 0, showParticles: true })
      }
      if (poisonChance <= 0.1) {
        player.addEffect("poison", 200, {amplifier: 0, showParticles: true })
      }
    }
    if (itemUsed.typeId === "nicothekid:diamond_apple") {
      player.addEffect("resistance", 3600, {amplifier: 2, showParticles: true })
      player.addEffect("absorption", 1200, {amplifier: 1, showParticles: true })
      player.addEffect("health_boost", 600, {amplifier: 0, showParticles: true })
      player.addEffect("regeneration", 300, {amplifier: 1, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:egg_sandwich") {
      let regenerationChance = Math.random();
      if (regenerationChance <= 0.05) {
        player.addEffect("regeneration", 100, {amplifier: 0, showParticles: true })
      }
    }
    if (itemUsed.typeId === "nicothekid:emerald_apple") {
      player.addEffect("haste", 1200, {amplifier: 1, showParticles: true })
      player.addEffect("regeneration", 300, {amplifier: 1, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:glow_berry_cookie") {
      player.addEffect("night_vision", 200, {amplifier: 0, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:glow_berry_pie") {
      player.addEffect("night_vision", 900, {amplifier: 0, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:glow_lichen_stew") {
      player.addEffect("night_vision", 500, {amplifier: 0, showParticles: true })
      player.addEffect("mining_fatigue", 400, {amplifier: 0, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:iron_apple") {
      player.addEffect("strength", 1200, {amplifier: 1, showParticles: true })
      player.addEffect("regeneration", 300, {amplifier: 1, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:jar_chocolate_full") {
      player.removeEffect("slowness")
    }
    if (itemUsed.typeId === "nicothekid:jar_chocolate_half") {
      player.removeEffect("slowness")
    }
    if (itemUsed.typeId === "nicothekid:jar_glow_berry_juice_full") {
      player.removeEffect("blindness")
    }
    if (itemUsed.typeId === "nicothekid:jar_glow_berry_juice_half") {
      player.removeEffect("blindness")
    }
    if (itemUsed.typeId === "nicothekid:jar_honey_full") {
      player.removeEffect("poison")
      player.removeEffect("fatal_poison")
    }
    if (itemUsed.typeId === "nicothekid:jar_honey_half") {
      player.removeEffect("poison")
      player.removeEffect("fatal_poison")
    }
    if (itemUsed.typeId === "nicothekid:jar_milk_full") {
      player.removeEffect("fatal_poison")
      player.removeEffect("levitation")
      player.removeEffect("mining_fatigue")
      player.removeEffect("nausea")
      player.removeEffect("poison")
      player.removeEffect("weakness")
    }
    if (itemUsed.typeId === "nicothekid:jar_milk_half") {
      player.removeEffect("fatal_poison")
      player.removeEffect("levitation")
      player.removeEffect("mining_fatigue")
      player.removeEffect("nausea")
      player.removeEffect("poison")
      player.removeEffect("weakness")
    }
    if (itemUsed.typeId === "nicothekid:jar_sweet_berry_juice_full") {
      player.removeEffect("hunger")
    }
    if (itemUsed.typeId === "nicothekid:jar_sweet_berry_juice_half") {
      player.removeEffect("hunger")
    }
    if (itemUsed.typeId === "nicothekid:lapis_lazuli_apple") {
      player.addEffect("speed", 1200, {amplifier: 1, showParticles: true })
      player.addEffect("regeneration", 300, {amplifier: 1, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:netherite_apple") {
      player.addEffect("resistance", 4800, {amplifier: 2, showParticles: true })
      player.addEffect("absorption", 3600, {amplifier: 1, showParticles: true })
      player.addEffect("strength", 3600, {amplifier: 1, showParticles: true })
      player.addEffect("regeneration", 1200, {amplifier: 1, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:pea_stew") {
      let nauseaChance = Math.random();
      if (nauseaChance <= 0.1) {
        player.addEffect("nausea", 200, {amplifier: 0, showParticles: true })
      }
    }
    if (itemUsed.typeId === "nicothekid:potato_soup") {
      player.removeEffect("hunger")
      player.removeEffect("nausea")
    }
    if (itemUsed.typeId === "nicothekid:pumpkin_slice") {
      let nauseaChance = Math.random();
      if (nauseaChance <= 0.25) {
        player.addEffect("nausea", 300, {amplifier: 0, showParticles: true })
      }
    }
    if (itemUsed.typeId === "nicothekid:seagrass_stew") {
      let nauseaChance = Math.random();
      if (nauseaChance <= 0.25) {
        player.addEffect("nausea", 300, {amplifier: 0, showParticles: true })
      }
    }
    if (itemUsed.typeId === "nicothekid:soup") {
      player.removeEffect("hunger")
    }
    if (itemUsed.typeId === "nicothekid:sweet_berry_cookie") {
      player.addEffect("regeneration", 200, {amplifier: 0, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:sweet_berry_pie") {
      player.addEffect("regeneration", 300, {amplifier: 0, showParticles: true })
    }
    if (itemUsed.typeId === "nicothekid:warped_stew") {
      let nauseaChance = Math.random();
      let poisonChance = Math.random();
      if (nauseaChance <= 0.25) {
        player.addEffect("nausea", 300, {amplifier: 0, showParticles: true })
      }
      if (poisonChance <= 0.1) {
        player.addEffect("poison", 200, {amplifier: 0, showParticles: true })
      }
    }
	}
	else return;
});
world.afterEvents.playerBreakBlock.subscribe(eventData => {
  const player = eventData.player;
  const itemUsed = eventData.itemStackBeforeBreak;
  const brokenBlock = eventData.brokenBlockPermutation;
  const playerEquippable = player.getComponent("equippable");
  const instantDiggableBlocks = [
    "minecraft:acacia_sapling",
    "minecraft:allium",
    "minecraft:azalea",
    "minecraft:azure_bluet",
    "minecraft:beetroot",
    "minecraft:birch_sapling",
    "minecraft:blue_orchid",
    "minecraft:brain_coral",
    "minecraft:brain_coral_fan",
    "minecraft:brown_mushroom",
    "minecraft:bubble_coral",
    "minecraft:bubble_coral_fan",
    "minecraft:carrots",
    "minecraft:cave_vines",
    "minecraft:cave_vines_body_with_berries",
    "minecraft:cave_vines_head_with_berries",
    "minecraft:cherry_sapling",
    "minecraft:coral_fan_dead",
    "minecraft:coral_fan_hang",
    "minecraft:coral_fan_hang2",
    "minecraft:coral_fan_hang3",
    "minecraft:cornflower",
    "minecraft:crimson_fungus",
    "minecraft:crimson_roots",
    "minecraft:dark_oak_sapling",
    "minecraft:dead_brain_coral",
    "minecraft:dead_brain_coral_fan",
    "minecraft:dead_bubble_coral",
    "minecraft:dead_bubble_coral_fan",
    "minecraft:dead_fire_coral",
    "minecraft:dead_fire_coral_fan",
    "minecraft:dead_horn_coral",
    "minecraft:dead_horn_coral_fan",
    "minecraft:dead_tube_coral",
    "minecraft:dead_tube_coral_fan",
    "minecraft:deadbush",
    "minecraft:decorated_pot",
    "minecraft:double_plant", // old name
    "minecraft:end_rod",
    "minecraft:fern",
    "minecraft:fire",
    "minecraft:fire_coral",
    "minecraft:fire_coral_fan",
    "minecraft:flowering_azalea",
    "minecraft:flower_pot",
    "minecraft:frog_spawn",
    "minecraft:honey_block",
    "minecraft:hanging_roots",
    "minecraft:horn_coral",
    "minecraft:horn_coral_fan",
    "minecraft:jungle_sapling",
    "minecraft:kelp",
    "minecraft:lily_of_the_valley",
    "minecraft:mangrove_propagule",
    "minecraft:melon_stem",
    "minecraft:nether_sprouts",
    "minecraft:nether_wart",
    "minecraft:oak_sapling",
    "minecraft:orange_tulip",
    "minecraft:oxeye_daisy",
    "minecraft:pink_petals",
    "minecraft:pink_tulip",
    "minecraft:pitcher_plant",
    "minecraft:poppy",
    "minecraft:potatoes",
    "minecraft:powered_comparator",
    "minecraft:powered_repeater",
    "minecraft:pumpkin_stem",
    "minecraft:red_flower", // old name
    "minecraft:red_mushroom",
    "minecraft:red_tulip",
    "minecraft:redstone_torch",
    "minecraft:redstone_wire",
    "minecraft:reeds",
    "minecraft:sea_pickle",
    "minecraft:seagrass",
    "minecraft:short_grass",
    "minecraft:slime",
    "minecraft:soul_fire",
    "minecraft:soul_torch",
    "minecraft:spore_blossom",
    "minecraft:spruce_sapling",
    "minecraft:sweet_berry_bush",
    "minecraft:tallgrass", // old name
    "minecraft:tnt",
    "minecraft:torch",
    "minecraft:torchflower",
    "minecraft:tube_coral",
    "minecraft:tube_coral_fan",
    "minecraft:trip_wire",
    "minecraft:tripwire_hook",
    "minecraft:twisting_vines",
    "minecraft:unlit_redstone_torch",
    "minecraft:unpowered_comparator",
    "minecraft:unpowered_repeater",
    "minecraft:warped_fungus",
    "minecraft:warped_roots",
    "minecraft:waterlily",
    "minecraft:weeping_vines",
    "minecraft:wheat",
    "minecraft:white_tulip",
    "minecraft:wither_rose",
    "minecraft:yellow_flower",
    "minecraft:tall_grass",
    "minecraft:large_fern",
    "minecraft:sunflower",
    "minecraft:lilac",
    "minecraft:rose_bush",
    "minecraft:peony"
  ]
  const customAxes = [
    "nicothekid:copper_axe"
  ]
  const axeDiggableBlocks = [
    "minecraft:acacia_button",
    "minecraft:acacia_door",
    "minecraft:acacia_double_slab",
    "minecraft:acacia_fence",
    "minecraft:acacia_fence_gate",
    "minecraft:acacia_hanging_sign",
    "minecraft:acacia_log",
    "minecraft:acacia_planks",
    "minecraft:acacia_pressure_plate",
    "minecraft:acacia_slab",
    "minecraft:acacia_stairs",
    "minecraft:acacia_standing_sign",
    "minecraft:acacia_trapdoor",
    "minecraft:acacia_wall_sign",
    "minecraft:acacia_wood",
    "minecraft:bamboo",
    "minecraft:bamboo_block",
    "minecraft:bamboo_button",
    "minecraft:bamboo_door",
    "minecraft:bamboo_double_slab",
    "minecraft:bamboo_fence",
    "minecraft:bamboo_fence_gate",
    "minecraft:bamboo_hanging_sign",
    "minecraft:bamboo_mosaic",
    "minecraft:bamboo_mosaic_double_slab",
    "minecraft:bamboo_mosaic_slab",
    "minecraft:bamboo_mosaic_stairs",
    "minecraft:bamboo_planks",
    "minecraft:bamboo_pressure_plate",
    "minecraft:bamboo_sapling",
    "minecraft:bamboo_slab",
    "minecraft:bamboo_stairs",
    "minecraft:bamboo_standing_sign",
    "minecraft:bamboo_trapdoor",
    "minecraft:bamboo_wall_sign",
    "minecraft:barrel",
    "minecraft:bee_nest",
    "minecraft:beehive",
    "minecraft:birch_button",
    "minecraft:birch_door",
    "minecraft:birch_double_slab",
    "minecraft:birch_fence",
    "minecraft:birch_fence_gate",
    "minecraft:birch_hanging_sign",
    "minecraft:birch_log",
    "minecraft:birch_planks",
    "minecraft:birch_pressure_plate",
    "minecraft:birch_slab",
    "minecraft:birch_stairs",
    "minecraft:birch_standing_sign",
    "minecraft:birch_trapdoor",
    "minecraft:birch_wall_sign",
    "minecraft:birch_wood",
    "minecraft:bookshelf",
    "minecraft:brown_mushroom_block",
    "minecraft:campfire",
    "minecraft:cartography_table",
    "minecraft:carved_pumpkin",
    "minecraft:cherry_button",
    "minecraft:cherry_door",
    "minecraft:cherry_double_slab",
    "minecraft:cherry_fence",
    "minecraft:cherry_fence_gate",
    "minecraft:cherry_hanging_sign",
    "minecraft:cherry_log",
    "minecraft:cherry_planks",
    "minecraft:cherry_pressure_plate",
    "minecraft:cherry_slab",
    "minecraft:cherry_stairs",
    "minecraft:cherry_standing_sign",
    "minecraft:cherry_trapdoor",
    "minecraft:cherry_wall_sign",
    "minecraft:cherry_wood",
    "minecraft:chest",
    "minecraft:chiseled_bookshelf",
    "minecraft:chorus_flower",
    "minecraft:chorus_plant",
    "minecraft:cocoa",
    "minecraft:composter",
    "minecraft:crafting_table",
    "minecraft:crimson_button",
    "minecraft:crimson_door",
    "minecraft:crimson_double_slab",
    "minecraft:crimson_fence",
    "minecraft:crimson_fence_gate",
    "minecraft:crimson_hanging_sign",
    "minecraft:crimson_hyphae",
    "minecraft:crimson_planks",
    "minecraft:crimson_pressure_plate",
    "minecraft:crimson_slab",
    "minecraft:crimson_stairs",
    "minecraft:crimson_standing_sign",
    "minecraft:crimson_stem",
    "minecraft:crimson_trapdoor",
    "minecraft:crimson_wall_sign",
    "minecraft:dark_oak_button",
    "minecraft:dark_oak_door",
    "minecraft:dark_oak_double_slab",
    "minecraft:dark_oak_fence",
    "minecraft:dark_oak_fence_gate",
    "minecraft:dark_oak_hanging_sign",
    "minecraft:dark_oak_log",
    "minecraft:dark_oak_planks",
    "minecraft:dark_oak_pressure_plate",
    "minecraft:dark_oak_slab",
    "minecraft:dark_oak_stairs",
    "minecraft:dark_oak_trapdoor",
    "minecraft:dark_oak_wood",
    "minecraft:darkoak_standing_sign",
    "minecraft:darkoak_wall_sign",
    "minecraft:daylight_detector",
    "minecraft:daylight_detector_inverted",
    "minecraft:fence", // old name
    "minecraft:fence_gate",
    "minecraft:fletching_table",
    "minecraft:jukebox",
    "minecraft:jungle_button",
    "minecraft:jungle_door",
    "minecraft:jungle_double_slab",
    "minecraft:jungle_fence",
    "minecraft:jungle_fence_gate",
    "minecraft:jungle_hanging_sign",
    "minecraft:jungle_log",
    "minecraft:jungle_planks",
    "minecraft:jungle_pressure_plate",
    "minecraft:jungle_slab",
    "minecraft:jungle_stairs",
    "minecraft:jungle_standing_sign",
    "minecraft:jungle_trapdoor",
    "minecraft:jungle_wall_sign",
    "minecraft:jungle_wood",
    "minecraft:ladder",
    "minecraft:lectern",
    "minecraft:lit_pumpkin",
    "minecraft:log", // old name
    "minecraft:log2", // old name
    "minecraft:loom",
    "minecraft:mangrove_button",
    "minecraft:mangrove_door",
    "minecraft:mangrove_double_slab",
    "minecraft:mangrove_fence",
    "minecraft:mangrove_fence_gate",
    "minecraft:mangrove_hanging_sign",
    "minecraft:mangrove_log",
    "minecraft:mangrove_planks",
    "minecraft:mangrove_pressure_plate",
    "minecraft:mangrove_roots",
    "minecraft:mangrove_slab",
    "minecraft:mangrove_stairs",
    "minecraft:mangrove_standing_sign",
    "minecraft:mangrove_trapdoor",
    "minecraft:mangrove_wall_sign",
    "minecraft:mangrove_wood",
    "minecraft:melon_block",
    "minecraft:noteblock",
    "minecraft:oak_double_slab",
    "minecraft:oak_fence",
    "minecraft:oak_hanging_sign",
    "minecraft:oak_log",
    "minecraft:oak_planks",
    "minecraft:oak_slab",
    "minecraft:oak_stairs",
    "minecraft:oak_wood",
    "minecraft:pumpkin",
    "minecraft:red_mushroom_block",
    "minecraft:smithing_table",
    "minecraft:soul_campfire",
    "minecraft:spruce_button",
    "minecraft:spruce_door",
    "minecraft:spruce_double_slab",
    "minecraft:spruce_fence",
    "minecraft:spruce_fence_gate",
    "minecraft:spruce_hanging_sign",
    "minecraft:spruce_log",
    "minecraft:spruce_planks",
    "minecraft:spruce_pressure_plate",
    "minecraft:spruce_slab",
    "minecraft:spruce_stairs",
    "minecraft:spruce_standing_sign",
    "minecraft:spruce_trapdoor",
    "minecraft:spruce_wall_sign",
    "minecraft:spruce_wood",
    "minecraft:standing_banner",
    "minecraft:standing_sign",
    "minecraft:stripped_acacia_log",
    "minecraft:stripped_acacia_wood",
    "minecraft:stripped_bamboo_block",
    "minecraft:stripped_birch_log",
    "minecraft:stripped_birch_wood",
    "minecraft:stripped_cherry_log",
    "minecraft:stripped_cherry_wood",
    "minecraft:stripped_crimson_hyphae",
    "minecraft:stripped_crimson_stem",
    "minecraft:stripped_dark_oak_log",
    "minecraft:stripped_dark_oak_wood",
    "minecraft:stripped_jungle_log",
    "minecraft:stripped_jungle_wood",
    "minecraft:stripped_mangrove_log",
    "minecraft:stripped_mangrove_wood",
    "minecraft:stripped_oak_log",
    "minecraft:stripped_oak_wood",
    "minecraft:stripped_spruce_log",
    "minecraft:stripped_spruce_wood",
    "minecraft:stripped_warped_hyphae",
    "minecraft:stripped_warped_stem",
    "minecraft:trapdoor",
    "minecraft:trapped_chest",
    "minecraft:vine",
    "minecraft:wall_banner",
    "minecraft:wall_sign",
    "minecraft:warped_button",
    "minecraft:warped_door",
    "minecraft:warped_double_slab",
    "minecraft:warped_fence",
    "minecraft:warped_fence_gate",
    "minecraft:warped_hanging_sign",
    "minecraft:warped_hyphae",
    "minecraft:warped_planks",
    "minecraft:warped_pressure_plate",
    "minecraft:warped_slab",
    "minecraft:warped_stairs",
    "minecraft:warped_standing_sign",
    "minecraft:warped_stem",
    "minecraft:warped_trapdoor",
    "minecraft:warped_wall_sign",
    "minecraft:wooden_button",
    "minecraft:wooden_door",
    "minecraft:wooden_pressure_plate"
  ]
  const customHoes = [
    "nicothekid:copper_hoe"
  ]
  const hoeDiggableBlocks = [
    "minecraft:acacia_leaves",
    "minecraft:azalea_leaves",
    "minecraft:azalea_leaves_flowered",
    "minecraft:birch_leaves",
    "minecraft:calibrated_sculk_sensor",
    "minecraft:cherry_leaves",
    "minecraft:dark_oak_leaves",
    "minecraft:hay_block",
    "minecraft:jungle_leaves",
    "minecraft:mangrove_leaves",
    "minecraft:nether_wart_block",
    "minecraft:oak_leaves",
    "minecraft:shroomlight",
    "minecraft:sculk",
    "minecraft:sculk_vein",
    "minecraft:sculk_catalyst",
    "minecraft:sculk_sensor",
    "minecraft:sculk_shrieker",
    "minecraft:sponge",
    "minecraft:spruce_leaves",
    "minecraft:target",
    "minecraft:warped_wart_block"
  ]
  const customPickaxes = [
    "nicothekid:copper_pickaxe"
  ]
  const pickaxeDiggableBlocks = [
    "minecraft:activator_rail",
    "minecraft:amethyst_block",
    "minecraft:amethyst_cluster",
    "minecraft:ancient_debris",
    "minecraft:andesite",
    "minecraft:andesite_stairs",
    "minecraft:anvil",
    "minecraft:basalt",
    "minecraft:bell",
    "minecraft:black_concrete",
    "minecraft:black_glazed_terracotta",
    "minecraft:black_shulker_box",
    "minecraft:black_terracotta",
    "minecraft:blackstone",
    "minecraft:blackstone_double_slab",
    "minecraft:blackstone_slab",
    "minecraft:blackstone_stairs",
    "minecraft:blackstone_wall",
    "minecraft:blast_furnace",
    "minecraft:blue_concrete",
    "minecraft:blue_glazed_terracotta",
    "minecraft:blue_ice",
    "minecraft:blue_shulker_box",
    "minecraft:blue_terracotta",
    "minecraft:bone_block",
    "minecraft:brain_coral_block",
    "minecraft:brewing_stand",
    "minecraft:brick_block",
    "minecraft:brick_slab",
    "minecraft:brick_stairs",
    "minecraft:brown_concrete",
    "minecraft:brown_glazed_terracotta",
    "minecraft:brown_shulker_box",
    "minecraft:brown_terracotta",
    "minecraft:bubble_coral_block",
    "minecraft:budding_amethyst",
    "minecraft:calcite",
    "minecraft:cauldron",
    "minecraft:chain",
    "minecraft:chiseled_copper",
    "minecraft:chiseled_deepslate",
    "minecraft:chiseled_nether_bricks",
    "minecraft:chiseled_polished_blackstone",
    "minecraft:chiseled_tuff",
    "minecraft:chiseled_tuff_bricks",
    "minecraft:coal_block",
    "minecraft:coal_ore",
    "minecraft:cobbled_deepslate",
    "minecraft:cobbled_deepslate_double_slab",
    "minecraft:cobbled_deepslate_slab",
    "minecraft:cobbled_deepslate_stairs",
    "minecraft:cobbled_deepslate_wall",
    "minecraft:cobblestone",
    "minecraft:cobblestone_slab",
    "minecraft:cobblestone_wall",
    "minecraft:concrete", // old name
    "minecraft:conduit",
    "minecraft:copper_block",
    "minecraft:copper_bulb",
    "minecraft:copper_door",
    "minecraft:copper_grate",
    "minecraft:copper_ore",
    "minecraft:copper_trapdoor",
    "minecraft:coral_block", // old name
    "minecraft:cracked_deepslate_bricks",
    "minecraft:cracked_deepslate_tiles",
    "minecraft:cracked_nether_bricks",
    "minecraft:cracked_polished_blackstone_bricks",
    "minecraft:crafter",
    "minecraft:crimson_nylium",
    "minecraft:crying_obsidian",
    "minecraft:cut_copper",
    "minecraft:cut_copper_slab",
    "minecraft:cut_copper_stairs",
    "minecraft:cyan_concrete",
    "minecraft:cyan_glazed_terracotta",
    "minecraft:cyan_shulker_box",
    "minecraft:cyan_terracotta",
    "minecraft:dark_prismarine_stairs",
    "minecraft:dead_brain_coral_block",
    "minecraft:dead_bubble_coral_block",
    "minecraft:dead_fire_coral_block",
    "minecraft:dead_horn_coral_block",
    "minecraft:dead_tube_coral_block",
    "minecraft:deepslate",
    "minecraft:deepslate_brick_double_slab",
    "minecraft:deepslate_brick_slab",
    "minecraft:deepslate_brick_stairs",
    "minecraft:deepslate_brick_wall",
    "minecraft:deepslate_bricks",
    "minecraft:deepslate_coal_ore",
    "minecraft:deepslate_copper_ore",
    "minecraft:deepslate_gold_ore",
    "minecraft:deepslate_iron_ore",
    "minecraft:deepslate_lapis_ore",
    "minecraft:deepslate_redstone_ore",
    "minecraft:deepslate_tile_double_slab",
    "minecraft:deepslate_tile_slab",
    "minecraft:deepslate_tile_stairs",
    "minecraft:deepslate_tile_wall",
    "minecraft:deepslate_tiles",
    "minecraft:detector_rail",
    "minecraft:diamond_block",
    "minecraft:diamond_ore",
    "minecraft:diorite",
    "minecraft:diorite_stairs",
    "minecraft:dispenser",
    "minecraft:double_cut_copper_slab",
    "minecraft:double_stone_slab",
    "minecraft:double_stone_slab2",
    "minecraft:double_stone_slab3",
    "minecraft:double_stone_slab4",
    "minecraft:dripstone_block",
    "minecraft:dropper",
    "minecraft:emerald_block",
    "minecraft:emerald_ore",
    "minecraft:enchanting_table",
    "minecraft:end_brick_stairs",
    "minecraft:end_bricks",
    "minecraft:end_stone",
    "minecraft:ender_chest",
    "minecraft:exposed_chiseled_copper",
    "minecraft:exposed_copper",
    "minecraft:exposed_copper_bulb",
    "minecraft:exposed_copper_door",
    "minecraft:exposed_copper_grate",
    "minecraft:exposed_copper_trapdoor",
    "minecraft:exposed_cut_copper",
    "minecraft:exposed_cut_copper_slab",
    "minecraft:exposed_cut_copper_stairs",
    "minecraft:exposed_double_cut_copper_slab",
    "minecraft:fire_coral_block",
    "minecraft:furnace",
    "minecraft:gilded_blackstone",
    "minecraft:gold_block",
    "minecraft:gold_ore",
    "minecraft:golden_rail",
    "minecraft:granite",
    "minecraft:granite_stairs",
    "minecraft:gray_concrete",
    "minecraft:gray_glazed_terracotta",
    "minecraft:gray_shulker_box",
    "minecraft:gray_terracotta",
    "minecraft:green_concrete",
    "minecraft:green_glazed_terracotta",
    "minecraft:green_shulker_box",
    "minecraft:green_terracotta",
    "minecraft:grindstone",
    "minecraft:hardened_clay",
    "minecraft:heavy_core",
    "minecraft:heavy_weighted_pressure_plate",
    "minecraft:hopper",
    "minecraft:horn_coral_block",
    "minecraft:ice",
    "minecraft:infested_deepslate",
    "minecraft:iron_bars",
    "minecraft:iron_block",
    "minecraft:iron_door",
    "minecraft:iron_ore",
    "minecraft:iron_trapdoor",
    "minecraft:lantern",
    "minecraft:lapis_block",
    "minecraft:lapis_ore",
    "minecraft:large_amethyst_bud",
    "minecraft:light_blue_concrete",
    "minecraft:light_blue_glazed_terracotta",
    "minecraft:light_blue_shulker_box",
    "minecraft:light_blue_terracotta",
    "minecraft:light_gray_concrete",
    "minecraft:light_gray_shulker_box",
    "minecraft:light_gray_terracotta",
    "minecraft:light_weighted_pressure_plate",
    "minecraft:lightning_rod",
    "minecraft:lime_concrete",
    "minecraft:lime_glazed_terracotta",
    "minecraft:lime_shulker_box",
    "minecraft:lime_terracotta",
    "minecraft:lit_blast_furnace",
    "minecraft:lit_furnace",
    "minecraft:lit_redstone_ore",
    "minecraft:lit_smoker",
    "minecraft:lodestone",
    "minecraft:magenta_concrete",
    "minecraft:magenta_glazed_terracotta",
    "minecraft:magenta_shulker_box",
    "minecraft:magenta_terracotta",
    "minecraft:magma",
    "minecraft:medium_amethyst_bud",
    "minecraft:mob_spawner",
    "minecraft:monster_egg",
    "minecraft:mossy_cobblestone",
    "minecraft:mossy_cobblestone_stairs",
    "minecraft:mossy_stone_brick_stairs",
    "minecraft:mud_brick_double_slab",
    "minecraft:mud_brick_slab",
    "minecraft:mud_brick_stairs",
    "minecraft:mud_brick_wall",
    "minecraft:mud_bricks",
    "minecraft:nether_brick",
    "minecraft:nether_brick_fence",
    "minecraft:nether_brick_slab",
    "minecraft:nether_brick_stairs",
    "minecraft:nether_gold_ore",
    "minecraft:netherite_block",
    "minecraft:netherrack",
    "minecraft:normal_stone_stairs",
    "minecraft:observer",
    "minecraft:obsidian",
    "minecraft:orange_concrete",
    "minecraft:orange_glazed_terracotta",
    "minecraft:orange_shulker_box",
    "minecraft:orange_terracotta",
    "minecraft:oxidized_chiseled_copper",
    "minecraft:oxidized_copper",
    "minecraft:oxidized_copper_bulb",
    "minecraft:oxidized_copper_door",
    "minecraft:oxidized_copper_grate",
    "minecraft:oxidized_copper_trapdoor",
    "minecraft:oxidized_cut_copper",
    "minecraft:oxidized_cut_copper_slab",
    "minecraft:oxidized_cut_copper_stairs",
    "minecraft:oxidized_double_cut_copper_slab",
    "minecraft:packed_ice",
    "minecraft:packed_mud",
    "minecraft:pink_concrete",
    "minecraft:pink_glazed_terracotta",
    "minecraft:pink_shulker_box",
    "minecraft:pink_terracotta",
    "minecraft:piston",
    "minecraft:pointed_dripstone",
    "minecraft:polished_andesite",
    "minecraft:polished_andesite_stairs",
    "minecraft:polished_basalt",
    "minecraft:polished_blackstone",
    "minecraft:polished_blackstone_brick_double_slab",
    "minecraft:polished_blackstone_brick_slab",
    "minecraft:polished_blackstone_brick_stairs",
    "minecraft:polished_blackstone_brick_wall",
    "minecraft:polished_blackstone_bricks",
    "minecraft:polished_blackstone_button",
    "minecraft:polished_blackstone_double_slab",
    "minecraft:polished_blackstone_pressure_plate",
    "minecraft:polished_blackstone_slab",
    "minecraft:polished_blackstone_stairs",
    "minecraft:polished_blackstone_wall",
    "minecraft:polished_deepslate",
    "minecraft:polished_deepslate_double_slab",
    "minecraft:polished_deepslate_slab",
    "minecraft:polished_deepslate_stairs",
    "minecraft:polished_deepslate_wall",
    "minecraft:polished_diorite",
    "minecraft:polished_diorite_stairs",
    "minecraft:polished_granite",
    "minecraft:polished_granite_stairs",
    "minecraft:polished_tuff",
    "minecraft:polished_tuff_double_slab",
    "minecraft:polished_tuff_slab",
    "minecraft:polished_tuff_stairs",
    "minecraft:polished_tuff_wall",
    "minecraft:prismarine",
    "minecraft:prismarine_bricks_stairs",
    "minecraft:prismarine_stairs",
    "minecraft:purple_concrete",
    "minecraft:purple_glazed_terracotta",
    "minecraft:purple_shulker_box",
    "minecraft:purple_terracotta",
    "minecraft:purpur_block",
    "minecraft:purpur_stairs",
    "minecraft:quartz_block",
    "minecraft:quartz_bricks",
    "minecraft:quartz_ore",
    "minecraft:quartz_slab",
    "minecraft:quartz_stairs",
    "minecraft:rail",
    "minecraft:raw_copper_block",
    "minecraft:raw_gold_block",
    "minecraft:raw_iron_block",
    "minecraft:red_concrete",
    "minecraft:red_glazed_terracotta",
    "minecraft:red_nether_brick",
    "minecraft:red_nether_brick_stairs",
    "minecraft:red_sandstone",
    "minecraft:red_sandstone_stairs",
    "minecraft:red_shulker_box",
    "minecraft:red_terracotta",
    "minecraft:redstone_block",
    "minecraft:redstone_ore"
    "minecraft:respawn_anchor",
    "minecraft:sandstone",
    "minecraft:sandstone_slab",
    "minecraft:sandstone_stairs",
    "minecraft:shulker_box", // old name
    "minecraft:silver_glazed_terracotta",
    "minecraft:small_amethyst_bud",
    "minecraft:smoker",
    "minecraft:smooth_basalt",
    "minecraft:smooth_quartz_stairs",
    "minecraft:smooth_red_sandstone_stairs",
    "minecraft:smooth_sandstone_stairs",
    "minecraft:smooth_stone",
    "minecraft:smooth_stone_slab",
    "minecraft:soul_lantern",
    "minecraft:stained_hardened_clay", // old name
    "minecraft:sticky_piston",
    "minecraft:stone",
    "minecraft:stone_brick_slab",
    "minecraft:stone_brick_stairs",
    "minecraft:stone_button",
    "minecraft:stone_pressure_plate",
    "minecraft:stone_slab", // removed in 1.21
    "minecraft:stone_slab2",
    "minecraft:stone_slab3",
    "minecraft:stone_slab4",
    "minecraft:stone_stairs",
    "minecraft:stonebrick",
    "minecraft:stonecutter_block",
    "minecraft:tube_coral_block",
    "minecraft:tuff",
    "minecraft:tuff_brick_double_slab",
    "minecraft:tuff_brick_slab",
    "minecraft:tuff_brick_stairs",
    "minecraft:tuff_brick_wall",
    "minecraft:tuff_bricks",
    "minecraft:tuff_double_slab",
    "minecraft:tuff_slab",
    "minecraft:tuff_stairs",
    "minecraft:tuff_wall",
    "minecraft:undyed_shulker_box",
    "minecraft:warped_nylium",
    "minecraft:waxed_chiseled_copper",
    "minecraft:waxed_copper",
    "minecraft:waxed_copper_bulb",
    "minecraft:waxed_copper_door",
    "minecraft:waxed_copper_grate",
    "minecraft:waxed_copper_trapdoor",
    "minecraft:waxed_cut_copper",
    "minecraft:waxed_cut_copper_slab",
    "minecraft:waxed_cut_copper_stairs",
    "minecraft:waxed_double_cut_copper_slab",
    "minecraft:waxed_exposed_chiseled_copper",
    "minecraft:waxed_exposed_copper",
    "minecraft:waxed_exposed_copper_bulb",
    "minecraft:waxed_exposed_copper_door",
    "minecraft:waxed_exposed_copper_grate",
    "minecraft:waxed_exposed_copper_trapdoor",
    "minecraft:waxed_exposed_cut_copper",
    "minecraft:waxed_exposed_cut_copper_slab",
    "minecraft:waxed_exposed_cut_copper_stairs",
    "minecraft:waxed_exposed_double_cut_copper_slab",
    "minecraft:waxed_oxidized_chiseled_copper",
    "minecraft:waxed_oxidized_copper",
    "minecraft:waxed_oxidized_copper_bulb",
    "minecraft:waxed_oxidized_copper_door",
    "minecraft:waxed_oxidized_copper_grate",
    "minecraft:waxed_oxidized_copper_trapdoor",
    "minecraft:waxed_oxidized_cut_copper",
    "minecraft:waxed_oxidized_cut_copper_slab",
    "minecraft:waxed_oxidized_cut_copper_stairs",
    "minecraft:waxed_oxidized_double_cut_copper_slab",
    "minecraft:waxed_weathered_chiseled_copper",
    "minecraft:waxed_weathered_copper",
    "minecraft:waxed_weathered_copper_bulb",
    "minecraft:waxed_weathered_copper_door",
    "minecraft:waxed_weathered_copper_grate",
    "minecraft:waxed_weathered_copper_trapdoor",
    "minecraft:waxed_weathered_cut_copper",
    "minecraft:waxed_weathered_cut_copper_slab",
    "minecraft:waxed_weathered_cut_copper_stairs",
    "minecraft:waxed_weathered_double_cut_copper_slab",
    "minecraft:weathered_chiseled_copper",
    "minecraft:weathered_copper",
    "minecraft:weathered_copper_bulb",
    "minecraft:weathered_copper_door",
    "minecraft:weathered_copper_grate",
    "minecraft:weathered_copper_trapdoor",
    "minecraft:weathered_cut_copper",
    "minecraft:weathered_cut_copper_slab",
    "minecraft:weathered_cut_copper_stairs",
    "minecraft:weathered_double_cut_copper_slab",
    "minecraft:white_concrete",
    "minecraft:white_glazed_terracotta",
    "minecraft:white_shulker_box",
    "minecraft:white_terracotta",
    "minecraft:yellow_concrete",
    "minecraft:yellow_glazed_terracotta",
    "minecraft:yellow_shulker_box",
    "minecraft:yellow_terracotta"
  ]
  const customShovels = [
    "nicothekid:copper_shovel"
  ]
  const shovelDiggableBlocks = [
    "minecraft:black_concrete_powder",
    "minecraft:blue_concrete_powder",
    "minecraft:brown_concrete_powder",
    "minecraft:clay",
    "minecraft:concrete_powder", // old name
    "minecraft:cyan_concrete_powder",
    "minecraft:dirt",
    "minecraft:dirt_with_roots",
    "minecraft:farmland",
    "minecraft:grass_block",
    "minecraft:grass_path",
    "minecraft:gravel",
    "minecraft:gray_concrete_powder",
    "minecraft:green_concrete_powder",
    "minecraft:light_blue_concrete_powder",
    "minecraft:light_gray_concrete_powder",
    "minecraft:lime_concrete_powder",
    "minecraft:magenta_concrete_powder",
    "minecraft:mud",
    "minecraft:muddy_mangrove_roots",
    "minecraft:mycelium",
    "minecraft:orange_concrete_powder",
    "minecraft:pink_concrete_powder",
    "minecraft:podzol",
    "minecraft:purple_concrete_powder",
    "minecraft:red_concrete_powder",
    "minecraft:sand",
    "minecraft:snow",
    "minecraft:snow_layer",
    "minecraft:soul_sand",
    "minecraft:soul_soil",
    "minecraft:suspicious_gravel",
    "minecraft:suspicious_sand",
    "minecraft:white_concrete_powder",
    "minecraft:yellow_concrete_powder"
  ]
  const customSwords = [
    "nicothekid:copper_sword"
  ]
  const swordDiggableBlocks = [
    "minecraft:infested_deepslate",
    "minecraft:monster_egg",
    "minecraft:web"
  ]
  const customWeapons = [
    "nicothekid:dripstone_club",
    "nicothekid:jar_opener",
    "nicothekid:magma_club",
    "nicothekid:wooden_club"
  ]
  const customStaff = [
    "nicothekid:blazing_staff",
    "nicothekid:powder_staff",
    "nicothekid:staff_of_the_sea"
  ]
  if (itemUsed === undefined || player.matches({ gameMode: GameMode.creative })) return;
  if (customAxes.includes(itemUsed.typeId) || customHoes.includes(itemUsed.typeId) || customPickaxes.includes(itemUsed.typeId) || customShovels.includes(itemUsed.typeId) || customSwords.includes(itemUsed.typeId) || customWeapons.includes(itemUsed.typeId) || customStaff.includes(itemUsed.typeId)) {
    if (!instantDiggableBlocks.includes(brokenBlock.type.id) && !brokenBlock.hasTag("instant_diggable")) {
      if (customAxes.includes(itemUsed.typeId)) {
        const itemEnchantable = itemUsed.getComponent("enchantable");
        const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
        const breakChance = 100 / (unbreakingLevel + 1);
        const randomizeChance = Math.random() * 100;
        if (breakChance < randomizeChance) return;
        const itemDurability = itemUsed.getComponent("durability");
        if (!itemDurability) return;
        const itemMaxDurability = itemDurability.maxDurability;
        const itemDurabilityDamage = itemDurability.damage;
        const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
        let damageAmount = 0;
        if (axeDiggableBlocks.includes(brokenBlock.type.id) || brokenBlock.hasTag("axe_diggable") || brokenBlock.hasTag("wood")) {
          damageAmount = 1;
        }
        else {
          damageAmount = 2;
        };
        const currentDurability = durabilityCalculation - damageAmount;
        if (currentDurability <= 0) {
          player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
          playerEquippable.setEquipment("Mainhand", null);
        }
        else {
          itemDurability.damage += damageAmount;
          playerEquippable.setEquipment("Mainhand", itemUsed)
        }
      }
      if (customHoes.includes(itemUsed.typeId)) {
        const itemEnchantable = itemUsed.getComponent("enchantable");
        const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
        const breakChance = 100 / (unbreakingLevel + 1);
        const randomizeChance = Math.random() * 100;
        if (breakChance < randomizeChance) return;
        const itemDurability = itemUsed.getComponent("durability");
        if (!itemDurability) return;
        const itemMaxDurability = itemDurability.maxDurability;
        const itemDurabilityDamage = itemDurability.damage;
        const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
        let damageAmount = 0;
        if (hoeDiggableBlocks.includes(brokenBlock.type.id) || brokenBlock.hasTag("hoe_diggable") || brokenBlock.hasTag("leaves")) {
          damageAmount = 1;
        }
        else {
          damageAmount = 2;
        };
        const currentDurability = durabilityCalculation - damageAmount;
        if (currentDurability <= 0) {
          player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
          playerEquippable.setEquipment("Mainhand", null);
        }
        else {
          itemDurability.damage += damageAmount;
          playerEquippable.setEquipment("Mainhand", itemUsed)
        }
      }
      if (customPickaxes.includes(itemUsed.typeId)) {
        const itemEnchantable = itemUsed.getComponent("enchantable");
        const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
        const breakChance = 100 / (unbreakingLevel + 1);
        const randomizeChance = Math.random() * 100;
        if (breakChance < randomizeChance) return;
        const itemDurability = itemUsed.getComponent("durability");
        if (!itemDurability) return;
        const itemMaxDurability = itemDurability.maxDurability;
        const itemDurabilityDamage = itemDurability.damage;
        const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
        let damageAmount = 0;
        if (pickaxeDiggableBlocks.includes(brokenBlock.type.id) || brokenBlock.hasTag("pickaxe_diggable") || brokenBlock.hasTag("stone")) {
          damageAmount = 1;
        }
        else {
          damageAmount = 2;
        };
        const currentDurability = durabilityCalculation - damageAmount;
        if (currentDurability <= 0) {
          player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
          playerEquippable.setEquipment("Mainhand", null);
        }
        else {
          itemDurability.damage += damageAmount;
          playerEquippable.setEquipment("Mainhand", itemUsed)
        }
      }
      if (customShovels.includes(itemUsed.typeId)) {
        const itemEnchantable = itemUsed.getComponent("enchantable");
        const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
        const breakChance = 100 / (unbreakingLevel + 1);
        const randomizeChance = Math.random() * 100;
        if (breakChance < randomizeChance) return;
        const itemDurability = itemUsed.getComponent("durability");
        if (!itemDurability) return;
        const itemMaxDurability = itemDurability.maxDurability;
        const itemDurabilityDamage = itemDurability.damage;
        const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
        let damageAmount = 0;
        if (shovelDiggableBlocks.includes(brokenBlock.type.id) || brokenBlock.hasTag("shovel_diggable") || brokenBlock.hasTag("dirt")) {
          damageAmount = 1;
        }
        else {
          damageAmount = 2;
        };
        const currentDurability = durabilityCalculation - damageAmount;
        if (currentDurability <= 0) {
          player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
          playerEquippable.setEquipment("Mainhand", null);
        }
        else {
          itemDurability.damage += damageAmount;
          playerEquippable.setEquipment("Mainhand", itemUsed)
        }
      }
      if (customSwords.includes(itemUsed.typeId)) {
        const itemEnchantable = itemUsed.getComponent("enchantable");
        const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
        const breakChance = 100 / (unbreakingLevel + 1);
        const randomizeChance = Math.random() * 100;
        if (breakChance < randomizeChance) return;
        const itemDurability = itemUsed.getComponent("durability");
        if (!itemDurability) return;
        const itemMaxDurability = itemDurability.maxDurability;
        const itemDurabilityDamage = itemDurability.damage;
        const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
        let damageAmount = 0;
        if (swordDiggableBlocks.includes(brokenBlock.type.id) || brokenBlock.hasTag("sword_diggable")) {
          damageAmount = 1;
        }
        else {
          damageAmount = 2;
        };
        const currentDurability = durabilityCalculation - damageAmount;
        if (currentDurability <= 0) {
          player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
          playerEquippable.setEquipment("Mainhand", null);
        }
        else {
          itemDurability.damage += damageAmount;
          playerEquippable.setEquipment("Mainhand", itemUsed)
        }
      }
      if (customWeapons.includes(itemUsed.typeId)) {
        const itemEnchantable = itemUsed.getComponent("enchantable");
        const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
        const breakChance = 100 / (unbreakingLevel + 1);
        const randomizeChance = Math.random() * 100;
        if (breakChance < randomizeChance) return;
        const itemDurability = itemUsed.getComponent("durability");
        if (!itemDurability) return;
        const itemMaxDurability = itemDurability.maxDurability;
        const itemDurabilityDamage = itemDurability.damage;
        const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
        let damageAmount = 2;
        const currentDurability = durabilityCalculation - damageAmount;
        if (currentDurability <= 0) {
          player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
          playerEquippable.setEquipment("Mainhand", null);
        }
        else {
          itemDurability.damage += damageAmount;
          playerEquippable.setEquipment("Mainhand", itemUsed)
        }
      }
      if (customStaff.includes(itemUsed.typeId)) {
        const itemEnchantable = itemUsed.getComponent("enchantable");
        const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
        const breakChance = 100 / (unbreakingLevel + 1);
        const randomizeChance = Math.random() * 100;
        if (breakChance < randomizeChance) return;
        const itemDurability = itemUsed.getComponent("durability");
        if (!itemDurability) return;
        const itemMaxDurability = itemDurability.maxDurability;
        const itemDurabilityDamage = itemDurability.damage;
        const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
        let damageAmount = 3;
        const currentDurability = durabilityCalculation - damageAmount;
        if (currentDurability <= 0) {
          player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
          playerEquippable.setEquipment("Mainhand", null);
        }
        else {
          itemDurability.damage += damageAmount;
          playerEquippable.setEquipment("Mainhand", itemUsed)
        }
      }
    }
    else return;
  }
  else return;
});
world.afterEvents.playerBreakBlock.subscribe(eventData => {
  const player = eventData.player;
  const itemUsed = eventData.itemStackBeforeBreak;
  const brokenBlock = eventData.brokenBlockPermutation;
  const playerEquippable = player.getComponent("equippable");
  const vanillaTools = [
    "minecraft:diamond_axe",
    "minecraft:diamond_hoe",
    "minecraft:diamond_pickaxe",
    "minecraft:diamond_shovel",
    "minecraft:diamond_sword",
    "minecraft:flint_and_steel",
    "minecraft:golden_axe",
    "minecraft:golden_hoe",
    "minecraft:golden_pickaxe",
    "minecraft:golden_shovel",
    "minecraft:golden_sword",
    "minecraft:iron_axe",
    "minecraft:iron_hoe",
    "minecraft:iron_pickaxe",
    "minecraft:iron_shovel",
    "minecraft:iron_sword",
    "minecraft:mace",
    "minecraft:netherite_axe",
    "minecraft:netherite_hoe",
    "minecraft:netherite_pickaxe",
    "minecraft:netherite_shovel",
    "minecraft:netherite_sword",
    "minecraft:shield",
    "minecraft:stone_axe",
    "minecraft:stone_hoe",
    "minecraft:stone_pickaxe",
    "minecraft:stone_shovel",
    "minecraft:stone_sword",
    "minecraft:wooden_axe",
    "minecraft:wooden_hoe",
    "minecraft:wooden_pickaxe",
    "minecraft:wooden_shovel",
    "minecraft:wooden_sword"
  ]
  const customTools = [
    "nicothekid:copper_axe",
    "nicothekid:copper_hoe",
    "nicothekid:copper_pickaxe",
    "nicothekid:copper_shovel",
    "nicothekid:copper_sword",
    "nicothekid:dripstone_club",
    "nicothekid:jar_opener",
    "nicothekid:magma_club",
    "nicothekid:wooden_club",
    "nicothekid:blazing_staff",
    "nicothekid:powder_staff",
    "nicothekid:staff_of_the_sea"
  ]
  if (itemUsed === undefined || player.matches({ gameMode: GameMode.creative })) return;
  if (customTools.includes(itemUsed.typeId)) return;
  if (vanillaTools.includes(itemUsed.typeId) || itemUsed.hasTag("minecraft:is_axe") || itemUsed.hasTag("minecraft:is_hoe") || itemUsed.hasTag("minecraft:is_pickaxe") || itemUsed.hasTag("minecraft:is_shovel") || itemUsed.hasTag("minecraft:is_sword")) {
    if (brokenBlock.hasTag("nicothekid_blocks")) {
      if (!brokenBlock.hasTag("instant_diggable")) {
        const otherTools = [
          "minecraft:flint_and_steel",
          "minecraft:mace",
          "minecraft:shield"
        ]
        if (itemUsed.hasTag("minecraft:is_axe")) {
          const itemEnchantable = itemUsed.getComponent("enchantable");
          const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
          const breakChance = 100 / (unbreakingLevel + 1);
          const randomizeChance = Math.random() * 100;
          if (breakChance < randomizeChance) return;
          const itemDurability = itemUsed.getComponent("durability");
          if (!itemDurability) return;
          const itemMaxDurability = itemDurability.maxDurability;
          const itemDurabilityDamage = itemDurability.damage;
          const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
          let damageAmount = 0;
          if (brokenBlock.hasTag("axe_diggable") || brokenBlock.hasTag("any_tool_diggable")) {
            damageAmount = 1;
          }
          else {
            damageAmount = 2;
          };
          const currentDurability = durabilityCalculation - damageAmount;
          if (currentDurability <= 0) {
            player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
            playerEquippable.setEquipment("Mainhand", null);
          }
          else {
            itemDurability.damage += damageAmount;
            playerEquippable.setEquipment("Mainhand", itemUsed)
          }
        }
        if (itemUsed.hasTag("minecraft:is_hoe")) {
          const itemEnchantable = itemUsed.getComponent("enchantable");
          const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
          const breakChance = 100 / (unbreakingLevel + 1);
          const randomizeChance = Math.random() * 100;
          if (breakChance < randomizeChance) return;
          const itemDurability = itemUsed.getComponent("durability");
          if (!itemDurability) return;
          const itemMaxDurability = itemDurability.maxDurability;
          const itemDurabilityDamage = itemDurability.damage;
          const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
          let damageAmount = 0;
          if (brokenBlock.hasTag("hoe_diggable") || brokenBlock.hasTag("any_tool_diggable")) {
            damageAmount = 1;
          }
          else {
            damageAmount = 2;
          };
          const currentDurability = durabilityCalculation - damageAmount;
          if (currentDurability <= 0) {
            player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
            playerEquippable.setEquipment("Mainhand", null);
          }
          else {
            itemDurability.damage += damageAmount;
            playerEquippable.setEquipment("Mainhand", itemUsed)
          }
        }
        if (itemUsed.hasTag("minecraft:is_pickaxe")) {
          const itemEnchantable = itemUsed.getComponent("enchantable");
          const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
          const breakChance = 100 / (unbreakingLevel + 1);
          const randomizeChance = Math.random() * 100;
          if (breakChance < randomizeChance) return;
          const itemDurability = itemUsed.getComponent("durability");
          if (!itemDurability) return;
          const itemMaxDurability = itemDurability.maxDurability;
          const itemDurabilityDamage = itemDurability.damage;
          const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
          let damageAmount = 0;
          if (brokenBlock.hasTag("pickaxe_diggable") || brokenBlock.hasTag("any_tool_diggable")) {
            damageAmount = 1;
          }
          else {
            damageAmount = 2;
          };
          const currentDurability = durabilityCalculation - damageAmount;
          if (currentDurability <= 0) {
            player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
            playerEquippable.setEquipment("Mainhand", null);
          }
          else {
            itemDurability.damage += damageAmount;
            playerEquippable.setEquipment("Mainhand", itemUsed)
          }
        }
        if (itemUsed.hasTag("minecraft:is_shovel")) {
          const itemEnchantable = itemUsed.getComponent("enchantable");
          const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
          const breakChance = 100 / (unbreakingLevel + 1);
          const randomizeChance = Math.random() * 100;
          if (breakChance < randomizeChance) return;
          const itemDurability = itemUsed.getComponent("durability");
          if (!itemDurability) return;
          const itemMaxDurability = itemDurability.maxDurability;
          const itemDurabilityDamage = itemDurability.damage;
          const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
          let damageAmount = 0;
          if (brokenBlock.hasTag("shovel_diggable") || brokenBlock.hasTag("any_tool_diggable")) {
            damageAmount = 1;
          }
          else {
            damageAmount = 2;
          };
          const currentDurability = durabilityCalculation - damageAmount;
          if (currentDurability <= 0) {
            player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
            playerEquippable.setEquipment("Mainhand", null);
          }
          else {
            itemDurability.damage += damageAmount;
            playerEquippable.setEquipment("Mainhand", itemUsed)
          }
        }
        if (itemUsed.hasTag("minecraft:is_sword")) {
          const itemEnchantable = itemUsed.getComponent("enchantable");
          const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
          const breakChance = 100 / (unbreakingLevel + 1);
          const randomizeChance = Math.random() * 100;
          if (breakChance < randomizeChance) return;
          const itemDurability = itemUsed.getComponent("durability");
          if (!itemDurability) return;
          const itemMaxDurability = itemDurability.maxDurability;
          const itemDurabilityDamage = itemDurability.damage;
          const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
          let damageAmount = 0;
          if (brokenBlock.hasTag("sword_diggable") || brokenBlock.hasTag("any_tool_diggable")) {
            damageAmount = 1;
          }
          else {
            damageAmount = 2;
          };
          const currentDurability = durabilityCalculation - damageAmount;
          if (currentDurability <= 0) {
            player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
            playerEquippable.setEquipment("Mainhand", null);
          }
          else {
            itemDurability.damage += damageAmount;
            playerEquippable.setEquipment("Mainhand", itemUsed)
          }
        }
        if (otherTools.includes(itemUsed.typeId)) {
          const itemEnchantable = itemUsed.getComponent("enchantable");
          const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
          const breakChance = 100 / (unbreakingLevel + 1);
          const randomizeChance = Math.random() * 100;
          if (breakChance < randomizeChance) return;
          const itemDurability = itemUsed.getComponent("durability");
          if (!itemDurability) return;
          const itemMaxDurability = itemDurability.maxDurability;
          const itemDurabilityDamage = itemDurability.damage;
          const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
          let damageAmount = 2;
          const currentDurability = durabilityCalculation - damageAmount;
          //console.warn(currentDurability);
          if (currentDurability <= 0) {
            player.playSound("random.break", { pitch: 0.9, location: player.location, volume: 1 });
            playerEquippable.setEquipment("Mainhand", null);
          }
          else {
            itemDurability.damage += damageAmount;
            playerEquippable.setEquipment("Mainhand", itemUsed)
          }
        }
      }
      else return;
    }
    else return;
  }
  else return;
});
world.afterEvents.entityHitEntity.subscribe(eventData => {
  const damager = eventData.damagingEntity;
  const target = eventData.hitEntity;
  const { x, y, z } = damager.location;
  const damagerEquippable = damager.getComponent("equippable");
  if (!damagerEquippable) return;
  const itemUsed = damagerEquippable.getEquipment("Mainhand");
  const customWeapons = [
    "nicothekid:blazing_staff",
    "nicothekid:dripstone_club",
    "nicothekid:magma_club",
    "nicothekid:powder_staff",
    "nicothekid:staff_of_the_sea",
    "nicothekid:wooden_club"
  ]
  if (itemUsed === undefined) return;
  if (customWeapons.includes(itemUsed.typeId)) {
    if (itemUsed.typeId === "nicothekid:blazing_staff") {
      if (!target.matches({ excludeFamilies:["blaze", "magmacube", "strider", "fire_bird", "soul_fire_bird", "magma_golem", "nether_wisp", "nether_soul_wisp"] })) {
        const pitchRange = Math.random() * (2.2 - 1.8) + 1.8;
        damager.playSound("mob.ghast.fireball", { pitch: pitchRange, location: damager.location, volume: 0.5 });
        if (target.typeId === "minecraft:blaze") {
          target.applyDamage( 2, { cause: "override", damagingEntity: damager });
          target.applyKnockback( x, z, 0.0, 0.0 );
          target.addEffect("instant_health", 2, {amplifier: 0, showParticles: false });
        }
        else {
          target.applyDamage( 3, { cause: "override", damagingEntity: damager });
          target.applyKnockback( x, z, 0.0, 0.0 );
          target.addEffect("instant_health", 2, {amplifier: 0, showParticles: false });
        }
      } 
      else {
        target.setOnFire( 4, true );
      }
      const itemEnchantable = itemUsed.getComponent("enchantable");
      const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
      const breakChance = 100 / (unbreakingLevel + 1);
      const randomizeChance = Math.random() * 100;
      if (breakChance < randomizeChance) return;
      const itemDurability = itemUsed.getComponent("durability");
      if (!itemDurability) return;
      const itemMaxDurability = itemDurability.maxDurability;
      const itemDurabilityDamage = itemDurability.damage;
      const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
      let damageAmount = 0;
      if (damager.typeId === "minecraft:player") {
        if (!damager.matches({ gameMode: GameMode.creative })) {
          damageAmount = 3;
        }
        else return;
      }
      else {
        damageAmount = 2;
      };
      const currentDurability = durabilityCalculation - damageAmount;
      if (currentDurability <= 0) {
        damager.playSound("random.break", { pitch: 0.9, location: damager.location, volume: 1 });
        damagerEquippable.setEquipment("Mainhand", null);
      }
      else {
        itemDurability.damage += damageAmount;
        damagerEquippable.setEquipment("Mainhand", itemUsed)
      }
    }
    if (itemUsed.typeId === "nicothekid:dripstone_club") {
      const { x, z } = damager.getViewDirection();
      let knockbackChance = Math.random();
      let extraDamageChance = Math.random();
      if (knockbackChance <= 0.15) {
        target.applyKnockback( x, z, 1, 0.1 );
        damager.playSound("game.player.attack.strong", { pitch: 1.2, location: damager.location, volume: 1.2 });
      }
      if (extraDamageChance <= 0.05) {
        target.applyDamage( 2, { cause: "override", damagingEntity: damager });
        target.applyKnockback( x, z, 0.0, 0.0 );
        damager.playSound("game.player.attack.strong", { pitch: 0.9, location: damager.location, volume: 1.2 });
      }
    }
    if (itemUsed.typeId === "nicothekid:magma_club") {
      const { x, z } = damager.getViewDirection();
      let knockbackChance = Math.random();
      let fireChance = Math.random();
      if (knockbackChance <= 0.15) {
        target.applyKnockback( x, z, 1, 0.1 );
        damager.playSound("game.player.attack.strong", { pitch: 1.2, location: damager.location, volume: 1.2 });
      }
      if (fireChance <= 0.05) {
        target.setOnFire( 2, true );
      }
    }
    if (itemUsed.typeId === "nicothekid:powder_staff") {
      const itemEnchantable = itemUsed.getComponent("enchantable");
      const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
      const breakChance = 100 / (unbreakingLevel + 1);
      const randomizeChance = Math.random() * 100;
      if (breakChance < randomizeChance) return;
      const itemDurability = itemUsed.getComponent("durability");
      if (!itemDurability) return;
      const itemMaxDurability = itemDurability.maxDurability;
      const itemDurabilityDamage = itemDurability.damage;
      const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
      let damageAmount = 0;
      if (damager.typeId === "minecraft:player") {
        if (!damager.matches({ gameMode: GameMode.creative })) {
          damageAmount = 3;
        }
        else return;
      }
      else {
        damageAmount = 2;
      };
      const currentDurability = durabilityCalculation - damageAmount;
      if (currentDurability <= 0) {
        damager.playSound("random.break", { pitch: 0.9, location: damager.location, volume: 1 });
        damagerEquippable.setEquipment("Mainhand", null);
      }
      else {
        itemDurability.damage += damageAmount;
        damagerEquippable.setEquipment("Mainhand", itemUsed)
      }
    }
    if (itemUsed.typeId === "nicothekid:staff_of_the_sea") {
      const pitchRange = Math.random() * (2.4 - 0.8) + 0.8;
      if (!target.matches({ excludeFamilies:[ "blaze", "magmacube", "strider", "enderman", "fire_bird", "soul_fire_bird", "magma_golem", "nether_wisp", "nether_soul_wisp" ] })) {
        if (target.typeId === "minecraft:magma_cube" || target.typeId === "nicothekid:magma_golem") {
          target.applyDamage( 2, { cause: "override", damagingEntity: damager });
          target.applyKnockback( x, z, 0.0, 0.0 );
          damager.playSound("random.fizz", { pitch: pitchRange, location: damager.location, volume: 0.7 });
        }
        else if (target.typeId === "minecraft:strider" || target.typeId === "minecraft:enderman") {
          target.applyDamage( 2, { cause: "override", damagingEntity: damager });
          target.applyKnockback( x, z, 0.0, 0.0 );
        }
        else {
          target.applyDamage( 3, { cause: "override", damagingEntity: damager });
          target.applyKnockback( x, z, 0.0, 0.0 );
          damager.playSound("random.fizz", { pitch: pitchRange, location: damager.location, volume: 0.7 });
        }
      }
      if (target.hasComponent("minecraft:onfire")) {
        target.extinguishFire( true );
        damager.playSound("random.fizz", { pitch: pitchRange, location: damager.location, volume: 0.8 });
      }
      const itemEnchantable = itemUsed.getComponent("enchantable");
      const unbreakingLevel = itemEnchantable?.getEnchantment("unbreaking")?.level ?? 0;
      const breakChance = 100 / (unbreakingLevel + 1);
      const randomizeChance = Math.random() * 100;
      if (breakChance < randomizeChance) return;
      const itemDurability = itemUsed.getComponent("durability");
      if (!itemDurability) return;
      const itemMaxDurability = itemDurability.maxDurability;
      const itemDurabilityDamage = itemDurability.damage;
      const durabilityCalculation = itemMaxDurability - itemDurabilityDamage;
      let damageAmount = 0;
      if (damager.typeId === "minecraft:player") {
        if (!damager.matches({ gameMode: GameMode.creative })) {
          damageAmount = 3;
        }
        else return;
      }
      else {
        damageAmount = 2;
      };
      const currentDurability = durabilityCalculation - damageAmount;
      if (currentDurability <= 0) {
        damager.playSound("random.break", { pitch: 0.9, location: damager.location, volume: 1 });
        damagerEquippable.setEquipment("Mainhand", null);
      }
      else {
        itemDurability.damage += damageAmount;
        damagerEquippable.setEquipment("Mainhand", itemUsed)
      }
    }
    if (itemUsed.typeId === "nicothekid:wooden_club") {
      const { x, z } = damager.getViewDirection();
      let knockbackChance = Math.random();
      if (knockbackChance <= 0.15) {
        target.applyKnockback( x, z, 1, 0.1 );
        damager.playSound("game.player.attack.strong", { pitch: 1.2, location: damager.location, volume: 0.8 });
      }
    }
  }
  else return;
});
world.beforeEvents.playerInteractWithBlock.subscribe(function (eventData) {
  if (eventData.player.isSneaking) return;
  if (eventData.block.typeId !== "minecraft:iron_door" && eventData.block.typeId !== "minecraft:iron_trapdoor") return;
    if (eventData.itemStack?.typeId !== "minecraft:redstone_torch") return;
    system.run(function () {
      eventData.player.playSound(`open.${eventData.block.typeId.split(":")[1]}`, { location: eventData.block.location });
      eventData.block.setPermutation(eventData.block.permutation.withState("open_bit", !eventData.block.permutation.getState("open_bit")));
      if (eventData.block.permutation.getState("upper_block_bit")) {
        const block = eventData.block.below(1);
        if (block === undefined) return;
        block.setPermutation(block.permutation.withState("open_bit", !block.permutation.getState("open_bit")));
      }
    });
});
