Search in sources :

Example 1 with ErrorState

use of binnie.core.machines.errors.ErrorState in project Binnie by ForestryMC.

the class FruitPressLogic method canProgress.

@Override
public ErrorState canProgress() {
    if (!this.getUtil().spaceInTank(FruitPressMachine.TANK_OUTPUT, 5)) {
        return new ErrorState(CoreErrorCode.NO_SPACE_TANK, FruitPressMachine.TANK_OUTPUT);
    }
    FluidStack fluidOutputTank = this.getUtil().getFluid(FruitPressMachine.TANK_OUTPUT);
    FluidStack recipeOutput = FruitPressRecipeManager.getOutput(this.getUtil().getStack(FruitPressMachine.SLOT_CURRENT));
    if (fluidOutputTank != null && !fluidOutputTank.isFluidEqual(recipeOutput)) {
        return new ErrorState(CoreErrorCode.TANK_DIFFRENT_FLUID, FruitPressMachine.TANK_OUTPUT);
    }
    return super.canProgress();
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) ErrorState(binnie.core.machines.errors.ErrorState)

Example 2 with ErrorState

use of binnie.core.machines.errors.ErrorState in project Binnie by ForestryMC.

the class LumbermillLogic method canWork.

@Override
public ErrorState canWork() {
    MachineUtil util = getUtil();
    ItemStack logStack = util.getStack(LumbermillMachine.SLOT_LOG);
    if (logStack.isEmpty()) {
        return new ErrorState(ExtraTreesErrorCode.LUMBERMILL_NO_WOOD, LumbermillMachine.SLOT_LOG);
    }
    ItemStack plankResult = LumbermillRecipeManager.getPlankProduct(logStack, util.getWorld());
    if (!util.isSlotEmpty(LumbermillMachine.SLOT_PLANKS) && !plankResult.isEmpty()) {
        final ItemStack currentPlank = util.getStack(LumbermillMachine.SLOT_PLANKS);
        if (!plankResult.isItemEqual(currentPlank) || plankResult.getCount() + currentPlank.getCount() > currentPlank.getMaxStackSize()) {
            return new ErrorState(ExtraTreesErrorCode.LUMBERMILL_NO_SPACE_PLANKS, new int[] { LumbermillMachine.SLOT_PLANKS });
        }
    }
    if (!util.isSlotEmpty(LumbermillMachine.SLOT_BARK)) {
        ItemStack itemStack = util.getStack(LumbermillMachine.SLOT_BARK);
        if (itemStack.getCount() + 2 > itemStack.getMaxStackSize()) {
            return new ErrorState(ExtraTreesErrorCode.LUMBERMILL_NO_SPACE_BARK, new int[] { LumbermillMachine.SLOT_BARK });
        }
    }
    if (!util.isSlotEmpty(LumbermillMachine.SLOT_SAWDUST)) {
        ItemStack itemStack = util.getStack(LumbermillMachine.SLOT_SAWDUST);
        if (itemStack.getCount() + 2 > itemStack.getMaxStackSize()) {
            return new ErrorState(ExtraTreesErrorCode.LUMBERMILL_NO_SPACE_SAW_DUST, new int[] { LumbermillMachine.SLOT_SAWDUST });
        }
    }
    return super.canWork();
}
Also used : MachineUtil(binnie.core.machines.MachineUtil) ErrorState(binnie.core.machines.errors.ErrorState) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ErrorState

use of binnie.core.machines.errors.ErrorState in project Binnie by ForestryMC.

the class SplicerLogic method isValidSerum.

