thaumcraft.api.ThaumcraftApiHelper Java Examples

The following examples show how to use thaumcraft.api.ThaumcraftApiHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InfusionEnchantmentRecipe.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
protected boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy)
  {
if (stack0==null && stack1!=null) return false;
if (stack0!=null && stack1==null) return false;
if (stack0==null && stack1==null) return true;
boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1);
if (!t1) return false;
if (fuzzy) {
	Integer od = OreDictionary.getOreID(stack0);
	if (od!=-1) {
		ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{});
		if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores))
			return true;
	}
}
      return stack0.getItem() != stack1.getItem() ? false : (stack0.getItemDamage() != stack1.getItemDamage() ? false : stack0.stackSize <= stack0.getMaxStackSize() );
  }
 
Example #2
Source File: TileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void playVortexEffects() {
    for (int a = 0; a < Thaumcraft.proxy.particleCount(1); a++) {
        int tx = this.xCoord + this.worldObj.rand.nextInt(4) - this.worldObj.rand.nextInt(4);
        int ty = this.yCoord + 1 + this.worldObj.rand.nextInt(4) - this.worldObj.rand.nextInt(4);
        int tz = this.zCoord + this.worldObj.rand.nextInt(4) - this.worldObj.rand.nextInt(4);
        if (ty > this.worldObj.getHeightValue(tx, tz)) {
            ty = this.worldObj.getHeightValue(tx, tz);
        }
        Vec3 v1 = Vec3.createVectorHelper(this.xCoord + 0.5D, this.yCoord + 1.5D, this.zCoord + 0.5D);
        Vec3 v2 = Vec3.createVectorHelper(tx + 0.5D, ty + 0.5D, tz + 0.5D);

        MovingObjectPosition mop = ThaumcraftApiHelper.rayTraceIgnoringSource(this.worldObj, v1, v2, true, false, false);
        if ((mop != null) && (getDistanceFrom(mop.blockX, mop.blockY, mop.blockZ) < 16.0D)) {
            tx = mop.blockX;
            ty = mop.blockY;
            tz = mop.blockZ;
            Block bi = this.worldObj.getBlock(tx, ty, tz);
            int md = this.worldObj.getBlockMetadata(tx, ty, tz);
            if (!bi.isAir(this.worldObj, tx, ty, tz)) {
                Thaumcraft.proxy.hungryNodeFX(this.worldObj, tx, ty, tz, this.xCoord, this.yCoord + 1, this.zCoord, bi, md);
            }
        }
    }
}
 
Example #3
Source File: InfusionRecipe.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public static boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy)
  {
if (stack0==null && stack1!=null) return false;
if (stack0!=null && stack1==null) return false;
if (stack0==null && stack1==null) return true;

//nbt
boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1);		
if (!t1) return false;

if (fuzzy) {
	Integer od = OreDictionary.getOreID(stack0);
	if (od!=-1) {
		ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{});
		if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores))
			return true;
	}
}

//damage
boolean damage = stack0.getItemDamage() == stack1.getItemDamage() ||
		stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE;		

      return stack0.getItem() != stack1.getItem() ? false : (!damage ? false : stack0.stackSize <= stack0.getMaxStackSize() );
  }
 
Example #4
Source File: TileStickyJar.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void fillJar() {
    ForgeDirection inputDir = placedOn.getOpposite();

    TileEntity te = ThaumcraftApiHelper.getConnectableTile(parent.getWorldObj(), parent.xCoord, parent.yCoord, parent.zCoord, inputDir);
    if (te != null)
    {
        IEssentiaTransport ic = (IEssentiaTransport)te;
        if (!ic.canOutputTo(ForgeDirection.DOWN)) {
            return;
        }
        Aspect ta = null;
        if (parent.aspectFilter != null) {
            ta = parent.aspectFilter;
        } else if ((parent.aspect != null) && (parent.amount > 0)) {
            ta = parent.aspect;
        } else if ((ic.getEssentiaAmount(inputDir.getOpposite()) > 0) &&
                (ic.getSuctionAmount(inputDir.getOpposite()) < getSuctionAmount(ForgeDirection.UP)) && (getSuctionAmount(ForgeDirection.UP) >= ic.getMinimumSuction())) {
            ta = ic.getEssentiaType(inputDir.getOpposite());
        }
        if ((ta != null) && (ic.getSuctionAmount(inputDir.getOpposite()) < getSuctionAmount(ForgeDirection.UP))) {
            addToContainer(ta, ic.takeEssentia(ta, 1, inputDir.getOpposite()));
        }
    }
}
 
