public static boolean itemContainsMagic(ItemStack stack) {
    if (isInfiniteContainer(stack)) return true;

    MagicAmounts amounts = getContainedMagic(stack);

    return amounts != null && !amounts.isEmpty();
  }
  public static MagicAmounts getMagicLimits(ItemStack stack) {
    if (stack.stackSize != 1) return null;

    Item item = stack.getItem();
    if (!(item instanceof ItemMagicContainer)) return null;

    MagicAmounts m = ((ItemMagicContainer) item).getCapacity(stack);
    if (m == null) return null;

    return m.copy();
  }
  public static ItemStack setContainedMagic(ItemStack output, MagicAmounts amounts) {
    if (output == null) {
      return null;
    }

    if (output.stackSize != 1) {
      return null;
    }

    if (isInfiniteContainer(output)) return output;

    if (amounts != null) {
      if (amounts.isEmpty()) {
        amounts = null;
      }
    }

    if (amounts != null) {
      output = identifyQuality(output);

      NBTTagCompound nbt = output.getTagCompound();
      if (nbt == null) {
        nbt = new NBTTagCompound();
        output.setTagCompound(nbt);
      }

      for (int i = 0; i < MagicAmounts.ELEMENTS; i++) {
        nbt.setFloat("" + i, amounts.amounts[i]);
      }

      return output;
    } else {
      NBTTagCompound nbt = output.getTagCompound();

      if (nbt != null) {
        for (int i = 0; i < MagicAmounts.ELEMENTS; i++) {
          nbt.removeTag("" + i);
        }

        if (nbt.getKeySet().size() == 0) output.setTagCompound(null);
      }

      return output;
    }
  }