ClientHelper.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.minecraft.item.Item;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.util.Identifier;
  10. import java.util.List;
  11. import java.util.Map;
  12. public interface ClientHelper {
  13. /**
  14. * @return the api instance of {@link ClientHelperImpl}
  15. */
  16. @SuppressWarnings("deprecation")
  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 stack using either packets or commands.
  49. *
  50. * @param stack the stack to cheat in
  51. * @return whether it failed
  52. */
  53. boolean tryCheatingEntry(EntryStack stack);
  54. default boolean tryCheatingStack(ItemStack stack) {
  55. return tryCheatingEntry(EntryStack.create(stack));
  56. }
  57. /**
  58. * Finds recipe for the stack and opens the recipe screen.
  59. *
  60. * @param stack the stack to find recipe for
  61. * @return whether the stack has any recipes to show
  62. */
  63. boolean executeRecipeKeyBind(EntryStack stack);
  64. default boolean executeRecipeKeyBind(ItemStack stack) {
  65. return executeRecipeKeyBind(EntryStack.create(stack));
  66. }
  67. /**
  68. * Finds usage for the stack and opens the recipe screen.
  69. *
  70. * @param stack the stack to find usage for
  71. * @return whether the stack has any usages to show
  72. */
  73. boolean executeUsageKeyBind(EntryStack stack);
  74. default boolean executeUsageKeyBind(ItemStack stack) {
  75. return executeUsageKeyBind(EntryStack.create(stack));
  76. }
  77. /**
  78. * Gets the mod from an item
  79. *
  80. * @param item the item to find
  81. * @return the mod name
  82. */
  83. String getModFromItem(Item item);
  84. /**
  85. * Tries to delete the player's cursor item
  86. */
  87. void sendDeletePacket();
  88. /**
  89. * Gets the formatted mod from an item
  90. *
  91. * @param item the item to find
  92. * @return the mod name with blue and italic formatting
  93. */
  94. String getFormattedModFromItem(Item item);
  95. /**
  96. * Gets the formatted mod from an identifier
  97. *
  98. * @param identifier the identifier to find
  99. * @return the mod name with blue and italic formatting
  100. */
  101. String getFormattedModFromIdentifier(Identifier identifier);
  102. /**
  103. * Gets the mod from an identifier
  104. *
  105. * @param identifier the identifier to find
  106. * @return the mod name
  107. */
  108. default String getModFromIdentifier(Identifier identifier) {
  109. if (identifier == null)
  110. return "";
  111. return getModFromModId(identifier.getNamespace());
  112. }
  113. /**
  114. * Gets the mod from a modid
  115. *
  116. * @param modid the modid of the mod
  117. * @return the mod name
  118. */
  119. String getModFromModId(String modid);
  120. /**
  121. * Finds all recipes and open them in a recipe screen.
  122. *
  123. * @return whether there are any recipes to show
  124. */
  125. boolean executeViewAllRecipesKeyBind();
  126. boolean executeViewAllRecipesFromCategory(Identifier category);
  127. boolean executeViewAllRecipesFromCategories(List<Identifier> categories);
  128. }