Example #5
Source File: TileBlockProtector.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void fillJar() {
    TileEntity te = ThaumcraftApiHelper.getConnectableTile(this.worldObj, this.xCoord, this.yCoord, this.zCoord, ForgeDirection.DOWN);
    if (te != null) {
        IEssentiaTransport ic = (IEssentiaTransport) te;
        if (!ic.canOutputTo(ForgeDirection.UP)) {
            return;
        }
        Aspect ta = null;
        if (this.aspectFilter != null) {
            ta = this.aspectFilter;
        } else if ((this.aspect != null) && (this.amount > 0)) {
            ta = this.aspect;
        } else if ((ic.getEssentiaAmount(ForgeDirection.UP) > 0) &&
                (ic.getSuctionAmount(ForgeDirection.UP) < getSuctionAmount(ForgeDirection.DOWN)) && (getSuctionAmount(ForgeDirection.DOWN) >= ic.getMinimumSuction())) {
            ta = ic.getEssentiaType(ForgeDirection.UP);
        }
        if ((ta != null) && (ic.getSuctionAmount(ForgeDirection.UP) < getSuctionAmount(ForgeDirection.DOWN))) {
            addToContainer(ta, ic.takeEssentia(ta, 1, ForgeDirection.UP));
        }
    }
}
 
Example #6
Source File: BlockNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) {
    TileNodeManipulator tile = (TileNodeManipulator) world.getTileEntity(x, y, z);
    ItemStack heldItem = player.getHeldItem();
    if(tile.isInMultiblock()) {
        super.onBlockActivated(world, x, y, z, player, side, par7, par8, par9);
    } else if(!world.isRemote && heldItem != null && heldItem.getItem() instanceof ItemWandCasting) {
        tile.checkMultiblock();
        if (tile.isMultiblockStructurePresent()) {
            String research = tile.getMultiblockType().getResearchNeeded();
            if(!ResearchManager.isResearchComplete(player.getCommandSenderName(), research)) return false;
            if (ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, tile.getMultiblockType().getMultiblockCosts(), true)) {
                tile.formMultiblock();
                return true;
            }
        }
    }
    return false;
}
 
Example #7
Source File: InfusionEnchantmentRecipe.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
protected boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy)
  {
if (stack0==null && stack1!=null) return false;
if (stack0!=null && stack1==null) return false;
if (stack0==null && stack1==null) return true;
boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1);
if (!t1) return false;
if (fuzzy) {
	Integer od = OreDictionary.getOreID(stack0);
	if (od!=-1) {
		ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{});
		if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores))
			return true;
	}
}
      return stack0.getItem() != stack1.getItem() ? false : (stack0.getItemDamage() != stack1.getItemDamage() ? false : stack0.stackSize <= stack0.getMaxStackSize() );
  }
 
Example #8
Source File: InfusionEnchantmentRecipe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
protected boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy)
  {
if (stack0==null && stack1!=null) return false;
if (stack0!=null && stack1==null) return false;
if (stack0==null && stack1==null) return true;
boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1);
if (!t1) return false;
if (fuzzy) {
	int od = OreDictionary.getOreID(stack0);
	if (od!=-1) {
		ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{});
		if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores))
			return true;
	}
}
      return stack0.getItem() != stack1.getItem() ? false : (stack0.getItemDamage() != stack1.getItemDamage() ? false : stack0.stackSize <= stack0.getMaxStackSize() );
  }
 
Example #9
Source File: ShapedArcaneRecipe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public boolean matches(IInventory inv, World world, EntityPlayer player)
{
	if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) {
		return false;
	}
    for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
    {
        for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
        {
            if (checkMatch(inv, x, y, false))
            {
                return true;
            }

            if (mirrored && checkMatch(inv, x, y, true))
            {
                return true;
            }
        }
    }

    return false;
}
 