@Nullable
public ErrorState isValidSerum() {
    final ItemStack serum = this.getUtil().getStack(Splicer.SLOT_SERUM_VIAL);
    if (serum.isEmpty()) {
        return null;
    }
    final ItemStack target = this.getUtil().getStack(Splicer.SLOT_TARGET);
    final IGene[] genes = Engineering.getGenes(serum);
    if (genes.length == 0) {
        return new ErrorState(GeneticsErrorCode.INVALID_SERUM_NO);
    }
    if (!genes[0].getSpeciesRoot().isMember(target)) {
        return new ErrorState(GeneticsErrorCode.INVALID_SERUM_MISMATCH);
    }
    final IIndividual individual = genes[0].getSpeciesRoot().getMember(target);
    boolean hasAll = true;
    for (final IGene gene : genes) {
        if (hasAll) {
            final IAllele a = individual.getGenome().getActiveAllele(gene.getChromosome());
            final IAllele b = individual.getGenome().getInactiveAllele(gene.getChromosome());
            hasAll = (hasAll && a.getUID().equals(gene.getAllele().getUID()) && b.getUID().equals(gene.getAllele().getUID()));
        }
    }
    if (hasAll) {
        return new ErrorState(GeneticsErrorCode.DEFUNCT_SERUM);
    }
    return null;
}
Also used : IAllele(forestry.api.genetics.IAllele) IIndividual(forestry.api.genetics.IIndividual) ErrorState(binnie.core.machines.errors.ErrorState) IGene(binnie.core.api.genetics.IGene) ItemStack(net.minecraft.item.ItemStack) Nullable(javax.annotation.Nullable)

Example 4 with ErrorState

use of binnie.core.machines.errors.ErrorState in project Binnie by ForestryMC.

the class GenepoolLogic method canProgress.

@Override
public ErrorState canProgress() {
    MachineUtil util = getUtil();
    ItemStack individual = util.getStack(Genepool.SLOT_BEE);
    if (!util.spaceInTank(Genepool.TANK_DNA, getDNAAmount(individual))) {
        return new ErrorState(CoreErrorCode.NO_SPACE_TANK, new int[] { Genepool.SLOT_BEE });
    }
    if (!util.liquidInTank(Genepool.TANK_ETHANOL, 1)) {
        return new ErrorState(GeneticsErrorCode.GENEPOOL_INSUFFICIENT_ETHANOL, Genepool.TANK_ETHANOL);
    }
    if (util.getSlotCharge(Genepool.SLOT_ENZYME) == 0.0f) {
        return new ErrorState(GeneticsErrorCode.GENEPOOL_INSUFFICIENT_ENZYME, Genepool.SLOT_ENZYME);
    }
    return super.canProgress();
}
Also used : MachineUtil(binnie.core.machines.MachineUtil) ErrorState(binnie.core.machines.errors.ErrorState) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ErrorState

use of binnie.core.machines.errors.ErrorState in project Binnie by ForestryMC.

the class InoculatorLogic method canWork.

@Override
public ErrorState canWork() {
    if (this.getUtil().isSlotEmpty(Inoculator.SLOT_TARGET)) {
        return new ErrorState(GeneticsErrorCode.NO_INDIVIDUAL, Inoculator.SLOT_TARGET);
    }
    if (this.getUtil().isSlotEmpty(Inoculator.SLOT_SERUM_VIAL)) {
        return new ErrorState(GeneticsErrorCode.NO_SERUM, Inoculator.SLOT_SERUM_VIAL);
    }
    final ErrorState state = this.isValidSerum();
    if (state != null) {
        return state;
    }
    ItemStack serum = this.getUtil().getStack(Inoculator.SLOT_SERUM_VIAL);
    if (!serum.isEmpty() && Engineering.getCharges(serum) == 0) {
        return new ErrorState(GeneticsErrorCode.EMPTY_SERUM, Inoculator.SLOT_SERUM_VIAL);
    }
    if (getUtil().isTankEmpty(Inoculator.TANK_VEKTOR)) {
        return new ErrorState(GeneticsErrorCode.INOCULATOR_INSUFFICIENT_VECTOR, Inoculator.TANK_VEKTOR);
    }
    return super.canWork();
}
Also used : ErrorState(binnie.core.machines.errors.ErrorState) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ErrorState (binnie.core.machines.errors.ErrorState)9 ItemStack (net.minecraft.item.ItemStack)6 MachineUtil (binnie.core.machines.MachineUtil)3 IGene (binnie.core.api.genetics.IGene)2 IAllele (forestry.api.genetics.IAllele)2 IIndividual (forestry.api.genetics.IIndividual)2 Nullable (javax.annotation.Nullable)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 IGenome (forestry.api.genetics.IGenome)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1