public static void getSqueezerOutputs(ItemStack inputStack, NonNullList<ItemStack> outputItems) { for (ISqueezerRecipe recipe : RecipeManagers.squeezerManager.recipes()) { if (matches(recipe, inputStack)) { if (!recipe.getRemnants().isEmpty()) { outputItems.add(recipe.getRemnants()); } } } }
@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 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; }
@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()); }