ic2.api.recipe.IRecipeInput Java Examples

The following examples show how to use ic2.api.recipe.IRecipeInput. 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: GTJeiMultiRecipeWrapper.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void getIngredients(IIngredients ingredients) {
	ArrayList<FluidStack> inputFluids = new ArrayList<>();
	ArrayList<ItemStack> inputItems = new ArrayList<>();
	for (IRecipeInput input : multiRecipe.getInputs()) {
		if (input instanceof RecipeInputFluid) {
			inputFluids.add(((RecipeInputFluid) input).fluid);
		} else {
			inputItems.addAll(input.getInputs());
		}
	}
	if (!inputFluids.isEmpty()) {
		ingredients.setInputs(FluidStack.class, inputFluids);
	}
	ingredients.setInputs(ItemStack.class, inputItems);
	MachineOutput output = multiRecipe.getOutputs();
	if (output instanceof GTFluidMachineOutput) {
		ingredients.setOutputs(FluidStack.class, ((GTFluidMachineOutput) output).getFluids());
	}
	ingredients.setOutputs(ItemStack.class, multiRecipe.getOutputs().getAllOutputs());
}
 
Example #2
Source File: GTJeiMagicFuelCategory.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setRecipe(IRecipeLayout layout, GTJeiMagicFuelWrapper wrapper, IIngredients ingredients) {
	IGuiItemStackGroup itemGroup = layout.getItemStacks();
	IGuiFluidStackGroup fluidGroup = layout.getFluidStacks();
	int index = 0;
	int actualIndex = 0;
	for (IRecipeInput list : wrapper.getMultiRecipe().getInputs()) {
		int x = index % 3;
		int y = index / 3;
		if (list instanceof RecipeInputFluid) {
			fluidGroup.init(actualIndex, true, (18 * x) + 1, (18 * y)
					+ 1, 16, 16, ((RecipeInputFluid) list).fluid.amount, true, null);
			fluidGroup.set(actualIndex, ((RecipeInputFluid) list).fluid);
		} else {
			itemGroup.init(actualIndex, true, (18 * x), (18 * y));
			itemGroup.set(actualIndex, list.getInputs());
		}
		index++;
		actualIndex++;
		if (index >= 6) {
			break;
		}
	}
}
 
Example #3
Source File: GTRecipeCraftingHandler.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static IRecipeInput combineRecipeObjects(Object... entries) {
	List<IRecipeInput> parsedEntries = new ArrayList<>();
	for (Object object : entries) {
		if (object instanceof String) {
			parsedEntries.add(new RecipeInputOreDict((String) object));
		}
		if (object instanceof Block) {
			parsedEntries.add(new RecipeInputItemStack(new ItemStack((Block) object)));
		}
		if (object instanceof Item) {
			parsedEntries.add(new RecipeInputItemStack(new ItemStack((Item) object)));
		}
		if (object instanceof ItemStack) {
			parsedEntries.add(new RecipeInputItemStack(((ItemStack) object).copy()));
		}
		if (object instanceof IRecipeInput) {
			parsedEntries.add((IRecipeInput) object);
		}
	}
	IRecipeInput[] parsedFinal = new IRecipeInput[entries.length];
	parsedEntries.toArray(parsedFinal);
	return new RecipeInputCombined(1, parsedFinal);
}
 
Example #4
Source File: GTRecipeBasicMachineList.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void addRecipe(IRecipeInput input, MachineOutput output, String id) {
	assert output != null;
	assert input != null;
	assert !Strings.isNullOrEmpty(id);
	if (checksRecipes() && !RecipeManager.register(registryID, id)) {
		return;
	}
	RecipeEntry toAdd = new RecipeEntry(input, output, id);
	Map<CompareableStack, RecipeEntry> addMap = new LinkedHashMap<CompareableStack, RecipeEntry>();
	for (ItemStack stack : input.getInputs()) {
		if (stack.isEmpty()) {
			continue;
		}
		CompareableStack meta = new CompareableStack(stack);
		RecipeEntry entry = recipeMap.get(meta);
		if (entry != null) {
			GTMod.logger.info("Recipe Overlap: " + entry.getInput() + " Recipe ID: " + id);
			return;
		}
		addMap.put(meta, toAdd);
	}
	recipeMap.putAll(addMap);
}
 
