Search in sources :

Example 1 with IMultipleTankHandler

use of gregtech.api.capability.IMultipleTankHandler in project GregTech by GregTechCE.

the class AbstractRecipeLogic method trySearchNewRecipe.

protected void trySearchNewRecipe() {
    long maxVoltage = getMaxVoltage();
    Recipe currentRecipe = null;
    IItemHandlerModifiable importInventory = getInputInventory();
    IMultipleTankHandler importFluids = getInputTank();
    if (previousRecipe != null && previousRecipe.matches(false, importInventory, importFluids)) {
        // if previous recipe still matches inputs, try to use it
        currentRecipe = previousRecipe;
    } else {
        boolean dirty = checkRecipeInputsDirty(importInventory, importFluids);
        if (dirty || forceRecipeRecheck) {
            this.forceRecipeRecheck = false;
            // else, try searching new recipe for given inputs
            currentRecipe = findRecipe(maxVoltage, importInventory, importFluids);
            if (currentRecipe != null) {
                this.previousRecipe = currentRecipe;
            }
        }
    }
    if (currentRecipe != null && setupAndConsumeRecipeInputs(currentRecipe)) {
        setupRecipe(currentRecipe);
    }
}
Also used : IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) Recipe(gregtech.api.recipes.Recipe) IMultipleTankHandler(gregtech.api.capability.IMultipleTankHandler)

Example 2 with IMultipleTankHandler

use of gregtech.api.capability.IMultipleTankHandler in project GregTech by GregTechCE.

the class AbstractRecipeLogic method setupAndConsumeRecipeInputs.

protected boolean setupAndConsumeRecipeInputs(Recipe recipe) {
    int[] resultOverclock = calculateOverclock(recipe.getEUt(), recipe.getDuration());
    int totalEUt = resultOverclock[0] * resultOverclock[1];
    IItemHandlerModifiable importInventory = getInputInventory();
    IItemHandlerModifiable exportInventory = getOutputInventory();
    IMultipleTankHandler importFluids = getInputTank();
    IMultipleTankHandler exportFluids = getOutputTank();
    return (totalEUt >= 0 ? getEnergyStored() >= (totalEUt > getEnergyCapacity() / 2 ? resultOverclock[0] : totalEUt) : (getEnergyStored() - resultOverclock[0] <= getEnergyCapacity())) && MetaTileEntity.addItemsToItemHandler(exportInventory, true, recipe.getAllItemOutputs(exportInventory.getSlots())) && MetaTileEntity.addFluidsToFluidHandler(exportFluids, true, recipe.getFluidOutputs()) && recipe.matches(true, importInventory, importFluids);
}
Also used : IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) IMultipleTankHandler(gregtech.api.capability.IMultipleTankHandler)

Aggregations

IMultipleTankHandler (gregtech.api.capability.IMultipleTankHandler)2 IItemHandlerModifiable (net.minecraftforge.items.IItemHandlerModifiable)2 Recipe (gregtech.api.recipes.Recipe)1