瀏覽代碼

Out of beta: Build 110

Unknown 6 年之前
父節點
當前提交
dc23a3e555

+ 9 - 4
CHANGELOG.md

@@ -1,15 +1,20 @@
 View full changelog [here](https://github.com/shedaniel/RoughlyEnoughItems/blob/1.14/CHANGELOG.md).
-## v2.9-beta+build.109 (BETA)
+## v2.9+build.110
+- Fixed: Build 109 Crash
+- Fixed: Next Page / Previous Page crash in villager recipe mode
+- Added: Scrolling in villager recipe mode
+- Added: New bad javadoc: https://shedaniel.me/RoughlyEnoughItems/
+#### v2.9-beta+build.109 (BETA)
 - Fixed [#92](https://github.com/shedaniel/RoughlyEnoughItems/issues/92): Make REI Buttons use an extra sheet
 - Adds: Support for `{item_name}` in cheating items for getting the path of the item identifier
-## v2.9-beta+build.108 (BETA)
+#### v2.9-beta+build.108 (BETA)
 - Fixed [#88](https://github.com/shedaniel/RoughlyEnoughItems/issues/88): Stupid Item Search
-## v2.9-beta+build.107 (BETA)
+#### v2.9-beta+build.107 (BETA)
 - Fixed: Crashing when clicking tabs
 - Added: Buttons to switch category page
 - Fixed: NullPointerException by geniii
 - Fixed [#58](https://github.com/shedaniel/RoughlyEnoughItems/issues/58): Keybinds (e.g. O, R, U) working even a search field is focused
-## v2.9-beta+build.106 (BETA)
+#### v2.9-beta+build.106 (BETA)
 - Using: [HammerLib](https://minecraft.curseforge.com/projects/hammer-lib) as a simple opengl scissors api
 - New: Mod Name of category new shows in category tooltips
 - New: Renderer API

+ 6 - 6
build.gradle

@@ -59,12 +59,12 @@ dependencies {
     modCompile "cloth:ClothEvents:${cloth_events_version}"
     modCompile "cloth-config:ClothConfig:${cloth_config_version}"
     if (includeDep) {
-//        include "net.fabricmc:fabric:${project.fabric_version}"
-        include "net.fabricmc.fabric-api:fabric-keybindings-v0:${project.fabric_keybindings}"
-        include "net.fabricmc.fabric-api:fabric-api-base:${project.fabric_api_base}"
-        include "net.fabricmc.fabric-api:fabric-networking-v0:${project.fabric_networking}"
-        include "net.fabricmc.fabric-api:fabric-events-lifecycle-v0:${project.fabric_events_lifecycle}"
-        include "net.fabricmc.fabric-api:fabric-resource-loader-v0:${project.fabric_resource_loader}"
+        include "net.fabricmc:fabric:${project.fabric_version}"
+//        include "net.fabricmc.fabric-api:fabric-keybindings-v0:${project.fabric_keybindings}"
+//        include "net.fabricmc.fabric-api:fabric-api-base:${project.fabric_api_base}"
+//        include "net.fabricmc.fabric-api:fabric-networking-v0:${project.fabric_networking}"
+//        include "net.fabricmc.fabric-api:fabric-events-lifecycle-v0:${project.fabric_events_lifecycle}"
+//        include "net.fabricmc.fabric-api:fabric-resource-loader-v0:${project.fabric_resource_loader}"
         include "cloth:ClothEvents:${cloth_events_version}"
         include "cloth-config:ClothConfig:${cloth_config_version}"
     }

+ 1 - 1
gradle.properties

@@ -1,4 +1,4 @@
-mod_version=2.9-beta+build.109
+mod_version=2.9+build.110
 minecraft_version=1.14
 yarn_version=1.14+build.21
 fabricloader_version=0.4.6+build.141

+ 19 - 0
src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java

@@ -11,11 +11,30 @@ import java.awt.*;
 import java.util.List;
 
 public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler<Screen> {
+    /**
+     * Gets the exclusion zones by the screen class
+     *
+     * @param currentScreenClass the current screen class
+     * @param isOnRightSide      whether the user has set the overlay to the right
+     * @return the list of exclusion zones
+     */
     List<Rectangle> getCurrentExclusionZones(Class<? extends Screen> currentScreenClass, boolean isOnRightSide);
     
+    /**
+     * Register an exclusion zone
+     *
+     * @param screenClass the screen
+     * @param supplier    the exclusion zone supplier
+     */
     void registerExclusionZones(Class<? extends Screen> screenClass, ExclusionZoneSupplier supplier);
     
     public static interface ExclusionZoneSupplier {
+        /**
+         * Gets the current exclusion zones
+         *
+         * @param isOnRightSide whether the user has set the overlay to the right
+         * @return the list of exclusion zones
+         */
         List<Rectangle> apply(boolean isOnRightSide);
     }
 }

+ 18 - 3
src/main/java/me/shedaniel/rei/api/ClientHelper.java

@@ -41,9 +41,9 @@ public interface ClientHelper {
     
     /**
      * 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
+     * Opens {@link me.shedaniel.rei.gui.PreRecipeViewingScreen} if not set
+     * Opens {@link me.shedaniel.rei.gui.RecipeViewingScreen} if set to default
+     * Opens {@link me.shedaniel.rei.gui.VillagerRecipeViewingScreen} if set to villager
      *
      * @param map the map of recipes
      */
@@ -115,14 +115,29 @@ public interface ClientHelper {
      */
     String getModFromIdentifier(Identifier identifier);
     
+    /**
+     * @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();
     
     /**

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

@@ -27,6 +27,12 @@ public interface ItemRegistry {
     @Deprecated
     List<ItemStack> getModifiableItemList();
     
+    /**
+     * Gets all possible stacks from an item
+     *
+     * @param item the item to find
+     * @return the array of possible stacks
+     */
     ItemStack[] getAllStacksFromItem(Item item);
     
     /**
@@ -37,12 +43,23 @@ public interface ItemRegistry {
      */
     void registerItemStack(Item afterItem, ItemStack stack);
     
+    /**
+     * Registers multiple stacks to the item list
+     *
+     * @param afterItem the stack to put after
+     * @param stacks    the stacks to register
+     */
     default void registerItemStack(Item afterItem, ItemStack... stacks) {
         for(ItemStack stack : stacks)
             if (stack != null && !stack.isEmpty())
                 registerItemStack(afterItem, stack);
     }
     
+    /**
+     * Registers multiple stacks to the item list
+     *
+     * @param stacks the stacks to register
+     */
     default void registerItemStack(ItemStack... stacks) {
         for(ItemStack stack : stacks)
             if (stack != null && !stack.isEmpty())

+ 31 - 0
src/main/java/me/shedaniel/rei/api/PluginDisabler.java

@@ -9,20 +9,51 @@ import net.minecraft.util.Identifier;
 
 public interface PluginDisabler {
     
+    /**
+     * Disables multiple functions from a plugin
+     *
+     * @param plugin    the identifier of the plugin
+     * @param functions the array of functions to be disabled
+     */
     default void disablePluginFunctions(Identifier plugin, PluginFunction... functions) {
         for(PluginFunction function : functions)
             disablePluginFunction(plugin, function);
     }
     
+    /**
+     * Enables multiple functions from a plugin
+     *
+     * @param plugin    the identifier of the plugin
+     * @param functions the array of functions to be enabled
+     */
     default void enablePluginFunctions(Identifier plugin, PluginFunction... functions) {
         for(PluginFunction function : functions)
             enablePluginFunction(plugin, function);
     }
     
+    /**
+     * Disables a function from a plugin
+     *
+     * @param plugin    the identifier of the plugin
+     * @param function the function to be disabled
+     */
     void disablePluginFunction(Identifier plugin, PluginFunction function);
     
+    /**
+     * Enables a function from a plugin
+     *
+     * @param plugin    the identifier of the plugin
+     * @param function the function to be enabled
+     */
     void enablePluginFunction(Identifier plugin, PluginFunction function);
     
+    /**
+     * Checks if a plugin function has been disabled
+     *
+     * @param plugin   the identifier of the plugin
+     * @param function the function to check
+     * @return whether if it has been disabled
+     */
     boolean isFunctionEnabled(Identifier plugin, PluginFunction function);
     
 }

+ 19 - 0
src/main/java/me/shedaniel/rei/api/RecipeDisplay.java

@@ -15,16 +15,35 @@ import java.util.Optional;
 
 public interface RecipeDisplay<T extends Recipe> {
     
+    /**
+     * @return the optional recipe
+     */
     Optional<T> getRecipe();
     
+    /**
+     * @return a list of items
+     */
     List<List<ItemStack>> getInput();
     
+    /**
+     * @return a list of outputs
+     */
     List<ItemStack> getOutput();
     
+    /**
+     * Gets the required items used in craftable filters
+     *
+     * @return the list of required items
+     */
     default List<List<ItemStack>> getRequiredItems() {
         return Lists.newArrayList();
     }
     
+    /**
+     * Gets the recipe display category identifier
+     *
+     * @return the identifier of the category
+     */
     Identifier getRecipeCategory();
     
 }

+ 90 - 1
src/main/java/me/shedaniel/rei/api/RecipeHelper.java

@@ -24,10 +24,24 @@ public interface RecipeHelper {
         return RoughlyEnoughItemsCore.getRecipeHelper();
     }
     
+    /**
+     * Gets the total recipe count registered
+     *
+     * @return the recipe count
+     */
     int getRecipeCount();
     
-    List<Recipe> getVanillaSortedRecipes();
+    /**
+     * @return a list of sorted recipes
+     */
+    List<Recipe> getAllSortedRecipes();
     
+    /**
+     * Gets all craftable items from materials.
+     *
+     * @param inventoryItems the materials
+     * @return the list of craftable items
+     */
     List<ItemStack> findCraftableByItems(List<ItemStack> inventoryItems);
     
     /**
@@ -45,6 +59,12 @@ public interface RecipeHelper {
      */
     void registerDisplay(Identifier categoryIdentifier, RecipeDisplay display);
     
+    /**
+     * Gets a map of recipes for an itemstack
+     *
+     * @param stack the stack to be crafted
+     * @return the map of recipes
+     */
     Map<RecipeCategory, List<RecipeDisplay>> getRecipesFor(ItemStack stack);
     
     /**
@@ -56,32 +76,101 @@ public interface RecipeHelper {
     
     /**
      * Gets all registered categories
+     *
      * @return the list of categories
      */
     List<RecipeCategory> getAllCategories();
     
+    /**
+     * Gets a map of usages for an itemstack
+     *
+     * @param stack the stack to be used
+     * @return the map of recipes
+     */
     Map<RecipeCategory, List<RecipeDisplay>> getUsagesFor(ItemStack stack);
     
+    /**
+     * Gets the optional of the speed crafting button area from a category
+     *
+     * @param category the category of the display
+     * @return the optional of speed crafting button area
+     */
     Optional<ButtonAreaSupplier> getSpeedCraftButtonArea(RecipeCategory category);
     
+    /**
+     * Registers a speed crafting button area
+     *
+     * @param category  the category of the button area
+     * @param rectangle the button area
+     */
     void registerSpeedCraftButtonArea(Identifier category, ButtonAreaSupplier rectangle);
     
+    /**
+     * Registers a default speed crafting button area, which is bottom right
+     *
+     * @param category the category of the button area
+     */
     void registerDefaultSpeedCraftButtonArea(Identifier category);
     
+    /**
+     * Gets the speed crafting functional from a category
+     *
+     * @param category the category of the speed crafting functional
+     * @return the list of speed crafting functionals
+     */
     List<SpeedCraftFunctional> getSpeedCraftFunctional(RecipeCategory category);
     
+    /**
+     * Registers a speed crafting functional
+     *
+     * @param category   the category of the speed crafting functional
+     * @param functional the functional to be registered
+     */
     void registerSpeedCraftFunctional(Identifier category, SpeedCraftFunctional functional);
     
+    /**
+     * Gets the map of all recipes visible to the player
+     *
+     * @return the map of recipes
+     */
     Map<RecipeCategory, List<RecipeDisplay>> getAllRecipes();
     
+    /**
+     * Registers a recipe visibility handler
+     *
+     * @param visibilityHandler the handler to be registered
+     */
     void registerRecipeVisibilityHandler(DisplayVisibilityHandler visibilityHandler);
     
+    /**
+     * Unregisters a recipe visibility handler
+     *
+     * @param visibilityHandler the handler to be unregistered
+     */
     void unregisterRecipeVisibilityHandler(DisplayVisibilityHandler visibilityHandler);
     
+    /**
+     * Gets an unmodifiable list of recipe visibility handlers
+     *
+     * @return the unmodifiable list of handlers
+     */
     List<DisplayVisibilityHandler> getDisplayVisibilityHandlers();
     
+    /**
+     * Checks if the display is visible by asking recipe visibility handlers
+     *
+     * @param display       the display to be checked
+     * @param respectConfig whether it should respect the user's config
+     * @return whether the display should be visible
+     */
     boolean isDisplayVisible(RecipeDisplay display, boolean respectConfig);
     
+    /**
+     * Gets the cached category setting by the category identifier
+     *
+     * @param category the identifier of the category
+     * @return the optional of the category settings
+     */
     Optional<DisplaySettings> getCachedCategorySettings(Identifier category);
     
 }

+ 34 - 6
src/main/java/me/shedaniel/rei/api/Renderable.java

@@ -19,6 +19,12 @@ import java.util.function.Supplier;
  */
 public interface Renderable {
     
+    /**
+     * Gets an item stack renderer by an item stack supplier
+     *
+     * @param supplier the supplier for getting the item stack
+     * @return the item stack renderer
+     */
     static ItemStackRenderer fromItemStackSupplier(Supplier<ItemStack> supplier) {
         return new ItemStackRenderer() {
             @Override
@@ -28,19 +34,32 @@ public interface Renderable {
         };
     }
     
+    /**
+     * Gets an item stack renderer by an item stack
+     *
+     * @param stack the item stack to be displayed
+     * @return the item stack renderer
+     */
     static ItemStackRenderer fromItemStack(ItemStack stack) {
-        return new ItemStackRenderer() {
-            @Override
-            public ItemStack getItemStack() {
-                return stack;
-            }
-        };
+        return fromItemStackSupplier(() -> stack);
     }
     
+    /**
+     * Gets an empty renderer
+     *
+     * @return an empty renderer
+     */
     static EmptyRenderer empty() {
         return EmptyRenderer.INSTANCE;
     }
     
+    /**
+     * Gets a simple recipe renderer from inputs and outputs
+     *
+     * @param input  the list of input items
+     * @param output the list of output items
+     * @return the recipe renderer
+     */
     static SimpleRecipeRenderer fromRecipe(Supplier<List<List<ItemStack>>> input, Supplier<List<ItemStack>> output) {
         return new SimpleRecipeRenderer(input, output);
     }
@@ -56,5 +75,14 @@ public interface Renderable {
         };
     }
     
+    /**
+     * Renders of the renderable
+     *
+     * @param x      the x coordinate of the renderable
+     * @param y      the y coordinate of the renderable
+     * @param mouseX the x coordinate of the mouse
+     * @param mouseY the y coordinate of the mouse
+     * @param delta  the delta
+     */
     void render(int x, int y, double mouseX, double mouseY, float delta);
 }

+ 10 - 0
src/main/java/me/shedaniel/rei/api/Renderer.java

@@ -8,10 +8,20 @@ package me.shedaniel.rei.api;
 import net.minecraft.client.gui.DrawableHelper;
 
 public abstract class Renderer extends DrawableHelper implements Renderable {
+    /**
+     * Gets the current blit offset
+     *
+     * @return the blit offset
+     */
     public int getBlitOffset() {
         return this.blitOffset;
     }
     
+    /**
+     * Sets the current blit offset
+     *
+     * @param offset the new blit offset
+     */
     public void setBlitOffset(int offset) {
         this.blitOffset = offset;
     }

+ 19 - 0
src/main/java/me/shedaniel/rei/api/SpeedCraftFunctional.java

@@ -9,10 +9,29 @@ import net.minecraft.client.gui.Screen;
 
 public interface SpeedCraftFunctional<T extends RecipeDisplay> {
     
+    /**
+     * Gets the classes that it is functioning for
+     *
+     * @return the array of classes
+     */
     Class[] getFunctioningFor();
     
+    /**
+     * Performs the auto crafting
+     *
+     * @param screen the current screen
+     * @param recipe the current recipe
+     * @return whether it worked
+     */
     boolean performAutoCraft(Screen screen, T recipe);
     
+    /**
+     * Gets if this functional accepts the auto crafting
+     *
+     * @param screen the current screen
+     * @param recipe the current recipe
+     * @return whether it is accepted
+     */
     boolean acceptRecipe(Screen screen, T recipe);
     
 }

+ 1 - 1
src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java

@@ -250,7 +250,7 @@ public class RecipeHelperImpl implements RecipeHelper {
     }
     
     @Override
-    public List<Recipe> getVanillaSortedRecipes() {
+    public List<Recipe> getAllSortedRecipes() {
         return getRecipeManager().values().stream().sorted(RECIPE_COMPARATOR).collect(Collectors.toList());
     }
     

+ 14 - 26
src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java

@@ -24,12 +24,8 @@ import net.minecraft.network.chat.TextComponent;
 import net.minecraft.network.chat.TranslatableComponent;
 import net.minecraft.sound.SoundEvents;
 import net.minecraft.util.math.MathHelper;
-import org.lwjgl.BufferUtils;
-import org.lwjgl.glfw.GLFW;
-import org.lwjgl.opengl.GL11;
 
 import java.awt.*;
-import java.nio.IntBuffer;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -212,15 +208,14 @@ public class VillagerRecipeViewingScreen extends Screen {
                 return true;
         if (bounds.contains(ClientUtils.getMouseLocation())) {
             if (double_3 < 0 && categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) {
-                selectedCategoryIndex++;
-                if (selectedCategoryIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size())
-                    selectedCategoryIndex = 0;
+                selectedRecipeIndex++;
+                if (selectedRecipeIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size())
+                    selectedRecipeIndex = 0;
                 init();
-                return true;
             } else if (categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) {
-                selectedCategoryIndex--;
-                if (selectedCategoryIndex < 0)
-                    selectedCategoryIndex = categoryMap.get(categories.get(selectedCategoryIndex)).size() - 1;
+                selectedRecipeIndex--;
+                if (selectedRecipeIndex < 0)
+                    selectedRecipeIndex = categoryMap.get(categories.get(selectedCategoryIndex)).size() - 1;
                 init();
                 return true;
             }
@@ -238,7 +233,7 @@ public class VillagerRecipeViewingScreen extends Screen {
         });
         GuiLighting.disable();
         ScreenHelper.getLastOverlay().render(mouseX, mouseY, delta);
-        GL11.glPushMatrix();
+        GlStateManager.pushMatrix();
         Scissors.begin();
         Scissors.scissor(0, scrollListBounds.y + 1, width, scrollListBounds.height - 2);
         for(int i = 0; i < buttonWidgets.size(); i++) {
@@ -258,17 +253,10 @@ public class VillagerRecipeViewingScreen extends Screen {
             }
         }
         Scissors.end();
-        GL11.glPopMatrix();
+        GlStateManager.popMatrix();
         ScreenHelper.getLastOverlay().lateRender(mouseX, mouseY, delta);
     }
     
-    private int getTitleBarHeight() {
-        IntBuffer useless = BufferUtils.createIntBuffer(3), top = BufferUtils.createIntBuffer(1);
-        GLFW.glfwGetWindowFrameSize(minecraft.window.getHandle(), useless, top, useless, useless);
-        System.out.println(top.get(0));
-        return top.get(0) / 3 * 2;
-    }
-    
     private int getReal(int i) {
         return (int) (i / ((double) minecraft.window.getScaledWidth() / (double) minecraft.window.getWidth()));
     }
@@ -288,18 +276,18 @@ public class VillagerRecipeViewingScreen extends Screen {
         }
         if (ClientHelper.getInstance().getNextPageKeyBinding().matchesKey(int_1, int_2)) {
             if (categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) {
-                selectedCategoryIndex++;
-                if (selectedCategoryIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size())
-                    selectedCategoryIndex = 0;
+                selectedRecipeIndex ++;
+                if (selectedRecipeIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size())
+                    selectedRecipeIndex = 0;
                 init();
                 return true;
             }
             return false;
         } else if (ClientHelper.getInstance().getPreviousPageKeyBinding().matchesKey(int_1, int_2)) {
             if (categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) {
-                selectedCategoryIndex--;
-                if (selectedCategoryIndex < 0)
-                    selectedCategoryIndex = categoryMap.get(categories.get(selectedCategoryIndex)).size() - 1;
+                selectedRecipeIndex--;
+                if (selectedRecipeIndex < 0)
+                    selectedRecipeIndex = categoryMap.get(categories.get(selectedCategoryIndex)).size() - 1;
                 init();
                 return true;
             }

+ 1 - 1
src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java

@@ -110,7 +110,7 @@ public class DefaultPlugin implements REIPluginEntry {
     
     @Override
     public void registerRecipeDisplays(RecipeHelper recipeHelper) {
-        for(Recipe recipe : recipeHelper.getVanillaSortedRecipes())
+        for(Recipe recipe : recipeHelper.getAllSortedRecipes())
             if (recipe instanceof ShapelessRecipe)
                 recipeHelper.registerDisplay(CRAFTING, new DefaultShapelessDisplay((ShapelessRecipe) recipe));
             else if (recipe instanceof ShapedRecipe)