RecipeDisplay.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Roughly Enough Items by Danielshe.
  3. * Licensed under the MIT License.
  4. */
  5. package me.shedaniel.rei.api;
  6. import me.shedaniel.rei.api.annotations.ToBeRemoved;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.util.Identifier;
  9. import java.util.ArrayList;
  10. import java.util.Collections;
  11. import java.util.List;
  12. import java.util.Optional;
  13. public interface RecipeDisplay {
  14. /**
  15. * @return a list of items
  16. * @see RecipeDisplay#getInputStacks()
  17. */
  18. @ToBeRemoved
  19. @Deprecated
  20. default List<List<ItemStack>> getInput() {
  21. return Collections.emptyList();
  22. }
  23. /**
  24. * @return a list of inputs
  25. */
  26. default List<List<EntryStack>> getInputEntries() {
  27. List<List<ItemStack>> input = getInput();
  28. if (input.isEmpty())
  29. return Collections.emptyList();
  30. List<List<EntryStack>> list = new ArrayList<>();
  31. for (List<ItemStack> stacks : input) {
  32. List<EntryStack> entries = new ArrayList<>();
  33. for (ItemStack stack : stacks) {
  34. entries.add(EntryStack.create(stack));
  35. }
  36. list.add(entries);
  37. }
  38. return list;
  39. }
  40. /**
  41. * @return a list of outputs
  42. */
  43. @ToBeRemoved
  44. @Deprecated
  45. default List<ItemStack> getOutput() {
  46. return Collections.emptyList();
  47. }
  48. /**
  49. * @return a list of outputs
  50. */
  51. default List<EntryStack> getOutputEntries() {
  52. List<ItemStack> input = getOutput();
  53. if (input.isEmpty())
  54. return Collections.emptyList();
  55. List<EntryStack> entries = new ArrayList<>();
  56. for (ItemStack stack : input) {
  57. entries.add(EntryStack.create(stack));
  58. }
  59. return entries;
  60. }
  61. /**
  62. * Gets the required items used in craftable filters
  63. *
  64. * @return the list of required items
  65. */
  66. default List<List<EntryStack>> getRequiredEntries() {
  67. List<List<ItemStack>> input = getRequiredItems();
  68. if (input.isEmpty())
  69. return Collections.emptyList();
  70. List<List<EntryStack>> list = new ArrayList<>();
  71. for (List<ItemStack> stacks : input) {
  72. List<EntryStack> entries = new ArrayList<>();
  73. for (ItemStack stack : stacks) {
  74. entries.add(EntryStack.create(stack));
  75. }
  76. list.add(entries);
  77. }
  78. return list;
  79. }
  80. @ToBeRemoved
  81. @Deprecated
  82. default List<List<ItemStack>> getRequiredItems() {
  83. return Collections.emptyList();
  84. }
  85. /**
  86. * Gets the recipe display category identifier
  87. *
  88. * @return the identifier of the category
  89. */
  90. Identifier getRecipeCategory();
  91. /**
  92. * Gets the recipe location from datapack
  93. *
  94. * @return the recipe location
  95. */
  96. default Optional<Identifier> getRecipeLocation() {
  97. return Optional.empty();
  98. }
  99. }