diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-11-14 02:36:33 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-11-14 02:36:33 +0800 |
| commit | 760f20e8bdf63ee4af47bb408cdac18e6dd7a591 (patch) | |
| tree | c82c23af4b13334723345612dc65f225f81cf5c3 | |
| parent | 5b99b04e23728c32387183df3719b1f696e994fe (diff) | |
| parent | 57f59e7da8ae83f1ad952e410601409eecf2e1c4 (diff) | |
| download | RoughlyEnoughItems-760f20e8bdf63ee4af47bb408cdac18e6dd7a591.tar.gz RoughlyEnoughItems-760f20e8bdf63ee4af47bb408cdac18e6dd7a591.tar.bz2 RoughlyEnoughItems-760f20e8bdf63ee4af47bb408cdac18e6dd7a591.zip | |
Merge remote-tracking branch 'origin/6.x-1.17' into 7.x-1.18
# Conflicts:
# gradle.properties
81 files changed, 4598 insertions, 826 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/REIRuntime.java b/api/src/main/java/me/shedaniel/rei/api/client/REIRuntime.java index 354c1ce19..1af65d4ad 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/REIRuntime.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/REIRuntime.java @@ -24,18 +24,22 @@ package me.shedaniel.rei.api.client; import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.config.ConfigObject; 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.client.registry.screen.ScreenRegistry; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import java.util.Optional; @@ -54,10 +58,14 @@ public interface REIRuntime extends Reloadable<REIClientPlugin> { void toggleOverlayVisible(); default Optional<ScreenOverlay> getOverlay() { - return getOverlay(false); + return getOverlay(false, false); } - Optional<ScreenOverlay> getOverlay(boolean reset); + default Optional<ScreenOverlay> getOverlay(boolean reset) { + return getOverlay(reset, true); + } + + Optional<ScreenOverlay> getOverlay(boolean reset, boolean init); @Nullable AbstractContainerScreen<?> getPreviousContainerScreen(); @@ -76,7 +84,13 @@ public interface REIRuntime extends Reloadable<REIClientPlugin> { SearchFieldLocation getContextualSearchFieldLocation(); - Rectangle calculateEntryListArea(); + @ApiStatus.ScheduledForRemoval + @Deprecated + default Rectangle calculateEntryListArea() { + return calculateEntryListArea(ScreenRegistry.getInstance().getOverlayBounds(ConfigObject.getInstance().getDisplayPanelLocation(), Minecraft.getInstance().screen)); + } + + Rectangle calculateEntryListArea(Rectangle bounds); Rectangle calculateFavoritesListArea(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java index 20165ffc1..8d35049c2 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.api.client.config; import me.shedaniel.clothconfig2.api.ModifierKeyCode; +import me.shedaniel.rei.api.client.config.entry.EntryStackProvider; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.gui.config.*; import me.shedaniel.rei.api.common.entry.EntryStack; @@ -88,6 +89,8 @@ public interface ConfigObject { int getMaxRecipePerPage(); + int getMaxRecipesPageHeight(); + boolean doesDisableRecipeBook(); boolean doesFixTabCloseContainer(); @@ -142,8 +145,12 @@ public interface ConfigObject { @ApiStatus.Experimental List<FavoriteEntry> getFavoriteEntries(); + @ApiStatus.ScheduledForRemoval + @Deprecated List<EntryStack<?>> getFilteredStacks(); + List<EntryStackProvider<?>> getFilteredStackProviders(); + @ApiStatus.Experimental boolean shouldAsyncSearch(); @@ -158,10 +165,22 @@ public interface ConfigObject { boolean isInventoryHighlightingAllowed(); @ApiStatus.Experimental - double getHorizontalEntriesBoundaries(); + double getHorizontalEntriesBoundariesPercentage(); + + @ApiStatus.Experimental + double getVerticalEntriesBoundariesPercentage(); + + @ApiStatus.Experimental + double getHorizontalEntriesBoundariesColumns(); + + @ApiStatus.Experimental + double getVerticalEntriesBoundariesRows(); + + @ApiStatus.Experimental + double getFavoritesHorizontalEntriesBoundariesPercentage(); @ApiStatus.Experimental - double getVerticalEntriesBoundaries(); + double getFavoritesHorizontalEntriesBoundariesColumns(); @ApiStatus.Experimental SyntaxHighlightingMode getSyntaxHighlightingMode(); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java b/api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java new file mode 100644 index 000000000..3f784b798 --- /dev/null +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java @@ -0,0 +1,120 @@ +/* + * 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.config.entry; + +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.nbt.CompoundTag; +import org.jetbrains.annotations.ApiStatus; + +import java.util.Objects; + +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface EntryStackProvider<T> { + EntryStack<T> provide(); + + CompoundTag save(); + + boolean isValid(); + + static <T> EntryStackProvider<T> defer(CompoundTag tag) { + return new EntryStackProvider<T>() { + private EntryStack<T> stack; + + @Override + public EntryStack<T> provide() { + if (stack == null) { + try { + stack = (EntryStack<T>) EntryStack.read(tag); + } catch (Exception e) { + e.printStackTrace(); + return (EntryStack<T>) EntryStack.empty(); + } + + stack = stack.normalize(); + } + + return stack; + } + + @Override + public CompoundTag save() { + return tag.copy(); + } + + @Override + public boolean isValid() { + return !provide().isEmpty(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof EntryStackProvider)) return false; + Ent |