Example #5
Source File: GTJeiUUAmplifierWrapper.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void getIngredients(IIngredients ingredients) {
	ArrayList<FluidStack> inputFluids = new ArrayList<>();
	ArrayList<ItemStack> inputItems = new ArrayList<>();
	for (IRecipeInput input : multiRecipe.getInputs()) {
		if (input instanceof RecipeInputFluid) {
			inputFluids.add(((RecipeInputFluid) input).fluid);
		} else {
			inputItems.addAll(input.getInputs());
		}
	}
	if (!inputFluids.isEmpty()) {
		ingredients.setInputs(FluidStack.class, inputFluids);
	}
	ingredients.setInputs(ItemStack.class, inputItems);
	ingredients.setOutputs(ItemStack.class, multiRecipe.getOutputs().getAllOutputs());
}
 
Example #6
Source File: GTJeiMagicFuelWrapper.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void getIngredients(IIngredients ingredients) {
	ArrayList<FluidStack> inputFluids = new ArrayList<>();
	ArrayList<ItemStack> inputItems = new ArrayList<>();
	for (IRecipeInput input : multiRecipe.getInputs()) {
		if (input instanceof RecipeInputFluid) {
			inputFluids.add(((RecipeInputFluid) input).fluid);
		} else {
			inputItems.addAll(input.getInputs());
		}
	}
	if (!inputFluids.isEmpty()) {
		ingredients.setInputs(FluidStack.class, inputFluids);
	}
	ingredients.setInputs(ItemStack.class, inputItems);
	ingredients.setOutputs(ItemStack.class, multiRecipe.getOutputs().getAllOutputs());
}
 
Example #7
Source File: GTTileMagicEnergyConverter.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** Checks for compatible fluids **/
public int getMagicFuelValue(Fluid fluid) {
	if (RECIPE_LIST.getRecipeList().isEmpty()) {
		return 0;
	}
	for (MultiRecipe map : RECIPE_LIST.getRecipeList()) {
		IRecipeInput input = map.getInput(0);
		if (input instanceof RecipeInputFluid) {
			Fluid fluidinput = ((RecipeInputFluid) input).fluid.getFluid();
			if (fluidinput == fluid) {
				return map.getOutputs().getMetadata().getInteger("RecipeTime");
			}
		}
	}
	return 0;
}
 
Example #8
Source File: GTRecipeMultiInputList.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void rebuildValidInputs() {
	validInputs.clear();
	for (MultiRecipe recipe : recipes) {
		List<IRecipeInput> inputs = recipe.getInputs();
		for (int i = 0; i < inputs.size(); i++) {
			if (inputs.get(i) != null) {
				for (ItemStack stack : inputs.get(i).getInputs()) {
					ItemWithMeta meta = new ItemWithMeta(stack);
					List<IRecipeInput> list = validInputs.get(meta);
					if (list == null) {
						list = new ArrayList<IRecipeInput>();
						validInputs.put(meta, list);
					}
					list.add(inputs.get(i));
				}
			}
		}
	}
}
 
Example #9
Source File: GTTileDisassembler.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void init() {
	if (GTConfig.general.enableDisassembler) {
		for (IRecipe recipe : ForgeRegistries.RECIPES) {
			ItemStack input = recipe.getRecipeOutput().copy();
			List<ItemStack> outputList = new ArrayList<>();
			for (int i = 0; i < recipe.getIngredients().size(); ++i) {
				List<ItemStack> tempList = new ArrayList<>();
				Collections.addAll(tempList, recipe.getIngredients().get(i).getMatchingStacks());
				if (!tempList.isEmpty()) {
					ItemStack tempStack = isHighValueMaterial(tempList.get(0).copy()) ? Ic2Items.scrapMetal.copy()
							: tempList.get(0).copy();
					if (canItemBeReturned(tempStack)) {
						outputList.add(tempStack);
					}
				}
			}
			if (canInputBeUsed(input) && !outputList.isEmpty()) {
				ItemStack[] arr = outputList.toArray(new ItemStack[0]);
				addRecipe(new IRecipeInput[] { new RecipeInputItemStack(input) }, totalEu(5000), arr);
			}
		}
	}
}
 
