From ea634e7ba29146d4ebc2c05b61257fa6c3b0642e Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 5 Feb 2021 10:08:44 +0800 Subject: More relocation Signed-off-by: shedaniel --- .../me/shedaniel/rei/api/AutoTransferHandler.java | 25 +- .../me/shedaniel/rei/api/BaseBoundsHandler.java | 62 ---- .../java/me/shedaniel/rei/api/BuiltinPlugin.java | 2 +- .../me/shedaniel/rei/api/ButtonAreaSupplier.java | 1 - .../java/me/shedaniel/rei/api/ClientHelper.java | 6 +- .../java/me/shedaniel/rei/api/ConfigObject.java | 1 + .../main/java/me/shedaniel/rei/api/Display.java | 68 ++++ .../shedaniel/rei/api/DisplayBoundsRegistry.java | 99 ++++++ .../java/me/shedaniel/rei/api/DisplayHelper.java | 100 ------ .../rei/api/DisplayVisibilityHandler.java | 10 +- .../me/shedaniel/rei/api/DrawableConsumer.java | 35 --- .../java/me/shedaniel/rei/api/EntryRegistry.java | 1 + .../main/java/me/shedaniel/rei/api/EntryStack.java | 203 ------------ .../java/me/shedaniel/rei/api/ExclusionZones.java | 61 ++++ .../me/shedaniel/rei/api/FocusedStackProvider.java | 8 +- .../me/shedaniel/rei/api/LiveRecipeGenerator.java | 3 +- .../main/java/me/shedaniel/rei/api/REIPlugin.java | 49 +++ .../java/me/shedaniel/rei/api/REIPluginEntry.java | 44 --- .../java/me/shedaniel/rei/api/RecipeCategory.java | 131 -------- .../java/me/shedaniel/rei/api/RecipeDisplay.java | 74 ----- .../java/me/shedaniel/rei/api/RecipeHelper.java | 300 ------------------ .../java/me/shedaniel/rei/api/RecipeRegistry.java | 265 ++++++++++++++++ .../main/java/me/shedaniel/rei/api/Renderer.java | 43 --- .../me/shedaniel/rei/api/TextRepresentable.java | 44 --- .../java/me/shedaniel/rei/api/TransferDisplay.java | 46 +++ .../shedaniel/rei/api/TransferDisplayCategory.java | 38 +++ .../shedaniel/rei/api/TransferRecipeCategory.java | 37 --- .../shedaniel/rei/api/TransferRecipeDisplay.java | 44 --- .../rei/api/entry/AbstractEntryRenderer.java | 29 -- .../shedaniel/rei/api/entry/AbstractRenderer.java | 39 --- .../rei/api/entry/BatchEntryRenderer.java | 61 ---- .../shedaniel/rei/api/entry/BuiltinEntryTypes.java | 37 --- .../shedaniel/rei/api/entry/ComparisonContext.java | 59 ---- .../shedaniel/rei/api/entry/EntryDefinition.java | 82 ----- .../me/shedaniel/rei/api/entry/EntryRenderer.java | 38 --- .../me/shedaniel/rei/api/entry/EntryStacks.java | 187 ----------- .../java/me/shedaniel/rei/api/entry/EntryType.java | 48 --- .../shedaniel/rei/api/entry/EntryTypeBridge.java | 36 --- .../shedaniel/rei/api/entry/EntryTypeRegistry.java | 50 --- .../shedaniel/rei/api/entry/VanillaEntryTypes.java | 35 --- .../shedaniel/rei/api/favorites/FavoriteEntry.java | 6 +- .../rei/api/fluid/FluidSupportProvider.java | 2 +- .../rei/api/ingredient/EntryIngredient.java | 25 ++ .../shedaniel/rei/api/ingredient/EntryStack.java | 205 +++++++++++++ .../ingredient/entry/AbstractEntryRenderer.java | 29 ++ .../rei/api/ingredient/entry/AbstractRenderer.java | 39 +++ .../api/ingredient/entry/BatchEntryRenderer.java | 61 ++++ .../api/ingredient/entry/BuiltinEntryTypes.java | 38 +++ .../api/ingredient/entry/ComparisonContext.java | 59 ++++ .../rei/api/ingredient/entry/EntryDefinition.java | 82 +++++ .../rei/api/ingredient/entry/EntryRenderer.java | 38 +++ .../rei/api/ingredient/entry/EntryType.java | 48 +++ .../rei/api/ingredient/entry/EntryTypeBridge.java | 36 +++ .../api/ingredient/entry/EntryTypeRegistry.java | 50 +++ .../api/ingredient/entry/VanillaEntryTypes.java | 35 +++ .../rei/api/ingredient/util/EntryIngredients.java | 95 ++++++ .../rei/api/ingredient/util/EntryStacks.java | 195 ++++++++++++ .../me/shedaniel/rei/api/plugins/REIPluginV0.java | 31 +- .../rei/api/registry/CategoryRegistry.java | 54 ++++ .../rei/api/registry/category/DisplayCategory.java | 133 ++++++++ .../shedaniel/rei/api/server/ContainerContext.java | 39 +++ .../me/shedaniel/rei/api/server/ContainerInfo.java | 118 +++++++ .../rei/api/server/ContainerInfoHandler.java | 56 ++++ .../me/shedaniel/rei/api/server/DumpHandler.java | 58 ++++ .../shedaniel/rei/api/server/GridCleanHandler.java | 50 +++ .../rei/api/server/GridStacksProvider.java | 31 ++ .../rei/api/server/InventoryStackAccessor.java | 52 ++++ .../me/shedaniel/rei/api/server/RecipeFinder.java | 341 +++++++++++++++++++++ .../rei/api/server/RecipeFinderPopulator.java | 35 +++ .../rei/api/server/RecipeGridAligner.java | 44 +++ .../rei/api/server/SlotStackAccessor.java | 50 +++ .../me/shedaniel/rei/api/server/StackAccessor.java | 34 ++ .../shedaniel/rei/api/subsets/SubsetsRegistry.java | 2 +- .../shedaniel/rei/api/util/DrawableConsumer.java | 35 +++ .../java/me/shedaniel/rei/api/util/Renderer.java | 43 +++ .../shedaniel/rei/api/util/TextRepresentable.java | 44 +++ .../java/me/shedaniel/rei/api/widgets/Slot.java | 2 +- .../java/me/shedaniel/rei/api/widgets/Widgets.java | 2 +- .../shedaniel/rei/gui/entries/DisplayRenderer.java | 44 +++ .../shedaniel/rei/gui/entries/RecipeRenderer.java | 44 --- .../rei/gui/entries/SimpleDisplayRenderer.java | 165 ++++++++++ .../rei/gui/entries/SimpleRecipeRenderer.java | 159 ---------- .../main/java/me/shedaniel/rei/impl/Internals.java | 19 +- .../java/me/shedaniel/rei/impl/RenderingEntry.java | 115 ------- .../me/shedaniel/rei/server/ContainerContext.java | 39 --- .../me/shedaniel/rei/server/ContainerInfo.java | 118 ------- .../shedaniel/rei/server/ContainerInfoHandler.java | 56 ---- .../java/me/shedaniel/rei/server/DumpHandler.java | 58 ---- .../me/shedaniel/rei/server/GridCleanHandler.java | 50 --- .../shedaniel/rei/server/GridStacksProvider.java | 31 -- .../rei/server/InventoryStackAccessor.java | 52 ---- .../java/me/shedaniel/rei/server/RecipeFinder.java | 341 --------------------- .../rei/server/RecipeFinderPopulator.java | 35 --- .../me/shedaniel/rei/server/RecipeGridAligner.java | 44 --- .../me/shedaniel/rei/server/SlotStackAccessor.java | 50 --- .../me/shedaniel/rei/server/StackAccessor.java | 34 -- .../me/shedaniel/rei/utils/CollectionUtils.java | 4 +- .../rei/utils/EntryStackCompoundList.java | 44 --- 98 files changed, 3162 insertions(+), 3138 deletions(-) delete mode 100644 api/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/Display.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/DisplayBoundsRegistry.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/DisplayHelper.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/DrawableConsumer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/EntryStack.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ExclusionZones.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/REIPlugin.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/RecipeCategory.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/RecipeHelper.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/RecipeRegistry.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/Renderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/TextRepresentable.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/TransferDisplay.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/TransferDisplayCategory.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/TransferRecipeCategory.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/AbstractEntryRenderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/AbstractRenderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/BatchEntryRenderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/BuiltinEntryTypes.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/ComparisonContext.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/EntryDefinition.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/EntryRenderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/EntryStacks.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/EntryType.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/EntryTypeBridge.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/EntryTypeRegistry.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/entry/VanillaEntryTypes.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/EntryIngredient.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/EntryStack.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/entry/AbstractEntryRenderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/entry/AbstractRenderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/entry/BatchEntryRenderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/entry/BuiltinEntryTypes.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/entry/ComparisonContext.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryDefinition.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryRenderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryType.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryTypeBridge.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryTypeRegistry.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/entry/VanillaEntryTypes.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/util/EntryIngredients.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/ingredient/util/EntryStacks.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/registry/CategoryRegistry.java create 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/server/ContainerContext.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/server/ContainerInfo.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/server/ContainerInfoHandler.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/server/DumpHandler.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/server/GridCleanHandler.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/server/GridStacksProvider.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/server/InventoryStackAccessor.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/server/RecipeFinder.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/server/RecipeFinderPopulator.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/server/RecipeGridAligner.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/server/SlotStackAccessor.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/server/StackAccessor.java create 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/Renderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/util/TextRepresentable.java create 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/RecipeRenderer.java create mode 100644 api/src/main/java/me/shedaniel/rei/gui/entries/SimpleDisplayRenderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/gui/entries/SimpleRecipeRenderer.java delete mode 100644 api/src/main/java/me/shedaniel/rei/impl/RenderingEntry.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/ContainerContext.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/ContainerInfo.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/ContainerInfoHandler.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/DumpHandler.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/GridCleanHandler.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/GridStacksProvider.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/InventoryStackAccessor.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/RecipeFinder.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/RecipeFinderPopulator.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/RecipeGridAligner.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/SlotStackAccessor.java delete mode 100644 api/src/main/java/me/shedaniel/rei/server/StackAccessor.java delete mode 100644 api/src/main/java/me/shedaniel/rei/utils/EntryStackCompoundList.java (limited to 'api/src/main/java/me/shedaniel') 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 743538410..d4c29fcea 100644 --- a/api/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java +++ b/api/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java @@ -37,7 +37,7 @@ import org.jetbrains.annotations.Nullable; import java.util.function.Supplier; @Environment(EnvType.CLIENT) -public interface AutoTransferHandler { +public interface AutoTransferHandler extends Comparable { /** * @return the priority of this handler, higher priorities will be called first. @@ -49,6 +49,11 @@ public interface AutoTransferHandler { @NotNull Result handle(@NotNull Context context); + @Override + default int compareTo(@NotNull AutoTransferHandler o) { + return Double.compare(getPriority(), o.getPriority()); + } + @ApiStatus.NonExtendable interface Result { /** @@ -90,7 +95,7 @@ public interface AutoTransferHandler { * Creates a passing result, further handlers will be called. * * @param errorKey The error itself - * @param redSlots A list of slots to be marked as red. Will be passed to {@link TransferRecipeCategory}. + * @param redSlots A list of slots to be marked as red. Will be passed to {@link TransferDisplayCategory}. */ static Result createFailed(String errorKey, IntList redSlots) { return new ResultImpl(errorKey, redSlots, 1744764928); @@ -102,7 +107,7 @@ public interface AutoTransferHandler { * * @param errorKey The error itself * @param color A special color for the button - * @param redSlots A list of slots to be marked as red. Will be passed to {@link TransferRecipeCategory}. + * @param redSlots A list of slots to be marked as red. Will be passed to {@link TransferDisplayCategory}. */ static Result createFailedCustomButtonColor(String errorKey, IntList redSlots, int color) { return new ResultImpl(errorKey, redSlots, color); @@ -155,15 +160,15 @@ public interface AutoTransferHandler { String getErrorKey(); /** - * @return a list of slots to be marked as red. Will be passed to {@link TransferRecipeCategory}. + * @return a list of slots to be marked as red. Will be passed to {@link TransferDisplayCategory}. */ IntList getIntegers(); } @ApiStatus.NonExtendable interface Context { - static Context create(boolean actuallyCrafting, AbstractContainerScreen containerScreen, RecipeDisplay recipeDisplay) { - return new ContextImpl(actuallyCrafting, containerScreen, () -> recipeDisplay); + static Context create(boolean actuallyCrafting, AbstractContainerScreen containerScreen, Display display) { + return new ContextImpl(actuallyCrafting, containerScreen, () -> display); } default Minecraft getMinecraft() { @@ -175,7 +180,7 @@ public interface AutoTransferHandler { @Nullable AbstractContainerScreen getContainerScreen(); - RecipeDisplay getRecipe(); + Display getRecipe(); @Nullable default AbstractContainerMenu getContainer() { @@ -259,9 +264,9 @@ public interface AutoTransferHandler { final class ContextImpl implements Context { private boolean actuallyCrafting; private AbstractContainerScreen containerScreen; - private Supplier recipeDisplaySupplier; + private Supplier recipeDisplaySupplier; - private ContextImpl(boolean actuallyCrafting, AbstractContainerScreen containerScreen, Supplier recipeDisplaySupplier) { + private ContextImpl(boolean actuallyCrafting, AbstractContainerScreen containerScreen, Supplier recipeDisplaySupplier) { this.actuallyCrafting = actuallyCrafting; this.containerScreen = containerScreen; this.recipeDisplaySupplier = recipeDisplaySupplier; @@ -278,7 +283,7 @@ public interface AutoTransferHandler { } @Override - public RecipeDisplay getRecipe() { + public Display getRecipe() { return recipeDisplaySupplier.get(); } } diff --git a/api/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java b/api/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java deleted file mode 100644 index 0448bc297..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java +++ /dev/null @@ -1,62 +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.math.Rectangle; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - -import java.util.List; -import java.util.function.Supplier; - -@Environment(EnvType.CLIENT) -public interface BaseBoundsHandler extends OverlayDecider { - - static BaseBoundsHandler getInstance() { - return DisplayHelper.getInstance().getBaseBoundsHandler(); - } - - /** - * Gets the exclusion zones by the screen class - * - * @param currentScreenClass the current screen class - * @return the list of exclusion zones - */ - default List getExclusionZones(Class currentScreenClass) { - return getExclusionZones(currentScreenClass, false); - } - - List getExclusionZones(Class currentScreenClass, boolean sort); - - int supplierSize(); - - /** - * Register an exclusion zone - * - * @param screenClass the screen - * @param supplier the exclusion zone supplier, returns the list of exclusion zones - */ - void registerExclusionZones(Class screenClass, Supplier> supplier); - -} diff --git a/api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java b/api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java index f0d3b112a..852a43476 100644 --- a/api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java +++ b/api/src/main/java/me/shedaniel/rei/api/BuiltinPlugin.java @@ -23,6 +23,7 @@ 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; @@ -42,7 +43,6 @@ public interface BuiltinPlugin { ResourceLocation STONE_CUTTING = new ResourceLocation("minecraft", "plugins/stone_cutting"); ResourceLocation STRIPPING = new ResourceLocation("minecraft", "plugins/stripping"); ResourceLocation BREWING = new ResourceLocation("minecraft", "plugins/brewing"); - ResourceLocation PLUGIN = new ResourceLocation("roughlyenoughitems", "default_plugin"); ResourceLocation COMPOSTING = new ResourceLocation("minecraft", "plugins/composting"); ResourceLocation FUEL = new ResourceLocation("minecraft", "plugins/fuel"); ResourceLocation SMITHING = new ResourceLocation("minecraft", "plugins/smithing"); diff --git a/api/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java b/api/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java index df6214642..64e4b27e8 100644 --- a/api/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java +++ b/api/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java @@ -46,5 +46,4 @@ public interface ButtonAreaSupplier { default String getButtonText() { return "+"; } - } 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 36b61033a..34f5c2213 100644 --- a/api/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/api/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -23,6 +23,8 @@ package me.shedaniel.rei.api; +import me.shedaniel.rei.api.ingredient.EntryStack; +import me.shedaniel.rei.api.registry.category.DisplayCategory; import me.shedaniel.rei.impl.Internals; import me.shedaniel.rei.utils.CollectionUtils; import me.shedaniel.rei.utils.FormattingUtils; @@ -180,7 +182,7 @@ public interface ClientHelper { ViewSearchBuilder addCategories(Collection categories); default ViewSearchBuilder addAllCategories() { - return addCategories(CollectionUtils.map(RecipeHelper.getInstance().getAllCategories(), RecipeCategory::getIdentifier)); + return addCategories(CollectionUtils.map(RecipeRegistry.getInstance().getAllCategories(), DisplayCategory::getIdentifier)); } @NotNull Set getCategories(); @@ -211,6 +213,6 @@ public interface ClientHelper { EntryStack getOutputNotice(); @NotNull - Map, List> buildMap(); + Map, List> buildMap(); } } 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 c84075e79..1eec1243c 100644 --- a/api/src/main/java/me/shedaniel/rei/api/ConfigObject.java +++ b/api/src/main/java/me/shedaniel/rei/api/ConfigObject.java @@ -25,6 +25,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 net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/api/src/main/java/me/shedaniel/rei/api/Display.java b/api/src/main/java/me/shedaniel/rei/api/Display.java new file mode 100644 index 000000000..a99a1797c --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/Display.java @@ -0,0 +1,68 @@ +/* + * 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 new file mode 100644 index 000000000..070fc4460 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/DisplayBoundsRegistry.java @@ -0,0 +1,99 @@ +/* + * 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.math.Rectangle; +import me.shedaniel.rei.gui.config.DisplayPanelLocation; +import me.shedaniel.rei.impl.Internals; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +@Environment(EnvType.CLIENT) +public interface DisplayBoundsRegistry { + + /** + * @return the instance of {@link DisplayBoundsRegistry} + */ + @NotNull + static DisplayBoundsRegistry getInstance() { + return Internals.getDisplayHelper(); + } + + List getSortedOverlayDeciders(Class screenClass); + + /** + * Gets all registered overlay deciders + * + * @return the list of registered overlay deciders + */ + List getAllOverlayDeciders(); + + /** + * Registers a bounds decider + * + * @param decider the decider to register + */ + void registerHandler(OverlayDecider decider); + + default void registerProvider(DisplayBoundsProvider provider) { + registerHandler(provider); + } + + /** + * Gets the left bounds of the overlay + * + * @param screen the current screen + * @return the left bounds + */ + Rectangle getOverlayBounds(DisplayPanelLocation location, T screen); + + @ApiStatus.Experimental + void resetCache(); + + ExclusionZones exclusionZones(); + + interface DisplayBoundsProvider extends OverlayDecider { + /** + * @param screen the screen + * @return the boundary of the base container panel. + */ + Rectangle getScreenBounds(T screen); + + /** + * Gets the base supported class for the bounds handler + * + * @return the base class + */ + Class getBaseSupportedClass(); + + @Override + default boolean isHandingScreen(Class screen) { + return getBaseSupportedClass().isAssignableFrom(screen); + } + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/api/src/main/java/me/shedaniel/rei/api/DisplayHelper.java deleted file mode 100644 index d63896203..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ /dev/null @@ -1,100 +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.math.Rectangle; -import me.shedaniel.rei.gui.config.DisplayPanelLocation; -import me.shedaniel.rei.impl.Internals; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -@Environment(EnvType.CLIENT) -public interface DisplayHelper { - - /** - * @return the instance of {@link me.shedaniel.rei.api.DisplayHelper} - */ - @NotNull - static DisplayHelper getInstance() { - return Internals.getDisplayHelper(); - } - - List getSortedOverlayDeciders(Class screenClass); - - /** - * Gets all registered overlay deciders - * - * @return the list of registered overlay deciders - */ - List getAllOverlayDeciders(); - - /** - * Registers a bounds decider - * - * @param decider the decider to register - */ - void registerHandler(OverlayDecider decider); - - default void registerProvider(DisplayBoundsProvider provider) { - registerHandler(provider); - } - - /** - * Gets the left bounds of the overlay - * - * @param screen the current screen - * @return the left bounds - */ - Rectangle getOverlayBounds(DisplayPanelLocation location, T screen); - - @ApiStatus.Experimental - void resetCache(); - - @ApiStatus.Internal - BaseBoundsHandler getBaseBoundsHandler(); - - interface DisplayBoundsProvider extends OverlayDecider { - /** - * @param screen the screen - * @return the boundary of the base container panel. - */ - Rectangle getScreenBounds(T screen); - - /** - * Gets the base supported class for the bounds handler - * - * @return the base class - */ - Class getBaseSupportedClass(); - - @Override - default boolean isHandingScreen(Class screen) { - return getBaseSupportedClass().isAssignableFrom(screen); - } - } -} 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 82d5c901f..8dcb57197 100644 --- a/api/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java +++ b/api/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java @@ -23,9 +23,11 @@ package me.shedaniel.rei.api; +import me.shedaniel.rei.api.registry.category.DisplayCategory; import net.minecraft.world.InteractionResult; +import org.jetbrains.annotations.NotNull; -public interface DisplayVisibilityHandler { +public interface DisplayVisibilityHandler extends Comparable { /** * Gets the priority of the handler, the higher the priority, the earlier this is called. @@ -46,6 +48,10 @@ public interface DisplayVisibilityHandler { * @param display the display of the recipe * @return the visibility */ - InteractionResult handleDisplay(RecipeCategory category, RecipeDisplay display); + InteractionResult handleDisplay(DisplayCategory category, Display display); + @Override + default int compareTo(@NotNull DisplayVisibilityHandler o) { + return Double.compare(getPriority(), o.getPriority()); + } } diff --git a/api/src/main/java/me/shedaniel/rei/api/DrawableConsumer.java b/api/src/main/java/me/shedaniel/rei/api/DrawableConsumer.java deleted file mode 100644 index 30d65028a..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/DrawableConsumer.java +++ /dev/null @@ -1,35 +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 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/EntryRegistry.java b/api/src/main/java/me/shedaniel/rei/api/EntryRegistry.java index d93701e09..bdf2ef97b 100644 --- a/api/src/main/java/me/shedaniel/rei/api/EntryRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/EntryRegistry.java @@ -23,6 +23,7 @@ package me.shedaniel.rei.api; +import me.shedaniel.rei.api.ingredient.EntryStack; 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/EntryStack.java b/api/src/main/java/me/shedaniel/rei/api/EntryStack.java deleted file mode 100644 index 19204804f..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/EntryStack.java +++ /dev/null @@ -1,203 +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.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.mojang.serialization.Dynamic; -import com.mojang.serialization.JsonOps; -import me.shedaniel.architectury.utils.Fraction; -import me.shedaniel.rei.api.entry.ComparisonContext; -import me.shedaniel.rei.api.entry.EntryDefinition; -import me.shedaniel.rei.api.entry.EntryRenderer; -import me.shedaniel.rei.api.entry.EntryType; -import me.shedaniel.rei.impl.Internals; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.resources.language.I18n; -import net.minecraft.nbt.NbtOps; -import net.minecraft.nbt.TagParser; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.GsonHelper; -import net.minecraft.util.Unit; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.function.Function; -import java.util.function.Supplier; - -@Environment(EnvType.CLIENT) -public interface EntryStack extends TextRepresentable, Renderer { - static EntryStack empty() { - return Internals.getEntryStackProvider().empty(); - } - - static EntryStack of(EntryDefinition definition, T value) { - return Internals.getEntryStackProvider().of(definition, value); - } - - static EntryStack of(EntryType type, T value) { - return of(type.getDefinition(), value); - } - - @ApiStatus.Internal - static EntryStack readFromJson(JsonElement jsonElement) { - try { - JsonObject obj = jsonElement.getAsJsonObject(); - EntryType type = EntryType.deferred(new ResourceLocation(GsonHelper.getAsString(obj, "type"))); - Object o = type.getDefinition().fromTag(TagParser.parseTag(obj.toString())); - return EntryStack.of(type, o); - } catch (Exception e) { - e.printStackTrace(); - return EntryStack.empty(); - } - } - - @ApiStatus.Internal - @Nullable - default JsonElement toJson() { - try { - JsonObject object = Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, getDefinition().toTag(this, getValue())).getAsJsonObject(); - object.addProperty("type", getType().getId().toString()); - return object; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - @NotNull - EntryDefinition getDefinition(); - - @NotNull - default EntryType getType() { - return getDefinition().getType(); - } - - @NotNull - default Class getValueType() { - return getDefinition().getValueType(); - } - - @NotNull - default EntryRenderer getRenderer() { - return getDefinition().getRenderer(); - } - - Optional getIdentifier(); - - Fraction getAmount(); - - void setAmount(Fraction amount); - - boolean isEmpty(); - - EntryStack copy(); - - @ApiStatus.Internal - default EntryStack rewrap() { - return copy(); - } - - @Deprecated - int hashCode(); - - int hash(ComparisonContext context); - - boolean equals(EntryStack other, ComparisonContext context); - - @Deprecated - boolean equals(Object o); - - T getValue(); - - EntryStack setting(Settings settings, R value); - - EntryStack removeSetting(Settings settings); - - EntryStack clearSettings(); - - R get(Settings settings); - - class Settings { - @ApiStatus.Internal - private static final List> SETTINGS = new ArrayList<>(); - - public static final Supplier TRUE = () -> true; - public static final Supplier FALSE = () -> false; - public static final Settings> RENDER = new Settings<>(TRUE); - public static final Settings> CHECK_TAGS = new Settings<>(FALSE); - public static final Settings> CHECK_AMOUNT = new Settings<>(FALSE); - public static final Settings> TOOLTIP_ENABLED = new Settings<>(TRUE); - public static final Settings> TOOLTIP_APPEND_MOD = new Settings<>(TRUE); - public static final Settings> RENDER_COUNTS = new Settings<>(TRUE); - public static final Settings, List>> TOOLTIP_APPEND_EXTRA = new Settings<>(stack -> Collections.emptyList()); - public static final Settings, String>> COUNTS = new Settings<>(stack -> null); - - private static short nextId; - private R defaultValue; - private short id; - - @ApiStatus.Internal - public Settings(R defaultValue) { - this.defaultValue = defaultValue; - this.id = nextId++; - SETTINGS.add(this); - } - - @ApiStatus.Internal - public static Settings getById(short id) { - return (Settings) SETTINGS.get(id); - } - - public R getDefaultValue() { - return defaultValue; - } - - @ApiStatus.Internal - public short getId() { - return id; - } - - public static class Fluid { - // Return null to disable - public static final Settings, String>> AMOUNT_TOOLTIP = new Settings<>(stack -> I18n.get("tooltip.rei.fluid_amount", stack.simplifyAmount().getAmount())); - - private Fluid() { - } - } - - } - - default EntryStack simplifyAmount() { - setAmount(getAmount().simplify()); - return this; - } -} diff --git a/api/src/main/java/me/shedaniel/rei/api/ExclusionZones.java b/api/src/main/java/me/shedaniel/rei/api/ExclusionZones.java new file mode 100644 index 000000000..244437991 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/ExclusionZones.java @@ -0,0 +1,61 @@ +/* + * 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.math.Rectangle; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import java.util.List; +import java.util.function.Supplier; + +@Environment(EnvType.CLIENT) +public interface ExclusionZones extends OverlayDecider { + + static ExclusionZones getInstance() { + return DisplayBoundsRegistry.getInstance().exclusionZones(); + } + + /** + * Gets the exclusion zones by the screen class + * + * @param currentScreenClass the current screen class + * @return the list of exclusion zones + */ + default List getExclusionZones(Class currentScreenClass) { + return getExclusionZones(currentScreenClass, false); + } + + List getExclusionZones(Class currentScreenClass, boolean sort); + + int getZonesCount(); + + /** + * Register an exclusion zone + * + * @param screenClass the screen + * @param supplier the exclusion zone supplier, returns the list of exclusion zones + */ + void register(Class screenClass, Supplier> supplier); +} diff --git a/api/src/main/java/me/shedaniel/rei/api/FocusedStackProvider.java b/api/src/main/java/me/shedaniel/rei/api/FocusedStackProvider.java index be0446f8c..bada29cf6 100644 --- a/api/src/main/java/me/shedaniel/rei/api/FocusedStackProvider.java +++ b/api/src/main/java/me/shedaniel/rei/api/FocusedStackProvider.java @@ -23,11 +23,12 @@ package me.shedaniel.rei.api; +import me.shedaniel.rei.api.ingredient.EntryStack; import net.minecraft.client.gui.screens.Screen; import net.minecraft.world.InteractionResultHolder; import org.jetbrains.annotations.NotNull; -public interface FocusedStackProvider { +public interface FocusedStackProvider extends Comparable { /** * @return the priority of this handler, higher priorities will be called first. */ @@ -37,4 +38,9 @@ public interface FocusedStackProvider { @NotNull InteractionResultHolder> provide(Screen screen); + + @Override + default int compareTo(@NotNull FocusedStackProvider o) { + return Double.compare(getPriority(), o.getPriority()); + } } 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 a4612eda3..dcf2517e6 100644 --- a/api/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java +++ b/api/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java @@ -23,12 +23,13 @@ package me.shedaniel.rei.api; +import me.shedaniel.rei.api.ingredient.EntryStack; import net.minecraft.resources.ResourceLocation; import java.util.List; import java.util.Optional; -public interface LiveRecipeGenerator { +public interface LiveRecipeGenerator { /** * @return the identifier of the category the recipes goes to. diff --git a/api/src/main/java/me/shedaniel/rei/api/REIPlugin.java b/api/src/main/java/me/shedaniel/rei/api/REIPlugin.java new file mode 100644 index 000000000..a7249f647 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/REIPlugin.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; + +import org.jetbrains.annotations.NotNull; + +/** + * Get base class of a REI plugin. + */ +public interface REIPlugin extends Comparable { + /** + * @return the priority of the plugin, the smaller the number, the earlier it is called. + */ + default int getPriority() { + return 0; + } + + default String getPluginName() { + Class self = getClass(); + String simpleName = self.getSimpleName(); + return simpleName == null ? self.getName() : simpleName; + } + + @Override + default int compareTo(@NotNull REIPlugin o) { + return Double.compare(getPriority(), o.getPriority()); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java b/api/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java deleted file mode 100644 index 3285898f2..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java +++ /dev/null @@ -1,44 +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 net.minecraft.resources.ResourceLocation; - -/** - * Get base class of a REI plugin. - */ -public interface REIPluginEntry { - /** - * @return the priority of the plugin, the smaller the number, the earlier it is called. - */ - default int getPriority() { - return 0; - } - - /** - * @return the unique identifier of the plugin. - */ - ResourceLocation getPluginIdentifier(); - -} diff --git a/api/src/main/java/me/shedaniel/rei/api/RecipeCategory.java b/api/src/main/java/me/shedaniel/rei/api/RecipeCategory.java deleted file mode 100644 index cda7af1e6..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/RecipeCategory.java +++ /dev/null @@ -1,131 +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.math.Rectangle; -import me.shedaniel.rei.api.widgets.Widgets; -import me.shedaniel.rei.gui.entries.RecipeRenderer; -import me.shedaniel.rei.gui.entries.SimpleRecipeRenderer; -import me.shedaniel.rei.gui.widget.Widget; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -@Environment(EnvType.CLIENT) -public interface RecipeCategory { - - /** - * Gets the identifier of the category, must be unique - * - * @return the unique identifier of the category - */ - @NotNull - ResourceLocation getIdentifier(); - - /** - * Gets the renderer of the icon, allowing developers to render things other than items - * - * @return the renderer of the icon - */ - @NotNull - default Renderer getLogo() { - return EntryStack.empty(); - } - - /** - * Gets the category name - * - * @return the name - */ - @NotNull - 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 - */ - @ApiStatus.OverrideOnly - @NotNull - default RecipeRenderer getSimpleRenderer(T recipe) { - return SimpleRecipeRenderer.from(recipe::getInputEntries, recipe::getResultingEntries); - } - - /** - * Setup the widgets for displaying the recipe - * - * @param recipeDisplay the recipe - * @param bounds the bounds of the display, configurable with overriding the width, height methods. - * @return the list of widgets - */ - @ApiStatus.OverrideOnly - @NotNull - default List setupDisplay(T recipeDisplay, Rectangle bounds) { - return Collections.singletonList(Widgets.createCategoryBase(bounds)); - } - - /** - * Gets the recipe display height - * - * @return the recipe display height - */ - default int getDisplayHeight() { - return 66; - } - - /** - * Gets the recipe display width - * - * @param display the recipe display - * @return the recipe display width - */ - default int getDisplayWidth(T display) { - return 150; - } - - /** - * Gets the maximum recipe per page. - * - * @return the maximum amount of recipes for page - */ - default int getMaximumRecipePerPage() { - return 99; - } - - /** - * Gets the fixed amount of recipes per page. - * - * @return the amount of recipes, returns -1 if not fixed - */ - default int getFixedRecipesPerPage() { - return -1; - } - -} diff --git a/api/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java b/api/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java deleted file mode 100644 index 582fd09da..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java +++ /dev/null @@ -1,74 +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 net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public interface RecipeDisplay { - - /** - * @return a list of inputs - */ - @NotNull - List>> getInputEntries(); - - /** - * @return a list of outputs - */ - @NotNull - List>> getResultingEntries(); - - /** - * Gets the required items used in craftable filters - * - * @return the list of required items - */ - @NotNull - default List>> getRequiredEntries() { - return Collections.emptyList(); - } - - /** - * Gets the recipe display category identifier - * - * @return the identifier of the category - */ - @NotNull - ResourceLocation getRecipeCategory(); - - /** - * Gets the recipe location from datapack. - * - * @return the recipe location - */ - @NotNull - default Optional getRecipeLocation() { - return Optional.empty(); - } -} diff --git a/api/src/main/java/me/shedaniel/rei/api/RecipeHelper.java b/api/src/main/java/me/shedaniel/rei/api/RecipeHelper.java deleted file mode 100644 index 74351ceda..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/RecipeHelper.java +++ /dev/null @@ -1,300 +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.math.Rectangle; -import me.shedaniel.rei.impl.Internals; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeManager; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Function; -import java.util.function.Predicate; - -@Environment(EnvType.CLIENT) -public interface RecipeHelper { - - /** - * @return the instance of {@link me.shedaniel.rei.api.RecipeHelper} - */ - @NotNull - static RecipeHelper getInstance() { - return Internals.getRecipeHelper(); - } - - AutoTransferHandler registerAutoCraftingHandler(AutoTransferHandler handler); - - void registerFocusedStackProvider(FocusedStackProvider provider); - - @Nullable - @ApiStatus.Internal - EntryStack getScreenFocusedStack(Screen screen); - - List getSortedAutoCraftingHandler(); - - /** - * Gets the total recipe count registered - * - * @return the recipe count - */ - int getRecipeCount(); - - /** - * @return a list of sorted recipes - */ - List> getAllSortedRecipes(); - - /** - * Gets all craftable items from materials. - * - * @param inventoryItems the materials - * @return the list of craftable entries - */ - List> findCraftableEntriesByItems(Iterable> inventoryItems); - - /** - * Gets all craftable items from materials. - * - * @param inventoryItems the materials - * @return the list of craftable entries - */ - default List> findCraftableEntriesByItems(List