Example #10
Source File: ShapedArcaneRecipe.java    From AdvancedMod with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean matches(IInventory inv, World world, EntityPlayer player)
{
	if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) {
		return false;
	}
    for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
    {
        for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
        {
            if (checkMatch(inv, x, y, false))
            {
                return true;
            }

            if (mirrored && checkMatch(inv, x, y, true))
            {
                return true;
            }
        }
    }

    return false;
}
 
Example #11
Source File: InfusionRecipe.java    From GardenCollection with MIT License 6 votes vote down vote up
public static boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy)
  {
if (stack0==null && stack1!=null) return false;
if (stack0!=null && stack1==null) return false;
if (stack0==null && stack1==null) return true;

//nbt
boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1);		
if (!t1) return false;

if (fuzzy) {
	Integer od = OreDictionary.getOreID(stack0);
	if (od!=-1) {
		ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{});
		if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores))
			return true;
	}
}

//damage
boolean damage = stack0.getItemDamage() == stack1.getItemDamage() ||
		stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE;		

      return stack0.getItem() != stack1.getItem() ? false : (!damage ? false : stack0.stackSize <= stack0.getMaxStackSize() );
  }
 
Example #12
Source File: InfusionRecipe.java    From AdvancedMod with GNU General Public License v3.0 6 votes vote down vote up
protected boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy)
  {
if (stack0==null && stack1!=null) return false;
if (stack0!=null && stack1==null) return false;
if (stack0==null && stack1==null) return true;
boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1);
if (!t1) return false;
if (fuzzy) {
	int od = OreDictionary.getOreID(stack0);
	if (od!=-1) {
		ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{});
		if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores))
			return true;
	}
}
      return stack0.getItem() != stack1.getItem() ? false : (stack0.getItemDamage() != stack1.getItemDamage() ? false : stack0.stackSize <= stack0.getMaxStackSize() );
  }
 
Example #13
Source File: InfusionEnchantmentRecipe.java    From AdvancedMod with GNU General Public License v3.0 6 votes vote down vote up
protected boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy)
  {
if (stack0==null && stack1!=null) return false;
if (stack0!=null && stack1==null) return false;
if (stack0==null && stack1==null) return true;
boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1);
if (!t1) return false;
if (fuzzy) {
	int od = OreDictionary.getOreID(stack0);
	if (od!=-1) {
		ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{});
		if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores))
			return true;
	}
}
      return stack0.getItem() != stack1.getItem() ? false : (stack0.getItemDamage() != stack1.getItemDamage() ? false : stack0.stackSize <= stack0.getMaxStackSize() );
  }
 
Example #14
Source File: ShapedArcaneRecipe.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean matches(IInventory inv, World world, EntityPlayer player)
{
	if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) {
		return false;
	}
    for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
    {
        for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
        {
            if (checkMatch(inv, x, y, false))
            {
                return true;
            }

            if (mirrored && checkMatch(inv, x, y, true))
            {
                return true;
            }
        }
    }

    return false;
}
 
Example #15
Source File: ShapedArcaneRecipe.java    From GardenCollection with MIT License 6 votes vote down vote up
@Override
public boolean matches(IInventory inv, World world, EntityPlayer player)
{
	if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) {
		return false;
	}
    for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
    {
        for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
        {
            if (checkMatch(inv, x, y, false))
            {
                return true;
            }

            if (mirrored && checkMatch(inv, x, y, true))
            {
                return true;
            }
        }
    }

    return false;
}
 
Example #16
Source File: InfusionRecipe.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
public static boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy)
  {
if (stack0==null && stack1!=null) return false;
if (stack0!=null && stack1==null) return false;
if (stack0==null && stack1==null) return true;

//nbt
boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1);		
if (!t1) return false;

if (fuzzy) {
	Integer od = OreDictionary.getOreID(stack0);
	if (od!=-1) {
		ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{});
		if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores))
			return true;
	}
}

//damage
boolean damage = stack0.getItemDamage() == stack1.getItemDamage() ||
		stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE;		

      return stack0.getItem() != stack1.getItem() ? false : (!damage ? false : stack0.stackSize <= stack0.getMaxStackSize() );
  }
 
