// COBBTOOLREQ.js

// Modify loot tables for stone, ores, and stones to require any pickaxe
ServerEvents.highPriorityData((event) => {
  // Helper function to create loot table conditions
  const createLootTable = (blockTag) => ({
    type: 'minecraft:block',
    pools: [
      {
        rolls: 1,
        entries: [
          {
            type: 'minecraft:item',
            name: blockTag,
            conditions: [
              {
                condition: 'minecraft:match_tool',
                predicate: {
                  tag: 'minecraft:pickaxes' // Matches any item tagged as a pickaxe
                }
              }
            ]
          }
        ]
      }
    ]
  });

  // Update normal stone
  event.addJson('minecraft:loot_tables/blocks/stone.json', createLootTable('minecraft:stone'));

  // Update all blocks tagged as ores
  event.addJson('kubejs:loot_tables/tags/c_ores.json', {
    type: 'minecraft:block',
    pools: [
      {
        rolls: 1,
        entries: [
          {
            type: 'minecraft:tag',
            name: 'c:ores', // Matches all blocks tagged as ores
            conditions: [
              {
                condition: 'minecraft:match_tool',
                predicate: {
                  tag: 'minecraft:pickaxes'
                }
              }
            ]
          }
        ]
      }
    ]
  });

  // Update all blocks tagged as stones
  event.addJson('kubejs:loot_tables/tags/c_stones.json', {
    type: 'minecraft:block',
    pools: [
      {
        rolls: 1,
        entries: [
          {
            type: 'minecraft:tag',
            name: 'c:stones', // Matches all blocks tagged as stones
            conditions: [
              {
                condition: 'minecraft:match_tool',
                predicate: {
                  tag: 'minecraft:pickaxes'
                }
              }
            ]
          }
        ]
      }
    ]
  });
});
