Java Code Examples for thaumcraft.api.aspects.AspectList#getAmount()

The following examples show how to use thaumcraft.api.aspects.AspectList#getAmount() . 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: CrucibleRecipe.java    From AdvancedMod with GNU General Public License v3.0 6 votes vote down vote up
public CrucibleRecipe(String researchKey, ItemStack result, Object cat, AspectList tags) {
	recipeOutput = result;
	this.aspects = tags;
	this.key = researchKey;
	this.catalyst = cat;
	if (cat instanceof String) {
		this.catalyst = OreDictionary.getOres((String) cat);
	}
	String hc = researchKey + result.toString();
	for (Aspect tag:tags.getAspects()) {
		hc += tag.getTag()+tags.getAmount(tag);
	}
	if (cat instanceof ItemStack) {
		hc += ((ItemStack)cat).toString();
	} else
	if (cat instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) {
		for (ItemStack is :(ArrayList<ItemStack>)catalyst) {
			hc += is.toString();
		}
	}
	
	hash = hc.hashCode();
}
 
Example 2
Source File: CrucibleRecipe.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public CrucibleRecipe(String researchKey, ItemStack result, Object cat, AspectList tags) {
	recipeOutput = result;
	this.aspects = tags;
	this.key = researchKey;
	this.catalyst = cat;
	if (cat instanceof String) {
		this.catalyst = OreDictionary.getOres((String) cat);
	}
	String hc = researchKey + result.toString();
	for (Aspect tag:tags.getAspects()) {
		hc += tag.getTag()+tags.getAmount(tag);
	}
	if (cat instanceof ItemStack) {
		hc += ((ItemStack)cat).toString();
	} else
	if (cat instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) {
		for (ItemStack is :(ArrayList<ItemStack>)catalyst) {
			hc += is.toString();
		}
	}
	
	hash = hc.hashCode();
}
 
Example 3
Source File: CrucibleRecipe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
public CrucibleRecipe(String researchKey, ItemStack result, Object cat, AspectList tags) {
	recipeOutput = result;
	this.aspects = tags;
	this.key = researchKey;
	this.catalyst = cat;
	if (cat instanceof String) {
		this.catalyst = OreDictionary.getOres((String) cat);
	}
	String hc = researchKey + result.toString();
	for (Aspect tag:tags.getAspects()) {
		hc += tag.getTag()+tags.getAmount(tag);
	}
	if (cat instanceof ItemStack) {
		hc += ((ItemStack)cat).toString();
	} else
	if (cat instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) {
		for (ItemStack is :(ArrayList<ItemStack>)catalyst) {
			hc += is.toString();
		}
	}
	
	hash = hc.hashCode();
}
 
Example 4
Source File: CrucibleRecipe.java    From GardenCollection with MIT License 6 votes vote down vote up
public CrucibleRecipe(String researchKey, ItemStack result, Object cat, AspectList tags) {
	recipeOutput = result;
	this.aspects = tags;
	this.key = researchKey;
	this.catalyst = cat;
	if (cat instanceof String) {
		this.catalyst = OreDictionary.getOres((String) cat);
	}
	String hc = researchKey + result.toString();
	for (Aspect tag:tags.getAspects()) {
		hc += tag.getTag()+tags.getAmount(tag);
	}
	if (cat instanceof ItemStack) {
		hc += ((ItemStack)cat).toString();
	} else
	if (cat instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) {
		for (ItemStack is :(ArrayList<ItemStack>)catalyst) {
			hc += is.toString();
		}
	}
	
	hash = hc.hashCode();
}
 
Example 5
Source File: CrucibleRecipe.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
public CrucibleRecipe(String researchKey, ItemStack result, Object cat, AspectList tags) {
	recipeOutput = result;
	this.aspects = tags;
	this.key = researchKey;
	this.catalyst = cat;
	if (cat instanceof String) {
		this.catalyst = OreDictionary.getOres((String) cat);
	}
	String hc = researchKey + result.toString();
	for (Aspect tag:tags.getAspects()) {
		hc += tag.getTag()+tags.getAmount(tag);
	}
	if (cat instanceof ItemStack) {
		hc += ((ItemStack)cat).toString();
	} else
	if (cat instanceof ArrayList && ((ArrayList<ItemStack>)catalyst).size()>0) {
		for (ItemStack is :(ArrayList<ItemStack>)catalyst) {
			hc += is.toString();
		}
	}
	
	hash = hc.hashCode();
}
 
