aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/api
diff options
context:
space:
mode:
authorDaniel She <shekwancheung0528@gmail.com>2019-05-12 10:55:21 +0800
committerDaniel She <shekwancheung0528@gmail.com>2019-05-12 10:55:21 +0800
commitf51e5af85e26f588cbe2eba2eef728e783201bc8 (patch)
treee490afcfe8974af8a6c65954667bf822505224d4 /src/main/java/me/shedaniel/rei/api
parent64c240a5a5eb6b4312b86e24ddbaaa70ada49359 (diff)
parentb99108611ea89dc0eda6c433447ce398a98ad4ad (diff)
downloadRoughlyEnoughItems-f51e5af85e26f588cbe2eba2eef728e783201bc8.tar.gz
RoughlyEnoughItems-f51e5af85e26f588cbe2eba2eef728e783201bc8.tar.bz2
RoughlyEnoughItems-f51e5af85e26f588cbe2eba2eef728e783201bc8.zip
Merge branch '1.14-dev' into 1.14
Diffstat (limited to 'src/main/java/me/shedaniel/rei/api')
-rw-r--r--src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java5
-rw-r--r--src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java16
-rw-r--r--src/main/java/me/shedaniel/rei/api/ClientHelper.java85
-rw-r--r--src/main/java/me/shedaniel/rei/api/ConfigManager.java39
-rw-r--r--src/main/java/me/shedaniel/rei/api/DisplayHelper.java91
-rw-r--r--src/main/java/me/shedaniel/rei/api/DisplaySettings.java27
-rw-r--r--src/main/java/me/shedaniel/rei/api/DisplayVisibility.java5
-rw-r--r--src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java21
-rw-r--r--src/main/java/me/shedaniel/rei/api/ItemCheatingMode.java5
-rw-r--r--src/main/java/me/shedaniel/rei/api/ItemRegistry.java28
-rw-r--r--src/main/java/me/shedaniel/rei/api/PluginDisabler.java5
-rw-r--r--src/main/java/me/shedaniel/rei/api/PluginFunction.java5
-rw-r--r--src/main/java/me/shedaniel/rei/api/REIPlugin.java10
-rw-r--r--src/main/java/me/shedaniel/rei/api/REIPluginEntry.java54
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeCategory.java81
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeDisplay.java5
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeHelper.java28
-rw-r--r--src/main/java/me/shedaniel/rei/api/RelativePoint.java5
-rw-r--r--src/main/java/me/shedaniel/rei/api/Renderable.java8
-rw-r--r--src/main/java/me/shedaniel/rei/api/Renderer.java5
-rw-r--r--src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java5
21 files changed, 530 insertions, 3 deletions
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 07125643c..01cdff416 100644
--- a/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java
+++ b/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java
@@ -1,11 +1,27 @@
+/*
+ * Roughly Enough Items by Danielshe.
+ * Licensed under the MIT License.
+ */
+
package me.shedaniel.rei.api;
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..e0fbfbed3 100644
--- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java
+++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java
@@ -1,7 +1,11 @@
+/*
+ * Roughly Enough Items by Danielshe.
+ * Licensed under the MIT License.
+ */
+
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;
@@ -10,35 +14,107 @@ 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}
+ */
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<ItemStack> 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<RecipeCategory, List<RecipeDisplay>> 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 +127,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..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;
@@ -7,18 +12,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/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java
index 8234c20b3..51e54302c 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;
@@ -10,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<DisplayBoundsHandler> getSortedBoundsHandlers(Class screenClass);
+ /**
+ * Gets all registered bounds handlers
+ *
+ * @return the list of registered bounds handlers
+ */
List<DisplayBoundsHandler> 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<T> {
+ /**
+ * 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/DisplaySettings.java b/src/main/java/me/shedaniel/rei/api/DisplaySettings.java
index 334d6cc6f..ddf1f3a75 100644
--- a/src/main/java/me/shedaniel/rei/api/DisplaySettings.java
+++ b/src/main/java/me/shedaniel/rei/api/DisplaySettings.java
@@ -1,13 +1,40 @@
+/*
+ * Roughly Enough Items by Danielshe.
+ * Licensed under the MIT License.
+ */
+
package me.shedaniel.rei.api;
public interface DisplaySettings<T extends RecipeDisplay> {
+ /**
+ * 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/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 813cfaad6..39a106783 100644
--- a/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java
+++ b/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java
@@ -1,11 +1,32 @@
+/*
+ * Roughly Enough Items by Danielshe.
+ * Licensed under the MIT License.
+ */
+
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/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..8751da416 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;
@@ -7,12 +12,29 @@ import java.util.List;
public interface ItemRegistry {
+ /**
+ * Gets the current unmodifiable item list
+ *
+ * @return an unmodifiable item list
+ */
List<ItemStack> getItemList();
+ /**
+ * Gets the current modifiable item list
+ *
+ * @return an modifiable item list
+ */
+ @Deprecated
List<ItemStack> 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) {
@@ -27,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/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 121a57496..372c9e23f 100644
--- a/src/main/java/me/shedaniel/rei/api/REIPlugin.java
+++ b/src/main/java/me/shedaniel/rei/api/REIPlugin.java
@@ -1,8 +1,18 @@
+/*
+ * Roughly Enough Items by Danielshe.
+ * Licensed under the MIT License.
+ */
+
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..615c53fd9 100644
--- a/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java
+++ b/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java
@@ -1,28 +1,82 @@
+/*
+ * Roughly Enough Items by Danielshe.
+ * Licensed under the MIT License.
+ */
+
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();
}
diff --git a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java
index 8304fde90..6993b45c4 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;
@@ -17,30 +22,80 @@ import java.util.function.Supplier;
public interface RecipeCategory<T extends RecipeDisplay> {
+ /**
+ * 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<Widget> setupDisplay(Supplier<T> 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
+ */