public void onArmorUnequipped(World world, EntityPlayer player, ItemStack armor) {
    NBTTagCompound nbt = getOrCreateTagCompound(armor);

    for (int i = 0; i < nbt.getInteger("moduleCount"); i++) {
      IArmorModule module = (IArmorModule) ModuleRegistry.getModule(nbt.getString("module" + i));

      if ((module != null)) {
        module.onArmorUnequipped(world, player);
      }
    }
  }
  @Override
  @Optional.Method(modid = "Thaumcraft")
  public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player) {
    NBTTagCompound nbt = getOrCreateTagCompound(itemstack);
    for (int i = 0; i < nbt.getInteger("moduleCount"); i++) {
      IArmorModule module = (IArmorModule) ModuleRegistry.getModule(nbt.getString("module" + i));

      if ((module != null) && (module.getArmorEffectType() == EnumArmorEffectType.SPECIAL)) {
        if (module == InitItems.itemThaumicMonocle) return true;
      }
    }
    return false;
  }
  @Override
  public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
    NBTTagCompound nbt = getOrCreateTagCompound(armor);
    for (int i = 0; i < nbt.getInteger("moduleCount"); i++) {
      IArmorModule module = (IArmorModule) ModuleRegistry.getModule(nbt.getString("module" + i));

      if ((module != null) && (module.getArmorEffectType() == EnumArmorEffectType.DEFENSIVE)) {
        IDefensiveArmorModule defmodule = (IDefensiveArmorModule) module;
        return defmodule.getArmorToDisplay();
      }
    }
    return 0;
  }
  @SuppressWarnings("all")
  @Override
  public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean flag) {
    if (stack != null) {
      list.add("Modules:");
      NBTTagCompound nbt = getOrCreateTagCompound(stack);

      for (int i = 0; i < nbt.getInteger("moduleCount"); i++) {
        IArmorModule module = (IArmorModule) ModuleRegistry.getModule(nbt.getString("module" + i));

        if (module != null) {
          list.add(module.getName());
        }
      }
    }
  }
  @Override
  public void onArmorTick(World world, EntityPlayer player, ItemStack is) {
    // int combinedModuleWeight = 0;

    NBTTagCompound nbt = getOrCreateTagCompound(is);

    for (int i = 0; i < nbt.getInteger("moduleCount"); i++) {
      IArmorModule module = (IArmorModule) ModuleRegistry.getModule(nbt.getString("module" + i));

      if ((module != null) && (module.getArmorEffectType() == EnumArmorEffectType.ONTICK)) {
        module.applyModuleEffect(world, player, is);
        // combinedModuleWeight += module.getModuleWeight();
      }
    }
    // if(this.getSlownessLevelFromWeight(combinedModuleWeight) >= 1)
    // player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5,
    // this.getSlownessLevelFromWeight(combinedModuleWeight), true));
  }
  @Override
  @SideOnly(Side.CLIENT)
  public void renderHelmetOverlay(
      ItemStack stack,
      EntityPlayer player,
      ScaledResolution resolution,
      float partialTicks,
      boolean hasScreen,
      int mouseX,
      int mouseY) {
    NBTTagCompound nbt = getOrCreateTagCompound(stack);

    for (int i = 0; i < nbt.getInteger("moduleCount"); i++) {
      IArmorModule module = (IArmorModule) ModuleRegistry.getModule(nbt.getString("module" + i));

      if ((module != null) && (module.getArmorEffectType() == EnumArmorEffectType.HUD)) {
        module.applyModuleEffect(player.getEntityWorld(), player, stack);
      }
    }
  }
  @Override
  public ArmorProperties getProperties(
      EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
    int priority = 0;
    int absorbRatio = 0;
    int absorbMax = 0;
    NBTTagCompound nbt = getOrCreateTagCompound(armor);

    for (int i = 0; i < nbt.getInteger("moduleCount"); i++) {
      IArmorModule module = (IArmorModule) ModuleRegistry.getModule(nbt.getString("module" + i));

      if ((module != null) && (module.getArmorEffectType() == EnumArmorEffectType.DEFENSIVE)) {
        IDefensiveArmorModule defmodule = (IDefensiveArmorModule) module;
        absorbRatio = defmodule.getDamageAbsorbRatio();
        absorbMax = defmodule.getMaxDamageAbsorb();
      }
      if (source.isUnblockable()) {
        absorbMax = 0;
        absorbRatio = 0;
      }
    }
    return new ArmorProperties(priority, absorbRatio, absorbMax);
  }