Example #10
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 #11
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 #12
Source File: WerkstoffLoader.java    From bartworks with MIT License 6 votes vote down vote up
public static void removeIC2Recipes() {
    try {
        Set<Map.Entry<IRecipeInput, RecipeOutput>> remset = new HashSet<>();
        for (Map.Entry<IRecipeInput, RecipeOutput> curr : Recipes.macerator.getRecipes().entrySet()) {
            if (curr.getKey() instanceof RecipeInputOreDict) {
                if (((RecipeInputOreDict) curr.getKey()).input.equalsIgnoreCase("oreNULL")) {
                    remset.add(curr);
                }
                for (ItemStack stack : curr.getValue().items) {
                    if (stack.getItem() instanceof BW_MetaGenerated_Items)
                        remset.add(curr);
                }
            }
        }
        Recipes.macerator.getRecipes().entrySet().removeAll(remset);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #13
Source File: GTRecipeIterators.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Ran post init **/
public static void createMortarRecipe() {
	// Grabs everything from the ic2 classic macerator list
	// Separate method so it can be done last in post init
	for (RecipeEntry entry : ClassicRecipes.macerator.getRecipeMap()) {
		if (entry.getInput().getInputs().get(0).getCount() == 1
				&& entry.getOutput().getAllOutputs().get(0).getCount() == 1) {
			IRecipeInput[] in = { entry.getInput() };
			GTBlockMortar.addRecipe(in, entry.getOutput().getAllOutputs().get(0));
		}
	}
}
 
Example #14
Source File: GTRecipeMachineHandler.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * This is a helper to make the base recipe adders for a GTC Recipe List
 * 
 * @param recipeList - the list to use
 * @param inputs     - IRecipeInput array of inputs
 * @param modifiers  - RecipeModifers can use totalEU method in this same class,
 *                   nullable
 * @param outputs    - ItemStack array of outputs
 */
public static void addRecipe(GTRecipeMultiInputList recipeList, @Nullable IRecipeInput[] inputs,
		IRecipeModifier[] modifiers, ItemStack... outputs) {
	List<IRecipeInput> inlist = new ArrayList<>();
	List<ItemStack> outlist = new ArrayList<>();
	Collections.addAll(inlist, inputs);
	Collections.addAll(outlist, outputs);
	NBTTagCompound mods = new NBTTagCompound();
	if (modifiers != null) {
		for (IRecipeModifier modifier : modifiers) {
			modifier.apply(mods);
		}
	}
	addRecipe(recipeList, inlist, new MachineOutput(modifiers != null ? mods : null, outlist));
}
 
Example #15
Source File: GTRecipeMultiInputList.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void addRecipe(List<IRecipeInput> inputs, MachineOutput output, String id, int eu) {
	id = getRecipeID(recipeMap.keySet(), id, 0);
	if (recipeMap.containsKey(id) || !RecipeManager.register(category, id)) {
		return;
	}
	for (int i = 0; i < inputs.size(); i++) {
		if (inputs.get(i) != null && isListInvalid(inputs.get(i).getInputs())) {
			if (GTConfig.general.debugMode) {
				GTMod.logger.info("Recipe[" + id + "] has a invalid input for machine " + category);
			}
			return;
		}
	}
	if (isListInvalid(output.getAllOutputs())) {
		if (GTConfig.general.debugMode) {
			GTMod.logger.info("Recipe[" + id + "] has a invalid output for machine " + category);
			for (int i = 0; i < inputs.size(); i++) {
				GTMod.logger.info("Recipe[" + id + ": " + inputs.get(i) + "] as input " + category);
			}
		}
		return;
	}
	MultiRecipe recipe = new MultiRecipe(inputs, output, id, eu);
	recipes.add(recipe);
	recipeMap.put(id, recipe);
	for (int i = 0; i < inputs.size(); i++) {
		if (inputs.get(i) != null) {
			for (ItemStack stack : inputs.get(i).getInputs()) {
				ItemWithMeta meta = new ItemWithMeta(stack);
				List<IRecipeInput> list = validInputs.get(meta);
				if (list == null) {
					list = new ArrayList<IRecipeInput>();
					validInputs.put(meta, list);
				}
				list.add(inputs.get(i));
			}
		}
	}
}
 
Example #16
Source File: GTRecipeMultiInputList.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean isValidRecipeInput(ItemStack stack) {
	List<IRecipeInput> inputs = validInputs.get(new ItemWithMeta(stack));
	if (inputs == null) {
		return false;
	}
	for (IRecipeInput input : inputs) {
		if (input.matches(stack)) {
			return true;
		}
	}
	return false;
}
 
Example #17
Source File: GTCraftTweakerActions.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static IRecipeInput[] of(IIngredient... ingredient) {
	IRecipeInput[] out = new IRecipeInput[ingredient.length];
	for (int index = 0; index < out.length; index++) {
		out[index] = of(ingredient[index]);
	}
	return out;
}
 
Example #18
Source File: GTRecipeMachineHandler.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Convert from a IC2 Recipe list to a GTC Recipe List
 * 
 * @param ic2RecipeList - the Ic2 Recipe List to use as a base
 * @param gtcRecipeList - the new GTC recipe list to convert too
 */
public static void convertIC2toGTC(List<RecipeEntry> ic2RecipeList, GTRecipeMultiInputList gtcRecipeList) {
	for (RecipeEntry entry : ic2RecipeList) {
		IRecipeInput[] in = { entry.getInput() };
		ItemStack[] out = {};
		GTRecipeMachineHandler.addRecipe(gtcRecipeList, in, GTRecipeMachineHandler.totalEu(gtcRecipeList, 120), entry.getOutput().getAllOutputs().toArray(out));
	}
}
 
Example #19
Source File: IC2.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init(){
    ItemStack advancedCircuit = IC2Items.getItem("advancedCircuit");
    ItemStack glassFibreCable = IC2Items.getItem("glassFiberCableItem");
    ItemStack advancedAlloy = IC2Items.getItem("advancedAlloy");
    ItemStack generator = IC2Items.getItem("generator");

    if(Config.enablePneumaticGeneratorRecipe) GameRegistry.addRecipe(new ItemStack(pneumaticGenerator), "pca", "trg", "pca", 'p', Itemss.printedCircuitBoard, 'c', advancedCircuit, 'a', advancedAlloy, 't', new ItemStack(Blockss.advancedPressureTube, 1, 0), 'r', Itemss.turbineRotor, 'g', glassFibreCable);
    if(Config.enableElectricCompressorRecipe) GameRegistry.addRecipe(new ItemStack(electricCompressor), "acp", "frt", "agp", 'p', Itemss.printedCircuitBoard, 'c', advancedCircuit, 'a', advancedAlloy, 't', new ItemStack(Blockss.advancedPressureTube, 1, 0), 'r', Itemss.turbineRotor, 'f', glassFibreCable, 'g', generator);
    try {
        if(Class.forName("ic2.api.recipe.Recipes") != null && Recipes.class.getField("macerator") != null && IMachineRecipeManager.class.getMethod("addRecipe", IRecipeInput.class, NBTTagCompound.class, ItemStack[].class) != null) {
            if(Config.enableCreeperPlantMaceratorRecipe) {
                Recipes.macerator.addRecipe(new IC2RecipeInput(new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.CREEPER_PLANT_DAMAGE)), null, new ItemStack(Items.gunpowder));
                Recipes.macerator.addRecipe(new IC2RecipeInput(new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.CREEPER_PLANT_DAMAGE + 16)), null, new ItemStack(Items.gunpowder));
            }
            if(Config.enableHeliumPlantMaceratorRecipe) {
                Recipes.macerator.addRecipe(new IC2RecipeInput(new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.HELIUM_PLANT_DAMAGE)), null, new ItemStack(Items.glowstone_dust));
                Recipes.macerator.addRecipe(new IC2RecipeInput(new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.HELIUM_PLANT_DAMAGE + 16)), null, new ItemStack(Items.glowstone_dust));
            }
            if(Config.enableFlyingFlowerExtractorRecipe) {
                Recipes.extractor.addRecipe(new IC2RecipeInput(new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.FLYING_FLOWER_DAMAGE)), null, new ItemStack(Items.feather));
                Recipes.extractor.addRecipe(new IC2RecipeInput(new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.FLYING_FLOWER_DAMAGE + 16)), null, new ItemStack(Items.feather));
            }
            if(Config.enablePropulsionPlantExtractorRecipe) {
                Recipes.extractor.addRecipe(new IC2RecipeInput(new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.PROPULSION_PLANT_DAMAGE)), null, new ItemStack(Items.sugar, 2, 1));
                Recipes.extractor.addRecipe(new IC2RecipeInput(new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.PROPULSION_PLANT_DAMAGE + 16)), null, new ItemStack(Items.sugar, 2, 1));
            }
        }
    } catch(Exception e) {
        System.err.println("[PneumaticCraft] Failed to load IC2's macerator, extractor and compressor recipes!");
        e.printStackTrace();
    }
}
 
