PlayerEvents.tick(event => {
  let player = event.player;
  if (player.level.isClientSide()) return;

  let magehelm =
    [
      'irons_spellbooks:wandering_magician_helmet',
      'irons_spellbooks:pumpkin_helmet',
      'irons_spellbooks:pyromancer_helmet',
      'irons_spellbooks:electromancer_helmet',
      'irons_spellbooks:archevoker_helmet',
      'irons_spellbooks:cultist_helmet',
      'irons_spellbooks:cryomancer_helmet',
      'irons_spellbooks:shadowwalker_helmet',
      'irons_spellbooks:priest_helmet',
      'irons_spellbooks:plagued_helmet'
    ]

  let magechest =
    [
      'irons_spellbooks:wandering_magician_chestplate',
      'irons_spellbooks:pumpkin_chestplate',
      'irons_spellbooks:pyromancer_chestplate',
      'irons_spellbooks:electromancer_chestplate',
      'irons_spellbooks:archevoker_chestplate',
      'irons_spellbooks:cultist_chestplate',
      'irons_spellbooks:cryomancer_chestplate',
      'irons_spellbooks:shadowwalker_chestplate',
      'irons_spellbooks:priest_chestplate',
      'irons_spellbooks:plagued_chestplate'
    ]

  let magelegs =
    [
      'irons_spellbooks:wandering_magician_leggings',
      'irons_spellbooks:pumpkin_leggings',
      'irons_spellbooks:pyromancer_leggings',
      'irons_spellbooks:electromancer_leggings',
      'irons_spellbooks:archevoker_leggings',
      'irons_spellbooks:cultist_leggings',
      'irons_spellbooks:cryomancer_leggings',
      'irons_spellbooks:shadowwalker_leggings',
      'irons_spellbooks:priest_leggings',
      'irons_spellbooks:plagued_leggings'
    ]

  let mageboots =
    [
      'irons_spellbooks:wandering_magician_boots',
      'irons_spellbooks:pumpkin_boots',
      'irons_spellbooks:pyromancer_boots',
      'irons_spellbooks:electromancer_boots',
      'irons_spellbooks:archevoker_boots',
      'irons_spellbooks:cultist_boots',
      'irons_spellbooks:cryomancer_boots',
      'irons_spellbooks:shadowwalker_boots',
      'irons_spellbooks:priest_boots',
      'irons_spellbooks:plagued_boots'
    ]

  let helmet = player.inventory.getArmor(3);
  let chest = player.inventory.getArmor(2);
  let legs = player.inventory.getArmor(1);
  let boots = player.inventory.getArmor(0);

  if (helmet && magehelm.includes(helmet.id)) {
    player.potionEffects.add('attributeslib:sundering', 120, 1, false, false);
  }

  if (chest && magechest.includes(chest.id)) {
    player.potionEffects.add('attributeslib:sundering', 120, 1, false, false);
  }

  if (legs && magelegs.includes(legs.id)) {
    player.potionEffects.add('attributeslib:sundering', 120, 1, false, false);
  }

  if (boots && mageboots.includes(boots.id)) {
    player.potionEffects.add('attributeslib:sundering', 120, 1, false, false);
  }
});
