package net.shadowfacts.enfusion.energy;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

/**
 * @author shadowfacts
 */
public class EnergyUtils {

	public static final String TAG_ENERGY = "Energy";

	public static ItemStack setEnergyInStack(ItemStack stack, int energy) {
		if (stack.stackTagCompound == null) stack.stackTagCompound = new NBTTagCompound();
		stack.stackTagCompound.setInteger(TAG_ENERGY, energy);
		return stack;
	}

	public static int getEnergyInStack(ItemStack stack) {
		if (stack.stackTagCompound == null || !stack.stackTagCompound.hasKey(TAG_ENERGY)) {
			return 0;
		}
		return stack.stackTagCompound.getInteger(TAG_ENERGY);
	}



}

@@ -225,16 +225,243 @@
 ergy%22;%0A%0A
+%09/**%0A%09 * Sets the energy in an %7B@link net.minecraft.item.ItemStack%7D%0A%09 * @param stack The %7B@link net.minecraft.item.ItemStack%7D%0A%09 * @param energy How much energy%0A%09 * @return The modified %7B@link net.minecraft.item.ItemStack%7D%0A%09 */%0A
 %09public 
@@ -687,16 +687,272 @@
 ck;%0A%09%7D%0A%0A
+%09/**%0A%09 * Gets the amount of energy in an %7B@link ItemStack%7D, returns 0 if if %7B@link net.minecraft.nbt.NBTTagCompound%7D is null or doesn't have the %22Energy%22 key.%0A%09 * @param stack The %7B@link net.minecraft.item.ItemStack%7D%0A%09 * @return The amount of energy.%0A%09 */%0A
 %09public 

Add JavaDoc to EnergyUtils