Example #17
Source File: InfusionEnchantmentRecipe.java    From GardenCollection with MIT License 6 votes vote down vote up
protected boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy)
  {
if (stack0==null && stack1!=null) return false;
if (stack0!=null && stack1==null) return false;
if (stack0==null && stack1==null) return true;
boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1);
if (!t1) return false;
if (fuzzy) {
	Integer od = OreDictionary.getOreID(stack0);
	if (od!=-1) {
		ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{});
		if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores))
			return true;
	}
}
      return stack0.getItem() != stack1.getItem() ? false : (stack0.getItemDamage() != stack1.getItemDamage() ? false : stack0.stackSize <= stack0.getMaxStackSize() );
  }
 
Example #18
Source File: ShapedArcaneRecipe.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean matches(IInventory inv, World world, EntityPlayer player)
{
	if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) {
		return false;
	}
    for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
    {
        for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
        {
            if (checkMatch(inv, x, y, false))
            {
                return true;
            }

            if (mirrored && checkMatch(inv, x, y, true))
            {
                return true;
            }
        }
    }

    return false;
}
 
Example #19
Source File: InfusionRecipe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
public static boolean areItemStacksEqual(ItemStack stack0, ItemStack stack1, boolean fuzzy)
  {
if (stack0==null && stack1!=null) return false;
if (stack0!=null && stack1==null) return false;
if (stack0==null && stack1==null) return true;

//nbt
boolean t1=ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(stack0, stack1);		
if (!t1) return false;

if (fuzzy) {
	int od = OreDictionary.getOreID(stack0);
	if (od!=-1) {
		ItemStack[] ores = OreDictionary.getOres(od).toArray(new ItemStack[]{});
		if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{stack1}, ores))
			return true;
	}
}

//damage
boolean damage = stack0.getItemDamage() == stack1.getItemDamage() ||
		stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE;		

      return stack0.getItem() != stack1.getItem() ? false : (!damage ? false : stack0.stackSize <= stack0.getMaxStackSize() );
  }
 
Example #20
Source File: ShapedArcaneRecipe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
private boolean checkItemEquals(ItemStack target, ItemStack input)
{
    if (input == null && target != null || input != null && target == null)
    {
        return false;
    }
    return (target.getItem() == input.getItem() && 
    		(!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input,target)) &&
    		(target.getItemDamage() == OreDictionary.WILDCARD_VALUE|| target.getItemDamage() == input.getItemDamage()));
}
 
Example #21
Source File: AspectList.java    From GardenCollection with MIT License 5 votes vote down vote up
/**
 * this creates a new aspect list with preloaded values based off the aspects of the given item.
 * @param the itemstack of the given item
 */
public AspectList(ItemStack stack) {
	try {
		AspectList temp = ThaumcraftApiHelper.getObjectAspects(stack);
		if (temp!=null)
		for (Aspect tag:temp.getAspects()) {
			add(tag,temp.getAmount(tag));
		}
	} catch (Exception e) {}
}
 
Example #22
Source File: ShapelessArcaneRecipe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
private boolean checkItemEquals(ItemStack target, ItemStack input)
{
    if (input == null && target != null || input != null && target == null)
    {
        return false;
    }
    return (target.getItem() == input.getItem() && 
    		(!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input,target)) &&
    		(target.getItemDamage() == OreDictionary.WILDCARD_VALUE|| target.getItemDamage() == input.getItemDamage()));
}
 
Example #23
Source File: ShapelessArcaneRecipe.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private boolean checkItemEquals(ItemStack target, ItemStack input)
{
    if (input == null && target != null || input != null && target == null)
    {
        return false;
    }
    return (target.getItem() == input.getItem() && 
    		(!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input,target)) &&
    		(target.getItemDamage() == OreDictionary.WILDCARD_VALUE|| target.getItemDamage() == input.getItemDamage()));
}
 
Example #24
Source File: CrucibleRecipe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
public boolean catalystMatches(ItemStack cat) {
	if (catalyst instanceof ItemStack && ThaumcraftApiHelper.itemMatches((ItemStack) catalyst,cat,false)) {
		return true;
	} else 
	if (catalyst instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) {
		ItemStack[] ores = ((ArrayList<ItemStack>)catalyst).toArray(new ItemStack[]{});
		if (ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{cat},ores)) return true;
	}
	return false;
}
 
