ClientHelper.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. * {@link me.shedaniel.rei.gui.PreRecipeViewingScreen} if not set
  37. * {@link me.shedaniel.rei.gui.RecipeViewingScreen} if set to default
  38. * {@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. /**
  69. * Gets the mod from an item
  70. *
  71. * @param item
  72. * @return the mod name
  73. */
  74. String getModFromItem(Item item);
  75. /**
  76. * Tries to delete the player's cursor item
  77. *
  78. * @return whether it failed
  79. */
  80. void sendDeletePacket();
  81. /**
  82. * Gets the formatted mod from an item
  83. *
  84. * @param item
  85. * @return the mod name with blue and italic formatting
  86. */
  87. String getFormattedModFromItem(Item item);
  88. /**
  89. * Gets the formatted mod from an identifier
  90. *
  91. * @param identifier
  92. * @return the mod name with blue and italic formatting
  93. */
  94. String getFormattedModFromIdentifier(Identifier identifier);
  95. /**
  96. * Gets the mod from an identifier
  97. *
  98. * @param identifier
  99. * @return the mod name
  100. */
  101. String getModFromIdentifier(Identifier identifier);
  102. FabricKeyBinding getRecipeKeyBinding();
  103. FabricKeyBinding getUsageKeyBinding();
  104. FabricKeyBinding getHideKeyBinding();
  105. FabricKeyBinding getPreviousPageKeyBinding();
  106. FabricKeyBinding getNextPageKeyBinding();
  107. /**
  108. * Finds all recipes and open them in a recipe screen.
  109. *
  110. * @return whether there are any recipes to show
  111. */
  112. boolean executeViewAllRecipesKeyBind();
  113. }