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

const grassTypes1 = [
  "minecraft:short_grass",
  "minecraft:fern"
];

const grassTypes2 = [
  "minecraft:tall_grass",
  "minecraft:large_fern"
];

world.afterEvents.playerBreakBlock.subscribe((event) => {
  const { brokenBlockPermutation} = event;
  const player = event.player;

  grassTypes2.forEach((id) => {
    if (
      brokenBlockPermutation.matches(id)
    ) {
      player.dimension.runCommand(
        `loot spawn ${event.block.x} ${event.block.y} ${event.block.z} loot "PixelBiester/Dino/araucaria_sprout_2"`
      );

      return;
    }
  });
  grassTypes1.forEach((id) => {
    if (
      brokenBlockPermutation.matches(id)
    ) {
      player.dimension.runCommand(
        `loot spawn ${event.block.x} ${event.block.y} ${event.block.z} loot "PixelBiester/Dino/araucaria_sprout_1"`
      );

      return;
    }
  });
});
