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();
}
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();
}
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;
}
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();
}
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();
}
Aggregations