Search in sources :

Example 36 with AspectList

use of thaumcraft.api.aspects.AspectList in project PneumaticCraft by MineMaarten.

the class BlockTrackEntryThaumcraft method addInformation.

@Override
public void addInformation(World world, int x, int y, int z, TileEntity te, List<String> infoList) {
    if (te instanceof IAspectContainer) {
        IAspectContainer container = (IAspectContainer) te;
        AspectList aspects = container.getAspects();
        if (aspects != null && aspects.size() > 0) {
            infoList.add("blockTracker.info.thaumcraft");
            for (Map.Entry<Aspect, Integer> entry : aspects.aspects.entrySet()) {
                infoList.add("-" + entry.getValue() + "x " + entry.getKey().getName());
            }
        } else {
            infoList.add(I18n.format("blockTracker.info.thaumcraft") + " -");
        }
        if (container instanceof INode) {
            INode node = (INode) container;
            infoList.add(I18n.format("blockTracker.info.thaumcraft.nodetype") + " " + I18n.format("nodetype." + node.getNodeType() + ".name"));
            if (node.getNodeModifier() != null)
                infoList.add(I18n.format("blockTracker.info.thaumcraft.nodeModifier") + " " + I18n.format("nodemod." + node.getNodeModifier() + ".name"));
        }
    }
}
Also used : INode(thaumcraft.api.nodes.INode) IAspectContainer(thaumcraft.api.aspects.IAspectContainer) AspectList(thaumcraft.api.aspects.AspectList) Aspect(thaumcraft.api.aspects.Aspect) Map(java.util.Map)

Example 37 with AspectList

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

the class ThaumcraftApi method exists.

// ASPECTS////////////////////////////////////////
/**
 * Checks to see if the passed item/block already has aspects associated with it.
 * @param id
 * @param meta
 * @return
 */
public static boolean exists(ItemStack item) {
    ItemStack stack = item.copy();
    stack.setCount(1);
    AspectList tmp = CommonInternals.objectTags.get(stack.serializeNBT().toString());
    if (tmp == null) {
        try {
            stack.setItemDamage(OreDictionary.WILDCARD_VALUE);
            tmp = CommonInternals.objectTags.get(stack.serializeNBT().toString());
            if (item.getItemDamage() == OreDictionary.WILDCARD_VALUE && tmp == null) {
                int index = 0;
                do {
                    stack.setItemDamage(index);
                    tmp = CommonInternals.objectTags.get(stack.serializeNBT().toString());
                    index++;
                } while (index < 16 && tmp == null);
            }
            if (tmp == null)
                return false;
        } catch (Exception e) {
        }
    }
    return true;
}
Also used : AspectList(thaumcraft.api.aspects.AspectList) ItemStack(net.minecraft.item.ItemStack)

Example 38 with AspectList

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

the class ThaumcraftApi method registerComplexObjectTag.

/**
 * Used to assign aspects to the given item/block.
 * Attempts to automatically generate aspect tags by checking registered recipes.
 * Here is an example of the declaration for pistons:<p>
 * <i>ThaumcraftApi.registerComplexObjectTag(new ItemStack(Blocks.PISTON), (new AspectList()).add(Aspect.MECHANISM, 2).add(Aspect.MOTION, 4));</i>
 * IMPORTANT - this should only be used if you are not happy with the default aspects the object would be assigned.
 * @param item, pass OreDictionary.WILDCARD_VALUE to meta if all damage values of this item/block should have the same aspects
 * @param aspects A ObjectTags object of the associated aspects
 */
public static void registerComplexObjectTag(ItemStack item, AspectList aspects) {
    if (!exists(item)) {
        AspectList tmp = AspectHelper.generateTags(item);
        if (tmp != null && tmp.size() > 0) {
            for (Aspect tag : tmp.getAspects()) {
                aspects.add(tag, tmp.getAmount(tag));
            }
        }
        registerObjectTag(item, aspects);
    } else {
        AspectList tmp = AspectHelper.getObjectAspects(item);
        for (Aspect tag : aspects.getAspects()) {
            tmp.merge(tag, tmp.getAmount(tag));
        }
        registerObjectTag(item, tmp);
    }
}
Also used : AspectList(thaumcraft.api.aspects.AspectList) Aspect(thaumcraft.api.aspects.Aspect)

Example 39 with AspectList

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

the class ItemGenericEssentiaContainer method getAspects.

@Override
public AspectList getAspects(ItemStack itemstack) {
    if (itemstack.hasTagCompound()) {
        AspectList aspects = new AspectList();
        aspects.readFromNBT(itemstack.getTagCompound());
        return aspects.size() > 0 ? aspects : null;
    }
    return null;
}
Also used : AspectList(thaumcraft.api.aspects.AspectList)

Aggregations

AspectList (thaumcraft.api.aspects.AspectList)39 Aspect (thaumcraft.api.aspects.Aspect)22 ItemStack (net.minecraft.item.ItemStack)15 DecimalFormat (java.text.DecimalFormat)3 Block (net.minecraft.block.Block)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 IGas (ladysnake.gaspunk.api.IGas)1 EnumDetector (mods.railcraft.common.blocks.detector.EnumDetector)1 EnumColor (mods.railcraft.common.plugins.color.EnumColor)1 Entity (net.minecraft.entity.Entity)1 EntityItem (net.minecraft.entity.item.EntityItem)1 BlockPos (net.minecraft.util.math.BlockPos)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 ThaumcraftApi (thaumcraft.api.ThaumcraftApi)1 IAspectContainer (thaumcraft.api.aspects.IAspectContainer)1 IEssentiaContainerItem (thaumcraft.api.aspects.IEssentiaContainerItem)1 ItemGenericEssentiaContainer (thaumcraft.api.items.ItemGenericEssentiaContainer)1