/** * 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 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); } } }
/** * Adds a new drying recipe * * @param input Input ItemStack * @param output Output ItemStack * @param time Recipe time in ticks */ public static void registerDryingRecipe(ItemStack input, ItemStack output, int time) { if(output.isEmpty() || input.isEmpty()) { return; } addDryingRecipe(new DryingRecipe(new RecipeMatch.Item(input, 1), output, time)); }
@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); } } } }
/** * Adds a new drying recipe * * @param oredict Input ore dictionary entry * @param output Output ItemStack * @param time Recipe time in ticks */ public static void registerDryingRecipe(String oredict, ItemStack output, int time) { if(output.isEmpty() || oredict == null) { return; } addDryingRecipe(new DryingRecipe(new RecipeMatch.Oredict(oredict, 1), output, time)); }
/** * Adds a new drying recipe * * @param input Input Item * @param output Output ItemStack * @param time Recipe time in ticks */ public static void registerDryingRecipe(Item input, ItemStack output, int time) { if(output.isEmpty() || input == null) { return; } ItemStack stack = new ItemStack(input, 1, OreDictionary.WILDCARD_VALUE); addDryingRecipe(new DryingRecipe(new RecipeMatch.Item(stack, 1), output, time)); }
/** * Adds a new drying recipe * * @param input Input Item * @param output Output Item * @param time Recipe time in ticks */ public static void registerDryingRecipe(Item input, Item output, int time) { if(output == null || input == null) { return; } ItemStack stack = new ItemStack(input, 1, OreDictionary.WILDCARD_VALUE); addDryingRecipe(new DryingRecipe(new RecipeMatch.Item(stack, 1), new ItemStack(output), time)); }
/** * Adds a new drying recipe * * @param input Input Block * @param output Output Block * @param time Recipe time in ticks */ public static void registerDryingRecipe(Block input, Block output, int time) { if(output == null || input == null) { return; } ItemStack stack = new ItemStack(input, 1, OreDictionary.WILDCARD_VALUE); addDryingRecipe(new DryingRecipe(new RecipeMatch.Item(stack, 1), new ItemStack(output), time)); }