diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-01-02 14:31:16 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-01-02 14:31:16 +0800 |
| commit | 5e2eccadbd91171c01cdb209d1338bcfb7786b1c (patch) | |
| tree | 6c7387de5baea8b335e8abe58651018f77ad2d41 /src/main/java/me/shedaniel/rei/api | |
| parent | e8714fe8fc1dcaec7ad299c63e2b657870c8fb40 (diff) | |
| download | RoughlyEnoughItems-5e2eccadbd91171c01cdb209d1338bcfb7786b1c.tar.gz RoughlyEnoughItems-5e2eccadbd91171c01cdb209d1338bcfb7786b1c.tar.bz2 RoughlyEnoughItems-5e2eccadbd91171c01cdb209d1338bcfb7786b1c.zip | |
3.3
Fix #58
Close #134
Close #158
Fix #227
Diffstat (limited to 'src/main/java/me/shedaniel/rei/api')
21 files changed, 328 insertions, 329 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java b/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java index 54b7e542d..c8e761e25 100644 --- a/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java +++ b/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java @@ -16,89 +16,89 @@ import net.minecraft.container.Container; import java.util.function.Supplier; public interface AutoTransferHandler { - + default double getPriority() { return 0d; } - + Result handle(Context context); - - public interface Result { + + interface Result { static Result createSuccessful() { return new ResultImpl(); } - + static Result createNotApplicable() { return new ResultImpl(false); } - + static Result createFailed(String errorKey) { return new ResultImpl(errorKey, new IntArrayList(), 1744764928); } - + static Result createFailedCustomButtonColor(String errorKey, int color) { return new ResultImpl(errorKey, new IntArrayList(), color); } - + static Result createFailed(String errorKey, IntList redSlots) { return new ResultImpl(errorKey, redSlots, 1744764928); } - + static Result createFailedCustomButtonColor(String errorKey, IntList redSlots, int color) { return new ResultImpl(errorKey, redSlots, color); } - + int getColor(); - + boolean isSuccessful(); - + boolean isApplicable(); - + String getErrorKey(); - + IntList getIntegers(); } - - public interface Context { + + interface Context { static Context create(boolean actuallyCrafting, AbstractContainerScreen<?> containerScreen, RecipeDisplay recipeDisplay) { return new ContextImpl(actuallyCrafting, containerScreen, () -> recipeDisplay); } - + default MinecraftClient getMinecraft() { return MinecraftClient.getInstance(); } - + boolean isActuallyCrafting(); - + AbstractContainerScreen<?> getContainerScreen(); - + RecipeDisplay getRecipe(); - + default Container getContainer() { return getContainerScreen().getContainer(); } - + default ContainerScreenOverlay getOverlay() { return ScreenHelper.getLastOverlay(); } } - - public final class ResultImpl implements Result { + + final class ResultImpl implements Result { private boolean successful, applicable; private String errorKey; private IntList integers = new IntArrayList(); private int color; - + private ResultImpl() { this.successful = true; this.applicable = true; } - + public ResultImpl(boolean applicable) { this.successful = false; this.applicable = applicable; } - + public ResultImpl(String errorKey, IntList integers, int color) { this.successful = false; this.applicable = true; @@ -107,58 +107,58 @@ public interface AutoTransferHandler { this.integers = integers; this.color = color; } - + @Override public int getColor() { return color; } - + @Override public boolean isSuccessful() { return successful; } - + @Override public boolean isApplicable() { return applicable; } - + @Override public String getErrorKey() { return errorKey; } - + @Override public IntList getIntegers() { return integers; } } - - public final class ContextImpl implements Context { + + final class ContextImpl implements Context { boolean actuallyCrafting; AbstractContainerScreen<?> containerScreen; Supplier<RecipeDisplay> recipeDisplaySupplier; - + private ContextImpl(boolean actuallyCrafting, AbstractContainerScreen<?> containerScreen, Supplier<RecipeDisplay> recipeDisplaySupplier) { this.actuallyCrafting = actuallyCrafting; this.containerScreen = containerScreen; this.recipeDisplaySupplier = recipeDisplaySupplier; } - + @Override public boolean isActuallyCrafting() { return actuallyCrafting; } - + @Override public AbstractContainerScreen<?> getContainerScreen() { return containerScreen; } - + @Override public RecipeDisplay getRecipe() { return recipeDisplaySupplier.get(); } } - + } diff --git a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java index 0a4011f2d..84b8574a6 100644 --- a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java +++ b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java @@ -26,16 +26,16 @@ public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler<Sc default List<Rectangle> getCurrentExclusionZones(Class<?> currentScreenClass, boolean isOnRightSide) { return getExclusionZones(currentScreenClass, false); } - + @Deprecated default List<Rectangle> getCurrentExclusionZones(Class<?> currentScreenClass, boolean isOnRightSide, boolean sort) { return getExclusionZones(currentScreenClass, sort); } - + List<Rectangle> getExclusionZones(Class<?> currentScreenClass, boolean sort); - + int supplierSize(); - + /** * Register an exclusion zone * @@ -51,7 +51,7 @@ public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler<Sc return zones; }); } - + void registerExclusionZones(Class<?> screenClass, Supplier<List<Rectangle>> supplier); - + } diff --git a/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java b/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java index b3af06c01..8ec5f3527 100644 --- a/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java +++ b/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java @@ -8,7 +8,7 @@ package me.shedaniel.rei.api; import me.shedaniel.math.api.Rectangle; public interface ButtonAreaSupplier { - + /** * Declares the button bounds * @@ -16,7 +16,7 @@ public interface ButtonAreaSupplier { * @return the bounds of the button */ Rectangle get(Rectangle bounds); - + /** * Declares the button text * @@ -25,5 +25,5 @@ public interface ButtonAreaSupplier { default String getButtonText() { return "+"; } - + } diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java index 6e33eba30..08ab4fcab 100644 --- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -22,14 +22,14 @@ public interface ClientHelper { static ClientHelper getInstance() { return ClientHelperImpl.instance; } - + /** * Checks if cheating is enabled * * @return whether cheating is enabled */ boolean isCheating(); - + /** * Sets current cheating mode * Should save the config in {@link ConfigManager}. @@ -37,9 +37,9 @@ public interface ClientHelper { * @param cheating the new cheating mode */ void setCheating(boolean cheating); - + List<ItemStack> getInventoryItemsTypes(); - + /** * Opens a recipe viewing screen: * Opens {@link me.shedaniel.rei.gui.PreRecipeViewingScreen} if not set @@ -49,12 +49,12 @@ public interface ClientHelper { * @param map the map of recipes */ void openRecipeViewingScreen(Map<RecipeCategory<?>, List<RecipeDisplay>> map); - + /** * Registers REI's keybinds using Fabric API. */ void registerFabricKeyBinds(); - + /** * Tries to cheat stack using either packets or commands. * @@ -62,11 +62,11 @@ public interface ClientHelper { * @return whether it failed */ boolean tryCheatingEntry(EntryStack stack); - + default boolean tryCheatingStack(ItemStack stack) { return tryCheatingEntry(EntryStack.create(stack)); } - + /** * Finds recipe for the stack and opens the recipe screen. * @@ -74,11 +74,11 @@ public interface ClientHelper { * @return whether the stack has any recipes to show */ boolean executeRecipeKeyBind(EntryStack stack); - + default boolean executeRecipeKeyBind(ItemStack stack) { return executeRecipeKeyBind(EntryStack.create(stack)); } - + /** * Finds usage for the stack and opens the recipe screen. * @@ -86,15 +86,11 @@ public interface ClientHelper { * @return whether the stack has any usages to show */ boolean executeUsageKeyBind(EntryStack stack); - + default boolean executeUsageKeyBind(ItemStack stack) { return executeUsageKeyBind(EntryStack.create(stack)); } - - FabricKeyBinding getFocusSearchFieldKeyBinding(); - - FabricKeyBinding getCopyRecipeIdentifierKeyBinding(); - + /** * Gets the mod from an item * @@ -102,12 +98,12 @@ public interface ClientHelper { * @return the mod name */ String getModFromItem(Item item); - + /** * Tries to delete the player's cursor item */ void sendDeletePacket(); - + /** * Gets the formatted mod from an item * @@ -115,7 +111,7 @@ public interface ClientHelper { * @return the mod name with blue and italic formatting */ String getFormattedModFromItem(Item item); - + /** * Gets the formatted mod from an identifier * @@ -123,7 +119,7 @@ public interface ClientHelper { * @return the mod name with blue and italic formatting */ String getFormattedModFromIdentifier(Identifier identifier); - + /** * Gets the mod from an identifier * @@ -131,42 +127,15 @@ public interface ClientHelper { * @return the mod name */ String getModFromIdentifier(Identifier identifier); - - FabricKeyBinding[] getREIKeyBindings(); - - /** - * @return the recipe keybind, defaulted R - */ - FabricKeyBinding getRecipeKeyBinding(); - - /** - * @return the usage keybind, defaulted U - */ - FabricKeyBinding getUsageKeyBinding(); - - /** - * @return the hide keybind, defaulted O - */ - FabricKeyBinding getHideKeyBinding(); - - /** - * @return the previous page keybind, defaulted not set - */ - FabricKeyBinding getPreviousPageKeyBinding(); - - /** - * @return the next page keybind, defaulted not set - */ - FabricKeyBinding getNextPageKeyBinding(); - + /** * Finds all recipes and open them in a recipe screen. * * @return whether there are any recipes to show */ boolean executeViewAllRecipesKeyBind(); - + boolean executeViewAllRecipesFromCategory(Identifier category); - + boolean executeViewAllRecipesFromCategories(List<Identifier> categories); } diff --git a/src/main/java/me/shedaniel/rei/api/ConfigManager.java b/src/main/java/me/shedaniel/rei/api/ConfigManager.java index 26b5bf218..ca11825ba 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigManager.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigManager.java @@ -11,19 +11,19 @@ import net.minecraft.client.gui.screen.Screen; import java.util.List; public interface ConfigManager { - + @SuppressWarnings("deprecation") static ConfigManager getInstance() { return RoughlyEnoughItemsCore.getConfigManager(); } - + List<EntryStack> getFavorites(); - + /** * Saves the config. */ void saveConfig(); - + /** * Gets the config instance * @@ -32,26 +32,26 @@ public interface ConfigManager { */ @Deprecated ConfigObject getConfig(); - + /** * Gets if craftable only filter is enabled * * @return whether craftable only filter is enabled */ boolean isCraftableOnlyEnabled(); - + /** * Toggles the craftable only filter */ void toggleCraftableOnly(); - + /** * Opens the config screen * * @param parent the screen shown before */ void openConfigScreen(Screen parent); - + /** * Gets the config screen * @@ -59,5 +59,5 @@ public interface ConfigManager { * @return the config screen */ Screen getConfigScreen(Screen parent); - + } diff --git a/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/src/main/java/me/shedaniel/rei/api/ConfigObject.java index ac807ec03..ca3adc5a2 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigObject.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigObject.java @@ -5,10 +5,12 @@ package me.shedaniel.rei.api; +import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.rei.gui.config.ItemCheatingMode; import me.shedaniel.rei.gui.config.ItemListOrdering; import me.shedaniel.rei.gui.config.RecipeScreenType; import me.shedaniel.rei.gui.config.SearchFieldLocation; +import me.shedaniel.rei.impl.ConfigObjectImpl; import net.minecraft.client.util.InputUtil; import java.lang.annotation.ElementType; @@ -17,108 +19,137 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; public interface ConfigObject { - + @SuppressWarnings("deprecation") static ConfigObject getInstance() { return ConfigManager.getInstance().getConfig(); } - + boolean isLighterButtonHover(); - + void setLighterButtonHover(boolean lighterButtonHover); - + boolean isOverlayVisible(); - + void setOverlayVisible(boolean overlayVisible); - + boolean isCheating(); - + void setCheating(boolean cheating); - + ItemListOrdering getItemListOrdering(); - + boolean isItemListAscending(); - + boolean isUsingDarkTheme(); - + boolean isToastDisplayedOnCopyIdentifier(); - + @Deprecated default boolean doesRenderEntryExtraOverlay() { return doesRenderEntryEnchantmentGlint(); } - + boolean doesRenderEntryEnchantmentGlint(); - + boolean isEntryListWidgetScrolled(); - + boolean shouldAppendModNames(); - + RecipeScreenType getRecipeScreenType(); - + void setRecipeScreenType(RecipeScreenType recipeScreenType); - + boolean isLoadingDefaultPlugin(); - + SearchFieldLocation getSearchFieldLocation(); - + boolean isLeftHandSidePanel(); - + boolean isCraftableFilterEnabled(); - + String getGamemodeCommand(); - + String getGiveCommand(); - + String getWeatherCommand(); - + int getMaxRecipePerPage(); - + boolean doesShowUtilsButtons(); - + boolean doesDisableRecipeBook(); - + boolean doesFixTabCloseContainer(); - + boolean areClickableRecipeArrowsEnabled(); - + ItemCheatingMode getItemCheatingMode(); - + boolean isUsingLightGrayRecipeBorder(); - + boolean doesVillagerScreenHavePermanentScrollBar(); - + boolean doesRegisterRecipesInAnotherThread(); - + boolean doesSnapToRows(); - + boolean isFavoritesEnabled(); - + boolean doDisplayFavoritesTooltip(); - + boolean doDisplayFavoritesOnTheLeft(); - + boolean doesFastEntryRendering(); - + boolean doDebugRenderTimeRequired(); - + boolean doSearchFavorites(); - - InputUtil.KeyCode getFavoriteKeybind(); - + + @Deprecated + default InputUtil.KeyCode getFavoriteKeybind() { + return getFavoriteKeyCode().getKeyCode(); + } + + ModifierKeyCode getFavoriteKeyCode(); + + ModifierKeyCode getRecipeKeybind(); + + ModifierKeyCode getUsageKeybind(); + + ModifierKeyCode getHideKeybind(); + + ModifierKeyCode getPreviousPageKeybind(); + + ModifierKeyCode getNextPageKeybind(); + + ModifierKeyCode getFocusSearchFieldKeybind(); + + ModifierKeyCode getCopyRecipeIdentifierKeybind(); + + double getEntrySize(); + + @Deprecated + abstract ConfigObjectImpl.General getGeneral(); + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) - public @interface AddInFrontKeyCode { - } - + @interface AddInFrontKeyCode {} + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) - public @interface DontApplyFieldName { - } - + @interface DontApplyFieldName {} + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) - public @interface UseEnumSelectorInstead { + @interface UseEnumSelectorInstead {} + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.FIELD}) + @interface UsePercentage { + double min(); + + double max(); } - + } diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index 25c04295d..4314b0e7c 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -11,16 +11,17 @@ import me.shedaniel.rei.gui.config.SearchFieldLocation; import net.minecraft.util.ActionResult; import java.util.List; +import java.util.function.Supplier; import static net.minecraft.util.ActionResult.PASS; public interface DisplayHelper { - + @SuppressWarnings("deprecation") static DisplayHelper getInstance() { return RoughlyEnoughItemsCore.getDisplayHelper(); } - + /** * Gets the sorted version of all responsible bounds handlers * @@ -29,14 +30,14 @@ public interface DisplayHelper { * @see DisplayHelper#getResponsibleBoundsHandler(Class) for the unsorted version */ List<DisplayBoundsHandler<?>> getSortedBoundsHandlers(Class<?> screenClass); - + /** * Gets all registered bounds handlers * * @return the list of registered bounds handlers */ List<DisplayBoundsHandler<?>> getAllBoundsHandlers(); - + /** * Gets all responsible bounds handlers * @@ -45,29 +46,29 @@ public interface DisplayHelper { * @see DisplayHelper#getSortedBoundsHandlers(Class) for the sorted version */ DisplayBoundsHandler<?> getResponsibleBoundsHandler(Class<?> screenClass); - + /** * Registers a bounds handler * * @param handler the handler to register */ void registerBoundsHandler(DisplayBoundsHandler<?> handler); - + /** * Gets the base bounds handler api for exclusion zones * * @return the base bounds handler */ BaseBoundsHandler getBaseBoundsHandler(); - - public static interface DisplayBoundsHandler<T> { + + interface DisplayBoundsHandler<T> { /** * Gets the base supported class for the bounds handler * * @return the base class */ Class<?> getBaseSupportedClass(); - + /** * Gets the left bounds of the overlay * @@ -75,7 +76,7 @@ public interface DisplayHelper { * @return the left bounds */ Rectangle getLeftBounds(T screen); - + /** * Gets the right bounds of the overlay * @@ -83,7 +84,7 @@ public interface DisplayHelper { * @return the right bounds */ Rectangle getRightBounds(T screen); - + /** * Checks if item slot can fit the screen * @@ -92,12 +93,12 @@ public interface DisplayHelper { * @param screen the current screen * @param fullBounds the current bounds * @return whether the item slot can fit - * @see BaseBoundsHandler#registerExclusionZones(Class, BaseBoundsHandler.ExclusionZoneSupplier) for easier api + * @see BaseBoundsHandler#registerExclusionZones(Class, Supplier) for easier api */ default ActionResult canItemSlotWidgetFit(int left, int top, T screen, Rectangle fullBounds) { return PASS; } - + /** * Checks if item slot can fit the screen * @@ -113,7 +114,7 @@ public interface DisplayHelper { default ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, T screen, Rectangle fullBounds) { return canItemSlotWidgetFit(left, top, screen, fullBounds); } - + /** * Checks if mouse is inside the overlay * @@ -127,7 +128,7 @@ public interface DisplayHelper { default ActionResult isInZone(boolean isOnRightSide, double mouseX, double mouseY) { return isInZone(mouseX, mouseY); } - + /** * Checks if mouse is inside the overlay * @@ -138,7 +139,7 @@ public interface DisplayHelper { default ActionResult isInZone(double mouseX, double mouseY) { return PASS; } - + /** * Gets the item list bounds by the overlay bounds * @@ -148,12 +149,12 @@ public interface DisplayHelper { default Rectangle getItemListArea(Rectangle rectangle) { return new Rectangle(rectangle.x + 1, rectangle.y + 2 + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + (ConfigObject.getInstance().isEntryListWidgetScrolled() ? 0 : 22), rectangle.width - 2, rectangle.height - (ConfigObject.getInstance().getSearchFieldLocation() != SearchFieldLocation.CENTER ? 27 + 22 : 27) + (!ConfigObject.getInstance().isEntryListWidgetScrolled() ? 0 : 22)); } - + default Rectangle getFavoritesListArea(Rectangle rectangle) { int offset = 31 + (ConfigObject.getInstance().doesShowUtilsButtons() ? 25 : 0); return new Rectangle(rectangle.x + 1, rectangle.y + 2 + offset, rectangle.width - 2, rectangle.height - 5 - offset); } - + /** * Checks if REI should recalculate the overlay bounds * @@ -164,7 +165,7 @@ public interface DisplayHelper { default boolean shouldRecalculateArea(boolean isOnRightSide, Rectangle rectangle) { return false; } - + /** * Gets the priority of the handler, the higher it is, the earlier it is called. * @@ -174,5 +175,5 @@ public interface DisplayHelper { return 0f; } } - + } diff --git a/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java b/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java index 388929cda..5e6cde696 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java @@ -8,7 +8,7 @@ package me.shedaniel.rei.api; import net.minecraft.util.ActionResult; public interface DisplayVisibilityHandler { - + /** * Gets the priority of the handler * @@ -17,7 +17,7 @@ public interface DisplayVisibilityHandler { default float getPriority() { return 0f; } - + |
