@Override public void getIngredients(IIngredients ingredients) { ICentrifugeRecipe recipe = getRecipe(); ingredients.setInputs(ItemStack.class, Collections.singletonList(recipe.getInput())); Set<ItemStack> outputs = recipe.getAllProducts().keySet(); ingredients.setOutputs(ItemStack.class, new ArrayList<>(outputs)); } }
@Override protected String getRecipeInfo() { return LogHelper.getStackDescription(recipe.getInput()); } }
@Override public void setRecipe(IRecipeLayout recipeLayout, CentrifugeRecipeWrapper recipeWrapper, IIngredients ingredients) { IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); guiItemStacks.init(inputSlot, true, 4, 18); List<List<ItemStack>> inputs = ingredients.getInputs(ItemStack.class); guiItemStacks.set(inputSlot, inputs.get(0)); ForestryTooltipCallback tooltip = new ForestryTooltipCallback(); Map<ItemStack, Float> products = recipeWrapper.getRecipe().getAllProducts(); setResults(tooltip, products, guiItemStacks); guiItemStacks.addTooltipCallback(tooltip); }
private void checkRecipe() { ItemStack resource = getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE); ICentrifugeRecipe matchingRecipe = CentrifugeRecipeManager.findMatchingRecipe(resource); if (currentRecipe != matchingRecipe) { currentRecipe = matchingRecipe; if (currentRecipe != null) { int recipeTime = currentRecipe.getProcessingTime(); setTicksPerWorkCycle(recipeTime * TICKS_PER_RECIPE_TIME); setEnergyPerWorkCycle(recipeTime * ENERGY_PER_RECIPE_TIME); } } }
@Override public boolean workCycle() { if (tryAddPending()) { return true; } if (!pendingProducts.isEmpty()) { craftPreviewInventory.setInventorySlotContents(0, ItemStack.EMPTY); return false; } if (currentRecipe == null) { return false; } // We are done, add products to queue Collection<ItemStack> products = currentRecipe.getProducts(world.rand); pendingProducts.addAll(products); //Add Item to preview slot. ItemStack previewStack = getInternalInventory().getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE).copy(); previewStack.setCount(1); craftPreviewInventory.setInventorySlotContents(0, previewStack); getInternalInventory().decrStackSize(InventoryCentrifuge.SLOT_RESOURCE, 1); return true; }
@Nullable public static ICentrifugeRecipe findMatchingRecipe(ItemStack itemStack) { if (itemStack.isEmpty()) { return null; } for (ICentrifugeRecipe recipe : recipes) { ItemStack recipeInput = recipe.getInput(); if (ItemStackUtil.isCraftingEquivalent(recipeInput, itemStack)) { return recipe; } } return null; }
public static void getCentrifugeOutputs(ItemStack inputStack, NonNullList<ItemStack> outputItems) { for (ICentrifugeRecipe recipe : RecipeManagers.centrifugeManager.recipes()) { if (inputStack.isItemEqual(recipe.getInput())) { outputItems.addAll(recipe.getAllProducts().keySet()); } } }
@Override public boolean checkIsRecipe(ICentrifugeRecipe recipe) { return recipe != null && matches(input, toIItemStack(recipe.getInput())); } }