Search in sources :

Example 26 with Aspect

use of thaumcraft.api.aspects.Aspect 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)

Aggregations

Aspect (thaumcraft.api.aspects.Aspect)26 AspectList (thaumcraft.api.aspects.AspectList)21 DecimalFormat (java.text.DecimalFormat)3 ItemStack (net.minecraft.item.ItemStack)3 com.github.technus.tectech.elementalMatter.core.tElementalException (com.github.technus.tectech.elementalMatter.core.tElementalException)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Block (net.minecraft.block.Block)1 Minecraft (net.minecraft.client.Minecraft)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 IAspectContainer (thaumcraft.api.aspects.IAspectContainer)1 INode (thaumcraft.api.nodes.INode)1