Browse Source

More docs

Unknown 6 years ago
parent
commit
0d6acf3375

+ 14 - 0
src/main/java/com/zeitheron/hammercore/client/utils/Scissors.java

@@ -11,10 +11,21 @@ import org.lwjgl.opengl.GL11;
  * @author Zeitheron
  * @author Zeitheron
  */
  */
 public class Scissors {
 public class Scissors {
+    /**
+     * Starts the scissor test
+     */
     public static void begin() {
     public static void begin() {
         GL11.glEnable(GL11.GL_SCISSOR_TEST);
         GL11.glEnable(GL11.GL_SCISSOR_TEST);
     }
     }
     
     
+    /**
+     * Setup the scissor bounds
+     *
+     * @param x      the top left x coordinates
+     * @param y      the top left y coordinates
+     * @param width  the width of the bounds
+     * @param height the height of the bounds
+     */
     public static void scissor(int x, int y, int width, int height) {
     public static void scissor(int x, int y, int width, int height) {
         Window window = MinecraftClient.getInstance().window;
         Window window = MinecraftClient.getInstance().window;
         
         
@@ -32,6 +43,9 @@ public class Scissors {
         GL11.glScissor(x, sh - height - y, width, height);
         GL11.glScissor(x, sh - height - y, width, height);
     }
     }
     
     
+    /**
+     * Stops the scissor test
+     */
     public static void end() {
     public static void end() {
         GL11.glDisable(GL11.GL_SCISSOR_TEST);
         GL11.glDisable(GL11.GL_SCISSOR_TEST);
     }
     }

+ 86 - 0
src/main/java/me/shedaniel/rei/api/DisplayHelper.java

@@ -15,41 +15,127 @@ import static net.minecraft.util.ActionResult.PASS;
 
 
 public interface DisplayHelper {
 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);
     List<DisplayBoundsHandler> getSortedBoundsHandlers(Class screenClass);
     
     
+    /**
+     * Gets all registered bounds handlers
+     *
+     * @return the list of registered bounds handlers
+     */
     List<DisplayBoundsHandler> getAllBoundsHandlers();
     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);
     DisplayBoundsHandler getResponsibleBoundsHandler(Class screenClass);
     
     
+    /**
+     * Registers a bounds handler
+     *
+     * @param handler the handler to register
+     */
     void registerBoundsHandler(DisplayBoundsHandler handler);
     void registerBoundsHandler(DisplayBoundsHandler handler);
     
     
+    /**
+     * Gets the base bounds handler api for exclusion zones
+     *
+     * @return the base bounds handler
+     */
     BaseBoundsHandler getBaseBoundsHandler();
     BaseBoundsHandler getBaseBoundsHandler();
     
     
     public static interface DisplayBoundsHandler<T> {
     public static interface DisplayBoundsHandler<T> {
+        /**
+         * An empty rectangle
+         */
         public static final Rectangle EMPTY = new Rectangle();
         public static final Rectangle EMPTY = new Rectangle();
         
         
+        /**
+         * Gets the base supported class for the bounds handler
+         *
+         * @return
+         */
         Class getBaseSupportedClass();
         Class getBaseSupportedClass();
         
         
+        /**
+         * Gets the left bounds of the overlay
+         *
+         * @param screen the current screen
+         * @return the left bounds
+         */
         Rectangle getLeftBounds(T screen);
         Rectangle getLeftBounds(T screen);
         
         
+        /**
+         * Gets the right bounds of the overlay
+         *
+         * @param screen the current screen
+         * @return the right bounds
+         */
         Rectangle getRightBounds(T screen);
         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) {
         default ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, T screen, Rectangle fullBounds) {
             return PASS;
             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) {
         default ActionResult isInZone(boolean isOnRightSide, double mouseX, double mouseY) {
             return PASS;
             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) {
         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));
             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) {
         default boolean shouldRecalculateArea(boolean isOnRightSide, Rectangle rectangle) {
             return false;
             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() {
         default float getPriority() {
             return 0f;
             return 0f;
         }
         }

+ 23 - 0
src/main/java/me/shedaniel/rei/api/ItemRegistry.java

@@ -12,12 +12,29 @@ import java.util.List;
 
 
 public interface ItemRegistry {
 public interface ItemRegistry {
     
     
+    /**
+     * Gets the current unmodifiable item list
+     *
+     * @return an unmodifiable item list
+     */
     List<ItemStack> getItemList();
     List<ItemStack> getItemList();
     
     
+    /**
+     * Gets the current modifiable item list
+     *
+     * @return an modifiable item list
+     */
+    @Deprecated
     List<ItemStack> getModifiableItemList();
     List<ItemStack> getModifiableItemList();
     
     
     ItemStack[] getAllStacksFromItem(Item item);
     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);
     void registerItemStack(Item afterItem, ItemStack stack);
     
     
     default void registerItemStack(Item afterItem, ItemStack... stacks) {
     default void registerItemStack(Item afterItem, ItemStack... stacks) {
@@ -32,6 +49,12 @@ public interface ItemRegistry {
                 registerItemStack(null, stack);
                 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) {
     default boolean alreadyContain(ItemStack stack) {
         return getItemList().stream().anyMatch(stack1 -> ItemStack.areEqual(stack, stack1));
         return getItemList().stream().anyMatch(stack1 -> ItemStack.areEqual(stack, stack1));
     }
     }

+ 75 - 1
src/main/java/me/shedaniel/rei/api/RecipeCategory.java

@@ -22,30 +22,80 @@ import java.util.function.Supplier;
 
 
 public interface RecipeCategory<T extends RecipeDisplay> {
 public interface RecipeCategory<T extends RecipeDisplay> {
     
     
+    /**
+     * Gets the identifier of the category, must be unique
+     *
+     * @return the unique identifier of the category
+     */
     Identifier getIdentifier();
     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() {
     default Renderer getIcon() {
         return Renderable.fromItemStackSupplier(this::getCategoryIcon);
         return Renderable.fromItemStackSupplier(this::getCategoryIcon);
     }
     }
     
     
+    /**
+     * Gets the category name
+     *
+     * @return the name
+     */
     String getCategoryName();
     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) {
     default RecipeRenderer getSimpleRenderer(T recipe) {
         return Renderable.fromRecipe(recipe::getInput, recipe::getOutput);
         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) {
     default List<Widget> setupDisplay(Supplier<T> recipeDisplaySupplier, Rectangle bounds) {
         return Collections.singletonList(new RecipeBaseWidget(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) {
     default void drawCategoryBackground(Rectangle bounds, int mouseX, int mouseY, float delta) {
         new CategoryBaseWidget(bounds).render();
         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 + 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());
         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() {
     default DisplaySettings getDisplaySettings() {
         return new DisplaySettings<T>() {
         return new DisplaySettings<T>() {
             @Override
             @Override
@@ -65,18 +115,42 @@ public interface RecipeCategory<T extends RecipeDisplay> {
         };
         };
     }
     }
     
     
+    /**
+     * Gets the recipe display height
+     *
+     * @return the recipe display height
+     * @apiNote Please do not override this, use {@link RecipeCategory#getDisplaySettings()} instead
+     */
     default int getDisplayHeight() {
     default int getDisplayHeight() {
         return RecipeHelper.getInstance().getCachedCategorySettings(getIdentifier()).map(settings -> settings.getDisplayHeight(this)).orElse(0);
         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) {
     default int getDisplayWidth(T display) {
         return RecipeHelper.getInstance().getCachedCategorySettings(getIdentifier()).map(settings -> settings.getDisplayWidth(this, display)).orElse(0);
         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() {
     default int getMaximumRecipePerPage() {
         return RecipeHelper.getInstance().getCachedCategorySettings(getIdentifier()).map(settings -> settings.getMaximumRecipePerPage(this)).orElse(0);
         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() {
     default boolean checkTags() {
         return false;
         return false;
     }
     }

+ 23 - 0
src/main/java/me/shedaniel/rei/api/RecipeHelper.java

@@ -17,6 +17,9 @@ import java.util.Optional;
 
 
 public interface RecipeHelper {
 public interface RecipeHelper {
     
     
+    /**
+     * @return the api instance of {@link me.shedaniel.rei.client.RecipeHelperImpl}
+     */
     static RecipeHelper getInstance() {
     static RecipeHelper getInstance() {
         return RoughlyEnoughItemsCore.getRecipeHelper();
         return RoughlyEnoughItemsCore.getRecipeHelper();
     }
     }
@@ -27,14 +30,34 @@ public interface RecipeHelper {
     
     
     List<ItemStack> findCraftableByItems(List<ItemStack> inventoryItems);
     List<ItemStack> findCraftableByItems(List<ItemStack> inventoryItems);
     
     
+    /**
+     * Registers a category
+     *
+     * @param category the category to register
+     */
     void registerCategory(RecipeCategory category);
     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);
     void registerDisplay(Identifier categoryIdentifier, RecipeDisplay display);
     
     
     Map<RecipeCategory, List<RecipeDisplay>> getRecipesFor(ItemStack stack);
     Map<RecipeCategory, List<RecipeDisplay>> getRecipesFor(ItemStack stack);
     
     
+    /**
+     * Gets the vanilla recipe manager
+     *
+     * @return the recipe manager
+     */
     RecipeManager getRecipeManager();
     RecipeManager getRecipeManager();
     
     
+    /**
+     * Gets all registered categories
+     * @return the list of categories
+     */
     List<RecipeCategory> getAllCategories();
     List<RecipeCategory> getAllCategories();
     
     
     Map<RecipeCategory, List<RecipeDisplay>> getUsagesFor(ItemStack stack);
     Map<RecipeCategory, List<RecipeDisplay>> getUsagesFor(ItemStack stack);

+ 3 - 0
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.List;
 import java.util.function.Supplier;
 import java.util.function.Supplier;
 
 
+/**
+ * The base class for renderables
+ */
 public interface Renderable {
 public interface Renderable {
     
     
     static ItemStackRenderer fromItemStackSupplier(Supplier<ItemStack> supplier) {
     static ItemStackRenderer fromItemStackSupplier(Supplier<ItemStack> supplier) {

+ 11 - 0
src/main/java/me/shedaniel/rei/gui/widget/Widget.java

@@ -10,9 +10,20 @@ import net.minecraft.client.font.TextRenderer;
 import net.minecraft.client.gui.AbstractParentElement;
 import net.minecraft.client.gui.AbstractParentElement;
 import net.minecraft.client.gui.Drawable;
 import net.minecraft.client.gui.Drawable;
 
 
+/**
+ * The base class for a screen widget
+ *
+ * @see HighlightableWidget for a widget with bounds
+ */
 public abstract class Widget extends AbstractParentElement implements Drawable {
 public abstract class Widget extends AbstractParentElement implements Drawable {
     
     
+    /**
+     * The Minecraft Client instance
+     */
     protected final MinecraftClient minecraft = MinecraftClient.getInstance();
     protected final MinecraftClient minecraft = MinecraftClient.getInstance();
+    /**
+     * The font for rendering text
+     */
     protected final TextRenderer font = minecraft.textRenderer;
     protected final TextRenderer font = minecraft.textRenderer;
     
     
 }
 }