const harmoniousEngineeringTags = event => {
  event.add('harmeng:diamond_tier_saws', 'natural-progression:diamond_saw');
  event.add('harmeng:diamond_tier_saws', 'natural-progression:netherite_saw');

  event.add('harmeng:presses', 'thermal:machine_press');
  event.add('harmeng:presses', 'create:mechanical_press');

  event.add('harmeng:basic_tank', 'create:fluid_tank');
  event.add('harmeng:basic_tank', 'mekanism:basic_fluid_tank');
  event.add('harmeng:basic_tank', 'industrialforegoing:pity_black_hole_tank');
  event.add('harmeng:basic_tank', 'industrialforegoing:simple_black_hole_tank');
  event.add('harmeng:basic_tank', 'thermal:fluid_cell');

  event.add('harmeng:chestless_logs', '#tconstruct:greenheart_logs');
  event.add('harmeng:chestless_logs', '#tconstruct:skyroot_logs');
  event.add('harmeng:chestless_logs', '#tconstruct:bloodshroom_logs');

  event.add('harmeng:chestless_planks', 'quark:white_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:orange_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:magenta_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:light_blue_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:yellow_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:lime_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:pink_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:gray_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:light_gray_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:cyan_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:purple_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:blue_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:brown_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:green_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:red_stained_planks');
  event.add('harmeng:chestless_planks', 'quark:black_stained_planks');
  event.add('harmeng:chestless_planks', 'tconstruct:greenheart_planks');
  event.add('harmeng:chestless_planks', 'tconstruct:skyroot_planks');
  event.add('harmeng:chestless_planks', 'tconstruct:bloodshroom_planks');

  event.add('harmeng:saw_blade', 'thermal:saw_blade');
  event.add('harmeng:saw_blade', '#forge:sawblades');

  event.add('harmeng:meka/filler_1', 'powah:crystal_blazing');
  event.add('harmeng:meka/filler_1', 'industrialforegoing:pink_slime_ingot');
  event.add('harmeng:meka/filler_1', '#forge:ingots/enderium');
  event.add('harmeng:meka/filler_1', '#forge:ingots/refined_obsidian');

  event.add('harmeng:meka/filler_2', 'powah:capacitor_blazing');
  event.add('harmeng:meka/filler_2', 'industrialforegoing:range_addon11');
  event.add('harmeng:meka/filler_2', 'thermal:upgrade_augment_2');
  event.add('harmeng:meka/filler_2', '#forge:batteries');

  event.add('harmeng:meka/crafting_tool_1', 'minecraft:netherite_pickaxe');
  event.add('harmeng:meka/crafting_tool_1', 'mekanismtools:refined_obsidian_pickaxe');

  event.add('harmeng:meka/crafting_tool_2', 'minecraft:netherite_axe');
  event.add('harmeng:meka/crafting_tool_2', 'mekanismtools:refined_obsidian_axe');

  event.add('harmeng:meka/crafting_helm', 'minecraft:netherite_helmet');
  event.add('harmeng:meka/crafting_helm', 'mekanismtools:refined_obsidian_helmet');

  event.add('harmeng:meka/crafting_chest', 'minecraft:netherite_chestplate');
  event.add('harmeng:meka/crafting_chest', 'mekanismtools:refined_obsidian_chestplate');

  event.add('harmeng:meka/crafting_legs', 'minecraft:netherite_leggings');
  event.add('harmeng:meka/crafting_legs', 'mekanismtools:refined_obsidian_leggings');

  event.add('harmeng:meka/crafting_boots', 'minecraft:netherite_boots');
  event.add('harmeng:meka/crafting_boots', 'mekanismtools:refined_obsidian_boots');
};

