LootJS.modifiers((event) => {
  // Blacksmith
  event
    .addLootTableModifier("seadwellers:gameplay/blacksmith_loot_crate")
    .removeLoot(Ingredient.all)
    .addWeightedLoot([
      LootEntry.of("seadwellers:depth_ingot").limitCount([1, 3]).withChance(40),
      LootEntry.of("seadwellers:depth_block").withChance(25),
      LootEntry.of("seadwellers:aquamarine_block").withChance(15),
      LootEntry.of("seadwellers:depth_upgrade_smithing_template").withChance(
        10
      ),
      LootEntry.of("thermal:diving_helmet").withChance(2),
      LootEntry.of("thermal:diving_chestplate").withChance(2),
      LootEntry.of("thermal:diving_leggings").withChance(2),
      LootEntry.of("thermal:diving_boots").withChance(2),
    ]);

  // Architect
  event
    .addLootTableModifier("seadwellers:gameplay/architect_loot_crate")
    .removeLoot(Ingredient.all)
    .addWeightedLoot([
      LootEntry.of("seadwellers:depth_ingot").limitCount([1, 3]).withChance(40),
      LootEntry.of("seadwellers:depth_block").withChance(25),
      LootEntry.of("seadwellers:aquamarine_block").withChance(15),
      LootEntry.of("create:large_water_wheel").withChance(5),
      LootEntry.of("thermal:prismarine_rail").limitCount([8, 32]).withChance(5),
      LootEntry.of("minecraft:dark_prismarine")
        .limitCount([8, 32])
        .withChance(5),
      LootEntry.of("minecraft:sea_lantern").limitCount([3, 8]).withChance(5),
      LootEntry.of("creategbd:guardian_beam_capacitor").withChance(2),
      LootEntry.of("creategbd:elder_guardian_beam_capacitor").withChance(2),
    ]);

  // Farmer
  event
    .addLootTableModifier("seadwellers:gameplay/farmer_loot_crate")
    .removeLoot(Ingredient.all)
    .addWeightedLoot([
      LootEntry.of("seadwellers:depth_nugget")
        .limitCount([3, 10])
        .withChance(40),
      LootEntry.of("seadwellers:depth_ingot").limitCount([1, 3]).withChance(30),
      LootEntry.of("seadwellers:depth_block").withChance(6),
      LootEntry.of("thermal:aquachow").limitCount([4, 9]).withChance(5),
      LootEntry.of("thermal:deep_aquachow").limitCount([4, 9]).withChance(5),
      LootEntry.of(
        Item.of(
          "minecraft:fishing_rod",
          '{display:{Name:\'{"text":"Ancient Fishing Rod"}\'}}'
        )
          .enchant("minecraft:unbreaking", 5)
          .enchant("minecraft:lure", 5)
          .enchant("minecraft:luck_of_the_sea", 5)
          .enchant("minecraft:mending", 1)
          .withChance(2)
      ),
      LootEntry.of("moa_decor_toys:tortugamarina").withChance(2),
      LootEntry.of("crabbersdelight:crab_trap").withChance(5),
      LootEntry.of("oceansdelight:elder_guardian_slab").withChance(5),
    ]);

  // Hunter
  event
    .addLootTableModifier("seadwellers:gameplay/hunter_loot_crate")
    .removeLoot(Ingredient.all)
    .addWeightedLoot([
      LootEntry.of("seadwellers:depth_nugget")
        .limitCount([3, 10])
        .withChance(40),
      LootEntry.of("seadwellers:depth_ingot").limitCount([1, 3]).withChance(30),
      LootEntry.of("seadwellers:aquamarine_block").withChance(10),
      LootEntry.of(
        Item.of("minecraft:enchanted_book")
          .enchant("minecraft:loyalty", 3)
          .withChance(2)
      ),
      LootEntry.of(
        Item.of("minecraft:enchanted_book")
          .enchant("minecraft:riptide", 3)
          .withChance(2)
      ),
      LootEntry.of(
        Item.of("minecraft:enchanted_book")
          .enchant("minecraft:channeling", 1)
          .withChance(2)
      ),
      LootEntry.of("crabbersdelight:nautilus_shell_block").withChance(5),
      LootEntry.of("moa_decor_toys:guardian").withChance(2),
      LootEntry.of("moa_decor_toys:guardiananciano").withChance(2),
      LootEntry.of("seadwellers:broken_trident").withChance(1),
      LootEntry.of("oceansdelight:elder_guardian_slab").withChance(4),
    ]);

  // Collector
  event
    .addLootTableModifier("seadwellers:gameplay/collector_loot_crate")
    .removeLoot(Ingredient.all)
    .addWeightedLoot([
      LootEntry.of("minecards:aquatic_card_box").withChance(45),
      LootEntry.of("seadwellers:depth_block").withChance(10),
      LootEntry.of("moa_decor_toys:delfin").withChance(5),
      LootEntry.of("moa_decor_toys:calamar").withChance(5),
      LootEntry.of("moa_decor_toys:calamarbrillante").withChance(5),
      LootEntry.of("moa_decor_toys:tortugamarina").withChance(5),
      LootEntry.of("moa_decor_toys:guardian").withChance(5),
      LootEntry.of("moa_decor_toys:guardiananciano").withChance(5),
      LootEntry.of("moa_decor_toys:ajoloteazul").withChance(5),
      LootEntry.of("moa_decor_toys:ajolotecafe").withChance(5),
      LootEntry.of("moa_decor_toys:ajolotecian").withChance(5),
      LootEntry.of("moa_decor_toys:ajolotedorado").withChance(5),
      LootEntry.of("moa_decor_toys:ajoloterosa").withChance(5),
    ]);

  // Worker
  event
    .addLootTableModifier("seadwellers:gameplay/mermorph_loot_crate")
    .removeLoot(Ingredient.all)
    .addWeightedLoot([
      LootEntry.of("seadwellers:depth_nugget")
        .limitCount([3, 10])
        .withChance(30),
      LootEntry.of("seadwellers:depth_ingot").withChance(20),
      LootEntry.of("seadwellers:aquamarine").limitCount([3, 10]).withChance(10),
      LootEntry.of("thermal:diving_fabric").limitCount([2, 4]).withChance(10),
      LootEntry.of("moa_decor_toys:ajoloteazul").withChance(5),
      LootEntry.of("moa_decor_toys:ajolotecafe").withChance(5),
      LootEntry.of("moa_decor_toys:ajolotecian").withChance(5),
      LootEntry.of("moa_decor_toys:ajolotedorado").withChance(5),
      LootEntry.of("moa_decor_toys:ajoloterosa").withChance(5),
      LootEntry.of("oceansdelight:guardian").withChance(5),
    ]);

  // Polar
  event
    .addLootTableModifier("seadwellers:gameplay/icy_loot_crate")
    .removeLoot(Ingredient.all)
    .addWeightedLoot([
      LootEntry.of("seadwellers:depth_nugget")
        .limitCount([3, 10])
        .withChance(30),
      LootEntry.of("seadwellers:depth_ingot").withChance(20),
      LootEntry.of("seadwellers:aquamarine").limitCount([3, 10]).withChance(15),
      LootEntry.of("moa_decor_toys:llamablanca").withChance(5),
      LootEntry.of("moa_decor_toys:conejoblanco").withChance(5),
      LootEntry.of("moa_decor_toys:zorroblanco").withChance(5),
      LootEntry.of("moa_decor_toys:osopolar").withChance(5),
      LootEntry.of("moa_decor_toys:gatoblanco").withChance(5),
      LootEntry.of("moa_decor_toys:aldeanoinvierno").withChance(5),
      LootEntry.of("oceansdelight:guardian").withChance(5),
    ]);

  // River
  event
    .addLootTableModifier("seadwellers:gameplay/river_loot_crate")
    .removeLoot(Ingredient.all)
    .addWeightedLoot([
      LootEntry.of("seadwellers:depth_nugget")
        .limitCount([3, 10])
        .withChance(30),
      LootEntry.of("seadwellers:depth_ingot").withChance(20),
      LootEntry.of("seadwellers:aquamarine").limitCount([3, 10]).withChance(10),
      LootEntry.of("miners_delight:squid").limitCount([3, 10]).withChance(10),
      LootEntry.of("supplementaries:antique_ink")
        .limitCount([2, 3])
        .withChance(5),
      LootEntry.of("thermal:aquachow").limitCount([4, 9]).withChance(5),
      LootEntry.of(
        "minecraft:potion",
        '{Potion:"goblintraders:extended_water_breathing"}'
      ).withChance(5),
      LootEntry.of("moa_decor_toys:calamar").withChance(5),
      LootEntry.of("moa_decor_toys:tortugamarina").withChance(5),
      LootEntry.of("oceansdelight:guardian").withChance(5),
    ]);

  // Depths
  event
    .addLootTableModifier("seadwellers:gameplay/cavern_loot_crate")
    .removeLoot(Ingredient.all)
    .addWeightedLoot([
      LootEntry.of("seadwellers:depth_nugget")
        .limitCount([3, 10])
        .withChance(30),
      LootEntry.of("seadwellers:depth_ingot").withChance(20),
      LootEntry.of("seadwellers:aquamarine").limitCount([3, 10]).withChance(10),
      LootEntry.of("miners_delight:glow_squid")
        .limitCount([3, 10])
        .withChance(10),
      LootEntry.of("minecards:aquatic_card_box").withChance(5),
      LootEntry.of("thermal:deep_aquachow").limitCount([4, 9]).withChance(5),
      LootEntry.of(
        "minecraft:potion",
        '{Potion:"goblintraders:extended_water_breathing"}'
      ).withChance(5),
      LootEntry.of("crabbersdelight:crab_trap").withChance(5),
      LootEntry.of("moa_decor_toys:calamarbrillante").withChance(5),
      LootEntry.of("oceansdelight:guardian").withChance(5),
    ]);

  // Orange and Yellow Coral
  event
    .addLootTableModifier("seadwellers:gameplay/coral_loot_crate")
    .removeLoot(Ingredient.all)
    .addWeightedLoot([
      LootEntry.of("seadwellers:depth_nugget")
        .limitCount([3, 10])
        .withChance(30),
      LootEntry.of("seadwellers:depth_ingot").withChance(20),
      LootEntry.of("seadwellers:aquamarine").limitCount([3, 10]).withChance(10),
      LootEntry.of("minecraft:fire_coral").limitCount([3, 8]).withChance(1),
      LootEntry.of("minecraft:fire_coral_block")
        .limitCount([3, 8])
        .withChance(1),
      LootEntry.of("minecraft:fire_coral_fan").limitCount([3, 8]).withChance(1),
      LootEntry.of("minecraft:tube_coral").limitCount([3, 8]).withChance(1),
      LootEntry.of("minecraft:tube_coral_block")
        .limitCount([3, 8])
        .withChance(1),
      LootEntry.of("minecraft:tube_coral_fan").limitCount([3, 8]).withChance(1),
      LootEntry.of("minecraft:brain_coral").limitCount([3, 8]).withChance(1),
      LootEntry.of("minecraft:brain_coral_block")
        .limitCount([3, 8])
        .withChance(1),
      LootEntry.of("minecraft:brain_coral_fan")
        .limitCount([3, 8])
        .withChance(1),
      LootEntry.of("minecraft:bubble_coral").limitCount([3, 8]).withChance(1),
      LootEntry.of("minecraft:bubble_coral_block")
        .limitCount([3, 8])
        .withChance(1),
      LootEntry.of("minecraft:bubble_coral_fan")
        .limitCount([3, 8])
        .withChance(1),
      LootEntry.of("minecraft:horn_coral").limitCount([3, 8]).withChance(1),
      LootEntry.of("minecraft:horn_coral_block")
        .limitCount([3, 8])
        .withChance(1),
      LootEntry.of("minecraft:horn_coral_fan").limitCount([3, 8]).withChance(1),
      LootEntry.of("moa_decor_toys:calamar").withChance(5),
      LootEntry.of("moa_decor_toys:tortugamarina").withChance(5),
      LootEntry.of("oceansdelight:guardian").withChance(15),
    ]);
});