Example #25
Source File: ShapelessArcaneRecipe.java    From GardenCollection with MIT License 5 votes vote down vote up
private boolean checkItemEquals(ItemStack target, ItemStack input)
{
    if (input == null && target != null || input != null && target == null)
    {
        return false;
    }
    return (target.getItem() == input.getItem() && 
    		(!target.hasTagCompound() || ThaumcraftApiHelper.areItemStackTagsEqualForCrafting(input,target)) &&
    		(target.getItemDamage() == OreDictionary.WILDCARD_VALUE|| target.getItemDamage() == input.getItemDamage()));
}
 
Example #26
Source File: PseudoResearchItem.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public boolean isHidden() {
    EntityPlayer p = Minecraft.getMinecraft().thePlayer;
    if(p != null) {
        if(!ThaumcraftApiHelper.isResearchComplete(p.getCommandSenderName(), this.key)) {
            return false;
        }
    }
    return super.isHidden();
}
 
Example #27
Source File: AspectList.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * this creates a new aspect list with preloaded values based off the aspects of the given item.
 * @param the itemstack of the given item
 */
public AspectList(ItemStack stack) {
	try {
		AspectList temp = ThaumcraftApiHelper.getObjectAspects(stack);
		if (temp!=null)
		for (Aspect tag:temp.getAspects()) {
			add(tag,temp.getAmount(tag));
		}
	} catch (Exception e) {}
}
 
Example #28
Source File: InfusionRecipe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
/**
    * Used to check if a recipe matches current crafting inventory
    * @param player 
    */
public boolean matches(ArrayList<ItemStack> input, ItemStack central, World world, EntityPlayer player) {
	if (getRecipeInput()==null) return false;
		
	if (research.length()>0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) {
   		return false;
   	}
	
	ItemStack i2 = central.copy();
	if (getRecipeInput().getItemDamage()==OreDictionary.WILDCARD_VALUE) {
		i2.setItemDamage(OreDictionary.WILDCARD_VALUE);
	}
	
	if (!areItemStacksEqual(i2, getRecipeInput(), true)) return false;
	
	ArrayList<ItemStack> ii = new ArrayList<ItemStack>();
	for (ItemStack is:input) {
		ii.add(is.copy());
	}
	
	for (ItemStack comp:getComponents()) {
		boolean b=false;
		for (int a=0;a<ii.size();a++) {
			 i2 = ii.get(a).copy();
			if (comp.getItemDamage()==OreDictionary.WILDCARD_VALUE) {
				i2.setItemDamage(OreDictionary.WILDCARD_VALUE);
			}
			if (areItemStacksEqual(i2, comp,true)) {
				ii.remove(a);
				b=true;
				break;
			}
		}
		if (!b) return false;
	}
	return ii.size()==0?true:false;
   }
 
Example #29
Source File: CrucibleRecipe.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
public boolean matches(AspectList itags, ItemStack cat) {
	if (catalyst instanceof ItemStack &&
			!ThaumcraftApiHelper.itemMatches((ItemStack) catalyst,cat,false)) {
		return false;
	} else 
	if (catalyst instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) {
		ItemStack[] ores = ((ArrayList<ItemStack>)catalyst).toArray(new ItemStack[]{});
		if (!ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{cat},ores)) return false;
	}
	if (itags==null) return false;
	for (Aspect tag:aspects.getAspects()) {
		if (itags.getAmount(tag)<aspects.getAmount(tag)) return false;
	}
	return true;
}
 
Example #30
Source File: CrucibleRecipe.java    From GardenCollection with MIT License 5 votes vote down vote up
public boolean matches(AspectList itags, ItemStack cat) {
	if (catalyst instanceof ItemStack &&
			!ThaumcraftApiHelper.itemMatches((ItemStack) catalyst,cat,false)) {
		return false;
	} else 
	if (catalyst instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) {
		ItemStack[] ores = ((ArrayList<ItemStack>)catalyst).toArray(new ItemStack[]{});
		if (!ThaumcraftApiHelper.containsMatch(false, new ItemStack[]{cat},ores)) return false;
	}
	if (itags==null) return false;
	for (Aspect tag:aspects.getAspects()) {
		if (itags.getAmount(tag)<aspects.getAmount(tag)) return false;
	}
	return true;
}