public void recalculateHealth(EntityPlayer player, TPlayerStats stats) {
    Side side = FMLCommonHandler.instance().getEffectiveSide();

    if (inventory[4] != null || inventory[5] != null || inventory[6] != null) {
      int bonusHP = 0;
      for (int i = 4; i < 7; i++) {
        ItemStack stack = inventory[i];
        if (stack != null && stack.getItem() instanceof IHealthAccessory) {
          bonusHP += ((IHealthAccessory) stack.getItem()).getHealthBoost(stack);
        }
      }
      int prevHealth = stats.bonusHealth;
      stats.bonusHealth = bonusHP;

      int healthChange = bonusHP - prevHealth;
      if (healthChange != 0) {
        IAttributeInstance attributeinstance =
            player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth);
        try {
          attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
        } catch (Exception e) {
        }
        attributeinstance.applyModifier(
            new AttributeModifier(globalID, "tconstruct.heartCanister", bonusHP, 0));
      }
    } else if (parent != null && parent.get() != null) {
      int prevHealth = stats.bonusHealth;
      int bonusHP = 0;
      stats.bonusHealth = bonusHP;
      int healthChange = bonusHP - prevHealth;
      if (healthChange != 0) {
        IAttributeInstance attributeinstance =
            player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth);
        try {
          attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
        } catch (Exception e) {
        }
      }
    }
  }