use of binnie.core.machines.errors.ErrorState in project Binnie by ForestryMC.
the class ContainerCraftGUI method createErrorNBT.
private NBTTagCompound createErrorNBT(final IErrorStateSource error) {
final NBTTagCompound nbt = new NBTTagCompound();
ErrorState state = null;
if (error.canWork() != null) {
nbt.setByte("type", (byte) 0);
state = error.canWork();
} else if (error.canProgress() != null) {
nbt.setByte("type", (byte) 1);
state = error.canProgress();
}
if (state != null) {
state.writeToNBT(nbt);
}
return nbt;
}
use of binnie.core.machines.errors.ErrorState in project Binnie by ForestryMC.
the class DistilleryLogic method canProgress.
@Override
public ErrorState canProgress() {
if (this.currentFluid == null) {
return new ErrorState(CoreErrorCode.TANK_EMPTY);
}
final MachineUtil util = this.getUtil();
FluidStack fluidInOutputTank = util.getFluid(DistilleryMachine.TANK_OUTPUT);
if (fluidInOutputTank != null) {
FluidStack inputFluid = util.getFluid(DistilleryMachine.TANK_INPUT);
FluidStack recipeOutput = DistilleryRecipeManager.getOutput(inputFluid, this.level);
if (recipeOutput != null) {
if (!recipeOutput.isFluidEqual(fluidInOutputTank)) {
return new ErrorState(CoreErrorCode.TANK_DIFFRENT_FLUID, DistilleryMachine.TANK_OUTPUT);
} else if (!util.spaceInTank(DistilleryMachine.TANK_OUTPUT, recipeOutput.amount)) {
return new ErrorState(CoreErrorCode.NO_SPACE_TANK, DistilleryMachine.TANK_OUTPUT);
}
}
}
return super.canProgress();
}
use of binnie.core.machines.errors.ErrorState in project Binnie by ForestryMC.
the class InoculatorLogic method isValidSerum.
@Nullable
public ErrorState isValidSerum() {
final ItemStack serum = this.getUtil().getStack(Inoculator.SLOT_SERUM_VIAL);
final ItemStack target = this.getUtil().getStack(Inoculator.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);
if (individual != null) {
final IGenome genome = individual.getGenome();
for (final IGene gene : genes) {
final IAllele a = genome.getActiveAllele(gene.getChromosome());
final IAllele b = genome.getInactiveAllele(gene.getChromosome());
if (!a.getUID().equals(gene.getAllele().getUID()) || !b.getUID().equals(gene.getAllele().getUID())) {
return null;
}
}
}
return new ErrorState(GeneticsErrorCode.DEFUNCT_SERUM);
}
use of binnie.core.machines.errors.ErrorState in project Binnie by ForestryMC.
the class SplicerLogic method canWork.
@Override
public ErrorState canWork() {
if (this.getUtil().isSlotEmpty(Splicer.SLOT_TARGET)) {
return new ErrorState(GeneticsErrorCode.NO_INDIVIDUAL, Splicer.SLOT_TARGET);
}
ItemStack serum = this.getUtil().getStack(Splicer.SLOT_SERUM_VIAL);
if (serum.isEmpty()) {
return new ErrorState(GeneticsErrorCode.NO_SERUM, Splicer.SLOT_SERUM_VIAL);
}
final ErrorState state = this.isValidSerum();
if (state != null) {
return state;
}
if (Engineering.getCharges(serum) == 0) {
return new ErrorState(GeneticsErrorCode.EMPTY_SERUM);
}
return super.canWork();
}
Aggregations