Example 6
Source File: ItemRenderRemoteJar.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack stack, Object... data) {
    GL11.glEnable(GL11.GL_ALPHA_TEST);

    AspectList aspects = ((ItemJarFilled)ConfigItems.itemJarFilled).getAspects(stack);
    if(aspects != null) {
        tile.aspect = aspects.getAspects()[0];
        tile.amount = aspects.getAmount(tile.aspect);
    } else {
        tile.aspect = null;
        tile.amount = 0;
    }

    if(stack.hasTagCompound()) {
        tile.networkId = NBTHelper.getUUID(stack.getTagCompound(), "networkId");
    }

    super.renderItem(type, stack, data);

    GL11.glPushMatrix();
    GL11.glTranslatef(0.5f, 0.5f, 0.5f);

    RenderingRegistry.instance().renderInventoryBlock(RenderBlocks.getInstance(), RegisteredBlocks.blockRemoteJar, 0, RegisteredBlocks.blockRemoteJar.getRenderType());
    GL11.glPopMatrix();
}
 
Example 7
Source File: ItemBlockRemoteJar.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
    boolean placed = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
    if (placed && stack.hasTagCompound()) {
        TileRemoteJar tile = (TileRemoteJar) world.getTileEntity(x, y, z);

        AspectList aspects = ((ItemJarFilled) ConfigItems.itemJarFilled).getAspects(stack);
        if(aspects != null) {
            tile.aspect = aspects.getAspects()[0];
            tile.amount = aspects.getAmount(tile.aspect);
        }

        if(!world.isRemote) {
            tile.networkId = NBTHelper.getUUID(stack.getTagCompound(), "networkId");
            tile.markForUpdate();
        }
    }
    return placed;
}
 
Example 8
Source File: RegisteredManipulations.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean affect(World world, INode node) {
    AspectList baseList = node.getAspectsBase();
    AspectList list = node.getAspects();
    for(Aspect a : baseList.getAspects()) {
        if(!a.isPrimal()) {
            Aspect[] subComponents = a.getComponents();
            int initialValue = baseList.getAmount(a);
            list.remove(a);
            baseList.remove(a);
            baseList.add(subComponents[0], initialValue);
            list.add(subComponents[0], initialValue);
            baseList.add(subComponents[1], initialValue);
            list.add(subComponents[1], initialValue);
            return true;
        }
    }
    return false;
}
 
Example 9
Source File: NodeManipulatorResultHandler.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void combine(AspectList containingList, Aspect a, Aspect b, int addition) {
    if(!canCombine(a, b)) return;
    Aspect combination = NodeManipulatorResultHandler.getCombination(a, b);
    int lowerAmount;
    if(containingList.getAmount(a) < containingList.getAmount(b)) {
        lowerAmount = containingList.getAmount(a);
    } else {
        lowerAmount = containingList.getAmount(b);
    }
    containingList.remove(a, lowerAmount);
    containingList.remove(b, lowerAmount);
    containingList.add(combination, lowerAmount + addition);
}
 
Example 10
Source File: AdapterAspectContainer.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.NUMBER, description = "Get amount of specific aspect stored in this block")
public int getAspectCount(IAspectContainer container,
		@Arg(name = "aspect", description = "Aspect to be checked") String aspectName) {

	Aspect aspect = Aspect.getAspect(aspectName.toLowerCase(Locale.ENGLISH));
	Preconditions.checkNotNull(aspect, "Invalid aspect name");
	AspectList list = container.getAspects();
	if (list == null) return 0;
	return list.getAmount(aspect);
}
 
Example 11
Source File: TileExtendedNodeJar.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean doesContainerContain(AspectList ot) {
    for (Aspect tt : ot.getAspects()) {
        if (this.aspects.getAmount(tt) < ot.getAmount(tt)) {
            return false;
        }
    }
    return true;
}
 
