diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-03-09 23:17:05 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-03-09 23:17:05 +0800 |
| commit | de461fde691f593b85ffeae837b5b419a9abf7cc (patch) | |
| tree | cec6e08c99427eddf9eef5e19d04edca56d3d0d4 /runtime/src/main/java/me/shedaniel/rei/impl | |
| parent | 64bc9937d6ec04c6d66240a84b4fb345026c0b12 (diff) | |
| download | RoughlyEnoughItems-de461fde691f593b85ffeae837b5b419a9abf7cc.tar.gz RoughlyEnoughItems-de461fde691f593b85ffeae837b5b419a9abf7cc.tar.bz2 RoughlyEnoughItems-de461fde691f593b85ffeae837b5b419a9abf7cc.zip | |
Use AbstractRecipeViewingScreen and remove static from ScreenHelper
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/impl')
18 files changed, 117 insertions, 127 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java b/runtime/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java index 1558b5a6e..9556b2866 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/AbstractEntryStack.java @@ -29,11 +29,11 @@ import it.unimi.dsi.fastutil.shorts.Short2ObjectMaps; import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.gui.AbstractRenderer; +import me.shedaniel.rei.api.gui.widgets.Tooltip; +import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.ingredient.entry.ComparisonContext; import me.shedaniel.rei.api.ingredient.util.EntryStacks; -import me.shedaniel.rei.api.gui.widgets.Tooltip; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java index 4ad00bb94..c877da769 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java @@ -209,7 +209,7 @@ public class ClientHelperImpl implements ClientHelper { if (ConfigObject.getInstance().getRecipeScreenType() == RecipeScreenType.VILLAGER) { screen = new VillagerRecipeViewingScreen(map, builder.getPreferredOpenedCategory()); } else if (ConfigObject.getInstance().getRecipeScreenType() == RecipeScreenType.UNSET) { - screen = new PreRecipeViewingScreen(REIHelper.getInstance().getPreviousContainerScreen(), RecipeScreenType.UNSET, true, original -> { + screen = new PreRecipeViewingScreen(REIHelper.getInstance().getPreviousScreen(), RecipeScreenType.UNSET, true, original -> { ConfigObject.getInstance().setRecipeScreenType(original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER); ConfigManager.getInstance().saveConfig(); openView(builder); @@ -224,7 +224,7 @@ public class ClientHelperImpl implements ClientHelper { ((RecipeScreen) screen).addResultStackToNotice(builder.getOutputNotice()); } if (Minecraft.getInstance().screen instanceof RecipeScreen) - ScreenHelper.storeRecipeScreen((RecipeScreen) Minecraft.getInstance().screen); + REIHelperImpl.getInstance().storeRecipeScreen((RecipeScreen) Minecraft.getInstance().screen); Minecraft.getInstance().setScreen(screen); return true; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java index 0e3e0ff92..c2930d4e6 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java @@ -169,7 +169,7 @@ public class ConfigManagerImpl implements ConfigManager { Collections.singletonList(new RecipeScreenTypeEntry(220, new TranslatableComponent(i13n), getUnsafely(field, config, RecipeScreenType.UNSET), getUnsafely(field, defaults), type -> setUnsafely(field, config, type))) , (field) -> field.getType() == RecipeScreenType.class, ConfigObjectImpl.UseSpecialRecipeTypeScreen.class); guiRegistry.registerAnnotationProvider((i13n, field, config, defaults, guiProvider) -> - Collections.singletonList(new SearchFilterSyntaxHighlightingEntry( new TranslatableComponent(i13n), getUnsafely(field, config, SyntaxHighlightingMode.COLORFUL), getUnsafely(field, defaults), type -> setUnsafely(field, config, type))) + Collections.singletonList(new SearchFilterSyntaxHighlightingEntry(new TranslatableComponent(i13n), getUnsafely(field, config, SyntaxHighlightingMode.COLORFUL), getUnsafely(field, defaults), type -> setUnsafely(field, config, type))) , (field) -> field.getType() == SyntaxHighlightingMode.class, ConfigObjectImpl.UseSpecialSearchFilterSyntaxHighlightingScreen.class); guiRegistry.registerAnnotationProvider((i13n, field, config, defaults, guiProvider) -> REIHelper.getInstance().getPreviousContainerScreen() == null || Minecraft.getInstance().getConnection() == null || Minecraft.getInstance().getConnection().getRecipeManager() == null ? @@ -274,8 +274,8 @@ public class ConfigManagerImpl implements ConfigManager { }).setSavingRunnable(() -> { saveConfig(); EntryRegistry.getInstance().refilter(); - if (ScreenHelper.getSearchField() != null) - ContainerScreenOverlay.getEntryListWidget().updateSearch(ScreenHelper.getSearchField().getText(), true); + if (REIHelperImpl.getSearchField() != null) + ContainerScreenOverlay.getEntryListWidget().updateSearch(REIHelperImpl.getSearchField().getText(), true); }).build(); }); Screen configScreen = provider.get(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java index 41962a690..b1960af17 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java @@ -31,9 +31,9 @@ import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.Comment; import me.shedaniel.clothconfig2.api.Modifier; import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.rei.api.ConfigObject; -import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.favorites.FavoriteEntry; import me.shedaniel.rei.api.gui.config.*; +import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.impl.filtering.FilteringRule; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java index 354e253f0..faf38e282 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java @@ -27,10 +27,10 @@ import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.ConfigObject; -import me.shedaniel.rei.api.plugins.REIPlugin; -import me.shedaniel.rei.api.registry.entry.EntryRegistry; import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.ingredient.util.EntryStacks; +import me.shedaniel.rei.api.plugins.REIPlugin; +import me.shedaniel.rei.api.registry.entry.EntryRegistry; import me.shedaniel.rei.api.util.CollectionUtils; import me.shedaniel.rei.impl.filtering.FilteringContextImpl; import me.shedaniel.rei.impl.filtering.FilteringContextType; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/InternalWidgets.java b/runtime/src/main/java/me/shedaniel/rei/impl/InternalWidgets.java index 938e996bf..4abe7aa01 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/InternalWidgets.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/InternalWidgets.java @@ -28,20 +28,20 @@ import com.mojang.blaze3d.vertex.PoseStack; import it.unimi.dsi.fastutil.ints.IntList; import me.shedaniel.math.Rectangle; import me.shedaniel.math.impl.PointHelper; -import me.shedaniel.rei.api.*; -import me.shedaniel.rei.api.registry.display.Display; -import me.shedaniel.rei.api.registry.display.DisplayCategory; +import me.shedaniel.rei.api.ConfigObject; +import me.shedaniel.rei.api.REIHelper; import me.shedaniel.rei.api.gui.widgets.Button; +import me.shedaniel.rei.api.gui.widgets.Widget; +import me.shedaniel.rei.api.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.gui.widgets.Widgets; -import me.shedaniel.rei.api.registry.display.DisplayRegistry; +import me.shedaniel.rei.api.registry.display.Display; +import me.shedaniel.rei.api.registry.display.DisplayCategory; import me.shedaniel.rei.api.registry.display.TransferDisplayCategory; import me.shedaniel.rei.api.registry.transfer.TransferHandler; import me.shedaniel.rei.api.registry.transfer.TransferHandlerRegistry; +import me.shedaniel.rei.api.util.CollectionUtils; import me.shedaniel.rei.gui.toast.CopyRecipeIdentifierToast; import me.shedaniel.rei.gui.widget.LateRenderable; -import me.shedaniel.rei.api.gui.widgets.Widget; -import me.shedaniel.rei.api.gui.widgets.WidgetWithBounds; -import me.shedaniel.rei.api.util.CollectionUtils; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.ChatFormatting; @@ -84,10 +84,14 @@ public final class InternalWidgets { e.printStackTrace(); } Minecraft.getInstance().setScreen(containerScreen); - ScreenHelper.getLastOverlay().init(); + REIHelper.getInstance().getOverlay().get().queueReloadOverlay(); }) .onRender((matrices, button) -> { button.setEnabled(false); + if (containerScreen == null) { + button.setTint(0); + return; + } List<String> error = null; int color = 0; visible[0] = false; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/PluginManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/PluginManagerImpl.java index 47ac120dc..bd7cbd299 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/PluginManagerImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/PluginManagerImpl.java @@ -70,7 +70,7 @@ public class PluginManagerImpl implements PluginManager { registerReloadable(new FavoriteEntryTypeRegistryImpl()); registerReloadable(new SubsetsRegistryImpl()); registerReloadable(new TransferHandlerRegistryImpl()); - registerReloadable(ScreenHelper::reload); + registerReloadable(new REIHelperImpl()); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java b/runtime/src/main/java/me/shedaniel/rei/impl/REIHelperImpl.java index 784190901..5f36fd2cd 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/REIHelperImpl.java @@ -26,10 +26,8 @@ package me.shedaniel.rei.impl; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.architectury.event.events.GuiEvent; import me.shedaniel.architectury.event.events.client.ClientTickEvent; -import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.ConfigManager; import me.shedaniel.rei.api.ConfigObject; @@ -38,7 +36,6 @@ import me.shedaniel.rei.api.REIOverlay; 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.ingredient.EntryStack; import me.shedaniel.rei.api.registry.screen.DisplayBoundsProvider; import me.shedaniel.rei.api.registry.screen.OverlayDecider; import me.shedaniel.rei.api.registry.screen.ScreenRegistry; @@ -52,39 +49,32 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionResult; -import org.apache.logging.log4j.util.TriConsumer; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.LinkedHashSet; import java.util.Optional; -import java.util.Set; - -import static me.shedaniel.rei.impl.Internals.attachInstance; @ApiStatus.Internal @Environment(EnvType.CLIENT) -public class ScreenHelper implements REIHelper { - @ApiStatus.Internal - public static boolean isWithinRecipeViewingScreen = false; +public class REIHelperImpl implements REIHelper { private static final ResourceLocation DISPLAY_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/display.png"); private static final ResourceLocation DISPLAY_TEXTURE_DARK = new ResourceLocation("roughlyenoughitems", "textures/gui/display_dark.png"); - private OverlaySearchField searchField; @ApiStatus.Internal - public static Set<EntryStack<?>> inventoryStacks = Sets.newHashSet(); - private static ContainerScreenOverlay overlay; - private static AbstractContainerScreen<?> previousContainerScreen = null; - private static LinkedHashSet<RecipeScreen> lastRecipeScreen = Sets.newLinkedHashSetWithExpectedSize(5); - private static ScreenHelper instance; + public static boolean isWithinRecipeViewingScreen = false; + private ContainerScreenOverlay overlay; + private OverlaySearchField searchField; + private AbstractContainerScreen<?> previousContainerScreen = null; + private Screen previousScreen = null; + private LinkedHashSet<RecipeScreen> lastRecipeScreen = Sets.newLinkedHashSetWithExpectedSize(10); /** * @return the instance of screen helper * @see REIHelper#getInstance() */ @ApiStatus.Internal - public static ScreenHelper getInstance() { - return instance; + public static REIHelperImpl getInstance() { + return (REIHelperImpl) REIHelper.getInstance(); } @Override @@ -97,6 +87,10 @@ public class ScreenHelper implements REIHelper { @Override @Nullable public TextField getSearchTextField() { + if (searchField == null) { + searchField = new OverlaySearchField(0, 0, 0, 0); + } + return searchField; } @@ -105,86 +99,67 @@ public class ScreenHelper implements REIHelper { return (OverlaySearchField) getInstance().getSearchTextField(); } - @ApiStatus.Internal - public static void setSearchField(OverlaySearchField searchField) { - getInstance().searchField = searchField; - } - - public static void storeRecipeScreen(RecipeScreen screen) { - while (lastRecipeScreen.size() >= 5) + public void storeRecipeScreen(RecipeScreen screen) { + while (lastRecipeScreen.size() >= 10) lastRecipeScreen.remove(Iterables.get(lastRecipeScreen, 0)); lastRecipeScreen.add(screen); } - public static boolean hasLastRecipeScreen() { + public boolean hasLastRecipeScreen() { return !lastRecipeScreen.isEmpty(); } - public static Screen getLastRecipeScreen() { + public Screen getLastRecipeScreen() { RecipeScreen screen = Iterables.getLast(lastRecipeScreen); lastRecipeScreen.remove(screen); screen.recalculateCategoryPage(); return (Screen) screen; } - @ApiStatus.Internal - public static void reload() { - lastRecipeScreen.clear(); - } - - public static boolean isOverlayVisible() { + @Override + public boolean isOverlayVisible() { return ConfigObject.getInstance().isOverlayVisible(); } - public static void toggleOverlayVisible() { + @Override + public void toggleOverlayVisible() { ConfigObject.getInstance().setOverlayVisible(!ConfigObject.getInstance().isOverlayVisible()); ConfigManager.getInstance().saveConfig(); } - public static Optional<ContainerScreenOverlay> getOptionalOverlay() { - return Optional.ofNullable(overlay); - } - @Override - public Optional<REIOverlay> getOverlay() { - return Optional.ofNullable(overlay); - } - - public static ContainerScreenOverlay getLastOverlay(boolean reset, boolean setPage) { + public Optional<REIOverlay> getOverlay(boolean reset) { if (overlay == null || reset) { overlay = new ContainerScreenOverlay(); overlay.init(); getSearchField().setFocused(false); } - return overlay; - } - - public static ContainerScreenOverlay getLastOverlay() { - return getLastOverlay(false, false); + + return Optional.ofNullable(overlay); } @Override + @Nullable public AbstractContainerScreen<?> getPreviousContainerScreen() { return previousContainerScreen; } - public static void setPreviousContainerScreen(AbstractContainerScreen<?> previousContainerScreen) { - ScreenHelper.previousContainerScreen = previousContainerScreen; - } - - public static void drawHoveringWidget(PoseStack matrices, int x, int y, TriConsumer<PoseStack, Point, Float> consumer, int width, int height, float delta) { - Window window = Minecraft.getInstance().getWindow(); - drawHoveringWidget(matrices, window.getGuiScaledWidth(), window.getGuiScaledHeight(), x, y, consumer, width, height, delta); + @Override + @Nullable + public Screen getPreviousScreen() { + return previousScreen; } - public static void drawHoveringWidget(PoseStack matrices, int screenWidth, int screenHeight, int x, int y, TriConsumer<PoseStack, Point, Float> consumer, int width, int height, float delta) { - int actualX = Math.max(x + 12, 6); - int actualY = Math.min(y - height / 2, screenHeight - height - 6); - if (actualX + width > screenWidth) - actualX -= 24 + width; - if (actualY < 6) - actualY += 24; - consumer.accept(matrices, new Point(actualX, actualY), delta); + public void setPreviousScreen(Screen previousScreen) { + if (previousScreen == null || previousScreen.getClass().getName().contains(".rei.")) { + return; + } + + this.previousScreen = previousScreen; + + if (previousScreen instanceof AbstractContainerScreen) { + this.previousContainerScreen = (AbstractContainerScreen<?>) previousScreen; + } } @Override @@ -193,30 +168,29 @@ public class ScreenHelper implements REIHelper { } @Override - public @NotNull ResourceLocation getDefaultDisplayTexture() { + public ResourceLocation getDefaultDisplayTexture() { return isDarkThemeEnabled() ? DISPLAY_TEXTURE_DARK : DISPLAY_TEXTURE; } - public ScreenHelper() { - ScreenHelper.instance = this; - attachInstance(instance, REIHelper.class); - } - - public static SearchFieldLocation getContextualSearchFieldLocation() { + @Override + public SearchFieldLocation getContextualSearchFieldLocation() { Window window = Minecraft.getInstance().getWindow(); for (OverlayDecider decider : ScreenRegistry.getInstance().getDeciders(Minecraft.getInstance().screen.getClass())) { if (decider instanceof DisplayBoundsProvider) { Rectangle containerBounds = ((DisplayBoundsProvider<Screen>) decider).getScreenBounds(Minecraft.getInstance().screen); - if (window.getGuiScaledHeight() - 20 <= containerBounds.getMaxY()) + if (window.getGuiScaledHeight() - 20 <= containerBounds.getMaxY()) { return SearchFieldLocation.BOTTOM_SIDE; - else break; + } else break; } } + return ConfigObject.getInstance().getSearchFieldLocation(); } - public static Rectangle getItemListArea(Rectangle bounds) { - SearchFieldLocation searchFieldLocation = ScreenHelper.getContextualSearchFieldLocation(); + @Override + public Rectangle calculateEntryListArea() { + Rectangle bounds = ScreenRegistry.getInstance().getOverlayBounds(ConfigObject.getInstance().getDisplayPanelLocation(), Minecraft.getInstance().screen); + SearchFieldLocation searchFieldLocation = getContextualSearchFieldLocation(); int yOffset = 2; if (searchFieldLocation == SearchFieldLocation.TOP_SIDE) yOffset += 24; @@ -226,13 +200,27 @@ public class ScreenHelper implements REIHelper { return new Rectangle(bounds.x, bounds.y + yOffset, bounds.width, bounds.height - 1 - yOffset - heightOffset); } - public static Rectangle getFavoritesListArea(Rectangle bounds) { + @Override + public Rectangle calculateFavoritesListArea() { + Rectangle bounds = ScreenRegistry.getInstance().getOverlayBounds(ConfigObject.getInstance().getDisplayPanelLocation().mirror(), Minecraft.getInstance().screen); + int yOffset = 8; if (ConfigObject.getInstance().doesShowUtilsButtons()) yOffset += 50; else if (!ConfigObject.getInstance().isLowerConfigButton()) yOffset += 25; return new Rectangle(bounds.x, bounds.y + yOffset, bounds.width, bounds.height - 3 - yOffset); } + @Override + public void startReload() { + getOverlay().ifPresent(REIOverlay::queueReloadOverlay); + lastRecipeScreen.clear(); + } + + @Override + public void endReload() { + getOverlay().ifPresent(REIOverlay::queueReloadOverlay); + } + public void onInitializeClient() { GuiEvent.INIT_PRE.register((screen, widgets, children) -> { if (previousContainerScreen != screen && screen instanceof AbstractContainerScreen) @@ -244,14 +232,4 @@ public class ScreenHelper implements REIHelper { getSearchField().tick(); }); } - - @Override - public void startReload() { - getOverlay().ifPresent(REIOverlay::queueReloadOverlay); - } - - @Override - public void endReload() { - getOverlay().ifPresent(REIOverlay::queueReloadOverlay); - } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/SearchArgument.java b/runtime/src/main/java/me/shedaniel/rei/impl/SearchArgument.java index 469439552..050f16f72 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/SearchArgument.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/SearchArgument.java @@ -26,13 +26,13 @@ package me.shedaniel.rei.impl; import com.google.common.base.MoreObjects; import com.google.common.collect.Lists; import me.shedaniel.math.Point; -import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.gui.widgets.Tooltip; +import me.shedaniel.rei.api.ingredient.EntryStack; +import me.shedaniel.rei.api.util.CollectionUtils; import me.shedaniel.rei.impl.search.AlwaysMatchingArgument; import me.shedaniel.rei.impl.search.Argument; import me.shedaniel.rei.impl.search.ArgumentsRegistry; import me.shedaniel.rei.impl.search.MatchStatus; -import me.shedaniel.rei.api.util.CollectionUtils; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/filtering/FilteringContextImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/filtering/FilteringContextImpl.java index a1636fcd4..15fe9d654 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/filtering/FilteringContextImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/filtering/FilteringContextImpl.java @@ -27,8 +27,8 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.impl.AmountIgnoredEntryStackWrapper; import me.shedaniel.rei.api.util.CollectionUtils; +import me.shedaniel.rei.impl.AmountIgnoredEntryStackWrapper; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/filtering/FilteringResult.java b/runtime/src/main/java/me/shedaniel/rei/impl/filtering/FilteringResult.java index 8da303354..d4acdc665 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/filtering/FilteringResult.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/filtering/FilteringResult.java @@ -25,8 +25,8 @@ package me.shedaniel.rei.impl.filtering; import com.google.common.collect.Lists; import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.impl.AmountIgnoredEntryStackWrapper; import me.shedaniel.rei.api.util.CollectionUtils; +import me.shedaniel.rei.impl.AmountIgnoredEntryStackWrapper; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import org.jetbrains.annotations.ApiStatus; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/filtering/rules/ManualFilteringRule.java b/runtime/src/main/java/me/shedaniel/rei/impl/filtering/rules/ManualFilteringRule.java index ebe957db3..4970f45d5 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/filtering/rules/ManualFilteringRule.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/filtering/rules/ManualFilteringRule.java @@ -29,10 +29,10 @@ import me.shedaniel.rei.api.ConfigObject; import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.ingredient.entry.ComparisonContext; import me.shedaniel.rei.api.ingredient.util.EntryStacks; +import me.shedaniel.rei.api.util.CollectionUtils; import me.shedaniel.rei.impl.filtering.AbstractFilteringRule; import me.shedaniel.rei.impl.filtering.FilteringContext; import me.shedaniel.rei.impl.filtering.FilteringResult; -import me.shedaniel.rei.api.util.CollectionUtils; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/filtering/rules/SearchFilteringRule.java b/runtime/src/main/java/me/shedaniel/rei/impl/filtering/rules/SearchFilteringRule.java index ed7abd4c6..6d5dd25cf 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/filtering/rules/SearchFilteringRule.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/filtering/rules/SearchFilteringRule.java @@ -24,14 +24,14 @@ package me.shedaniel.rei.impl.filtering.rules; import com.google.common.collect.Lists; -import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.gui.config.entry.FilteringEntry; import me.shedaniel.rei.api.gui.config.entry.FilteringRuleOptionsScreen; +import me.shedaniel.rei.api.ingredient.EntryStack; +import me.shedaniel.rei.api.util.CollectionUtils; import me.shedaniel.rei.impl.SearchArgument; import me.shedaniel.rei.impl.filtering.AbstractFilteringRule; import me.shedaniel.rei.impl.filtering.FilteringContext; import me.shedaniel.rei.impl.filtering.FilteringResult; -import me.shedaniel.rei.api.util.CollectionUtils; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.ChatFormatting; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/registry/CategoryRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/registry/CategoryRegistryImpl.java index 4a60b92d5..4766a26b5 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/registry/CategoryRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/registry/CategoryRegistryImpl.java @@ -35,7 +35,6 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import java.util.*; -import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; @ApiStatus.Internal @@ -93,44 +92,46 @@ public class CategoryRegistryImpl implements CategoryRegistry, Reloadable { public int size() { return categories.size(); } + private static class Configuration<T extends Display> implements CategoryConfiguration<T> { private final DisplayCategory<T> category; private final List<EntryIngredient> workstations = Collections.synchronizedList(new ArrayList<>()); - + private Optional<ButtonAreaSupplier> plusButtonArea = Optional.of(ButtonAreaSupplier.defaultArea()); - + public Configuration(DisplayCategory<T> category) { this.category = category; } - + @Override public void addWorkstations(EntryIngredient... stations) { this.workstations.addAll(Arrays.asList(stations)); } - + @Override public void setPlusButtonArea(ButtonAreaSupplier supplier) { this.plusButtonArea = Optional.ofNullable(supplier); } - + @Override public Optional<ButtonAreaSupplier> getPlusButtonArea() { return plusButtonArea; } - + @Override public List<EntryIngredient> getWorkstations() { return Collections.unmodifiableList(this.workstations); } - + @Override public DisplayCategory<T> getCategory() { return this.category; } + |
