From de461fde691f593b85ffeae837b5b419a9abf7cc Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 9 Mar 2021 23:17:05 +0800 Subject: Use AbstractRecipeViewingScreen and remove static from ScreenHelper Signed-off-by: shedaniel --- .../java/me/shedaniel/rei/api/ConfigObject.java | 2 +- .../main/java/me/shedaniel/rei/api/REIHelper.java | 30 ++- .../main/java/me/shedaniel/rei/api/REIOverlay.java | 12 +- .../shedaniel/rei/api/favorites/FavoriteEntry.java | 2 +- .../me/shedaniel/rei/api/gui/AbstractRenderer.java | 1 - .../shedaniel/rei/api/gui/drag/DraggableStack.java | 23 ++ .../rei/api/gui/drag/DraggableStackProvider.java | 23 ++ .../rei/api/gui/drag/DraggableStackVisitor.java | 23 ++ .../rei/api/gui/drag/DraggingContext.java | 49 +++- .../me/shedaniel/rei/api/gui/widgets/Widgets.java | 22 +- .../rei/api/ingredient/EntryIngredient.java | 2 +- .../rei/api/ingredient/entry/EntryDefinition.java | 1 - .../rei/api/ingredient/entry/EntryRenderer.java | 2 +- .../rei/api/registry/display/DisplayCategory.java | 2 - .../rei/api/registry/display/TransferDisplay.java | 1 - .../registry/display/TransferDisplayCategory.java | 2 - .../me/shedaniel/rei/api/server/ContainerInfo.java | 2 +- .../me/shedaniel/rei/api/server/RecipeFinder.java | 12 +- .../me/shedaniel/rei/api/util/CollectionUtils.java | 1 - .../shedaniel/rei/api/view/ViewSearchBuilder.java | 4 +- .../main/java/me/shedaniel/rei/impl/Internals.java | 6 - build.gradle | 1 + .../plugin/DefaultPotionEffectExclusionZones.java | 7 +- .../plugin/DefaultRecipeBookExclusionZones.java | 11 +- .../plugin/crafting/DefaultCraftingCategory.java | 22 +- .../shedaniel/rei/fabric/PluginDetectorImpl.java | 23 ++ .../rei/fabric/RoughlyEnoughItemsFabric.java | 23 ++ fabric/src/main/resources/fabric.mod.json | 10 +- .../me/shedaniel/rei/forge/PluginDetectorImpl.java | 23 ++ .../java/me/shedaniel/rei/forge/REIPlugin.java | 23 ++ .../rei/forge/RoughlyEnoughItemsForge.java | 23 ++ .../main/java/me/shedaniel/rei/PluginDetector.java | 23 ++ .../me/shedaniel/rei/RoughlyEnoughItemsCore.java | 36 ++- .../rei/RoughlyEnoughItemsInitializer.java | 2 +- .../me/shedaniel/rei/RoughlyEnoughItemsState.java | 1 - .../rei/api/gui/config/entry/FilteringScreen.java | 18 +- .../gui/config/entry/RecipeScreenTypeEntry.java | 2 +- .../rei/gui/AbstractRecipeViewingScreen.java | 136 +++++++++++ .../shedaniel/rei/gui/ContainerScreenOverlay.java | 159 +++++++------ .../me/shedaniel/rei/gui/CurrentDraggingStack.java | 25 +- .../me/shedaniel/rei/gui/OverlaySearchField.java | 6 +- .../shedaniel/rei/gui/PreRecipeViewingScreen.java | 9 +- .../shedaniel/rei/gui/RecipeDisplayExporter.java | 2 +- .../java/me/shedaniel/rei/gui/RecipeScreen.java | 7 +- .../me/shedaniel/rei/gui/RecipeViewingScreen.java | 181 +++++---------- .../gui/SearchFilterSyntaxHighlightingScreen.java | 6 +- .../rei/gui/VillagerRecipeViewingScreen.java | 81 ++----- .../java/me/shedaniel/rei/gui/modules/Menu.java | 8 +- .../entries/EntryStackSubsetsMenuEntry.java | 18 +- .../rei/gui/modules/entries/GameModeMenuEntry.java | 3 +- .../gui/modules/entries/SubSubsetsMenuEntry.java | 16 +- .../rei/gui/modules/entries/WeatherMenuEntry.java | 3 +- .../rei/gui/plugin/DefaultRuntimePlugin.java | 33 +-- .../rei/gui/plugin/entry/ItemEntryDefinition.java | 2 +- .../shedaniel/rei/gui/widget/EntryListWidget.java | 13 +- .../me/shedaniel/rei/gui/widget/EntryWidget.java | 15 +- .../rei/gui/widget/FavoritesListWidget.java | 12 +- .../rei/gui/widget/RecipeChoosePageWidget.java | 4 +- .../me/shedaniel/rei/gui/widget/TabWidget.java | 7 +- .../me/shedaniel/rei/impl/AbstractEntryStack.java | 4 +- .../me/shedaniel/rei/impl/ClientHelperImpl.java | 4 +- .../me/shedaniel/rei/impl/ConfigManagerImpl.java | 6 +- .../me/shedaniel/rei/impl/ConfigObjectImpl.java | 2 +- .../me/shedaniel/rei/impl/EntryRegistryImpl.java | 4 +- .../me/shedaniel/rei/impl/InternalWidgets.java | 20 +- .../me/shedaniel/rei/impl/PluginManagerImpl.java | 2 +- .../java/me/shedaniel/rei/impl/REIHelperImpl.java | 235 +++++++++++++++++++ .../java/me/shedaniel/rei/impl/ScreenHelper.java | 257 --------------------- .../java/me/shedaniel/rei/impl/SearchArgument.java | 4 +- .../rei/impl/filtering/FilteringContextImpl.java | 2 +- .../rei/impl/filtering/FilteringResult.java | 2 +- .../impl/filtering/rules/ManualFilteringRule.java | 2 +- .../impl/filtering/rules/SearchFilteringRule.java | 4 +- .../rei/impl/registry/CategoryRegistryImpl.java | 19 +- .../me/shedaniel/rei/impl/search/MatchStatus.java | 2 +- .../widgets/FillRectangleDrawableConsumer.java | 5 +- .../me/shedaniel/rei/impl/widgets/PanelWidget.java | 5 +- .../rei/impl/widgets/TextFieldWidget.java | 7 +- .../shedaniel/rei/tests/plugin/REITestPlugin.java | 4 +- 79 files changed, 1058 insertions(+), 748 deletions(-) create mode 100644 runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java create mode 100644 runtime/src/main/java/me/shedaniel/rei/impl/REIHelperImpl.java delete mode 100644 runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java 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 fc802346d..9558bdd1e 100644 --- a/api/src/main/java/me/shedaniel/rei/api/ConfigObject.java +++ b/api/src/main/java/me/shedaniel/rei/api/ConfigObject.java @@ -25,8 +25,8 @@ 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.api.gui.config.*; +import me.shedaniel.rei.api.ingredient.EntryStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import org.jetbrains.annotations.ApiStatus; diff --git a/api/src/main/java/me/shedaniel/rei/api/REIHelper.java b/api/src/main/java/me/shedaniel/rei/api/REIHelper.java index 3a46cf03b..f02ba4024 100644 --- a/api/src/main/java/me/shedaniel/rei/api/REIHelper.java +++ b/api/src/main/java/me/shedaniel/rei/api/REIHelper.java @@ -23,16 +23,17 @@ package me.shedaniel.rei.api; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.gui.config.SearchFieldLocation; import me.shedaniel.rei.api.gui.widgets.TextField; import me.shedaniel.rei.api.gui.widgets.Tooltip; +import me.shedaniel.rei.api.plugins.PluginManager; import me.shedaniel.rei.api.registry.Reloadable; -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 org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Optional; @@ -44,15 +45,25 @@ public interface REIHelper extends Reloadable { * @return the instance of {@link REIHelper} */ static REIHelper getInstance() { - return Internals.getREIHelper(); + return PluginManager.getInstance().get(REIHelper.class); } - @ApiStatus.Experimental - Optional getOverlay(); + boolean isOverlayVisible(); + + void toggleOverlayVisible(); + + default Optional getOverlay() { + return getOverlay(false); + } + + Optional getOverlay(boolean reset); @Nullable AbstractContainerScreen getPreviousContainerScreen(); + @Nullable + Screen getPreviousScreen(); + boolean isDarkThemeEnabled(); @Nullable @@ -60,6 +71,11 @@ public interface REIHelper extends Reloadable { void queueTooltip(@Nullable Tooltip tooltip); - @NotNull ResourceLocation getDefaultDisplayTexture(); + + SearchFieldLocation getContextualSearchFieldLocation(); + + Rectangle calculateEntryListArea(); + + Rectangle calculateFavoritesListArea(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/REIOverlay.java b/api/src/main/java/me/shedaniel/rei/api/REIOverlay.java index c9dc4c16e..2b66857d4 100644 --- a/api/src/main/java/me/shedaniel/rei/api/REIOverlay.java +++ b/api/src/main/java/me/shedaniel/rei/api/REIOverlay.java @@ -24,11 +24,17 @@ package me.shedaniel.rei.api; import me.shedaniel.rei.api.gui.drag.DraggingContext; +import me.shedaniel.rei.api.gui.widgets.WidgetWithBounds; import org.jetbrains.annotations.ApiStatus; @ApiStatus.Experimental -public interface REIOverlay { - void queueReloadOverlay(); +public abstract class REIOverlay extends WidgetWithBounds { + @ApiStatus.Internal + public abstract void closeOverlayMenu(); - DraggingContext getDraggingContext(); + 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/favorites/FavoriteEntry.java b/api/src/main/java/me/shedaniel/rei/api/favorites/FavoriteEntry.java index 0f8f3dd1a..a5cc707af 100644 --- a/api/src/main/java/me/shedaniel/rei/api/favorites/FavoriteEntry.java +++ b/api/src/main/java/me/shedaniel/rei/api/favorites/FavoriteEntry.java @@ -24,8 +24,8 @@ package me.shedaniel.rei.api.favorites; import com.google.gson.JsonObject; -import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.gui.Renderer; +import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.impl.Internals; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/AbstractRenderer.java b/api/src/main/java/me/shedaniel/rei/api/gui/AbstractRenderer.java index b4ffb75c5..7ce38fd5f 100644 --- a/api/src/main/java/me/shedaniel/rei/api/gui/AbstractRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/gui/AbstractRenderer.java @@ -23,7 +23,6 @@ package me.shedaniel.rei.api.gui; -import me.shedaniel.rei.api.gui.Renderer; import net.minecraft.client.gui.GuiComponent; public abstract class AbstractRenderer extends GuiComponent implements Renderer { diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStack.java b/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStack.java index 8d38fb4c8..6bd61c953 100644 --- a/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStack.java +++ b/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStack.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.gui.drag; import com.mojang.blaze3d.vertex.PoseStack; diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStackProvider.java b/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStackProvider.java index 7b799b26a..3a4b56afc 100644 --- a/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStackProvider.java +++ b/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStackProvider.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.gui.drag; import org.jetbrains.annotations.Nullable; diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStackVisitor.java b/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStackVisitor.java index e0e64bf9a..62f66de23 100644 --- a/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStackVisitor.java +++ b/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggableStackVisitor.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.gui.drag; import java.util.Optional; diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggingContext.java b/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggingContext.java index cd9bc3a32..1b76cbaaf 100644 --- a/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggingContext.java +++ b/api/src/main/java/me/shedaniel/rei/api/gui/drag/DraggingContext.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.gui.drag; import me.shedaniel.math.Point; @@ -6,6 +29,12 @@ import org.jetbrains.annotations.Nullable; import java.util.function.Supplier; +/** + * The context of the current dragged stack on the overlay. + *

+ * Widgets should implement {@link DraggableStackProvider} to submit applicable stacks to drag. + * Widgets should implement {@link DraggableStackVisitor} to accept incoming dragged stacks. + */ public interface DraggingContext { static DraggingContext getInstance() { return REIHelper.getInstance().getOverlay().get().getDraggingContext(); @@ -15,11 +44,29 @@ public interface DraggingContext { return getCurrentStack() != null; } + /** + * Returns the current dragged stack, may be null. + * + * @return the current dragged stack, may be null + */ @Nullable DraggableStack getCurrentStack(); + /** + * Returns the current position of the dragged stack, this is usually the position of the mouse pointer, + * but you should use this regardless to account for future changes. + * + * @return the current position of the dragged stack + */ @Nullable Point getCurrentPosition(); - void registerRenderBackToPosition(DraggableStack stack, Supplier position); + /** + * Renders the draggable stack back to the position {@code position}. + * This may be used to animate an unaccepted draggable stack returning to its initial position. + * + * @param stack the stack to use for render + * @param position the position supplier of the destination + */ + void renderBackToPosition(DraggableStack stack, Supplier position); } diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widgets.java b/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widgets.java index 614c5f4ec..bd7801533 100644 --- a/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widgets.java +++ b/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widgets.java @@ -194,19 +194,20 @@ public final class Widgets { } @NotNull - public static Panel createRecipeBase(@NotNull Rectangle rectangle) { - return Internals.getWidgetsProvider().createPanelWidget(rectangle) - .yTextureOffset(ConfigObject.getInstance().getRecipeBorderType().getYOffset()) - .rendering(Widgets::shouldRecipeBaseRender); + public static Panel createCategoryBase(@NotNull Rectangle rectangle) { + return Internals.getWidgetsProvider().createPanelWidget(rectangle); } - private static boolean shouldRecipeBaseRender(@NotNull Panel panel) { - return ConfigObject.getInstance().getRecipeBorderType().isRendering() && Internals.getWidgetsProvider().isRenderingPanel(panel); + @NotNull + public static Panel createCategoryBase(@NotNull Rectangle rectangle, int color) { + return createCategoryBase(rectangle).color(color); } @NotNull - public static Panel createCategoryBase(@NotNull Rectangle rectangle) { - return Internals.getWidgetsProvider().createPanelWidget(rectangle); + public static Panel createRecipeBase(@NotNull Rectangle rectangle) { + return Internals.getWidgetsProvider().createPanelWidget(rectangle) + .yTextureOffset(ConfigObject.getInstance().getRecipeBorderType().getYOffset()) + .rendering(Widgets::shouldRecipeBaseRender); } @NotNull @@ -214,9 +215,8 @@ public final class Widgets { return createRecipeBase(rectangle).color(color); } - @NotNull - public static Panel createCategoryBase(@NotNull Rectangle rectangle, int color) { - return createCategoryBase(rectangle).color(color); + private static boolean shouldRecipeBaseRender(@NotNull Panel panel) { + return ConfigObject.getInstance().getRecipeBorderType().isRendering() && Internals.getWidgetsProvider().isRenderingPanel(panel); } @NotNull diff --git a/api/src/main/java/me/shedaniel/rei/api/ingredient/EntryIngredient.java b/api/src/main/java/me/shedaniel/rei/api/ingredient/EntryIngredient.java index c19b0f01e..2d9feb9bb 100644 --- a/api/src/main/java/me/shedaniel/rei/api/ingredient/EntryIngredient.java +++ b/api/src/main/java/me/shedaniel/rei/api/ingredient/EntryIngredient.java @@ -45,6 +45,6 @@ public interface EntryIngredient extends List> { } static EntryIngredient of(Iterable> stacks) { - return Internals.getEntryIngredientProvider().of((Iterable>) (Iterable) stacks); + return Internals.getEntryIngredientProvider().of((Iterable>) stacks); } } diff --git a/api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryDefinition.java b/api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryDefinition.java index f2d22668f..b1380a963 100644 --- a/api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryDefinition.java +++ b/api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryDefinition.java @@ -29,7 +29,6 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.Optional; diff --git a/api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryRenderer.java index ea1bc15b4..3ff850bb3 100644 --- a/api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/ingredient/entry/EntryRenderer.java @@ -26,8 +26,8 @@ package me.shedaniel.rei.api.ingredient.entry; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.gui.widgets.Tooltip; +import me.shedaniel.rei.api.ingredient.EntryStack; import org.jetbrains.annotations.Nullable; public interface EntryRenderer { diff --git a/api/src/main/java/me/shedaniel/rei/api/registry/display/DisplayCategory.java b/api/src/main/java/me/shedaniel/rei/api/registry/display/DisplayCategory.java index ca57ef7b0..5e19b8d0b 100644 --- a/api/src/main/java/me/shedaniel/rei/api/registry/display/DisplayCategory.java +++ b/api/src/main/java/me/shedaniel/rei/api/registry/display/DisplayCategory.java @@ -29,13 +29,11 @@ import me.shedaniel.rei.api.gui.Renderer; import me.shedaniel.rei.api.gui.SimpleDisplayRenderer; import me.shedaniel.rei.api.gui.widgets.Widget; import me.shedaniel.rei.api.gui.widgets.Widgets; -import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.util.Identifiable; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.List; diff --git a/api/src/main/java/me/shedaniel/rei/api/registry/display/TransferDisplay.java b/api/src/main/java/me/shedaniel/rei/api/registry/display/TransferDisplay.java index 7f9e081aa..d04dea550 100644 --- a/api/src/main/java/me/shedaniel/rei/api/registry/display/TransferDisplay.java +++ b/api/src/main/java/me/shedaniel/rei/api/registry/display/TransferDisplay.java @@ -24,7 +24,6 @@ package me.shedaniel.rei.api.registry.display; import me.shedaniel.rei.api.ingredient.EntryIngredient; -import me.shedaniel.rei.api.registry.display.Display; import me.shedaniel.rei.api.server.ContainerInfo; import net.minecraft.world.inventory.AbstractContainerMenu; diff --git a/api/src/main/java/me/shedaniel/rei/api/registry/display/TransferDisplayCategory.java b/api/src/main/java/me/shedaniel/rei/api/registry/display/TransferDisplayCategory.java index 10c04d266..3c678d503 100644 --- a/api/src/main/java/me/shedaniel/rei/api/registry/display/TransferDisplayCategory.java +++ b/api/src/main/java/me/shedaniel/rei/api/registry/display/TransferDisplayCategory.java @@ -26,8 +26,6 @@ package me.shedaniel.rei.api.registry.display; import com.mojang.blaze3d.vertex.PoseStack; import it.unimi.dsi.fastutil.ints.IntList; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.registry.display.Display; -import me.shedaniel.rei.api.registry.display.DisplayCategory; import me.shedaniel.rei.api.gui.widgets.Widget; import org.jetbrains.annotations.ApiStatus; diff --git a/api/src/main/java/me/shedaniel/rei/api/server/ContainerInfo.java b/api/src/main/java/me/shedaniel/rei/api/server/ContainerInfo.java index 23325d6a4..d3be5a022 100644 --- a/api/src/main/java/me/shedaniel/rei/api/server/ContainerInfo.java +++ b/api/src/main/java/me/shedaniel/rei/api/server/ContainerInfo.java @@ -47,7 +47,7 @@ public interface ContainerInfo { for (StackAccessor gridStack : getGridStacks(context)) { GridCleanHandler.returnSlotToPlayerInventory(context, gridStack); } - + clearCraftingSlots(container); }; } diff --git a/api/src/main/java/me/shedaniel/rei/api/server/RecipeFinder.java b/api/src/main/java/me/shedaniel/rei/api/server/RecipeFinder.java index cbed0a639..162def884 100644 --- a/api/src/main/java/me/shedaniel/rei/api/server/RecipeFinder.java +++ b/api/src/main/java/me/shedaniel/rei/api/server/RecipeFinder.java @@ -171,7 +171,7 @@ public class RecipeFinder { this.bitSet.clear(0, this.ingredientCount + this.usableIngredientSize + this.ingredientCount); int int_5 = 0; List list_1 = new ArrayList<>(ingredientsInput); - + for (Ingredient ingredient : list_1) { if (boolean_2 && ingredient.isEmpty()) { intList_1.add(0); @@ -185,7 +185,7 @@ public class RecipeFinder { } } } - + ++int_5; } } @@ -196,7 +196,7 @@ public class RecipeFinder { private int[] getUsableIngredientItemIds() { IntCollection intCollection_1 = new IntAVLTreeSet(); - + for (Ingredient ingredient_1 : this.ingredients) { intCollection_1.addAll(ingredient_1.getStackingIds()); } @@ -321,15 +321,15 @@ public class RecipeFinder { @SuppressWarnings("deprecation") private int method_7415() { int int_1 = Integer.MAX_VALUE; - + for (Ingredient ingredient_1 : this.ingredients) { int int_2 = 0; - + int int_3; for (IntListIterator var5 = ingredient_1.getStackingIds().iterator(); var5.hasNext(); int_2 = Math.max(int_2, RecipeFinder.this.idToAmountMap.get(int_3))) { int_3 = var5.next(); } - + if (int_1 > 0) { int_1 = Math.min(int_1, int_2); } diff --git a/api/src/main/java/me/shedaniel/rei/api/util/CollectionUtils.java b/api/src/main/java/me/shedaniel/rei/api/util/CollectionUtils.java index 83a955c3c..a72891363 100644 --- a/api/src/main/java/me/shedaniel/rei/api/util/CollectionUtils.java +++ b/api/src/main/java/me/shedaniel/rei/api/util/CollectionUtils.java @@ -28,7 +28,6 @@ import com.google.common.collect.Sets; import com.google.common.collect.UnmodifiableIterator; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; -import jdk.nashorn.internal.runtime.arrays.IteratorAction; import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.ingredient.util.EntryStacks; import net.fabricmc.api.EnvType; diff --git a/api/src/main/java/me/shedaniel/rei/api/view/ViewSearchBuilder.java b/api/src/main/java/me/shedaniel/rei/api/view/ViewSearchBuilder.java index 2a61f9ff4..bc9ac9a1b 100644 --- a/api/src/main/java/me/shedaniel/rei/api/view/ViewSearchBuilder.java +++ b/api/src/main/java/me/shedaniel/rei/api/view/ViewSearchBuilder.java @@ -69,12 +69,12 @@ public interface ViewSearchBuilder { ViewSearchBuilder fillPreferredOpenedCategory(); - ViewSearchBuilder setInputNotice(@Nullable EntryStack stack); + ViewSearchBuilder setInputNotice(@Nullable EntryStack stack); @Nullable EntryStack getInputNotice(); - ViewSearchBuilder setOutputNotice(@Nullable EntryStack stack); + ViewSearchBuilder setOutputNotice(@Nullable EntryStack stack); @Nullable EntryStack getOutputNotice(); diff --git a/api/src/main/java/me/shedaniel/rei/impl/Internals.java b/api/src/main/java/me/shedaniel/rei/impl/Internals.java index f8763f46c..9762f4b28 100644 --- a/api/src/main/java/me/shedaniel/rei/impl/Internals.java +++ b/api/src/main/java/me/shedaniel/rei/impl/Internals.java @@ -27,7 +27,6 @@ import com.google.gson.JsonObject; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.ClientHelper; -import me.shedaniel.rei.api.REIHelper; import me.shedaniel.rei.api.favorites.FavoriteEntry; import me.shedaniel.rei.api.gui.DrawableConsumer; import me.shedaniel.rei.api.gui.Renderer; @@ -60,7 +59,6 @@ import java.util.function.Supplier; @ApiStatus.Internal public final class Internals { private static Supplier clientHelper = Internals::throwNotSetup; - private static Supplier reiHelper = Internals::throwNotSetup; private static Supplier entryStackProvider = Internals::throwNotSetup; private static Supplier entryIngredientProvider = Internals::throwNotSetup; private static Supplier widgetsProvider = Internals::throwNotSetup; @@ -82,10 +80,6 @@ public final class Internals { return clientHelper.get(); } - public static REIHelper getREIHelper() { - return reiHelper.get(); - } - public static EntryStackProvider getEntryStackProvider() { return entryStackProvider.get(); } diff --git a/build.gradle b/build.gradle index be2737ac4..29607c1cd 100755 --- a/build.gradle +++ b/build.gradle @@ -44,6 +44,7 @@ allprojects { license { header rootProject.file("HEADER") include "**/*.java" + exclude "mezz/jei/api/**/*.java" } jar { diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java index 9fd033af6..f46d5433b 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java @@ -25,10 +25,10 @@ package me.shedaniel.rei.plugin; import com.google.common.collect.Ordering; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.REIHelper; 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.client.gui.screens.inventory.EffectRenderingInventoryScreen; import net.minecraft.world.effect.MobEffectInstance; @@ -43,12 +43,13 @@ import java.util.function.Supplier; public class DefaultPotionEffectExclusionZones implements Supplier> { @Override public List get() { - if (!(REIHelper.getInstance().getPreviousContainerScreen() instanceof EffectRenderingInventoryScreen) || !((EffectRenderingInventoryScreen) REIHelper.getInstance().getPreviousContainerScreen()).doRenderEffects) + Screen screen = Minecraft.getInstance().screen; + if (!(screen instanceof EffectRenderingInventoryScreen) || !((EffectRenderingInventoryScreen) screen).doRenderEffects) return Collections.emptyList(); Collection activePotionEffects = Minecraft.getInstance().player.getActiveEffects(); if (activePotionEffects.isEmpty()) return Collections.emptyList(); - AbstractContainerScreen containerScreen = REIHelper.getInstance().getPreviousContainerScreen(); + AbstractContainerScreen containerScreen = (AbstractContainerScreen) screen; List list = new ArrayList<>(); int x = containerScreen.leftPos - 124; int y = containerScreen.topPos; diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java index bde75067d..7702c923a 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java @@ -25,10 +25,10 @@ package me.shedaniel.rei.plugin; import com.google.common.collect.Lists; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.REIHelper; 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.client.gui.screens.recipebook.RecipeBookComponent; import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener; @@ -43,11 +43,12 @@ public class DefaultRecipeBookExclusionZones implements Supplier @Override public List get() { - if (!(Minecraft.getInstance().screen instanceof RecipeUpdateListener) || !(REIHelper.getInstance().getPreviousContainerScreen().getMenu() instanceof RecipeBookMenu) || - !Minecraft.getInstance().player.getRecipeBook().isOpen(((RecipeBookMenu) REIHelper.getInstance().getPreviousContainerScreen().getMenu()).getRecipeBookType())) + Screen screen = Minecraft.getInstance().screen; + if (!(screen instanceof RecipeUpdateListener) || !(screen instanceof AbstractContainerScreen) || !(((AbstractContainerScreen) screen).getMenu() instanceof RecipeBookMenu) || + !Minecraft.getInstance().player.getRecipeBook().isOpen(((RecipeBookMenu) ((AbstractContainerScreen) screen).getMenu()).getRecipeBookType())) return Collections.emptyList(); - RecipeBookComponent recipeBookWidget = ((RecipeUpdateListener) Minecraft.getInstance().screen).getRecipeBookComponent(); - AbstractContainerScreen containerScreen = REIHelper.getInstance().getPreviousContainerScreen(); + RecipeBookComponent recipeBookWidget = ((RecipeUpdateListener) screen).getRecipeBookComponent(); + AbstractContainerScreen containerScreen = (AbstractContainerScreen) screen; List l = Lists.newArrayList(new Rectangle(containerScreen.leftPos - 4 - 145, containerScreen.topPos, 4 + 145 + 30, containerScreen.imageHeight)); int size = recipeBookWidget.tabButtons.size(); if (size > 0) diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java index ba3a149e5..086d994a9 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java @@ -40,12 +40,15 @@ import me.shedaniel.rei.api.server.ContainerInfo; import me.shedaniel.rei.api.server.ContainerInfoHandler; import me.shedaniel.rei.plugin.DefaultPlugin; import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.level.block.Blocks; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -97,18 +100,21 @@ public class DefaultCraftingCategory implements TransferDisplayCategory widgets, Rectangle bounds, DefaultCraftingDisplay display, IntList redSlots) { - if (REIHelper.getInstance().getPreviousContainerScreen() == null) return; - ContainerInfo info = (ContainerInfo) ContainerInfoHandler.getContainerInfo(getIdentifier(), REIHelper.getInstance().getPreviousContainerScreen().getMenu().getClass()); - if (info == null) + @Nullable + Screen previousScreen = REIHelper.getInstance().getPreviousScreen(); + if (!(previousScreen instanceof AbstractContainerScreen)) return; + AbstractContainerMenu containerMenu = ((AbstractContainerScreen) previousScreen).getMenu(); + ContainerInfo info = (ContainerInfo) ContainerInfoHandler.getContainerInfo(getIdentifier(), containerMenu.getClass()); + if (info == null) { return; + } matrices.pushPose(); matrices.translate(0, 0, 400); Point startPoint = new Point(bounds.getCenterX() - 58, bounds.getCenterY() - 27); - int width = info.getCraftingWidth(REIHelper.getInstance().getPreviousContainerScreen().getMenu()); - for (Integer slot : redSlots) { - int i = slot; - int x = i % width; - int y = Mth.floor(i / (float) width); + int width = info.getCraftingWidth(containerMenu); + for (int slot : redSlots) { + int x = slot % width; + int y = Mth.floor(slot / (float) width); GuiComponent.fill(matrices, startPoint.x + 1 + x * 18, startPoint.y + 1 + y * 18, startPoint.x + 1 + x * 18 + 16, startPoint.y + 1 + y * 18 + 16, 0x60ff0000); } matrices.popPose(); diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java index b8f10ba4e..b7a5900c2 100644 --- a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java +++ b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java @@ -1,3 +1,26 @@ +/* + * 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.fabric; import com.google.common.collect.Iterables; diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsFabric.java b/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsFabric.java index 11266d68e..a396c7838 100644 --- a/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsFabric.java +++ b/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsFabric.java @@ -1,3 +1,26 @@ +/* + * 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.fabric; import me.shedaniel.rei.impl.IssuesDetector; diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 0bfe4cb2d..4b91e41ed 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -32,7 +32,10 @@ "rei:translators": { "English": ["shedaniel"], "Japanese": ["swordglowsblue", "hinataaki"], - "Chinese Simplified": ["XuyuEre", "shedaniel", "SciUniv_Moring", "Takakura-Anri", "liushuyu", "lkxian17084", "MynameisTT", "detiam", "Snapshot_light", "JerryHan", "WarrenWN", "Lograthmic"], + "Chinese Simplified": [ + "XuyuEre", "shedaniel", "SciUniv_Moring", "Takakura-Anri", "liushuyu", "lkxian17084", "MynameisTT", "detiam", "Snapshot_light", "JerryHan", "WarrenWN", + "Lograthmic" + ], "Chinese Traditional": ["hugoalh", "gxy17886", "shedaniel", "961111ray"], "French": ["Yanis48", "Koockies", "dagdar", "samnamstyle123"], "German": ["MelanX", "guntram7", "tabmeier12", "Siphalor", "M-S-72", "SirClaver", "bugginggg", "wohlhabend", "Eiim", "valoeghese", "luro02"], @@ -42,7 +45,10 @@ "LOLCAT": ["shedaniel", "RaxedMC", "lkxian17084"], "Upside Down English": ["shedaniel", "magnusk28", "scarzdz"], "Bulgarian": ["geniiii", "Dremski"], - "Russian": ["MrYonter", "kwmika1girl", "LimyChitou", "Great_Manalal", "s3rbug", "TheByKotik", "ebogish", "xqr.", "scarzdz", "JCat", "map788", "kyrtion", "CanslerW", "MinerChAI", "nef1k"], + "Russian": [ + "MrYonter", "kwmika1girl", "LimyChitou", "Great_Manalal", "s3rbug", "TheByKotik", "ebogish", "xqr.", "scarzdz", "JCat", "map788", "kyrtion", "CanslerW", + "MinerChAI", "nef1k" + ], "Polish": ["mikolajkazmierczak", "Piteriuz", "BeetMacol"], "Norwegian": ["CanslerW"], "Turkish": ["NOYB"] diff --git a/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java index 4aace1982..973380f1e 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java @@ -1,3 +1,26 @@ +/* + * 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.forge; import me.shedaniel.rei.RoughlyEnoughItemsCore; diff --git a/forge/src/main/java/me/shedaniel/rei/forge/REIPlugin.java b/forge/src/main/java/me/shedaniel/rei/forge/REIPlugin.java index a4acbaa46..03c40897d 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/REIPlugin.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/REIPlugin.java @@ -1,3 +1,26 @@ +/* + * 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.forge; import java.lang.annotation.ElementType; diff --git a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java index d96afb6b4..61b99c72e 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java @@ -1,3 +1,26 @@ +/* + * 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.forge; import com.google.common.collect.Lists; diff --git a/runtime/src/main/java/me/shedaniel/rei/PluginDetector.java b/runtime/src/main/java/me/shedaniel/rei/PluginDetector.java index 5e6de2399..528e279a6 100644 --- a/runtime/src/main/java/me/shedaniel/rei/PluginDetector.java +++ b/runtime/src/main/java/me/shedaniel/rei/PluginDetector.java @@ -1,3 +1,26 @@ +/* + * 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; import me.shedaniel.architectury.annotations.ExpectPlatform; diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index c668dc282..15bee847e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -74,7 +74,6 @@ import net.minecraft.client.gui.screens.recipebook.GhostRecipe; import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener; import net.minecraft.client.resources.language.I18n; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; import net.minecraft.network.chat.TextComponent; @@ -392,7 +391,6 @@ public class RoughlyEnoughItemsCore { return hasPermissionToUsePackets() || Minecraft.getInstance().gameMode.hasInfiniteItems(); } - @SuppressWarnings("deprecation") public void onInitializeClient() { IssuesDetector.detect(); registerClothEvents(); @@ -456,8 +454,9 @@ public class RoughlyEnoughItemsCore { if (!decider.isHandingScreen(screen)) continue; InteractionResult result = decider.shouldScreenBeOverlaid(screen); - if (result != InteractionResult.PASS) - return result == InteractionResult.FAIL || REIHelper.getInstance().getPreviousContainerScreen() == null; + if (result != InteractionResult.PASS) { + return result == InteractionResult.FAIL || REIHelper.getInstance().getPreviousScreen() == null; + } } } catch (ConcurrentModificationException ignored) { } @@ -477,12 +476,11 @@ public class RoughlyEnoughItemsCore { return InteractionResult.PASS; });*/ GuiEvent.INIT_POST.register((screen, widgets, children) -> { + REIHelperImpl.getInstance().setPreviousScreen(screen); if (shouldReturn(screen)) return; if (screen instanceof InventoryScreen && client.gameMode.hasInfiniteItems()) return; - if (screen instanceof AbstractContainerScreen) - ScreenHelper.setPreviousContainerScreen((AbstractContainerScreen) screen); boolean alreadyAdded = false; for (GuiEventListener element : Lists.newArrayList(children)) if (ContainerScreenOverlay.class.isAssignableFrom(element.getClass())) @@ -491,14 +489,14 @@ public class RoughlyEnoughItemsCore { else alreadyAdded = true; if (!alreadyAdded) - children.add(ScreenHelper.getLastOverlay(true, false)); + children.add(REIHelper.getInstance().getOverlay(true).get()); }); ClientScreenInputEvent.MOUSE_CLICKED_PRE.register((minecraftClient, screen, mouseX, mouseY, button) -> { isLeftModePressed = true; - if (ScreenHelper.getOptionalOverlay().isPresent()) + if (REIHelper.getInstance().getOverlay().isPresent()) if (screen instanceof CreativeModeInventoryScreen) - if (ScreenHelper.isOverlayVisible() && ScreenHelper.getLastOverlay().mouseClicked(mouseX, mouseY, button)) { - screen.setFocused(ScreenHelper.getLastOverlay()); + if (REIHelper.getInstance().isOverlayVisible() && REIHelper.getInstance().getOverlay().get().mouseClicked(mouseX, mouseY, button)) { + screen.setFocused(REIHelper.getInstance().getOverlay().get()); if (button == 0) screen.setDragging(true); return InteractionResult.SUCCESS; @@ -509,8 +507,8 @@ public class RoughlyEnoughItemsCore { isLeftModePressed = false; if (shouldReturn(screen)) return InteractionResult.PASS; - if (ScreenHelper.getOptionalOverlay().isPresent()) - if (ScreenHelper.isOverlayVisible() && ScreenHelper.getLastOverlay().mouseReleased(mouseX, mouseY, button)) { + if (REIHelper.getInstance().getOverlay().isPresent()) + if (REIHelper.getInstance().isOverlayVisible() && REIHelper.getInstance().getOverlay().get().mouseReleased(mouseX, mouseY, button)) { return InteractionResult.SUCCESS; } return InteractionResult.PASS; @@ -518,29 +516,29 @@ public class RoughlyEnoughItemsCore { ClientScreenInputEvent.MOUSE_SCROLLED_PRE.register((minecraftClient, screen, mouseX, mouseY, amount) -> { if (shouldReturn(screen)) return InteractionResult.PASS; - if (ScreenHelper.isOverlayVisible() && ScreenHelper.getLastOverlay().mouseScrolled(mouseX, mouseY, amount)) + if (REIHelper.getInstance().isOverlayVisible() && REIHelper.getInstance().getOverlay().get().mouseScrolled(mouseX, mouseY, amount)) return InteractionResult.SUCCESS; return InteractionResult.PASS; }); ClientScreenInputEvent.CHAR_TYPED_PRE.register((minecraftClient, screen, character, keyCode) -> { if (shouldReturn(screen)) return InteractionResult.PASS; - if (ScreenHelper.getLastOverlay().charTyped(character, keyCode)) + if (REIHelper.getInstance().getOverlay().get().charTyped(character, keyCode)) return InteractionResult.SUCCESS; return InteractionResult.PASS; }); GuiEvent.RENDER_POST.register((screen, matrices, mouseX, mouseY, delta) -> { if (shouldReturn(screen)) return; - ScreenHelper.getLastOverlay().render(matrices, mouseX, mouseY, delta); - if (!ScreenHelper.isOverlayVisible()) + REIHelper.getInstance().getOverlay().get().render(matrices, mouseX, mouseY, delta); + if (!REIHelper.getInstance().isOverlayVisible()) return; - ScreenHelper.getLastOverlay().lateRender(matrices, mouseX, mouseY, delta); + ((ContainerScreenOverlay) REIHelper.getInstance().getOverlay().get()).lateRender(matrices, mouseX, mouseY, delta); }); ClientScreenInputEvent.MOUSE_DRAGGED_PRE.register((minecraftClient, screen, mouseX1, mouseY1, button, mouseX2, mouseY2) -> { if (shouldReturn(screen)) return InteractionResult.PASS; - if (screen instanceof AbstractContainerScreen && ScreenHelper.getLastOverlay().mouseDragged(mouseX1, mouseY1, button, mouseX2, mouseY2)) + if (screen instanceof AbstractContainerScreen && REIHelper.getInstance().getOverlay().get().mouseDragged(mouseX1, mouseY1, button, mouseX2, mouseY2)) return InteractionResult.SUCCESS; return InteractionResult.PASS; }); @@ -554,7 +552,7 @@ public class RoughlyEnoughItemsCore { } if (screen.getFocused() != null && screen.getFocused() instanceof EditBox || (screen.getFocused() instanceof RecipeBookComponent && ((RecipeBookComponent) screen.getFocused()).searchBox != null && ((RecipeBookComponent) screen.getFocused()).searchBox.isFocused())) return InteractionResult.PASS; - if (ScreenHelper.getLastOverlay().keyPressed(i, i1, i2)) + if (REIHelper.getInstance().getOverlay().get().keyPressed(i, i1, i2)) return InteractionResult.SUCCESS; return InteractionResult.PASS; }); diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java index 7308fbb38..dfe52a3a2 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java @@ -49,7 +49,7 @@ public class RoughlyEnoughItemsInitializer { initializeEntryPoint("me.shedaniel.rei.RoughlyEnoughItemsCore"); initializeEntryPoint("me.shedaniel.rei.REIModMenuEntryPoint"); initializeEntryPoint("me.shedaniel.rei.impl.ClientHelperImpl"); - initializeEntryPoint("me.shedaniel.rei.impl.ScreenHelper"); + initializeEntryPoint("me.shedaniel.rei.impl.REIHelperImpl"); } initializeEntryPoint("me.shedaniel.rei.impl.ErrorDisplayer"); diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java index 4f8c42bec..c827b50d9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java @@ -25,7 +25,6 @@ package me.shedaniel.rei; import me.shedaniel.architectury.platform.Platform; import me.shedaniel.architectury.utils.Env; -import net.fabricmc.api.EnvType; import net.minecraft.util.Tuple; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringScreen.java b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringScreen.java index f5d5464a2..cdd1b5add 100644 --- a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringScreen.java @@ -26,7 +26,10 @@ package me.shedaniel.rei.api.gui.config.entry; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.math.Matrix4f; import me.shedaniel.clothconfig2.ClothConfigInitializer; import me.shedaniel.clothconfig2.api.ScissorsHandler; @@ -36,13 +39,13 @@ import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.ConfigObject; -import me.shedaniel.rei.api.registry.entry.EntryRegistry; -import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.REIHelper; import me.shedaniel.rei.api.gui.widgets.Tooltip; +import me.shedaniel.rei.api.ingredient.EntryStack; +import me.shedaniel.rei.api.registry.entry.EntryRegistry; +import me.shedaniel.rei.gui.ContainerScreenOverlay; import me.shedaniel.rei.gui.OverlaySearchField; import me.shedaniel.rei.gui.widget.EntryWidget; -import me.shedaniel.rei.impl.ScreenHelper; import me.shedaniel.rei.impl.SearchArgument; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; @@ -262,7 +265,7 @@ public class FilteringScreen extends Screen { this.backButton.render(matrices, mouseX, mouseY, delta); if (tooltip != null) { - ScreenHelper.getLastOverlay().renderTooltip(matrices, tooltip); + ((ContainerScreenOverlay) REIHelper.getInstance().getOverlay().get()).renderTooltip(matrices, tooltip); } this.font.drawShadow(matrices, this.title.getVisualOrderText(), this.width / 2.0F - this.font.width(this.title) / 2.0F, 12.0F, -1); @@ -378,10 +381,7 @@ public class FilteringScreen extends Screen { return true; } } - if (backButton.mouseClicked(double_1, double_2, int_1)) { - return true; - } - return false; + return backButton.mouseClicked(double_1, double_2, int_1); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java index ed3aff6b7..3f32747e9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java @@ -27,8 +27,8 @@ import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.clothconfig2.gui.entries.TooltipListEntry; -import me.shedaniel.rei.gui.PreRecipeViewingScreen; import me.shedaniel.rei.api.gui.config.RecipeScreenType; +import me.shedaniel.rei.gui.PreRecipeViewingScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.chat.NarratorChatListener; import net.minecraft.client.gui.components.AbstractButton; diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java new file mode 100644 index 000000000..fd8007d19 --- /dev/null +++ b/runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java @@ -0,0 +1,136 @@ +/* + * 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, pu