Search in sources :

Example 1 with ReagentContainer

use of WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer in project BloodMagic by WayofTime.

the class TEBellJar method getContainerInfoFromItem.

public static ReagentContainerInfo[] getContainerInfoFromItem(ItemStack stack) {
    if (stack != null && stack.getItem() instanceof ItemBlock && ModBlocks.blockCrystalBelljar == ((ItemBlock) stack.getItem()).field_150939_a) {
        NBTTagCompound tag = stack.getTagCompound();
        if (tag != null) {
            NBTTagList tagList = tag.getTagList("reagentTanks", Constants.NBT.TAG_COMPOUND);
            int size = tagList.tagCount();
            ReagentContainer[] tanks = new ReagentContainer[size];
            ReagentContainerInfo[] infos = new ReagentContainerInfo[size];
            for (int i = 0; i < size; i++) {
                NBTTagCompound savedTag = tagList.getCompoundTagAt(i);
                tanks[i] = ReagentContainer.readFromNBT(savedTag);
                if (tanks[i] != null) {
                    infos[i] = tanks[i].getInfo();
                }
            }
            return infos;
        }
    }
    return new ReagentContainerInfo[0];
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ReagentContainerInfo(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemBlock(net.minecraft.item.ItemBlock) ReagentContainer(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer)

Example 2 with ReagentContainer

use of WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer in project BloodMagic by WayofTime.

the class BlockBelljar method getSubBlocks.

@SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
    if (this.equals(ModBlocks.blockCrystalBelljar)) {
        par3List.add(new ItemStack(par1, 1, 0));
        for (Reagent reagent : ReagentRegistry.reagentList.values()) {
            ItemStack stack = new ItemStack(par1, 1, 0);
            NBTTagCompound tag = new NBTTagCompound();
            ReagentContainer[] tanks = new ReagentContainer[1];
            tanks[0] = new ReagentContainer(reagent, 16000, 16000);
            NBTTagList tagList = new NBTTagList();
            NBTTagCompound savedTag = new NBTTagCompound();
            if (tanks[0] != null) {
                tanks[0].writeToNBT(savedTag);
            }
            tagList.appendTag(savedTag);
            tag.setTag("reagentTanks", tagList);
            stack.setTagCompound(tag);
            par3List.add(stack);
        }
    } else {
        super.getSubBlocks(par1, par2CreativeTabs, par3List);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent) ReagentContainer(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 3 with ReagentContainer

use of WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer in project BloodMagic by WayofTime.

the class ItemBlockCrystalBelljar method addInformation.

@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
    ReagentContainer[] tanks = this.getReagentContainers(stack);
    if (tanks == null) {
        list.add(StatCollector.translateToLocal("tooltip.crystalbelljar.empty"));
    } else {
        list.add(StatCollector.translateToLocal("tooltip.crystalbelljar.contents"));
        for (int i = 0; i < tanks.length; i++) {
            if (tanks[i] == null || tanks[i].getReagent() == null || tanks[i].getReagent().reagent == null) {
                list.add("- Empty");
            } else {
                ReagentStack reagentStack = tanks[i].getReagent();
                list.add("- " + reagentStack.reagent.name + ": " + reagentStack.amount + "/" + tanks[i].getCapacity() / 1000 + "k AR");
            }
        }
    }
}
Also used : ReagentStack(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack) ReagentContainer(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer)

Example 4 with ReagentContainer

use of WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer in project BloodMagic by WayofTime.

the class ItemBlockCrystalBelljar method getReagentContainers.

public ReagentContainer[] getReagentContainers(ItemStack stack) {
    if (stack != null && stack.hasTagCompound()) {
        NBTTagCompound tag = stack.getTagCompound();
        NBTTagList tagList = tag.getTagList("reagentTanks", Constants.NBT.TAG_COMPOUND);
        int size = tagList.tagCount();
        ReagentContainer[] tanks = new ReagentContainer[size];
        for (int i = 0; i < size; i++) {
            NBTTagCompound savedTag = tagList.getCompoundTagAt(i);
            tanks[i] = ReagentContainer.readFromNBT(savedTag);
        }
        return tanks;
    }
    return null;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ReagentContainer(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer)

Aggregations

ReagentContainer (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 Reagent (WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)1 ReagentContainerInfo (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo)1 ReagentStack (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 ItemBlock (net.minecraft.item.ItemBlock)1 ItemStack (net.minecraft.item.ItemStack)1