From dc92d0a4d262b633e9f322def3e89ab1a05417ab Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 5 Feb 2021 21:55:26 +0800 Subject: More Signed-off-by: shedaniel --- .../me/shedaniel/rei/api/AutoTransferHandler.java | 2 + .../java/me/shedaniel/rei/api/BuiltinPlugin.java | 70 --- .../java/me/shedaniel/rei/api/ClientHelper.java | 7 +- .../java/me/shedaniel/rei/api/ConfigObject.java | 2 +- .../main/java/me/shedaniel/rei/api/Display.java | 68 --- .../shedaniel/rei/api/DisplayBoundsRegistry.java | 2 +- .../rei/api/DisplayVisibilityHandler.java | 3 +- .../me/shedaniel/rei/api/LiveRecipeGenerator.java | 1 + .../java/me/shedaniel/rei/api/OverlayDecider.java | 2 +- .../main/java/me/shedaniel/rei/api/REIHelper.java | 6 +- .../java/me/shedaniel/rei/api/RecipeRegistry.java | 3 +- .../java/me/shedaniel/rei/api/TransferDisplay.java | 46 -- .../shedaniel/rei/api/TransferDisplayCategory.java | 38 -- .../shedaniel/rei/api/favorites/FavoriteEntry.java | 2 +- .../rei/api/favorites/FavoriteMenuEntry.java | 2 +- .../me/shedaniel/rei/api/gui/DisplayRenderer.java | 44 ++ .../me/shedaniel/rei/api/gui/DrawableConsumer.java | 35 ++ .../java/me/shedaniel/rei/api/gui/Renderer.java | 43 ++ .../rei/api/gui/SimpleDisplayRenderer.java | 165 ++++++ .../rei/api/gui/config/AppearanceTheme.java | 44 ++ .../rei/api/gui/config/ConfigButtonPosition.java | 44 ++ .../rei/api/gui/config/DisplayPanelLocation.java | 49 ++ .../rei/api/gui/config/EntryPanelOrdering.java | 40 ++ .../api/gui/config/EntryPanelOrderingConfig.java | 64 +++ .../rei/api/gui/config/ItemCheatingMode.java | 41 ++ .../rei/api/gui/config/ItemCheatingStyle.java | 44 ++ .../rei/api/gui/config/RecipeBorderType.java | 62 ++ .../rei/api/gui/config/RecipeScreenType.java | 44 ++ .../rei/api/gui/config/SearchFieldLocation.java | 42 ++ .../rei/api/gui/config/SyntaxHighlightingMode.java | 43 ++ .../me/shedaniel/rei/api/gui/widgets/Arrow.java | 87 +++ .../shedaniel/rei/api/gui/widgets/BaseWidget.java | 52 ++ .../shedaniel/rei/api/gui/widgets/BurningFire.java | 87 +++ .../me/shedaniel/rei/api/gui/widgets/Button.java | 186 ++++++ .../me/shedaniel/rei/api/gui/widgets/Label.java | 323 +++++++++++ .../me/shedaniel/rei/api/gui/widgets/Panel.java | 77 +++ .../me/shedaniel/rei/api/gui/widgets/Slot.java | 158 ++++++ .../shedaniel/rei/api/gui/widgets/TextField.java | 37 ++ .../me/shedaniel/rei/api/gui/widgets/Tooltip.java | 69 +++ .../me/shedaniel/rei/api/gui/widgets/Widget.java | 74 +++ .../rei/api/gui/widgets/WidgetWithBounds.java | 39 ++ .../me/shedaniel/rei/api/gui/widgets/Widgets.java | 211 +++++++ .../rei/api/ingredient/EntryIngredient.java | 10 +- .../shedaniel/rei/api/ingredient/EntryStack.java | 2 +- .../rei/api/ingredient/entry/AbstractRenderer.java | 2 +- .../api/ingredient/entry/BuiltinEntryTypes.java | 2 +- .../rei/api/ingredient/entry/EntryRenderer.java | 2 +- .../rei/api/ingredient/util/EntryStacks.java | 2 +- .../shedaniel/rei/api/plugins/BuiltinPlugin.java | 70 +++ .../rei/api/registry/CategoryRegistry.java | 42 +- .../rei/api/registry/ParentReloadable.java | 18 + .../shedaniel/rei/api/registry/PluginHandler.java | 10 + .../me/shedaniel/rei/api/registry/Reloadable.java | 5 + .../rei/api/registry/category/DisplayCategory.java | 133 ----- .../rei/api/registry/display/Display.java | 68 +++ .../rei/api/registry/display/DisplayCategory.java | 132 +++++ .../rei/api/registry/display/TransferDisplay.java | 46 ++ .../registry/display/TransferDisplayCategory.java | 39 ++ .../me/shedaniel/rei/api/util/CollectionUtils.java | 315 +++++++++++ .../shedaniel/rei/api/util/DrawableConsumer.java | 35 -- .../me/shedaniel/rei/api/util/FormattingUtils.java | 48 ++ .../me/shedaniel/rei/api/util/Identifiable.java | 7 + .../rei/api/util/ImmutableLiteralText.java | 98 ++++ .../java/me/shedaniel/rei/api/util/Renderer.java | 43 -- .../shedaniel/rei/api/util/TextRepresentable.java | 2 - .../java/me/shedaniel/rei/api/widgets/Arrow.java | 88 --- .../me/shedaniel/rei/api/widgets/BaseWidget.java | 53 -- .../me/shedaniel/rei/api/widgets/BurningFire.java | 88 --- .../java/me/shedaniel/rei/api/widgets/Button.java | 186 ------ .../java/me/shedaniel/rei/api/widgets/Label.java | 324 ----------- .../java/me/shedaniel/rei/api/widgets/Panel.java | 78 --- .../java/me/shedaniel/rei/api/widgets/Slot.java | 159 ------ .../java/me/shedaniel/rei/api/widgets/Tooltip.java | 69 --- .../java/me/shedaniel/rei/api/widgets/Widgets.java | 212 ------- .../shedaniel/rei/gui/config/AppearanceTheme.java | 44 -- .../rei/gui/config/ConfigButtonPosition.java | 44 -- .../rei/gui/config/DisplayPanelLocation.java | 49 -- .../rei/gui/config/EntryPanelOrdering.java | 40 -- .../rei/gui/config/EntryPanelOrderingConfig.java | 64 --- .../shedaniel/rei/gui/config/ItemCheatingMode.java | 41 -- .../rei/gui/config/ItemCheatingStyle.java | 44 -- .../shedaniel/rei/gui/config/RecipeBorderType.java | 62 -- .../shedaniel/rei/gui/config/RecipeScreenType.java | 44 -- .../rei/gui/config/SearchFieldLocation.java | 42 -- .../rei/gui/config/SyntaxHighlightingMode.java | 43 -- .../shedaniel/rei/gui/entries/DisplayRenderer.java | 44 -- .../rei/gui/entries/SimpleDisplayRenderer.java | 165 ------ .../shedaniel/rei/gui/widget/TextFieldWidget.java | 624 --------------------- .../java/me/shedaniel/rei/gui/widget/Widget.java | 74 --- .../shedaniel/rei/gui/widget/WidgetWithBounds.java | 39 -- .../main/java/me/shedaniel/rei/impl/Internals.java | 25 +- .../me/shedaniel/rei/utils/CollectionUtils.java | 315 ----------- .../me/shedaniel/rei/utils/FormattingUtils.java | 48 -- .../shedaniel/rei/utils/ImmutableLiteralText.java | 98 ---- 94 files changed, 3142 insertions(+), 3653 deletions(-) delete mode 100644 api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/Display.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/TransferDisplay.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/TransferDisplayCategory.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/DisplayRenderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/DrawableConsumer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/Renderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/SimpleDisplayRenderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/config/AppearanceTheme.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/config/ConfigButtonPosition.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/config/DisplayPanelLocation.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/config/EntryPanelOrdering.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/config/EntryPanelOrderingConfig.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/config/ItemCheatingMode.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/config/ItemCheatingStyle.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/config/RecipeBorderType.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/config/RecipeScreenType.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/config/SearchFieldLocation.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/config/SyntaxHighlightingMode.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/Arrow.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/BaseWidget.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/BurningFire.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/Button.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/Label.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/Panel.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/Slot.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/TextField.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/Tooltip.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widget.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/WidgetWithBounds.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widgets.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/plugins/BuiltinPlugin.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/registry/ParentReloadable.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/registry/PluginHandler.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/registry/Reloadable.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/registry/category/DisplayCategory.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/registry/display/Display.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/registry/display/DisplayCategory.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/registry/display/TransferDisplay.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/registry/display/TransferDisplayCategory.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/util/CollectionUtils.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/util/DrawableConsumer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/util/FormattingUtils.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/util/Identifiable.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/util/ImmutableLiteralText.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/util/Renderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/widgets/Arrow.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/widgets/BaseWidget.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/widgets/BurningFire.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/widgets/Button.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/widgets/Label.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/widgets/Panel.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/widgets/Slot.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/widgets/Tooltip.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/widgets/Widgets.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/config/AppearanceTheme.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/config/ConfigButtonPosition.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/config/DisplayPanelLocation.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrdering.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/config/EntryPanelOrderingConfig.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/config/ItemCheatingMode.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/config/ItemCheatingStyle.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/config/RecipeBorderType.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/config/RecipeScreenType.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/config/SearchFieldLocation.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/config/SyntaxHighlightingMode.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/entries/DisplayRenderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/entries/SimpleDisplayRenderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/widget/TextFieldWidget.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/widget/Widget.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/widget/WidgetWithBounds.java delete mode 100644 api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java delete mode 100644 api/src/main/java/me/shedaniel/rei/utils/FormattingUtils.java delete mode 100644 api/src/main/java/me/shedaniel/rei/utils/ImmutableLiteralText.java (limited to 'api/src') diff --git a/api/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java b/api/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java index d4c29fcea..ff137ad51 100644 --- a/api/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java +++ b/api/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java @@ -25,6 +25,8 @@ package me.shedaniel.rei.api; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; +import me.shedaniel.rei.api.registry.display.Display; +import me.shedaniel.rei.api.registry.display.TransferDisplayCategory; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; diff --git a/api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java b/api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java deleted file mode 100644 index 852a43476..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.api; - -import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.impl.Internals; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; - -import java.util.Collections; -import java.util.List; -import java.util.function.UnaryOperator; - -public interface BuiltinPlugin { - ResourceLocation CRAFTING = new ResourceLocation("minecraft", "plugins/crafting"); - ResourceLocation SMELTING = new ResourceLocation("minecraft", "plugins/smelting"); - ResourceLocation SMOKING = new ResourceLocation("minecraft", "plugins/smoking"); - ResourceLocation BLASTING = new ResourceLocation("minecraft", "plugins/blasting"); - ResourceLocation CAMPFIRE = new ResourceLocation("minecraft", "plugins/campfire"); - ResourceLocation STONE_CUTTING = new ResourceLocation("minecraft", "plugins/stone_cutting"); - ResourceLocation STRIPPING = new ResourceLocation("minecraft", "plugins/stripping"); - ResourceLocation BREWING = new ResourceLocation("minecraft", "plugins/brewing"); - ResourceLocation COMPOSTING = new ResourceLocation("minecraft", "plugins/composting"); - ResourceLocation FUEL = new ResourceLocation("minecraft", "plugins/fuel"); - ResourceLocation SMITHING = new ResourceLocation("minecraft", "plugins/smithing"); - ResourceLocation BEACON = new ResourceLocation("minecraft", "plugins/beacon"); - ResourceLocation BEACON_PAYMENT = new ResourceLocation("minecraft", "plugins/beacon_payment"); - ResourceLocation TILLING = new ResourceLocation("minecraft", "plugins/tilling"); - ResourceLocation PATHING = new ResourceLocation("minecraft", "plugins/pathing"); - ResourceLocation INFO = new ResourceLocation("roughlyenoughitems", "plugins/information"); - - static BuiltinPlugin getInstance() { - return Internals.getBuiltinPlugin(); - } - - default void registerBrewingRecipe(ItemStack input, Ingredient ingredient, ItemStack output) { - registerBrewingRecipe(Ingredient.of(input), ingredient, output); - } - - void registerBrewingRecipe(Ingredient input, Ingredient ingredient, ItemStack output); - - void registerInformation(List> entryStacks, Component name, UnaryOperator> textBuilder); - - default void registerInformation(EntryStack entryStack, Component name, UnaryOperator> textBuilder) { - registerInformation(Collections.singletonList(entryStack), name, textBuilder); - } -} diff --git a/api/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/api/src/main/java/me/shedaniel/rei/api/ClientHelper.java index 34f5c2213..c1ff48e21 100644 --- a/api/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/api/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -24,10 +24,11 @@ package me.shedaniel.rei.api; import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.api.registry.category.DisplayCategory; +import me.shedaniel.rei.api.registry.display.Display; +import me.shedaniel.rei.api.registry.display.DisplayCategory; +import me.shedaniel.rei.api.util.CollectionUtils; +import me.shedaniel.rei.api.util.FormattingUtils; import me.shedaniel.rei.impl.Internals; -import me.shedaniel.rei.utils.CollectionUtils; -import me.shedaniel.rei.utils.FormattingUtils; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.ChatFormatting; diff --git a/api/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/ConfigObject.java index 1eec1243c..fc802346d 100644 --- a/api/src/main/java/me/shedaniel/rei/api/ConfigObject.java +++ b/api/src/main/java/me/shedaniel/rei/api/ConfigObject.java @@ -26,7 +26,7 @@ package me.shedaniel.rei.api; import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.rei.api.favorites.FavoriteEntry; import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.gui.config.*; +import me.shedaniel.rei.api.gui.config.*; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import org.jetbrains.annotations.ApiStatus; diff --git a/api/src/main/java/me/shedaniel/rei/api/Display.java b/api/src/main/java/me/shedaniel/rei/api/Display.java deleted file mode 100644 index a99a1797c..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/Display.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.api; - -import me.shedaniel.rei.api.ingredient.EntryIngredient; -import net.minecraft.resources.ResourceLocation; - -import java.util.List; -import java.util.Optional; - -public interface Display { - - /** - * @return a list of inputs - */ - List getInputEntries(); - - /** - * @return a list of outputs - */ - List getResultingEntries(); - - /** - * Gets the required items used in craftable filters - * - * @return the list of required items - */ - default List getRequiredEntries() { - return getInputEntries(); - } - - /** - * Gets the recipe display category identifier - * - * @return the identifier of the category - */ - ResourceLocation getRecipeCategory(); - - /** - * Gets the recipe location from datapack. - * - * @return the recipe location - */ - default Optional getRecipeLocation() { - return Optional.empty(); - } -} diff --git a/api/src/main/java/me/shedaniel/rei/api/DisplayBoundsRegistry.java b/api/src/main/java/me/shedaniel/rei/api/DisplayBoundsRegistry.java index 070fc4460..14ea6d244 100644 --- a/api/src/main/java/me/shedaniel/rei/api/DisplayBoundsRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/DisplayBoundsRegistry.java @@ -24,7 +24,7 @@ package me.shedaniel.rei.api; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.gui.config.DisplayPanelLocation; +import me.shedaniel.rei.api.gui.config.DisplayPanelLocation; import me.shedaniel.rei.impl.Internals; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/api/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java b/api/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java index 8dcb57197..cfea1316d 100644 --- a/api/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java +++ b/api/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java @@ -23,7 +23,8 @@ package me.shedaniel.rei.api; -import me.shedaniel.rei.api.registry.category.DisplayCategory; +import me.shedaniel.rei.api.registry.display.Display; +import me.shedaniel.rei.api.registry.display.DisplayCategory; import net.minecraft.world.InteractionResult; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java b/api/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java index dcf2517e6..8549b95b7 100644 --- a/api/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java +++ b/api/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.api; import me.shedaniel.rei.api.ingredient.EntryStack; +import me.shedaniel.rei.api.registry.display.Display; import net.minecraft.resources.ResourceLocation; import java.util.List; diff --git a/api/src/main/java/me/shedaniel/rei/api/OverlayDecider.java b/api/src/main/java/me/shedaniel/rei/api/OverlayDecider.java index 1eac57611..84840d523 100644 --- a/api/src/main/java/me/shedaniel/rei/api/OverlayDecider.java +++ b/api/src/main/java/me/shedaniel/rei/api/OverlayDecider.java @@ -24,7 +24,7 @@ package me.shedaniel.rei.api; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.gui.config.DisplayPanelLocation; +import me.shedaniel.rei.api.gui.config.DisplayPanelLocation; import net.minecraft.world.InteractionResult; import static net.minecraft.world.InteractionResult.PASS; diff --git a/api/src/main/java/me/shedaniel/rei/api/REIHelper.java b/api/src/main/java/me/shedaniel/rei/api/REIHelper.java index c4bc5b429..bbc08a38b 100644 --- a/api/src/main/java/me/shedaniel/rei/api/REIHelper.java +++ b/api/src/main/java/me/shedaniel/rei/api/REIHelper.java @@ -23,8 +23,8 @@ package me.shedaniel.rei.api; -import me.shedaniel.rei.api.widgets.Tooltip; -import me.shedaniel.rei.gui.widget.TextFieldWidget; +import me.shedaniel.rei.api.gui.widgets.TextField; +import me.shedaniel.rei.api.gui.widgets.Tooltip; import me.shedaniel.rei.impl.Internals; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -55,7 +55,7 @@ public interface REIHelper { boolean isDarkThemeEnabled(); @Nullable - TextFieldWidget getSearchTextField(); + TextField getSearchTextField(); void queueTooltip(@Nullable Tooltip tooltip); diff --git a/api/src/main/java/me/shedaniel/rei/api/RecipeRegistry.java b/api/src/main/java/me/shedaniel/rei/api/RecipeRegistry.java index 6c700c0d6..50bcd8016 100644 --- a/api/src/main/java/me/shedaniel/rei/api/RecipeRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/RecipeRegistry.java @@ -25,7 +25,8 @@ package me.shedaniel.rei.api; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.api.registry.category.DisplayCategory; +import me.shedaniel.rei.api.registry.display.Display; +import me.shedaniel.rei.api.registry.display.DisplayCategory; import me.shedaniel.rei.impl.Internals; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/api/src/main/java/me/shedaniel/rei/api/TransferDisplay.java b/api/src/main/java/me/shedaniel/rei/api/TransferDisplay.java deleted file mode 100644 index 42e685077..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/TransferDisplay.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.api; - -import me.shedaniel.rei.api.ingredient.EntryIngredient; -import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.api.server.ContainerInfo; -import net.minecraft.world.inventory.AbstractContainerMenu; - -import java.util.List; - -public interface TransferDisplay extends Display { - - /** - * @return the width of the crafting grid. - */ - int getWidth(); - - /** - * @return the height of the crafting grid. - */ - int getHeight(); - - List getOrganisedInputEntries(ContainerInfo containerInfo, AbstractContainerMenu container); -} diff --git a/api/src/main/java/me/shedaniel/rei/api/TransferDisplayCategory.java b/api/src/main/java/me/shedaniel/rei/api/TransferDisplayCategory.java deleted file mode 100644 index 7fe0f42cb..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/TransferDisplayCategory.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 shedaniel - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.shedaniel.rei.api; - -import com.mojang.blaze3d.vertex.PoseStack; -import it.unimi.dsi.fastutil.ints.IntList; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.registry.category.DisplayCategory; -import me.shedaniel.rei.gui.widget.Widget; -import org.jetbrains.annotations.ApiStatus; - -import java.util.List; - -public interface TransferDisplayCategory extends DisplayCategory { - @ApiStatus.OverrideOnly - void renderRedSlots(PoseStack matrices, List widgets, Rectangle bounds, T display, IntList redSlots); -} diff --git a/api/src/main/java/me/shedaniel/rei/api/favorites/FavoriteEntry.java b/api/src/main/java/me/shedaniel/rei/api/favorites/FavoriteEntry.java index 8f943a015..0f8f3dd1a 100644 --- a/api/src/main/java/me/shedaniel/rei/api/favorites/FavoriteEntry.java +++ b/api/src/main/java/me/shedaniel/rei/api/favorites/FavoriteEntry.java @@ -25,7 +25,7 @@ package me.shedaniel.rei.api.favorites; import com.google.gson.JsonObject; import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.api.util.Renderer; +import me.shedaniel.rei.api.gui.Renderer; import me.shedaniel.rei.impl.Internals; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/me/shedaniel/rei/api/favorites/FavoriteMenuEntry.java b/api/src/main/java/me/shedaniel/rei/api/favorites/FavoriteMenuEntry.java index 575682f58..9d2d26883 100644 --- a/api/src/main/java/me/shedaniel/rei/api/favorites/FavoriteMenuEntry.java +++ b/api/src/main/java/me/shedaniel/rei/api/favorites/FavoriteMenuEntry.java @@ -23,7 +23,7 @@ package me.shedaniel.rei.api.favorites; -import me.shedaniel.rei.gui.widget.Widget; +import me.shedaniel.rei.api.gui.widgets.Widget; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/DisplayRenderer.java b/api/src/main/java/me/shedaniel/rei/api/gui/DisplayRenderer.java new file mode 100644 index 000000000..281d79a18 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/DisplayRenderer.java @@ -0,0 +1,44 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui; + +import me.shedaniel.math.Point; +import me.shedaniel.rei.api.ingredient.entry.AbstractRenderer; +import me.shedaniel.rei.api.gui.widgets.Tooltip; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@ApiStatus.OverrideOnly +public abstract class DisplayRenderer extends AbstractRenderer { + public abstract int getHeight(); + + public final int getWidth() { + return 100; + } + + @Override + public @Nullable Tooltip getTooltip(Point mouse) { + return null; + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/DrawableConsumer.java b/api/src/main/java/me/shedaniel/rei/api/gui/DrawableConsumer.java new file mode 100644 index 000000000..b98b777e5 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/DrawableConsumer.java @@ -0,0 +1,35 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui; + +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.GuiComponent; +import org.jetbrains.annotations.NotNull; + +/** + * Consumer of a {@link DrawableHelper} and information of mouse and delta. + */ +public interface DrawableConsumer { + void render(@NotNull GuiComponent helper, @NotNull PoseStack matrices, int mouseX, int mouseY, float delta); +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/Renderer.java b/api/src/main/java/me/shedaniel/rei/api/gui/Renderer.java new file mode 100644 index 000000000..f76e0ec1a --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/Renderer.java @@ -0,0 +1,43 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui; + +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.gui.widgets.Tooltip; +import org.jetbrains.annotations.Nullable; + +public interface Renderer { + void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta); + + @Nullable + default Tooltip getTooltip(Point mouse) { + return null; + } + + int getZ(); + + void setZ(int z); +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/SimpleDisplayRenderer.java b/api/src/main/java/me/shedaniel/rei/api/gui/SimpleDisplayRenderer.java new file mode 100644 index 000000000..3f42e72b2 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/SimpleDisplayRenderer.java @@ -0,0 +1,165 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui; + +import com.google.common.collect.Maps; +import com.mojang.blaze3d.vertex.PoseStack; +import it.unimi.dsi.fastutil.ints.IntOpenHashSet; +import it.unimi.dsi.fastutil.ints.IntSet; +import me.shedaniel.architectury.utils.Fraction; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.gui.widgets.Slot; +import me.shedaniel.rei.api.gui.widgets.Tooltip; +import me.shedaniel.rei.api.gui.widgets.Widgets; +import me.shedaniel.rei.api.ingredient.EntryIngredient; +import me.shedaniel.rei.api.ingredient.EntryStack; +import me.shedaniel.rei.api.ingredient.util.EntryStacks; +import me.shedaniel.rei.api.util.CollectionUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +public class SimpleDisplayRenderer extends DisplayRenderer { + private static final Comparator> ENTRY_COMPARATOR = Comparator.comparingLong(EntryStacks::hashExact); + private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); + private List inputWidgets; + private List outputWidgets; + + @ApiStatus.Internal + private SimpleDisplayRenderer(List input, List output) { + this.inputWidgets = simplify(input).stream().filter(stacks -> !stacks.isEmpty()).map(stacks -> Widgets.createSlot(new Point(0, 0)).entries(stacks).disableBackground().disableHighlight().disableTooltips()).collect(Collectors.toList()); + this.outputWidgets = CollectionUtils.map(simplify(output), outputStacks -> + Widgets.createSlot(new Point(0, 0)).entries(CollectionUtils.filter(outputStacks, stack -> !stack.isEmpty())).disableBackground().disableHighlight().disableTooltips()); + } + + private static List simplify(List original) { + Map> inputCounter = Maps.newLinkedHashMap(); + original.stream().collect(Collectors.groupingBy(stacks -> CollectionUtils.mapAndMax(stacks, EntryStack::getAmount, Fraction::compareTo).orElse(Fraction.zero()))) + .forEach((fraction, value) -> { + if (!fraction.equals(Fraction.zero())) { + value.forEach(stackList -> { + EntryIngredient stacks = inputCounter.keySet().stream().filter(s -> equalsList(stackList, s)).findFirst().orElse(stackList); + AtomicReference reference = inputCounter.computeIfAbsent(stacks, s -> new AtomicReference<>(Fraction.zero())); + reference.set(reference.get().add(fraction)); + }); + } + }); + return inputCounter.entrySet().stream().map(entry -> EntryIngredient.of(CollectionUtils.map(entry.getKey(), stack -> { + EntryStack s = stack.copy(); + s.setAmount(entry.getValue().get()); + return s; + }))).collect(Collectors.toList()); + } + + public static DisplayRenderer from(Supplier> input, Supplier> output) { + return from(input.get(), output.get()); + } + + public static DisplayRenderer from(List input, List output) { + return new SimpleDisplayRenderer(input, output); + } + + public static boolean equalsList(EntryIngredient left, EntryIngredient right) { + IntSet leftBytes = new IntOpenHashSet(left.size()); + for (EntryStack entryStack : left) { + leftBytes.add(EntryStacks.hashIgnoreCount(entryStack)); + } + if (leftBytes.size() > right.size()) return false; + IntSet rightBytes = new IntOpenHashSet(right.size()); + for (EntryStack entryStack : right) { + rightBytes.add(EntryStacks.hashIgnoreCount(entryStack)); + + if (rightBytes.size() > leftBytes.size()) return false; + } + return leftBytes.equals(rightBytes); + } + + @Override + public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { + int xx = bounds.x + 4, yy = bounds.y + 2; + int j = 0; + int itemsPerLine = getItemsPerLine(); + for (Slot entryWidget : inputWidgets) { + entryWidget.setZ(getZ() + 50); + entryWidget.getBounds().setLocation(xx, yy); + entryWidget.render(matrices, mouseX, mouseY, delta); + xx += 18; + j++; + if (j >= getItemsPerLine() - 2) { + yy += 18; + xx = bounds.x + 4; + j = 0; + } + } + xx = bounds.x + 4 + 18 * (getItemsPerLine() - 2); + yy = bounds.y + getHeight() / 2 - 8; + Minecraft.getInstance().getTextureManager().bind(CHEST_GUI_TEXTURE); + blit(matrices, xx, yy, 0, 28, 18, 18); + xx += 18; + yy += outputWidgets.size() * -9 + 9; + for (Slot outputWidget : outputWidgets) { + outputWidget.setZ(getZ() + 50); + outputWidget.getBounds().setLocation(xx, yy); + outputWidget.render(matrices, mouseX, mouseY, delta); + } + } + + @Nullable + @Override + public Tooltip getTooltip(Point point) { + for (Slot widget : inputWidgets) { + if (widget.containsMouse(point)) + return widget.getCurrentTooltip(point); + } + for (Slot widget : outputWidgets) { + if (widget.containsMouse(point)) + return widget.getCurrentTooltip(point); + } + return null; + } + + @Override + public int getHeight() { + return 4 + getItemsHeight() * 18; + } + + public int getItemsHeight() { + return Mth.ceil(((float) inputWidgets.size()) / (getItemsPerLine() - 2)); + } + + public int getItemsPerLine() { + return Mth.floor((getWidth() - 4f) / 18f); + } + +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/config/AppearanceTheme.java b/api/src/main/java/me/shedaniel/rei/api/gui/config/AppearanceTheme.java new file mode 100644 index 000000000..3d0f3d211 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/config/AppearanceTheme.java @@ -0,0 +1,44 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui.config; + +import me.shedaniel.clothconfig2.gui.entries.SelectionListEntry; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.resources.language.I18n; +import org.jetbrains.annotations.NotNull; + +import java.util.Locale; + +@Environment(EnvType.CLIENT) +public enum AppearanceTheme implements SelectionListEntry.Translatable { + LIGHT, + DARK; + + @Override + @NotNull + public String getKey() { + return I18n.get("config.roughlyenoughitems.theme." + name().toLowerCase(Locale.ROOT)); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/config/ConfigButtonPosition.java b/api/src/main/java/me/shedaniel/rei/api/gui/config/ConfigButtonPosition.java new file mode 100644 index 000000000..a77fc32a7 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/config/ConfigButtonPosition.java @@ -0,0 +1,44 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui.config; + +import me.shedaniel.clothconfig2.gui.entries.SelectionListEntry; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.resources.language.I18n; +import org.jetbrains.annotations.NotNull; + +import java.util.Locale; + +@Environment(EnvType.CLIENT) +public enum ConfigButtonPosition implements SelectionListEntry.Translatable { + UPPER, + LOWER; + + @Override + @NotNull + public String getKey() { + return I18n.get("config.roughlyenoughitems.layout.configButtonLocation." + name().toLowerCase(Locale.ROOT)); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/config/DisplayPanelLocation.java b/api/src/main/java/me/shedaniel/rei/api/gui/config/DisplayPanelLocation.java new file mode 100644 index 000000000..34e0807d2 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/config/DisplayPanelLocation.java @@ -0,0 +1,49 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui.config; + +import me.shedaniel.clothconfig2.gui.entries.SelectionListEntry; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.resources.language.I18n; +import org.jetbrains.annotations.NotNull; + +import java.util.Locale; + +@Environment(EnvType.CLIENT) +public enum DisplayPanelLocation implements SelectionListEntry.Translatable { + LEFT, + RIGHT; + + public DisplayPanelLocation mirror() { + if (this == LEFT) return RIGHT; + return LEFT; + } + + @Override + @NotNull + public String getKey() { + return I18n.get("config.roughlyenoughitems.accessibility.displayPanelLocation." + name().toLowerCase(Locale.ROOT)); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/config/EntryPanelOrdering.java b/api/src/main/java/me/shedaniel/rei/api/gui/config/EntryPanelOrdering.java new file mode 100644 index 000000000..c387b4061 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/config/EntryPanelOrdering.java @@ -0,0 +1,40 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui.config; + +public enum EntryPanelOrdering { + REGISTRY("ordering.rei.registry"), + NAME("ordering.rei.name"), + GROUPS("ordering.rei.item_groups"); + + private String nameTranslationKey; + + EntryPanelOrdering(String nameTranslationKey) { + this.nameTranslationKey = nameTranslationKey; + } + + public String getNameTranslationKey() { + return nameTranslationKey; + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/config/EntryPanelOrderingConfig.java b/api/src/main/java/me/shedaniel/rei/api/gui/config/EntryPanelOrderingConfig.java new file mode 100644 index 000000000..22a501ce5 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/config/EntryPanelOrderingConfig.java @@ -0,0 +1,64 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui.config; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.resources.language.I18n; + +@Environment(EnvType.CLIENT) +public enum EntryPanelOrderingConfig { + REGISTRY_ASCENDING(EntryPanelOrdering.REGISTRY, true), + NAME_ASCENDING(EntryPanelOrdering.NAME, true), + GROUPS_ASCENDING(EntryPanelOrdering.GROUPS, true), + REGISTRY_DESCENDING(EntryPanelOrdering.REGISTRY, false), + NAME_DESCENDING(EntryPanelOrdering.NAME, false), + GROUPS_DESCENDING(EntryPanelOrdering.GROUPS, false); + + private EntryPanelOrdering ordering; + private boolean isAscending; + + EntryPanelOrderingConfig(EntryPanelOrdering ordering, boolean isAscending) { + this.ordering = ordering; + this.isAscending = isAscending; + } + + public static EntryPanelOrderingConfig from(EntryPanelOrdering ordering, boolean isAscending) { + int index = ordering.ordinal() + (isAscending ? 0 : 3); + return values()[index]; + } + + public EntryPanelOrdering getOrdering() { + return ordering; + } + + public boolean isAscending() { + return isAscending; + } + + @Override + public String toString() { + return I18n.get("config.roughlyenoughitems.list_ordering_button", I18n.get(getOrdering().getNameTranslationKey()), I18n.get(isAscending ? "ordering.rei.ascending" : "ordering.rei.descending")); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/config/ItemCheatingMode.java b/api/src/main/java/me/shedaniel/rei/api/gui/config/ItemCheatingMode.java new file mode 100644 index 000000000..235fe11fd --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/config/ItemCheatingMode.java @@ -0,0 +1,41 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui.config; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.resources.language.I18n; + +import java.util.Locale; + +@Environment(EnvType.CLIENT) +public enum ItemCheatingMode { + REI_LIKE, + JEI_LIKE; + + @Override + public String toString() { + return I18n.get("config.roughlyenoughitems.itemCheatingMode." + name().toLowerCase(Locale.ROOT)); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/config/ItemCheatingStyle.java b/api/src/main/java/me/shedaniel/rei/api/gui/config/ItemCheatingStyle.java new file mode 100644 index 000000000..2500fb0f7 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/config/ItemCheatingStyle.java @@ -0,0 +1,44 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui.config; + +import me.shedaniel.clothconfig2.gui.entries.SelectionListEntry; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.resources.language.I18n; +import org.jetbrains.annotations.NotNull; + +import java.util.Locale; + +@Environment(EnvType.CLIENT) +public enum ItemCheatingStyle implements SelectionListEntry.Translatable { + GRAB, + GIVE; + + @Override + @NotNull + public String getKey() { + return I18n.get("config.roughlyenoughitems.cheatingStyle." + name().toLowerCase(Locale.ROOT)); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/config/RecipeBorderType.java b/api/src/main/java/me/shedaniel/rei/api/gui/config/RecipeBorderType.java new file mode 100644 index 000000000..07924a287 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/config/RecipeBorderType.java @@ -0,0 +1,62 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.api.gui.config; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.resources.language.I18n; + +import java.util.Locale; + +@Environment(EnvType.CLIENT) +public enum RecipeBorderType { + DEFAULT(66), + LIGHTER(0), + NONE(0, false); + + private int offset; + private boolean render; + + RecipeBorderType(int offset) { + this(offset, true); + } + + RecipeBorderType(int offset, boolean render) { + this.offset = offset; + this.render = render; + } + + public int getYOffset() { + return offset; + } + + public boolean isRendering() { + return render; + } + + @Override + public String toString() { + return I18n.get("config.roughlyenoughitems.recipeBorder." + name().toLowerCase(Locale.ROOT)); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/config/RecipeScreenType.java b/api/src/main/java/me/shedaniel/rei/api/gui/config/RecipeScreenType.java new file mode 100644 index 000000000..63ebd814c --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/gui/config/RecipeScreenType.java @@ -0,0 +1,44 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei