From b657842bcddcb65fb658d4cd9835e7fa15e1c236 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 16 May 2021 17:45:22 +0800 Subject: Update JEI API to 7.6.4 & Fix #520 --- .../common/entry/comparison/EntryComparator.java | 85 ++++++++++++++++++++++ .../entry/comparison/EntryComparatorRegistry.java | 49 +++++++++++++ .../entry/comparison/FluidComparatorRegistry.java | 45 ++++++++++++ .../common/entry/comparison/ItemComparator.java | 76 ------------------- .../entry/comparison/ItemComparatorRegistry.java | 28 +------ .../rei/api/common/plugins/REIPlugin.java | 10 +++ 6 files changed, 192 insertions(+), 101 deletions(-) create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparatorRegistry.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java delete mode 100644 api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparator.java (limited to 'api/src/main/java/me') diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java new file mode 100644 index 000000000..c40966887 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java @@ -0,0 +1,85 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.common.entry.comparison; + +import me.shedaniel.architectury.fluid.FluidStack; +import me.shedaniel.rei.impl.Internals; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.world.item.ItemStack; + +import java.util.Objects; +import java.util.function.ToLongFunction; + +/** + * Hasher implementation for {@link T}. + */ +@FunctionalInterface +public interface EntryComparator { + static EntryComparator noop() { + return (context, stack) -> 1; + } + + static EntryComparator itemNbt() { + ToLongFunction nbtHasher = nbtHasher("Count"); + return (context, stack) -> { + CompoundTag tag = stack.getTag(); + return tag == null ? 0L : nbtHasher.applyAsLong(tag); + }; + } + + static EntryComparator fluidNbt() { + ToLongFunction nbtHasher = nbtHasher("Amount"); + return (context, stack) -> { + CompoundTag tag = stack.getTag(); + return tag == null ? 0L : nbtHasher.applyAsLong(tag); + }; + } + + static ToLongFunction nbtHasher(String... ignoredKeys) { + return Internals.getNbtHasher(ignoredKeys); + } + + long hash(ComparisonContext context, T stack); + + default EntryComparator onlyExact() { + EntryComparator self = this; + + return (context, stack) -> { + return context.isExact() ? self.hash(context, stack) : 1; + }; + } + + default EntryComparator then(EntryComparator other) { + Objects.requireNonNull(other); + EntryComparator self = this; + + return (context, stack) -> { + long hash = 1L; + hash = hash * 31 + self.hash(context, stack); + hash = hash * 31 + other.hash(context, stack); + return hash; + }; + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparatorRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparatorRegistry.java new file mode 100644 index 000000000..ba77326e6 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparatorRegistry.java @@ -0,0 +1,49 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.common.entry.comparison; + +import me.shedaniel.rei.api.common.plugins.REIPlugin; +import me.shedaniel.rei.api.common.registry.Reloadable; + +/** + * Registry for registering custom methods for identifying variants of {@link T}. + * The default comparator is {@link EntryComparator#noop()}, which does not compare the NBT of the entries. + *

