Search in sources :

Example 1 with IEssentiaContainerItem

use of thaumcraft.api.aspects.IEssentiaContainerItem in project Railcraft by Railcraft.

the class EssentiaHelper method getEssentia.

public static boolean getEssentia(IInventory inv, int slot, Aspect aspect) {
    ItemStack stack = inv.getStackInSlot(slot);
    if (!InvTools.isEmpty(stack) && stack.getItem() instanceof IEssentiaContainerItem && "item.BlockJarFilledItem".equals(stack.getUnlocalizedName())) {
        IEssentiaContainerItem jar = (IEssentiaContainerItem) stack.getItem();
        AspectList aspects = jar.getAspects(stack);
        if (aspects.getAmount(aspect) > 0) {
            aspects.remove(aspect, 1);
            if (aspects.size() == 0) {
                ItemStack emptyJar = ThaumcraftPlugin.BLOCKS.get("jar");
                inv.setInventorySlotContents(slot, emptyJar);
            } else
                jar.setAspects(stack, aspects);
            return true;
        }
    }
    return false;
}
Also used : IEssentiaContainerItem(thaumcraft.api.aspects.IEssentiaContainerItem) AspectList(thaumcraft.api.aspects.AspectList) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)1 AspectList (thaumcraft.api.aspects.AspectList)1 IEssentiaContainerItem (thaumcraft.api.aspects.IEssentiaContainerItem)1