@Override public String getRecipeInfo() { return LogHelper.getStackDescription(recipe.getFluidOutput()); } }
public static void getSqueezerFluidOutputs(ItemStack inputStack, NonNullList<FluidStack> outputFluids) { for (ISqueezerRecipe recipe : RecipeManagers.squeezerManager.recipes()) { if (matches(recipe, inputStack)) { outputFluids.add(recipe.getFluidOutput()); } } }
@Override public boolean workCycle() { if (currentRecipe == null) { return false; } if (!inventory.removeResources(currentRecipe.getResources())) { return false; } FluidStack resultFluid = currentRecipe.getFluidOutput(); productTank.fillInternal(resultFluid, true); if (!currentRecipe.getRemnants().isEmpty() && world.rand.nextFloat() < currentRecipe.getRemnantsChance()) { ItemStack remnant = currentRecipe.getRemnants().copy(); inventory.addRemnant(remnant, true); } return true; }
@Override public void getIngredients(IIngredients ingredients) { NonNullList<ItemStack> resources = getRecipe().getResources(); ingredients.setInputs(ItemStack.class, resources); ItemStack remnants = getRecipe().getRemnants(); if (!remnants.isEmpty()) { ingredients.setOutput(ItemStack.class, remnants); } ingredients.setOutput(FluidStack.class, getRecipe().getFluidOutput()); }
@Override public boolean checkIsRecipe(ISqueezerRecipe recipe) { if(!StackHelper.matches(liquid, InputHelper.toILiquidStack(recipe.getFluidOutput()))) { return false; } if(ingredients != null) { boolean matched = true; if(ingredients.length != recipe.getResources().size()) { return false; } for(int i = 0; i < ingredients.length; i++) { if(!matches(ingredients[i], toIItemStack(recipe.getResources().get(i)))) matched = false; } return matched; } else { return true; } }
@Override public boolean hasWork() { checkRecipe(); boolean hasResources = inventory.hasResources(); boolean hasRecipe = true; boolean canFill = true; boolean canAdd = true; if (hasResources) { hasRecipe = currentRecipe != null; if (hasRecipe) { FluidStack resultFluid = currentRecipe.getFluidOutput(); canFill = productTank.fillInternal(resultFluid, false) == resultFluid.amount; if (!currentRecipe.getRemnants().isEmpty()) { canAdd = inventory.addRemnant(currentRecipe.getRemnants(), false); } } } IErrorLogic errorLogic = getErrorLogic(); errorLogic.setCondition(!hasResources, EnumErrorCode.NO_RESOURCE); errorLogic.setCondition(!hasRecipe, EnumErrorCode.NO_RECIPE); errorLogic.setCondition(!canFill, EnumErrorCode.NO_SPACE_TANK); errorLogic.setCondition(!canAdd, EnumErrorCode.NO_SPACE_INVENTORY); return hasResources && hasRecipe && canFill && canAdd; }
for (final ISqueezerRecipe entry : RecipeManagers.squeezerManager.recipes()) { final ItemStack input = entry.getResources().get(0); final FluidStack output = entry.getFluidOutput(); if (!ItemStack.areItemStacksEqual(stack, input) && !OreDictionary.itemMatches(input, stack, true)) { continue;