@Override public String getRecipeInfo() { return LogHelper.getStackDescription(recipe.getOutput()); } }
@Override public boolean addRecipe(IStillRecipe recipe) { FluidStack input = recipe.getInput(); recipeFluidInputs.add(input.getFluid()); FluidStack output = recipe.getOutput(); recipeFluidOutputs.add(output.getFluid()); return recipes.add(recipe); }
@Override public boolean removeRecipe(IStillRecipe recipe) { FluidStack input = recipe.getInput(); recipeFluidInputs.remove(input.getFluid()); FluidStack output = recipe.getOutput(); recipeFluidOutputs.remove(output.getFluid()); return recipes.remove(recipe); }
@Override public boolean workCycle() { Preconditions.checkNotNull(currentRecipe); int cycles = currentRecipe.getCyclesPerUnit(); FluidStack output = currentRecipe.getOutput(); FluidStack product = new FluidStack(output, output.amount * cycles); productTank.fillInternal(product, true); bufferedLiquid = null; return true; }
@Override public void getIngredients(IIngredients ingredients) { ingredients.setInputs(FluidStack.class, Collections.singletonList(getRecipe().getInput())); ingredients.setOutput(FluidStack.class, getRecipe().getOutput()); } }
@Override public boolean checkIsRecipe(IStillRecipe r) { if(r != null && matches(output, toILiquidStack(r.getOutput()))) { if(fluidInput != null) { return matches(fluidInput, toILiquidStack(r.getInput())); } else return true; } return false; } }
@Override public boolean hasWork() { checkRecipe(); boolean hasRecipe = currentRecipe != null; boolean hasTankSpace = true; boolean hasLiquidResource = true; if (hasRecipe) { FluidStack fluidStack = currentRecipe.getOutput(); hasTankSpace = productTank.fillInternal(fluidStack, false) == fluidStack.amount; if (bufferedLiquid == null) { int cycles = currentRecipe.getCyclesPerUnit(); FluidStack input = currentRecipe.getInput(); int drainAmount = cycles * input.amount; FluidStack drained = resourceTank.drain(drainAmount, false); hasLiquidResource = drained != null && drained.amount == drainAmount; if (hasLiquidResource) { bufferedLiquid = new FluidStack(input, drainAmount); resourceTank.drain(drainAmount, true); } } } IErrorLogic errorLogic = getErrorLogic(); errorLogic.setCondition(!hasRecipe, EnumErrorCode.NO_RECIPE); errorLogic.setCondition(!hasTankSpace, EnumErrorCode.NO_SPACE_TANK); errorLogic.setCondition(!hasLiquidResource, EnumErrorCode.NO_RESOURCE_LIQUID); return hasRecipe && hasLiquidResource && hasTankSpace; }