/** * Gets the result for a drying recipe * * @param input Input ItemStack * @return Output A copy of the output ItemStack, or Itemstack.EMPTY if no recipe is found */ public static ItemStack getDryingResult(ItemStack input) { for(DryingRecipe r : dryingRegistry) { if(r.matches(input)) { return r.getResult(); } } return ItemStack.EMPTY; }
public DryingRecipeWrapper(DryingRecipe recipe) { this.input = ImmutableList.of(recipe.input.getInputs()); this.output = ImmutableList.of(recipe.getResult()); this.time = recipe.getTime(); }
public static void addDryingRecipe(DryingRecipe recipe) { if(new TinkerRegisterEvent.DryingRackRegisterEvent(recipe).fire()) { dryingRegistry.add(recipe); } else { try { String input = recipe.input.getInputs().stream().findFirst().map(ItemStack::getUnlocalizedName).orElse("?"); String output = recipe.getResult().getUnlocalizedName(); log.debug("Registration of drying rack recipe for " + output + " from " + input + " has been cancelled by event"); } catch(Exception e) { log.error("Error when logging drying rack event", e); } } }
@SubscribeEvent public void onTinkerRegister(TinkerRegisterEvent.DryingRackRegisterEvent event) { if(event.getRecipe() instanceof DryingRecipeTweaker) { return; } for(Map.Entry<IItemStack, IItemStack> ent : DRYING_RECIPES.entrySet()) { if(ent.getKey().matches(InputHelper.toIItemStack(event.getRecipe().getResult()))) { if(ent.getValue() != null) { if(event.getRecipe().input.matches(NonNullList.withSize(1, (ItemStack) ent.getValue().getInternal())).isPresent()) { event.setCanceled(true); } } else event.setCanceled(true); } } } }