ClientHelper.java 4.0 KB

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