+ * This comparator is used when the comparison context is {@link ComparisonContext#EXACT}. + */ +public interface EntryComparatorRegistry extends Reloadable> { + void register(EntryComparator comparator, S entry); + + default void register(EntryComparator comparator, S... entries) { + for (S entry : entries) { + register(comparator, entry); + } + } + + long hashOf(ComparisonContext context, T stack); + + boolean containsComparator(S entry); + + int comparatorSize(); +} diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java new file mode 100644 index 000000000..f8489ef2e --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/FluidComparatorRegistry.java @@ -0,0 +1,45 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.common.entry.comparison; + +import me.shedaniel.architectury.fluid.FluidStack; +import me.shedaniel.rei.api.common.plugins.PluginManager; +import net.minecraft.world.level.material.Fluid; + +public interface FluidComparatorRegistry extends EntryComparatorRegistry { + /** + * @return the instance of {@link FluidComparatorRegistry} + */ + static FluidComparatorRegistry getInstance() { + return PluginManager.getInstance().get(FluidComparatorRegistry.class); + } + + default void registerNbt(Fluid fluid) { + register(EntryComparator.fluidNbt(), fluid); + } + + default void registerNbt(Fluid... fluids) { + register(EntryComparator.fluidNbt(), fluids); + } +} diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparator.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparator.java deleted file mode 100644 index 09c36cec6..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparator.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021 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.common.entry.comparison; - -import me.shedaniel.rei.impl.Internals; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.world.item.ItemStack; - -import java.util.Objects; -import java.util.function.ToLongFunction; - -/** - * Hasher implementation for {@link ItemStack}. - */ -@FunctionalInterface -public interface ItemComparator { - static ItemComparator noop() { - return (context, stack) -> 1; - } - - static ItemComparator itemNbt() { - ToLongFunction nbtHasher = nbtHasher("Count"); - return (context, stack) -> { - CompoundTag tag = stack.getTag(); - return tag == null ? 0L : nbtHasher.applyAsLong(tag); - }; - } - - static ToLongFunction nbtHasher(String... ignoredKeys) { - return Internals.getNbtHasher(ignoredKeys); - } - - long hash(ComparisonContext context, ItemStack stack); - - default ItemComparator onlyExact() { - ItemComparator self = this; - - return (context, stack) -> { - return context.isExact() ? self.hash(context, stack) : 1; - }; - } - - default ItemComparator then(ItemComparator other) { - Objects.requireNonNull(other); - ItemComparator self = this; - - return (context, stack) -> { - long hash = 1L; - hash = hash * 31 + self.hash(context, stack); - hash = hash * 31 + other.hash(context, stack); - return hash; - }; - } -} diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java index 99f8a0038..299eab648 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ItemComparatorRegistry.java @@ -24,18 +24,10 @@ package me.shedaniel.rei.api.common.entry.comparison; import me.shedaniel.rei.api.common.plugins.PluginManager; -import me.shedaniel.rei.api.common.plugins.REIPlugin; -import me.shedaniel.rei.api.common.registry.Reloadable; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -/** - * Registry for registering custom methods for identifying variants of {@link net.minecraft.world.item.ItemStack}. - * The default comparator is {@link ItemComparator#noop()}, which does not compare the NBT of the items. - *

- * This comparator is used when the comparison context is {@link ComparisonContext#EXACT}. - */ -public interface ItemComparatorRegistry extends Reloadable> { +public interface ItemComparatorRegistry extends EntryComparatorRegistry { /** * @return the instance of {@link ItemComparatorRegistry} */ @@ -43,25 +35,11 @@ public interface ItemComparatorRegistry extends Reloadable> { return PluginManager.getInstance().get(ItemComparatorRegistry.class); } - void register(ItemComparator comparator, Item item); - - default void register(ItemComparator comparator, Item... items) { - for (Item item : items) { - register(comparator, item); - } - } - default void registerNbt(Item item) { - register(ItemComparator.itemNbt(), item); + register(EntryComparator.itemNbt(), item); } default void registerNbt(Item... items) { - register(ItemComparator.itemNbt(), items); + register(EntryComparator.itemNbt(), items); } - - long hashOf(ComparisonContext context, ItemStack stack); - - boolean containsComparator(Item item); - - int comparatorSize(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java index 0c5559f05..44998c914 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.api.common.plugins; import me.shedaniel.rei.api.common.display.DisplaySerializerRegistry; +import me.shedaniel.rei.api.common.entry.comparison.FluidComparatorRegistry; import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry; import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry; import me.shedaniel.rei.api.common.fluid.FluidSupportProvider; @@ -68,6 +69,15 @@ public interface REIPlugin

> extends Comparable Date: Sun, 16 May 2021 19:26:43 +0800 Subject: Add abstraction for IRecipesGui, fix #529 --- .../me/shedaniel/rei/api/client/REIHelper.java | 5 ++- .../me/shedaniel/rei/api/client/REIOverlay.java | 39 ------------------- .../rei/api/client/gui/screen/DisplayScreen.java | 10 +++-- .../rei/api/client/gui/widgets/TextField.java | 4 +- .../rei/api/client/overlay/OverlayListWidget.java | 39 +++++++++++++++++++ .../rei/api/client/overlay/ScreenOverlay.java | 45 ++++++++++++++++++++++ .../rei/api/client/view/ViewSearchBuilder.java | 17 ++------ .../me/shedaniel/rei/api/client/view/Views.java | 33 ---------------- 8 files changed, 99 insertions(+), 93 deletions(-) delete mode 100644 api/src/main/java/me/shedaniel/rei/api/client/REIOverlay.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java create mode 100644 api/src/main/java/me/shedaniel/rei/api/client/overlay/ScreenOverlay.java (limited to 'api/src/main/java/me') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/REIHelper.java b/api/src/main/java/me/shedaniel/rei/api/client/REIHelper.java index b8066133b..94d57de3b 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/REIHelper.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/REIHelper.java @@ -27,6 +27,7 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.config.SearchFieldLocation; import me.shedaniel.rei.api.client.gui.widgets.TextField; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.overlay.ScreenOverlay; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; @@ -52,11 +53,11 @@ public interface REIHelper extends Reloadable { void toggleOverlayVisible(); - default Optional getOverlay() { + default Optional getOverlay() { return getOverlay(false); } - Optional getOverlay(boolean reset); + Optional getOverlay(boolean reset); @Nullable AbstractContainerScreen getPreviousContainerScreen(); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/REIOverlay.java b/api/src/main/java/me/shedaniel/rei/api/client/REIOverlay.java deleted file mode 100644 index 9d6778237..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/REIOverlay.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020, 2021 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.client; - -import me.shedaniel.rei.api.client.gui.drag.DraggingContext; -import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; -import org.jetbrains.annotations.ApiStatus; - -public abstract class REIOverlay extends WidgetWithBounds { - @ApiStatus.Internal - public abstract void closeOverlayMenu(); - - public abstract void queueReloadOverlay(); - - public abstract DraggingContext getDraggingContext(); - - public abstract boolean isNotInExclusionZones(double mouseX, double mouseY); -} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java index 68c4a0205..9174d9112 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java @@ -29,16 +29,18 @@ import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryStack; +import java.util.List; + public interface DisplayScreen { Rectangle getBounds(); - void setIngredientStackToNotice(EntryStack stack); + void addIngredientToNotice(EntryStack stack); - void setResultStackToNotice(EntryStack stack); + void addResultToNotice(EntryStack stack); - EntryStack getIngredientStackToNotice(); + List> getIngredientsToNotice(); - EntryStack getResultStackToNotice(); + List> getResultsToNotice(); default CategoryIdentifier getCurrentCategoryId() { return getCurrentCategory().getCategoryIdentifier(); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TextField.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TextField.java index 0f1c55142..51f039421 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TextField.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TextField.java @@ -52,9 +52,9 @@ public interface TextField { void setEditableColor(int editableColor); - void setNotEditableColor(int int_1); + void setNotEditableColor(int notEditableColor); boolean isFocused(); - void setFocused(boolean boolean_1); + void setFocused(boolean focused); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java b/api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java new file mode 100644 index 000000000..b3752af2e --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java @@ -0,0 +1,39 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.client.overlay; + +import me.shedaniel.rei.api.common.entry.EntryStack; + +import java.util.stream.Stream; + +public interface OverlayListWidget { + /** + * Returns the mouse hovered stack within the overlay list widget. + * + * @return the mouse hovered stack, returns {@link EntryStack#empty()} if none is hovered + */ + EntryStack getFocusedStacK(); + + Stream> getEntries(); +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/overlay/ScreenOverlay.java b/api/src/main/java/me/shedaniel/rei/api/client/overlay/ScreenOverlay.java new file mode 100644 index 000000000..01aa56e38 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/overlay/ScreenOverlay.java @@ -0,0 +1,45 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.client.overlay; + +import me.shedaniel.rei.api.client.gui.drag.DraggingContext; +import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; +import org.jetbrains.annotations.ApiStatus; + +import java.util.Optional; + +public abstract class ScreenOverlay extends WidgetWithBounds { + @ApiStatus.Internal + public abstract void closeOverlayMenu(); + + public abstract void queueReloadOverlay(); + + public abstract DraggingContext getDraggingContext(); + + public abstract boolean isNotInExclusionZones(double mouseX, double mouseY); + + public abstract OverlayListWidget getEntryList(); + + public abstract Optional getFavoritesList(); +} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java b/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java index 2dd4b0cff..589970db9 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java @@ -23,6 +23,7 @@ package me.shedaniel.rei.api.client.view; +import me.shedaniel.rei.api.client.ClientHelper; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.category.CategoryIdentifier; @@ -65,19 +66,9 @@ public interface ViewSearchBuilder { @Nullable CategoryIdentifier getPreferredOpenedCategory(); - ViewSearchBuilder fillPreferredOpenedCategory(); - - ViewSearchBuilder setInputNotice(@Nullable EntryStack stack); - - @Nullable - EntryStack getInputNotice(); - - ViewSearchBuilder setOutputNotice(@Nullable EntryStack stack); - - @Nullable - EntryStack getOutputNotice(); - Map, List> buildMap(); - + default boolean open() { + return ClientHelper.getInstance().openView(this); + } } \ No newline at end of file diff --git a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java index 731c94f15..6ddd1b416 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java @@ -24,26 +24,17 @@ package me.shedaniel.rei.api.client.view; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; -import me.shedaniel.rei.api.client.registry.display.DisplayCategory; -import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; -import org.jetbrains.annotations.ApiStatus; import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; public interface Views extends Reloadable { static Views getInstance() { return PluginManager.getClientInstance().get(Views.class); } - @ApiStatus.Internal - Map, List> buildMapFor(ViewSearchBuilder builder); - /** * Returns all craftable items from materials. * @@ -51,28 +42,4 @@ public interface Views extends Reloadable { * @return the list of craftable entries */ Collection> findCraftableEntriesByMaterials(Iterable> inventoryItems); - - /** - * Returns a map of recipes for an entry - * - * @param stack the stack to be crafted - * @return the map of recipes - */ - default Map, List> getRecipesFor(EntryStack stack) { - return ViewSearchBuilder.builder().addRecipesFor(stack).setInputNotice(stack).buildMap(); - } - - /** - * Returns a map of usages for an entry - * - * @param stack the stack to be used - * @return the map of recipes - */ - default Map, List> getUsagesFor(EntryStack stack) { - return ViewSearchBuilder.builder().addUsagesFor(stack).setInputNotice(stack).buildMap(); - } - - default Map, List> getAllRecipes() { - return ViewSearchBuilder.builder().addAllCategories().buildMap(); - } } -- cgit