From 357388d49c306a288f2c56cb6f25589237f7284e Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 12 May 2019 01:32:04 +0800 Subject: Small documentations --- .../me/shedaniel/rei/api/ButtonAreaSupplier.java | 11 ++++ .../java/me/shedaniel/rei/api/ClientHelper.java | 77 ++++++++++++++++++++++ .../java/me/shedaniel/rei/api/ConfigManager.java | 34 ++++++++++ .../java/me/shedaniel/rei/api/DisplaySettings.java | 22 +++++++ .../rei/api/DisplayVisibilityHandler.java | 16 +++++ src/main/java/me/shedaniel/rei/api/REIPlugin.java | 5 ++ .../java/me/shedaniel/rei/api/REIPluginEntry.java | 49 ++++++++++++++ 7 files changed, 214 insertions(+) (limited to 'src/main/java/me/shedaniel/rei/api') diff --git a/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java b/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java index 07125643c..f7bd8517e 100644 --- a/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java +++ b/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java @@ -4,8 +4,19 @@ import java.awt.*; public interface ButtonAreaSupplier { + /** + * Declares the button bounds + * + * @param bounds the bounds of the recipe display + * @return the bounds of the button + */ Rectangle get(Rectangle bounds); + /** + * Declares the button text + * + * @return the text of the button + */ 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 d4648bbaa..225d2384f 100644 --- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -11,34 +11,106 @@ import java.util.List; import java.util.Map; public interface ClientHelper extends ClientModInitializer { + /** + * @return the api instance of {@link ClientHelperImpl} + */ 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}. + * + * @param cheating the new cheating mode + */ void setCheating(boolean cheating); List getInventoryItemsTypes(); + /** + * Opens a recipe viewing screen: + * {@link me.shedaniel.rei.gui.PreRecipeViewingScreen} if not set + * {@link me.shedaniel.rei.gui.RecipeViewingScreen} if set to default + * {@link me.shedaniel.rei.gui.VillagerRecipeViewingScreen} if set to villager + * + * @param map the map of recipes + */ void openRecipeViewingScreen(Map> map); + /** + * Registers REI's keybinds using Fabric API. + */ void registerFabricKeyBinds(); + /** + * Tries to cheat items using either packets or commands. + * + * @param stack the stack to cheat in + * @return whether it failed + */ boolean tryCheatingStack(ItemStack stack); + /** + * Finds recipe for the item and opens the recipe screen. + * + * @param stack the stack to find recipe for + * @return whether the stack has any recipes to show + */ boolean executeRecipeKeyBind(ItemStack stack); + /** + * Finds usage for the item and opens the recipe screen. + * + * @param stack the stack to find usage for + * @return whether the stack has any usages to show + */ boolean executeUsageKeyBind(ItemStack stack); + /** + * Gets the mod from an item + * + * @param item + * @return the mod name + */ String getModFromItem(Item item); + /** + * Tries to delete the player's cursor item + * + * @return whether it failed + */ void sendDeletePacket(); + /** + * Gets the formatted mod from an item + * + * @param item + * @return the mod name with blue and italic formatting + */ String getFormattedModFromItem(Item item); + /** + * Gets the formatted mod from an identifier + * + * @param identifier + * @return the mod name with blue and italic formatting + */ String getFormattedModFromIdentifier(Identifier identifier); + /** + * Gets the mod from an identifier + * + * @param identifier + * @return the mod name + */ String getModFromIdentifier(Identifier identifier); FabricKeyBinding getRecipeKeyBinding(); @@ -51,5 +123,10 @@ public interface ClientHelper extends ClientModInitializer { FabricKeyBinding getNextPageKeyBinding(); + /** + * Finds all recipes and open them in a recipe screen. + * + * @return whether there are any recipes to show + */ boolean executeViewAllRecipesKeyBind(); } diff --git a/src/main/java/me/shedaniel/rei/api/ConfigManager.java b/src/main/java/me/shedaniel/rei/api/ConfigManager.java index d23429142..536d61c60 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigManager.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigManager.java @@ -7,18 +7,52 @@ import java.io.IOException; public interface ConfigManager { + /** + * Saves the config. + * + * @throws IOException + */ void saveConfig() throws IOException; + /** + * Loads the config from the json file, creates the file if not found. + * + * @throws IOException + */ void loadConfig() throws IOException; + /** + * Gets the config instance + * + * @return the config instance + */ 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 + * + * @param parent the screen shown before + * @return the config screen + */ Screen getConfigScreen(Screen parent); } diff --git a/src/main/java/me/shedaniel/rei/api/DisplaySettings.java b/src/main/java/me/shedaniel/rei/api/DisplaySettings.java index 334d6cc6f..ad9468bd2 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplaySettings.java +++ b/src/main/java/me/shedaniel/rei/api/DisplaySettings.java @@ -2,12 +2,34 @@ package me.shedaniel.rei.api; public interface DisplaySettings { + /** + * Gets the recipe display height + * + * @param category the category of the display + * @return the height + */ int getDisplayHeight(RecipeCategory category); + /** + * Gets the recipe display width + * + * @param category the category of the display + * @param display the display of the recipe + * @return the width + */ int getDisplayWidth(RecipeCategory category, T display); + /** + * Gets the maximum amount of recipe displays of the category displayed at the same time. + * @param category the category of the displays + * @return the maximum amount + */ int getMaximumRecipePerPage(RecipeCategory category); + /** + * Gets the fixed amount of recipes per page. + * @return the amount of recipes, returns -1 if not fixed + */ default int getFixedRecipesPerPage() { return -1; } diff --git a/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java b/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java index 813cfaad6..435d91d49 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java @@ -2,10 +2,26 @@ package me.shedaniel.rei.api; public interface DisplayVisibilityHandler { + /** + * Gets the priority of the handler + * + * @return the priority + */ default float getPriority() { return 0f; } + /** + * Handles the visibility of the display. + * {@link DisplayVisibility.PASS} to pass the handling to another handler + * {@link DisplayVisibility.ALWAYS_VISIBLE} to always display it + * {@link DisplayVisibility.CONFIG_OPTIONAL} to allow user to configure the visibility + * {@link DisplayVisibility.NEVER_VISIBLE} to never display it + * + * @param category the category of the display + * @param display the display of the recipe + * @return the visibility + */ DisplayVisibility handleDisplay(RecipeCategory category, RecipeDisplay display); } diff --git a/src/main/java/me/shedaniel/rei/api/REIPlugin.java b/src/main/java/me/shedaniel/rei/api/REIPlugin.java index 121a57496..6351a7d1d 100644 --- a/src/main/java/me/shedaniel/rei/api/REIPlugin.java +++ b/src/main/java/me/shedaniel/rei/api/REIPlugin.java @@ -3,6 +3,11 @@ package me.shedaniel.rei.api; import me.shedaniel.rei.RoughlyEnoughItemsCore; import net.minecraft.util.Identifier; +/** + * Get base class of a REI plugin. + * This class has been replaced by {@link REIPluginEntry} + */ +@Deprecated public interface REIPlugin extends REIPluginEntry { @Override default Identifier getPluginIdentifier() { diff --git a/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java b/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java index 786e129a0..8e3063f14 100644 --- a/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java +++ b/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java @@ -2,27 +2,76 @@ package me.shedaniel.rei.api; import net.minecraft.util.Identifier; +/** + * Get base class of a REI plugin. + */ public interface REIPluginEntry { + /** + * On register of the plugin + * + * @param pluginDisabler the helper class to disable other plugins + */ default void onFirstLoad(PluginDisabler pluginDisabler) {} + /** + * Registers items on the item panel + * + * @param itemRegistry the helper class + */ default void registerItems(ItemRegistry itemRegistry) {} + /** + * Registers categories + * + * @param recipeHelper the helper class + */ default void registerPluginCategories(RecipeHelper recipeHelper) {} + /** + * Registers displays for categories + * + * @param recipeHelper the helper class + */ default void registerRecipeDisplays(RecipeHelper recipeHelper) {} + /** + * Not called anymore! + * + * @param recipeHelper + * @see REIPluginEntry#registerOthers(RecipeHelper) + */ @Deprecated default void registerSpeedCraft(RecipeHelper recipeHelper) {} + /** + * Registers bounds handlers + * + * @param displayHelper the helper class + */ default void registerBounds(DisplayHelper displayHelper) {} + /** + * Register other stuff + * + * @param recipeHelper the helper class + */ default void registerOthers(RecipeHelper recipeHelper) {} + /** + * Gets the priority of the plugin. + * + * @return the priority + */ default int getPriority() { return 0; } + /** + * Get the identifier of the plugin + * + * @return the identifier + */ Identifier getPluginIdentifier(); } -- cgit From 7e1e39d8453b0a5b5c7c1045fc5e6bb428b840d8 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 12 May 2019 01:34:33 +0800 Subject: License Heading --- src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java | 5 +++++ src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java | 5 +++++ src/main/java/me/shedaniel/rei/api/ClientHelper.java | 5 +++++ src/main/java/me/shedaniel/rei/api/ConfigManager.java | 5 +++++ src/main/java/me/shedaniel/rei/api/DisplayHelper.java | 5 +++++ src/main/java/me/shedaniel/rei/api/DisplaySettings.java | 5 +++++ src/main/java/me/shedaniel/rei/api/DisplayVisibility.java | 5 +++++ src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java | 5 +++++ src/main/java/me/shedaniel/rei/api/ItemCheatingMode.java | 5 +++++ src/main/java/me/shedaniel/rei/api/ItemRegistry.java | 5 +++++ src/main/java/me/shedaniel/rei/api/PluginDisabler.java | 5 +++++ src/main/java/me/shedaniel/rei/api/PluginFunction.java | 5 +++++ src/main/java/me/shedaniel/rei/api/REIPlugin.java | 5 +++++ src/main/java/me/shedaniel/rei/api/REIPluginEntry.java | 5 +++++ src/main/java/me/shedaniel/rei/api/RecipeCategory.java | 5 +++++ src/main/java/me/shedaniel/rei/api/RecipeDisplay.java | 5 +++++ src/main/java/me/shedaniel/rei/api/RecipeHelper.java | 5 +++++ src/main/java/me/shedaniel/rei/api/RelativePoint.java | 5 +++++ src/main/java/me/shedaniel/rei/api/Renderable.java | 5 +++++ src/main/java/me/shedaniel/rei/api/Renderer.java | 5 +++++ src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java | 5 +++++ 21 files changed, 105 insertions(+) (limited to 'src/main/java/me/shedaniel/rei/api') diff --git a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java index 83cf9163c..f363dccac 100644 --- a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java +++ b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import net.minecraft.client.gui.Screen; diff --git a/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java b/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java index f7bd8517e..01cdff416 100644 --- a/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java +++ b/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import java.awt.*; diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java index 225d2384f..a6531d08b 100644 --- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import me.shedaniel.rei.client.ClientHelperImpl; diff --git a/src/main/java/me/shedaniel/rei/api/ConfigManager.java b/src/main/java/me/shedaniel/rei/api/ConfigManager.java index 536d61c60..00ebd2e46 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigManager.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigManager.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import me.shedaniel.rei.client.ConfigObject; diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index 8234c20b3..37d2db76c 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import me.shedaniel.rei.RoughlyEnoughItemsCore; diff --git a/src/main/java/me/shedaniel/rei/api/DisplaySettings.java b/src/main/java/me/shedaniel/rei/api/DisplaySettings.java index ad9468bd2..ddf1f3a75 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplaySettings.java +++ b/src/main/java/me/shedaniel/rei/api/DisplaySettings.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; public interface DisplaySettings { diff --git a/src/main/java/me/shedaniel/rei/api/DisplayVisibility.java b/src/main/java/me/shedaniel/rei/api/DisplayVisibility.java index 8195d88a0..8f1149e26 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayVisibility.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayVisibility.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; public enum DisplayVisibility { diff --git a/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java b/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java index 435d91d49..39a106783 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; public interface DisplayVisibilityHandler { diff --git a/src/main/java/me/shedaniel/rei/api/ItemCheatingMode.java b/src/main/java/me/shedaniel/rei/api/ItemCheatingMode.java index 41d5e5ead..56c97027e 100644 --- a/src/main/java/me/shedaniel/rei/api/ItemCheatingMode.java +++ b/src/main/java/me/shedaniel/rei/api/ItemCheatingMode.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; public enum ItemCheatingMode { diff --git a/src/main/java/me/shedaniel/rei/api/ItemRegistry.java b/src/main/java/me/shedaniel/rei/api/ItemRegistry.java index 1b3b0218b..6d8b39d24 100644 --- a/src/main/java/me/shedaniel/rei/api/ItemRegistry.java +++ b/src/main/java/me/shedaniel/rei/api/ItemRegistry.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import net.minecraft.item.Item; diff --git a/src/main/java/me/shedaniel/rei/api/PluginDisabler.java b/src/main/java/me/shedaniel/rei/api/PluginDisabler.java index 0c9ec9eb2..cd3b61578 100644 --- a/src/main/java/me/shedaniel/rei/api/PluginDisabler.java +++ b/src/main/java/me/shedaniel/rei/api/PluginDisabler.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import net.minecraft.util.Identifier; diff --git a/src/main/java/me/shedaniel/rei/api/PluginFunction.java b/src/main/java/me/shedaniel/rei/api/PluginFunction.java index 67e460a70..30844767f 100644 --- a/src/main/java/me/shedaniel/rei/api/PluginFunction.java +++ b/src/main/java/me/shedaniel/rei/api/PluginFunction.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; public enum PluginFunction { diff --git a/src/main/java/me/shedaniel/rei/api/REIPlugin.java b/src/main/java/me/shedaniel/rei/api/REIPlugin.java index 6351a7d1d..372c9e23f 100644 --- a/src/main/java/me/shedaniel/rei/api/REIPlugin.java +++ b/src/main/java/me/shedaniel/rei/api/REIPlugin.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import me.shedaniel.rei.RoughlyEnoughItemsCore; diff --git a/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java b/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java index 8e3063f14..615c53fd9 100644 --- a/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java +++ b/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import net.minecraft.util.Identifier; diff --git a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java index 8304fde90..f62cebbda 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import me.shedaniel.rei.gui.RecipeViewingScreen; diff --git a/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java b/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java index 109562aa2..4fb564133 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import com.google.common.collect.Lists; diff --git a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java index 4b0fde018..e5e89cdd0 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import me.shedaniel.rei.RoughlyEnoughItemsCore; diff --git a/src/main/java/me/shedaniel/rei/api/RelativePoint.java b/src/main/java/me/shedaniel/rei/api/RelativePoint.java index 23339c96e..0d54e866e 100644 --- a/src/main/java/me/shedaniel/rei/api/RelativePoint.java +++ b/src/main/java/me/shedaniel/rei/api/RelativePoint.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; public class RelativePoint { diff --git a/src/main/java/me/shedaniel/rei/api/Renderable.java b/src/main/java/me/shedaniel/rei/api/Renderable.java index 9059af798..f76a2fdb1 100644 --- a/src/main/java/me/shedaniel/rei/api/Renderable.java +++ b/src/main/java/me/shedaniel/rei/api/Renderable.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import me.shedaniel.rei.gui.renderables.EmptyRenderer; diff --git a/src/main/java/me/shedaniel/rei/api/Renderer.java b/src/main/java/me/shedaniel/rei/api/Renderer.java index 569285d84..c94fd2631 100644 --- a/src/main/java/me/shedaniel/rei/api/Renderer.java +++ b/src/main/java/me/shedaniel/rei/api/Renderer.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import net.minecraft.client.gui.DrawableHelper; diff --git a/src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java b/src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java index fc4ffde35..cec75d282 100644 --- a/src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java +++ b/src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java @@ -1,3 +1,8 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + package me.shedaniel.rei.api; import net.minecraft.client.gui.Screen; -- cgit From eab120d5619f972e29afc9776959f6d6096d3926 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 12 May 2019 10:36:42 +0800 Subject: More docs --- .../java/me/shedaniel/rei/api/DisplayHelper.java | 86 ++++++++++++++++++++++ .../java/me/shedaniel/rei/api/ItemRegistry.java | 23 ++++++ .../java/me/shedaniel/rei/api/RecipeCategory.java | 76 ++++++++++++++++++- .../java/me/shedaniel/rei/api/RecipeHelper.java | 23 ++++++ src/main/java/me/shedaniel/rei/api/Renderable.java | 3 + 5 files changed, 210 insertions(+), 1 deletion(-) (limited to 'src/main/java/me/shedaniel/rei/api') diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index 37d2db76c..51e54302c 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -15,41 +15,127 @@ import static net.minecraft.util.ActionResult.PASS; public interface DisplayHelper { + /** + * Gets the sorted version of all responsible bounds handlers + * + * @param screenClass the class for checking responsible bounds handlers + * @return the sorted list of responsible bounds handlers + * @see DisplayHelper#getResponsibleBoundsHandler(Class) for the unsorted version + */ List getSortedBoundsHandlers(Class screenClass); + /** + * Gets all registered bounds handlers + * + * @return the list of registered bounds handlers + */ List getAllBoundsHandlers(); + /** + * Gets all responsible bounds handlers + * + * @param screenClass the class for checking responsible bounds handlers + * @return the the list of responsible bounds handlers + * @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 { + /** + * An empty rectangle + */ public static final Rectangle EMPTY = new Rectangle(); + /** + * Gets the base supported class for the bounds handler + * + * @return + */ Class getBaseSupportedClass(); + /** + * Gets the left bounds of the overlay + * + * @param screen the current screen + * @return the left bounds + */ Rectangle getLeftBounds(T screen); + /** + * Gets the right bounds of the overlay + * + * @param screen the current screen + * @return the right bounds + */ Rectangle getRightBounds(T screen); + /** + * Checks if item slot can fit the screen + * + * @param isOnRightSide whether the user has set the overlay to the right + * @param left the left x coordinates of the stack + * @param top the top y coordinates for the stack + * @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 + */ default ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, T screen, Rectangle fullBounds) { return PASS; } + /** + * Checks if mouse is inside the overlay + * + * @param isOnRightSide whether the user has set the overlay to the right + * @param mouseX mouse's x coordinates + * @param mouseY mouse's y coordinates + * @return whether mouse is inside the overlay + */ default ActionResult isInZone(boolean isOnRightSide, double mouseX, double mouseY) { return PASS; } + /** + * Gets the item list bounds by the overlay bounds + * + * @param rectangle the overlay bounds + * @return the item list bounds + */ default Rectangle getItemListArea(Rectangle rectangle) { return new Rectangle(rectangle.x + 2, rectangle.y + 24, rectangle.width - 4, rectangle.height - (RoughlyEnoughItemsCore.getConfigManager().getConfig().sideSearchField ? 27 + 22 : 27)); } + /** + * Checks if REI should recalculate the overlay bounds + * + * @param isOnRightSide whether the user has set the overlay to the right + * @param rectangle the current overlay bounds + * @return whether REI should recalculate the overlay bounds + */ default boolean shouldRecalculateArea(boolean isOnRightSide, Rectangle rectangle) { return false; } + /** + * Gets the priority of the handler, the higher it is, the earlier it is called. + * + * @return the priority in float + */ default float getPriority() { return 0f; } diff --git a/src/main/java/me/shedaniel/rei/api/ItemRegistry.java b/src/main/java/me/shedaniel/rei/api/ItemRegistry.java index 6d8b39d24..8751da416 100644 --- a/src/main/java/me/shedaniel/rei/api/ItemRegistry.java +++ b/src/main/java/me/shedaniel/rei/api/ItemRegistry.java @@ -12,12 +12,29 @@ import java.util.List; public interface ItemRegistry { + /** + * Gets the current unmodifiable item list + * + * @return an unmodifiable item list + */ List getItemList(); + /** + * Gets the current modifiable item list + * + * @return an modifiable item list + */ + @Deprecated List getModifiableItemList(); ItemStack[] getAllStacksFromItem(Item item); + /** + * Registers an new stack to the item list + * + * @param afterItem + * @param stack the stack to register + */ void registerItemStack(Item afterItem, ItemStack stack); default void registerItemStack(Item afterItem, ItemStack... stacks) { @@ -32,6 +49,12 @@ public interface ItemRegistry { registerItemStack(null, stack); } + /** + * Checks if a stack is already registered + * + * @param stack the stack to check + * @return whether the stack has been registered + */ default boolean alreadyContain(ItemStack stack) { return getItemList().stream().anyMatch(stack1 -> ItemStack.areEqual(stack, stack1)); } diff --git a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java index f62cebbda..6993b45c4 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java @@ -22,30 +22,80 @@ import java.util.function.Supplier; public interface RecipeCategory { + /** + * Gets the identifier of the category, must be unique + * + * @return the unique identifier of the category + */ Identifier getIdentifier(); - ItemStack getCategoryIcon(); + /** + * Gets the stack to render for the icon + * + * @return the stack to render + * @deprecated use {@link RecipeCategory#getIcon()} instead + */ + @Deprecated + default ItemStack getCategoryIcon() { + return ItemStack.EMPTY; + } + /** + * Gets the renderer of the icon, allowing developers to render things other than items + * + * @return the renderer of the icon + */ default Renderer getIcon() { return Renderable.fromItemStackSupplier(this::getCategoryIcon); } + /** + * Gets the category name + * + * @return the name + */ String getCategoryName(); + /** + * Gets the recipe renderer for the category, used in {@link me.shedaniel.rei.gui.VillagerRecipeViewingScreen} for rendering simple recipes + * + * @param recipe the recipe to render + * @return the recipe renderer + */ default RecipeRenderer getSimpleRenderer(T recipe) { return Renderable.fromRecipe(recipe::getInput, recipe::getOutput); } + /** + * Setup the widgets for displaying the recipe + * + * @param recipeDisplaySupplier the supplier for getting the recipe + * @param bounds the bounds of the display, configurable with overriding {@link RecipeCategory#getDisplaySettings()} + * @return the list of widgets + */ default List setupDisplay(Supplier recipeDisplaySupplier, Rectangle bounds) { return Collections.singletonList(new RecipeBaseWidget(bounds)); } + /** + * Draws the category background, used in {@link RecipeViewingScreen} + * + * @param bounds the bounds of the whole recipe viewing screen + * @param mouseX the x coordinates for the mouse + * @param mouseY the y coordinates for the mouse + * @param delta the delta + */ default void drawCategoryBackground(Rectangle bounds, int mouseX, int mouseY, float delta) { new CategoryBaseWidget(bounds).render(); DrawableHelper.fill(bounds.x + 17, bounds.y + 5, bounds.x + bounds.width - 17, bounds.y + 17, RecipeViewingScreen.SUB_COLOR.getRGB()); DrawableHelper.fill(bounds.x + 17, bounds.y + 21, bounds.x + bounds.width - 17, bounds.y + 33, RecipeViewingScreen.SUB_COLOR.getRGB()); } + /** + * Gets the display settings for the category, used for getting the bounds for the display + * + * @return the display settings + */ default DisplaySettings getDisplaySettings() { return new DisplaySettings() { @Override @@ -65,18 +115,42 @@ public interface RecipeCategory { }; } + /** + * Gets the recipe display height + * + * @return the recipe display height + * @apiNote Please do not override this, use {@link RecipeCategory#getDisplaySettings()} instead + */ default int getDisplayHeight() { return RecipeHelper.getInstance().getCachedCategorySettings(getIdentifier()).map(settings -> settings.getDisplayHeight(this)).orElse(0); } + /** + * Gets the recipe display width + * + * @param display the recipe display + * @return the recipe display width + * @apiNote Please do not override this, use {@link RecipeCategory#getDisplaySettings()} instead + */ default int getDisplayWidth(T display) { return RecipeHelper.getInstance().getCachedCategorySettings(getIdentifier()).map(settings -> settings.getDisplayWidth(this, display)).orElse(0); } + /** + * Gets the maximum recipe per page + * + * @return the maximum amount of recipes for page + * @apiNote Please do not override this, use {@link RecipeCategory#getDisplaySettings()} instead + */ default int getMaximumRecipePerPage() { return RecipeHelper.getInstance().getCachedCategorySettings(getIdentifier()).map(settings -> settings.getMaximumRecipePerPage(this)).orElse(0); } + /** + * Gets whether the category will check tags, useful for potions + * + * @return whether the category will check tags + */ default boolean checkTags() { return false; } diff --git a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java index e5e89cdd0..58d67e97a 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java @@ -17,6 +17,9 @@ import java.util.Optional; public interface RecipeHelper { + /** + * @return the api instance of {@link me.shedaniel.rei.client.RecipeHelperImpl} + */ static RecipeHelper getInstance() { return RoughlyEnoughItemsCore.getRecipeHelper(); } @@ -27,14 +30,34 @@ public interface RecipeHelper { List findCraftableByItems(List inventoryItems); + /** + * Registers a category + * + * @param category the category to register + */ void registerCategory(RecipeCategory category); + /** + * Registers a recipe display + * + * @param categoryIdentifier the category to display in + * @param display the recipe display + */ void registerDisplay(Identifier categoryIdentifier, RecipeDisplay display); Map> getRecipesFor(ItemStack stack); + /** + * Gets the vanilla recipe manager + * + * @return the recipe manager + */ RecipeManager getRecipeManager(); + /** + * Gets all registered categories + * @return the list of categories + */ List getAllCategories(); Map> getUsagesFor(ItemStack stack); diff --git a/src/main/java/me/shedaniel/rei/api/Renderable.java b/src/main/java/me/shedaniel/rei/api/Renderable.java index f76a2fdb1..47b8f4beb 100644 --- a/src/main/java/me/shedaniel/rei/api/Renderable.java +++ b/src/main/java/me/shedaniel/rei/api/Renderable.java @@ -14,6 +14,9 @@ import net.minecraft.util.math.MathHelper; import java.util.List; import java.util.function.Supplier; +/** + * The base class for renderables + */ public interface Renderable { static ItemStackRenderer fromItemStackSupplier(Supplier supplier) { -- cgit From b99108611ea89dc0eda6c433447ce398a98ad4ad Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 12 May 2019 10:55:09 +0800 Subject: Build 109 --- src/main/java/me/shedaniel/rei/api/ClientHelper.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/api') diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java index a6531d08b..e0fbfbed3 100644 --- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -6,7 +6,6 @@ package me.shedaniel.rei.api; import me.shedaniel.rei.client.ClientHelperImpl; -import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -15,7 +14,7 @@ import net.minecraft.util.Identifier; import java.util.List; import java.util.Map; -public interface ClientHelper extends ClientModInitializer { +public interface ClientHelper { /** * @return the api instance of {@link ClientHelperImpl} */ -- cgit