Example #20
Source File: GTJeiMortarWrapper.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void getIngredients(IIngredients ingredients) {
	ArrayList<ItemStack> inputs = new ArrayList<>();
	for (IRecipeInput input : multiRecipe.getInputs()) {
		inputs.addAll(input.getInputs());
	}
	ingredients.setInputs(ItemStack.class, inputs);
	ingredients.setOutputs(ItemStack.class, multiRecipe.getOutputs().getAllOutputs());
}
 
Example #21
Source File: GTTileMultiFusionReactor.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void postInit() {
	/** Just regular recipes added manually **/
	addRecipe(new IRecipeInput[] { input(GTMaterialGen.getTube(GTMaterial.Deuterium, 1)),
			input(GTMaterialGen.getTube(GTMaterial.Tritium, 1)) }, totalEu(40000000), GTMaterialGen.getTube(GTMaterial.Helium, 1));
	addRecipe(new IRecipeInput[] { input(GTMaterialGen.getTube(GTMaterial.Deuterium, 1)),
			input(GTMaterialGen.getTube(GTMaterial.Helium3, 1)) }, totalEu(40000000), GTMaterialGen.getTube(GTMaterial.Helium, 1));
	/** This iterates the element objects to create all Fusion recipes **/
	Set<Integer> usedInputs = new HashSet<>();
	for (GTMaterialElement sum : GTMaterialElement.getElementList()) {
		for (GTMaterialElement input1 : GTMaterialElement.getElementList()) {
			for (GTMaterialElement input2 : GTMaterialElement.getElementList()) {
				int hash = input1.hashCode() + input2.hashCode();
				if ((input1.getNumber() + input2.getNumber() == sum.getNumber()) && input1 != input2
						&& !usedInputs.contains(hash)) {
					float ratio = (sum.getNumber() / 100.0F) * 7000000.0F;
					IRecipeInput recipeInput1 = input1.isFluid() ? input1.getOutputAsInput() : input1.getInput();
					IRecipeInput recipeInput2 = input2.isFluid() ? input2.getOutputAsInput() : input2.getInput();
					addRecipe(new IRecipeInput[] { recipeInput1,
							recipeInput2 }, totalEu(Math.round(ratio)), sum.getOutput());
					usedInputs.add(hash);
				}
			}
		}
	}
	addRecipe(new IRecipeInput[] { input(GTMaterialGen.getIc2(Ic2Items.uuMatter, 10)),
			input(GTMaterialGen.getIc2(Ic2Items.emptyCell, 1)), }, totalEu(10000000), GTMaterialGen.getIc2(Ic2Items.plasmaCell, 1));
}
 