// Sea Dwellers Currency
ServerEvents.tags("item", (event) => {
  event.removeAll("seadwellers:mermorph_currency_aquamarine");
  event.add("seadwellers:mermorph_currency_aquamarine", [
    "oceansdelight:bowl_of_guardian_soup",
    "qualitysdelight:bowl_of_guardian_soup_iron",
    "qualitysdelight:bowl_of_guardian_soup_gold",
    "qualitysdelight:bowl_of_guardian_soup_diamond"
  ]);
  event.removeAll("seadwellers:mermorph_currency_fish");
  event.add("seadwellers:mermorph_currency_fish", [
    /.*delight:salmon_roll.*/,
    /.*delight:cod_roll.*/,
    /.*delight:kelp_roll.*/,
    /.*delight:fugu_roll.*/,
    /.*delight:elder_guardian_roll.*/,
    "alexscaves:deep_sea_sushi_roll",
  ]);
  event.removeAll("seadwellers:mermorph_currency_nautilus");
  event.add("seadwellers:mermorph_currency_nautilus", [
    "oceansdelight:cabbage_wrapped_elder_guardian",
    "qualitysdelight:cabbage_wrapped_elder_guardian_iron",
    "qualitysdelight:cabbage_wrapped_elder_guardian_gold",
    "qualitysdelight:cabbage_wrapped_elder_guardian_diamond"
  ]);
});
