Java Code Examples for ic2.api.recipe.IRecipeInput#getAmount()

The following examples show how to use ic2.api.recipe.IRecipeInput#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: GTTileBaseFuelMachine.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean checkRecipe(GTRecipeMultiInputList.MultiRecipe entry, List<ItemStack> inputs) {
	List<IRecipeInput> recipeKeys = new LinkedList<IRecipeInput>(entry.getInputs());
	for (Iterator<IRecipeInput> keyIter = recipeKeys.iterator(); keyIter.hasNext();) {
		IRecipeInput key = keyIter.next();
		int toFind = key.getAmount();
		for (Iterator<ItemStack> inputIter = inputs.iterator(); inputIter.hasNext();) {
			ItemStack input = inputIter.next();
			if (key.matches(input)) {
				if (input.getCount() >= toFind) {
					input.shrink(toFind);
					keyIter.remove();
					if (input.isEmpty()) {
						inputIter.remove();
					}
					break;
				}
				toFind -= input.getCount();
				input.setCount(0);
				inputIter.remove();
			}
		}
	}
	return recipeKeys.isEmpty();
}
 
Example 2
Source File: GTTileBaseMachine.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean checkRecipe(MultiRecipe entry, List<ItemStack> inputs) {
	List<IRecipeInput> recipeKeys = new LinkedList<IRecipeInput>(entry.getInputs());
	for (Iterator<IRecipeInput> keyIter = recipeKeys.iterator(); keyIter.hasNext();) {
		IRecipeInput key = keyIter.next();
		int toFind = key.getAmount();
		for (Iterator<ItemStack> inputIter = inputs.iterator(); inputIter.hasNext();) {
			ItemStack input = inputIter.next();
			if (key.matches(input)) {
				if (input.getCount() >= toFind) {
					input.shrink(toFind);
					keyIter.remove();
					if (input.isEmpty()) {
						inputIter.remove();
					}
					break;
				}
				toFind -= input.getCount();
				input.setCount(0);
				inputIter.remove();
			}
		}
	}
	return recipeKeys.isEmpty();
}
 
Example 3
Source File: GTTileCentrifuge.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean checkRecipe(MultiRecipe entry, FluidStack inputFluid, List<ItemStack> inputs) {
	boolean hasCheckedFluid = false;
	List<IRecipeInput> recipeKeys = new LinkedList<IRecipeInput>(entry.getInputs());
	for (Iterator<IRecipeInput> keyIter = recipeKeys.iterator(); keyIter.hasNext();) {
		IRecipeInput key = keyIter.next();
		if (key instanceof RecipeInputFluid) {
			if (!hasCheckedFluid) {
				hasCheckedFluid = true;
				if (inputFluid != null && inputFluid.containsFluid(((RecipeInputFluid) key).fluid)) {
					keyIter.remove();
				}
			}
		}
		int toFind = key.getAmount();
		for (Iterator<ItemStack> inputIter = inputs.iterator(); inputIter.hasNext();) {
			ItemStack input = inputIter.next();
			if (key.matches(input)) {
				if (input.getCount() >= toFind) {
					input.shrink(toFind);
					keyIter.remove();
					if (input.isEmpty()) {
						inputIter.remove();
					}
					break;
				}
				toFind -= input.getCount();
				input.setCount(0);
				inputIter.remove();
			}
		}
	}
	return recipeKeys.isEmpty();
}
 
Example 4
Source File: GTRecipeMultiInputList.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public boolean matches(int slot, ItemStack stack) {
	if (inputs.size() <= slot || stack.isEmpty())
		return false;
	IRecipeInput input = inputs.get(slot);
	return input.matches(stack) && input.getAmount() <= stack.getCount();
}