Example #22
Source File: GTCraftTweakerCentrifuge.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void apply() {
	if (totalEu > 0) {
		if (input2 != null) {
			GTTileCentrifuge.addRecipe(new IRecipeInput[] { input1,
					input2 }, GTTileCentrifuge.totalEu(totalEu), output);
		} else {
			GTTileCentrifuge.addRecipe(new IRecipeInput[] {
					input1 }, GTTileCentrifuge.totalEu(totalEu), output);
		}
	} else {
		CraftTweakerAPI.logError(CraftTweakerAPI.getScriptFileAndLine() + " > "
				+ "Eu amount must be greater then 0!!");
	}
}
 
Example #23
Source File: GTTileMagicEnergyConverter.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Checks for compatible ItemStacks **/
public int getMagicFuelValue(ItemStack stack) {
	if (RECIPE_LIST.getRecipeList().isEmpty()) {
		return 0;
	}
	for (MultiRecipe map : RECIPE_LIST.getRecipeList()) {
		IRecipeInput input = map.getInput(0);
		if (!(input instanceof RecipeInputFluid) && input.matches(stack)) {
			return map.getOutputs().getMetadata().getInteger("RecipeTime");
		}
	}
	return 0;
}
 
Example #24
Source File: GTTileMagicEnergyConverter.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void addRecipe(IRecipeInput input, IRecipeModifier[] modifiers) {
	List<IRecipeInput> inlist = new ArrayList<>();
	List<ItemStack> outlist = new ArrayList<>();
	NBTTagCompound mods = new NBTTagCompound();
	for (IRecipeModifier modifier : modifiers) {
		modifier.apply(mods);
	}
	inlist.add(input);
	outlist.add(GTMaterialGen.get(Items.REDSTONE));
	addRecipe(inlist, new MachineOutput(mods, outlist));
}
 
