Search in sources :

Example 1 with FillStatus

use of forestry.core.fluids.FluidHelper.FillStatus in project ForestryMC by ForestryMC.

the class TileBottler method hasWork.

@Override
public boolean hasWork() {
    FluidHelper.FillStatus emptyStatus;
    FluidHelper.FillStatus fillStatus;
    IErrorLogic errorLogic = getErrorLogic();
    errorLogic.clearErrors();
    checkEmptyRecipe();
    if (currentRecipe != null) {
        IFluidTankProperties properties = tankManager.getTankProperties()[0];
        if (properties != null) {
            emptyStatus = FluidHelper.drainContainers(tankManager, this, InventoryBottler.SLOT_EMPTYING_PROCESSING, InventoryBottler.SLOT_OUTPUT_EMPTY_CONTAINER, false);
        } else {
            emptyStatus = FillStatus.SUCCESS;
        }
    } else {
        emptyStatus = null;
    }
    if (emptyStatus == null || emptyStatus != FillStatus.SUCCESS) {
        checkFillRecipe();
        if (currentRecipe == null) {
            return false;
        } else {
            fillStatus = FluidHelper.fillContainers(tankManager, this, InventoryBottler.SLOT_FILLING_PROCESSING, InventoryBottler.SLOT_OUTPUT_FULL_CONTAINER, currentRecipe.fluid.getFluid(), false);
        }
    } else {
        return true;
    }
    if (fillStatus == FillStatus.SUCCESS) {
        return true;
    }
    errorLogic.setCondition(fillStatus == FluidHelper.FillStatus.NO_FLUID, EnumErrorCode.NO_RESOURCE_LIQUID);
    errorLogic.setCondition(fillStatus == FluidHelper.FillStatus.NO_SPACE, EnumErrorCode.NO_SPACE_INVENTORY);
    errorLogic.setCondition(emptyStatus == FluidHelper.FillStatus.NO_SPACE_FLUID, EnumErrorCode.NO_SPACE_TANK);
    if (emptyStatus == FillStatus.INVALID_INPUT || fillStatus == FillStatus.INVALID_INPUT || errorLogic.hasErrors()) {
        currentRecipe = null;
        return false;
    }
    return true;
}
Also used : FillStatus(forestry.core.fluids.FluidHelper.FillStatus) IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) FluidHelper(forestry.core.fluids.FluidHelper) IErrorLogic(forestry.api.core.IErrorLogic)

Aggregations

IErrorLogic (forestry.api.core.IErrorLogic)1 FluidHelper (forestry.core.fluids.FluidHelper)1 FillStatus (forestry.core.fluids.FluidHelper.FillStatus)1 IFluidTankProperties (net.minecraftforge.fluids.capability.IFluidTankProperties)1