package cofh.lib.util.helpers; import cofh.api.item.IAugmentItem; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; public class AugmentHelper { private AugmentHelper() { } /* NBT TAG HELPERS */ public static void writeAugmentsToNBT(NBTTagCompound nbt, ItemStack[] augments) { if (augments.length <= 0) { return; } NBTTagList list = new NBTTagList(); for (int i = 0; i < augments.length; i++) { if (augments[i] != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("Slot", i); augments[i].writeToNBT(tag); list.appendTag(tag); } } nbt.setTag("Augments", list); } /* ITEM HELPERS */ public static void writeAugments(ItemStack stack, ItemStack[] augments) { if (augments.length <= 0) { return; } if (stack.stackTagCompound == null) { stack.setTagCompound(new NBTTagCompound()); } NBTTagList list = new NBTTagList(); for (int i = 0; i < augments.length; i++) { if (augments[i] != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("Slot", i); augments[i].writeToNBT(tag); list.appendTag(tag); } } stack.stackTagCompound.setTag("Augments", list); } public static boolean isAugmentItem(ItemStack stack) { return stack != null && stack.getItem() instanceof IAugmentItem; } }