ClientHelper.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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.impl.ClientHelperImpl;
  7. import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
  8. import net.minecraft.item.Item;
  9. import net.minecraft.item.ItemStack;
  10. import net.minecraft.util.Identifier;
  11. import java.util.List;
  12. import java.util.Map;
  13. public interface ClientHelper {
  14. /**
  15. * @return the api instance of {@link ClientHelperImpl}
  16. */
  17. @SuppressWarnings("deprecation")
  18. static ClientHelper getInstance() {
  19. return ClientHelperImpl.instance;
  20. }
  21. /**
  22. * Checks if cheating is enabled
  23. *
  24. * @return whether cheating is enabled
  25. */
  26. boolean isCheating();
  27. /**
  28. * Sets current cheating mode
  29. * Should save the config in {@link ConfigManager}.
  30. *
  31. * @param cheating the new cheating mode
  32. */
  33. void setCheating(boolean cheating);
  34. List<ItemStack> getInventoryItemsTypes();
  35. /**
  36. * Opens a recipe viewing screen:
  37. * Opens {@link me.shedaniel.rei.gui.PreRecipeViewingScreen} if not set
  38. * Opens {@link me.shedaniel.rei.gui.RecipeViewingScreen} if set to default
  39. * Opens {@link me.shedaniel.rei.gui.VillagerRecipeViewingScreen} if set to villager
  40. *
  41. * @param map the map of recipes
  42. */
  43. void openRecipeViewingScreen(Map<RecipeCategory<?>, List<RecipeDisplay>> map);
  44. /**
  45. * Registers REI's keybinds using Fabric API.
  46. */
  47. void registerFabricKeyBinds();
  48. /**
  49. * Tries to cheat stack using either packets or commands.
  50. *
  51. * @param stack the stack to cheat in
  52. * @return whether it failed
  53. */
  54. boolean tryCheatingEntry(EntryStack stack);
  55. default boolean tryCheatingStack(ItemStack stack) {
  56. return tryCheatingEntry(EntryStack.create(stack));
  57. }
  58. /**
  59. * Finds recipe for the stack and opens the recipe screen.
  60. *
  61. * @param stack the stack to find recipe for
  62. * @return whether the stack has any recipes to show
  63. */
  64. boolean executeRecipeKeyBind(EntryStack stack);
  65. default boolean executeRecipeKeyBind(ItemStack stack) {
  66. return executeRecipeKeyBind(EntryStack.create(stack));
  67. }
  68. /**
  69. * Finds usage for the stack and opens the recipe screen.
  70. *
  71. * @param stack the stack to find usage for
  72. * @return whether the stack has any usages to show
  73. */
  74. boolean executeUsageKeyBind(EntryStack stack);
  75. default boolean executeUsageKeyBind(ItemStack stack) {
  76. return executeUsageKeyBind(EntryStack.create(stack));
  77. }
  78. FabricKeyBinding getFocusSearchFieldKeyBinding();
  79. FabricKeyBinding getCopyRecipeIdentifierKeyBinding();
  80. /**
  81. * Gets the mod from an item
  82. *
  83. * @param item the item to find
  84. * @return the mod name
  85. */
  86. String getModFromItem(Item item);
  87. /**
  88. * Tries to delete the player's cursor item
  89. */
  90. void sendDeletePacket();
  91. /**
  92. * Gets the formatted mod from an item
  93. *
  94. * @param item the item to find
  95. * @return the mod name with blue and italic formatting
  96. */
  97. String getFormattedModFromItem(Item item);
  98. /**
  99. * Gets the formatted mod from an identifier
  100. *
  101. * @param identifier the identifier to find
  102. * @return the mod name with blue and italic formatting
  103. */
  104. String getFormattedModFromIdentifier(Identifier identifier);
  105. /**
  106. * Gets the mod from an identifier
  107. *
  108. * @param identifier the identifier to find
  109. * @return the mod name
  110. */
  111. String getModFromIdentifier(Identifier identifier);
  112. /**
  113. * @return the recipe keybind, defaulted R
  114. */
  115. FabricKeyBinding getRecipeKeyBinding();
  116. /**
  117. * @return the usage keybind, defaulted U
  118. */
  119. FabricKeyBinding getUsageKeyBinding();
  120. /**
  121. * @return the hide keybind, defaulted O
  122. */
  123. FabricKeyBinding getHideKeyBinding();
  124. /**
  125. * @return the previous page keybind, defaulted not set
  126. */
  127. FabricKeyBinding getPreviousPageKeyBinding();
  128. /**
  129. * @return the next page keybind, defaulted not set
  130. */
  131. FabricKeyBinding getNextPageKeyBinding();
  132. /**
  133. * Finds all recipes and open them in a recipe screen.
  134. *
  135. * @return whether there are any recipes to show
  136. */
  137. boolean executeViewAllRecipesKeyBind();
  138. boolean executeViewAllRecipesFromCategory(Identifier category);
  139. boolean executeViewAllRecipesFromCategories(List<Identifier> categories);
  140. }