Example #25
Source File: GTCraftTweakerFusion.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void apply() {
	if (totalEu > 0) {
		GTTileMultiFusionReactor.addRecipe(new IRecipeInput[] { input1,
				input2 }, GTTileMultiFusionReactor.totalEu(totalEu), output);
	} else {
		CraftTweakerAPI.logError(CraftTweakerAPI.getScriptFileAndLine() + " > "
				+ "Eu amount must be greater then 0!!");
	}
}
 
Example #26
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 #27
Source File: GTTileCentrifuge.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void addRecipe(ItemStack stack, int cells, IRecipeModifier[] modifiers, ItemStack... outputs) {
	if (cells > 0) {
		addRecipe(new IRecipeInput[] { new RecipeInputItemStack(stack),
				new RecipeInputItemStack(GTMaterialGen.get(GTItems.testTube, cells)) }, modifiers, outputs);
	} else {
		addRecipe(new IRecipeInput[] { new RecipeInputItemStack(stack) }, modifiers, outputs);
	}
}
 
Example #28
Source File: GTTileCentrifuge.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void addRecipe(String input, int amount, int cells, IRecipeModifier[] modifiers,
		ItemStack... outputs) {
	if (cells > 0) {
		addRecipe(new IRecipeInput[] { new RecipeInputOreDict(input, amount),
				new RecipeInputItemStack(GTMaterialGen.get(GTItems.testTube, cells)) }, modifiers, outputs);
	} else {
		addRecipe(new IRecipeInput[] { new RecipeInputOreDict(input, amount) }, modifiers, outputs);
	}
}
 
Example #29
Source File: GTTileCentrifuge.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void addRecipe(FluidStack fluid, int cells, IRecipeModifier[] modifiers, ItemStack... outputs) {
	if (cells > 0) {
		addRecipe(new IRecipeInput[] { new RecipeInputFluid(fluid),
				new RecipeInputItemStack(GTMaterialGen.get(GTItems.testTube, cells)) }, modifiers, outputs);
	} else {
		addRecipe(new IRecipeInput[] { new RecipeInputFluid(fluid) }, modifiers, outputs);
	}
}
 
Example #30
Source File: GTBlockMortar.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand h,
		EnumFacing facing, float hitX, float hitY, float hitZ) {
	ItemStack playerStack = player.getHeldItemMainhand();
	if (playerStack.isEmpty()) {
		return false;
	}
	int matches = 0;
	for (IRecipeInput inputMatcher : INPUT_LIST) {
		if (inputMatcher.matches(playerStack)) {
			matches++;
		}
	}
	if (matches == 0) {
		return false;
	}
	if (IC2.platform.isSimulating()) {
		int chance = this == GTBlocks.ironMortar ? 2 : 15;
		if (worldIn.rand.nextInt(chance) != 0) {
			return true;
		}
		for (MultiRecipe recipe : RECIPE_LIST.getRecipeList()) {
			IRecipeInput inputStack = recipe.getInputs().get(0);
			ItemStack outputStack = recipe.getOutputs().getAllOutputs().get(0);
			if (inputStack.matches(playerStack)) {
				playerStack.shrink(inputStack.getAmount());
				ItemHandlerHelper.giveItemToPlayer(player, outputStack.copy());
			}
		}
	}
	worldIn.playSound(player, pos, SoundEvents.BLOCK_ANVIL_BREAK, SoundCategory.BLOCKS, 1.0F, 1.0F);
	return true;
}