const naturalProgressionTags = event => {
  event.add('natural-progression:axes', 'immersiveengineering:axe_steel');
  event.add('natural-progression:axes', 'mekanismtools:stone_paxel');
  event.add('natural-progression:axes', 'mekanismtools:iron_paxel');
  event.add('natural-progression:axes', 'mekanismtools:gold_paxel');
  event.add('natural-progression:axes', 'mekanismtools:diamond_paxel');
  event.add('natural-progression:axes', 'mekanismtools:netherite_paxel');
  event.add('natural-progression:axes', 'mekanismtools:bronze_axe');
  event.add('natural-progression:axes', 'mekanismtools:bronze_paxel');
  event.add('natural-progression:axes', 'mekanismtools:osmium_axe');
  event.add('natural-progression:axes', 'mekanismtools:osmium_paxel');
  event.add('natural-progression:axes', 'mekanismtools:lapis_lazuli_axe');
  event.add('natural-progression:axes', 'mekanismtools:lapis_lazuli_paxel');
  event.add('natural-progression:axes', 'mekanismtools:refined_glowstone_axe');
  event.add('natural-progression:axes', 'mekanismtools:refined_obsidian_axe');
  event.add('natural-progression:axes', 'mekanismtools:refined_obsidian_paxel');
  event.add('natural-progression:axes', 'mekanismtools:steel_axe');
  event.add('natural-progression:axes', 'mekanismtools:steel_paxel');
  event.add('natural-progression:axes', 'tconstruct:hand_axe');
  event.add('natural-progression:axes', 'betterendforge:aeternium_axe');
  event.add('natural-progression:axes', 'betterendforge:thallasium_axe');
  event.add('natural-progression:axes', 'betterendforge:terminite_axe');
  event.add('natural-progression:axes', 'betternether:cincinnasite_axe');
  event.add('natural-progression:axes', 'betternether:nether_ruby_axe');
  event.add('natural-progression:axes', 'mekanismtools:refined_glowstone_paxel');
  event.add('natural-progression:axes', 'appliedenergistics2:certus_quartz_axe');
  event.add('natural-progression:axes', 'appliedenergistics2:nether_quartz_axe');
};

const thermalTags = event => {
  event.add('thermal:crafting/dies', 'immersiveengineering:mold_plate');
  event.add('thermal:crafting/dies', 'immersiveengineering:mold_gear');
  event.add('thermal:crafting/dies', 'immersiveengineering:mold_rod');
  event.add('thermal:crafting/dies', 'immersiveengineering:mold_bullet_casing');
  event.add('thermal:crafting/dies', 'immersiveengineering:mold_wire');
};

const curiousElytraTags = event => {
  event.add('curios:back', 'alexsmobs:tarantula_hawk_elytra');
  event.add('curios:back', 'mekanism:hdpe_elytra');
  event.add('curios:back', 'tconstruct:slime_chestplate');
  event.add('curios:back', 'redstone_arsenal:flux_elytra');
};

const removePlates = event => {
  [
    'bronze',
    'constantan',
    'copper',
    'electrum',
    'enderium',
    'gold',
    'invar',
    'iron',
    'lead',
    'lumium',
    'nickel',
    'signalum',
    'silver',
    'tin',
  ].forEach(mat => {
    event.remove(`forge:plates/${mat}`, `thermal:${mat}_plate`);
    event.remove(`forge:plates`, `thermal:${mat}_plate`);
  });

  [
    'copper',
    'aluminum',
    'lead',
    'silver',
    'nickel',
    'uranium',
    'constantan',
    'electrum',
    'steel',
    'iron',
    'gold',
  ].forEach(mat => {
    event.remove(`forge:plates/${mat}`, `immersiveengineering:plate_${mat}`);
    event.remove(`forge:plates`, `immersiveengineering:plate_${mat}`);
  });
};

const removeGears = event => {
  [
    'bronze',
    'constantan',
    'copper',
    'diamond',
    'electrum',
    'emerald',
    'enderium',
    'gold',
    'invar',
    'iron',
    'lapis',
    'lead',
    'lumium',
    'nickel',
    'quartz',
    'signalum',
    'silver',
    'tin',
  ].forEach(mat => {
    event.remove(`forge:gears/${mat}`, `thermal:${mat}_gear`);
    event.remove(`forge:gears`, `thermal:${mat}_gear`);
  });
};

onEvent('tags.blocks', event => {
  event.add('forge:stone', 'quark:deepslate');
});

onEvent('tags.items', event => {
  harmoniousEngineeringTags(event);
  naturalProgressionTags(event);
  removePlates(event);
  removeGears(event);
  thermalTags(event);
  curiousElytraTags(event);
  event.add('forge:stone', 'quark:deepslate');
  event.add('valhelsia_structures:axe_crafting_blacklisted', '#natural-progression:saw');
  event.add('forge:dusts/ender', 'betterendforge:ender_dust');
  event.add('forge:dusts/ender', 'appliedenergistics2:ender_dust');
});