Example 12
Source File: CrucibleRecipe.java    From AdvancedMod with GNU General Public License v3.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 13
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean canDrainFromWand(int cap) {
    ItemStack stack = getStackInSlot(0);
    if(stack == null || !(stack.getItem() instanceof ItemWandCasting)) return false;
    AspectList aspects = ((ItemWandCasting) stack.getItem()).getAllVis(stack);
    for(Aspect a : Aspect.getPrimalAspects()) {
        if(aspects.getAmount(a) < 100) continue;
        if(workAspectList.getAmount(a) < cap) return true;
    }
    return false;
}
 
Example 14
Source File: CrucibleRecipe.java    From PneumaticCraft with GNU General Public License v3.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 15
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Aspect drainAspectFromWand(int cap) {
    ItemStack stack = getStackInSlot(0);
    if(stack == null || !(stack.getItem() instanceof ItemWandCasting)) return null; //Should never happen..
    AspectList aspects = ((ItemWandCasting) stack.getItem()).getAllVis(stack);
    for(Aspect a : getRandomlyOrderedPrimalAspectList()) {
        if(aspects.getAmount(a) >= 100 && workAspectList.getAmount(a) < cap) {
            int amt = aspects.getAmount(a);
            ((ItemWandCasting) stack.getItem()).storeVis(stack, a, amt - 100);
            workAspectList.add(a, 1);
            return a;
        }
    }
    return null;
}
 
Example 16
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;
}
 
Example 17
Source File: ItemBaseFocus.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
	AspectList cost = getVisCost();
	if (cost != null && cost.size() > 0) {
		list.add(StatCollector.translateToLocal(isVisCostPerTick() ? "item.Focus.cost2" : "item.Focus.cost1"));
		for (Aspect aspect : cost.getAspectsSorted()) {
			float amount = cost.getAmount(aspect) / 100.0F;
			list.add(" " + '\u00a7' + aspect.getChatcolor() + aspect.getName() + '\u00a7' + "r x " + amount);
		}
	}
}
 
Example 18
Source File: PrimalAspectList.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public AspectList add(Aspect aspect, int amount) {
    AspectList al = new AspectList();
    al.add(aspect, amount);
    al = ResearchManager.reduceToPrimals(al);
    for(Aspect a : al.getAspects()) {
        super.add(a, al.getAmount(a));
    }
    return this;
}
 
Example 19
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 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 20
Source File: GuiResearchRecipeAuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public GuiResearchRecipeAuraEffects(ResearchItem research, int page, double x, double y) {
    super(research, page, x, y);

    Injector inj = new Injector(this, GuiResearchRecipe.class);

    ResearchPage[] additionalPages = ResearchPageAuraAspects.createAllAuraPagesFor(Minecraft.getMinecraft().thePlayer);
    ResearchPage[] pages = inj.getField("pages");
    ResearchPage[] newPages = new ResearchPage[pages.length + additionalPages.length];
    System.arraycopy(pages, 0, newPages, 0, pages.length);
    System.arraycopy(additionalPages, 0, newPages, pages.length, additionalPages.length);
    inj.setField("pages", newPages);
    inj.setField("maxPages", newPages.length);

    List<String> list = Thaumcraft.proxy.getScannedObjects().get(Minecraft.getMinecraft().thePlayer.getCommandSenderName());
    if ((list != null) && (list.size() > 0)) {
        for (String s : list) {
            try {
                String s2 = s.substring(1);
                ItemStack is = getFromCache(Integer.parseInt(s2));
                if (is != null) {
                    AspectList tags = ThaumcraftCraftingManager.getObjectTags(is);
                    tags = ThaumcraftCraftingManager.getBonusTags(is, tags);
                    if ((tags != null) && (tags.size() > 0)) {
                        for (Aspect a : tags.getAspects()) {
                            ArrayList<ItemStack> items = itemMap.get(a.getTag());
                            if (items == null) {
                                items = new ArrayList<ItemStack>();
                            }
                            ItemStack is2 = is.copy();
                            is2.stackSize = tags.getAmount(a);
                            items.add(is2);
                            itemMap.put(a.getTag(), items);
                        }
                    }
                }
            } catch (NumberFormatException e) {}
        }
    }
}