public static Set<Fluid> getRecipeFluids() { if (recipeFluids.isEmpty()) { for (ICarpenterRecipe recipe : recipes) { FluidStack fluidStack = recipe.getFluidResource(); if (fluidStack != null) { recipeFluids.add(fluidStack.getFluid()); } } } return Collections.unmodifiableSet(recipeFluids); }
private boolean removeLiquidResources(boolean doRemove) { if (currentRecipe == null) { return true; } FluidStack fluid = currentRecipe.getFluidResource(); if (fluid != null) { FluidStack drained = resourceTank.drainInternal(fluid, false); if (!fluid.isFluidStackIdentical(drained)) { return false; } if (doRemove) { resourceTank.drainInternal(fluid, true); } } return true; }
@Override public boolean checkIsRecipe(ICarpenterRecipe recipe) { if(recipe.getCraftingGridRecipe().getOutput().isItemEqual(output)) { if(fluidInput == null) { return true; } else { return fluidInput.isFluidEqual(recipe.getFluidResource()); } } return false; }
public static String[][] matches(@Nullable ICarpenterRecipe recipe, @Nullable FluidStack resource, ItemStack item, IInventory inventoryCrafting) { if (recipe == null) { return null; } FluidStack liquid = recipe.getFluidResource(); if (liquid != null) { if (resource == null || !resource.containsFluid(liquid)) { return null; } } ItemStack box = recipe.getBox(); if (!box.isEmpty() && !ItemStackUtil.isCraftingEquivalent(box, item)) { return null; } IDescriptiveRecipe internal = recipe.getCraftingGridRecipe(); return RecipeUtil.matches(internal, inventoryCrafting); }
@Override public void getIngredients(IIngredients ingredients) { ICarpenterRecipe recipe = getRecipe(); IDescriptiveRecipe craftingGridRecipe = recipe.getCraftingGridRecipe(); List<List<ItemStack>> inputStacks = new ArrayList<>(); ItemStack box = recipe.getBox(); if (!box.isEmpty()) { inputStacks.add(Collections.singletonList(box)); } inputStacks.addAll(getInputStacks()); ingredients.setInputLists(ItemStack.class, inputStacks); FluidStack fluidResource = recipe.getFluidResource(); if (fluidResource != null) { ingredients.setInputs(FluidStack.class, Collections.singletonList(fluidResource)); } ItemStack recipeOutput = craftingGridRecipe.getOutput(); ingredients.setOutput(ItemStack.class, recipeOutput); }
@Override protected void onIndexUpdate(int index, ICarpenterRecipe recipe) { selectedElement.add(new TankElement(91, 1, null, () -> new FluidTankInfo(recipe.getFluidResource(), Constants.PROCESSOR_TANK_CAPACITY), CARPENTER_TANK_OVERLAY)); IDescriptiveRecipe gridRecipe = recipe.getCraftingGridRecipe(); NonNullList<NonNullList<ItemStack>> ingredients = gridRecipe.getRawIngredients(); for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { int ingredientIndex = y * 3 + x; if (ingredientIndex >= ingredients.size()) { continue; } NonNullList<ItemStack> items = ingredients.get(ingredientIndex); selectedElement.add(new IngredientElement(1 + x * 19, 3 + y * 19, Ingredient.fromStacks(items.toArray(new ItemStack[items.size()])))); } } selectedElement.item(71, 41, gridRecipe.getOutput()); } }