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

world.beforeEvents.worldInitialize.subscribe(initEvent => {
  const bonePiles = [
    "nicothekid:bone_pile_1",
    "nicothekid:bone_pile_2",
    "nicothekid:bone_pile_3",
    "nicothekid:bone_pile_4",
    "nicothekid:bone_pile_5",
    "nicothekid:bone_pile_6",
    "nicothekid:bone_pile_7",
    "nicothekid:bone_pile_8",
    "nicothekid:bone_pile_9"
  ]
  const customPickaxes = [
    "nicothekid:brass_pickaxe",
    "nicothekid:bronze_pickaxe",
    "nicothekid:copper_pickaxe",
    "nicothekid:olivine_pickaxe",
    "nicothekid:tin_pickaxe",
    "nicothekid:zinc_pickaxe"
  ]
  initEvent.blockTypeRegistry.registerCustomComponent("nicothekid:bone_pile_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 damageDurability () {
        system.run(() => {
          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)
          }
        });
      }
      function spawnBone () {
        system.run(() => {
          const itemBone = new ItemStack ("minecraft:bone", 1);
          block.dimension.spawnItem(itemBone, { x: blockLocation.x + 0.5, y: blockLocation.y + 1.0, z: blockLocation.z + 0.5 });
        });
      }
      if (itemUsed === undefined || player.isSneaking) return;
      if (block.hasTag("bone_pile")) {
        if (customPickaxes.includes(itemUsed.typeId) || itemUsed.hasTag("minecraft:is_pickaxe")) {
          if (block.permutation.matches("nicothekid:bone_pile_1")) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("minecraft:air"));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "north" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_1", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "west" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_1", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "south" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_1", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "east" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_1", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "north" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "west" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "south" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "east" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "north" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "west" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "south" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "east" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "north" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "west" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "south" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "east" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "north" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "west" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "south" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "east" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "north" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "west" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "south" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "east" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "north" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "west" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "south" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "east" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_9", { "minecraft:cardinal_direction": "north" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_9", { "minecraft:cardinal_direction": "west" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_9", { "minecraft:cardinal_direction": "south" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_9", { "minecraft:cardinal_direction": "east" })) {
            damageDurability ();
            spawnBone ();
            block.dimension.playSound("block.itemframe.remove_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "east" }));
            return;
          }
        }
        if (itemUsed.typeId === "minecraft:bone") {
          if (block.permutation.matches("nicothekid:bone_pile_1", { "minecraft:cardinal_direction": "north" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_1", { "minecraft:cardinal_direction": "west" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_1", { "minecraft:cardinal_direction": "south" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_1", { "minecraft:cardinal_direction": "east" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "north" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "west" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "south" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_2", { "minecraft:cardinal_direction": "east" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "north" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "west" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "south" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_3", { "minecraft:cardinal_direction": "east" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "north" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "west" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "south" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_4", { "minecraft:cardinal_direction": "east" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "north" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "west" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "south" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_5", { "minecraft:cardinal_direction": "east" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "north" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "west" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "south" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_6", { "minecraft:cardinal_direction": "east" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "north" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "west" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "south" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_7", { "minecraft:cardinal_direction": "east" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "east" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "north" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_9", { "minecraft:cardinal_direction": "north" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "west" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_9", { "minecraft:cardinal_direction": "west" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "south" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_9", { "minecraft:cardinal_direction": "south" }));
            return;
          }
          if (block.permutation.matches("nicothekid:bone_pile_8", { "minecraft:cardinal_direction": "east" })) {
            decreaseItem ();
            block.dimension.playSound("block.itemframe.add_item", blockLocation, { pitch: 0.8, volume: 1.0 });
            block.setPermutation(BlockPermutation.resolve("nicothekid:bone_pile_9", { "minecraft:cardinal_direction": "east" }));
            return;
          }
        }
      }
      else return;
    }
  });
});
