aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-07-15 23:55:34 +0800
committershedaniel <daniel@shedaniel.me>2023-05-29 21:09:07 +0800
commit575d49c4a9ffd13ec9cffb2be006d316830a1e83 (patch)
tree3fbaf95d44a55c54fe977fde4f5edee7b143a574 /runtime/src/main/java
parent9950edc980e651614b98d0123f6860609fbada6a (diff)
downloadRoughlyEnoughItems-575d49c4a9ffd13ec9cffb2be006d316830a1e83.tar.gz
RoughlyEnoughItems-575d49c4a9ffd13ec9cffb2be006d316830a1e83.tar.bz2
RoughlyEnoughItems-575d49c4a9ffd13ec9cffb2be006d316830a1e83.zip
Remove subsets, clean up code
Diffstat (limited to 'runtime/src/main/java')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java1
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/RecipeDisplayExporter.java21
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java129
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/Menu.java113
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/EntryStackSubsetsMenuEntry.java136
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/SubSubsetsMenuEntry.java158
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/SearchFilterSyntaxHighlightingScreen.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/PanelWidget.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchField.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchFieldSyntaxHighlighter.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/Argument.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/subsets/SubsetsRegistryImpl.java49
14 files changed, 41 insertions, 592 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java
index 9e8d8baf1..f46bd01a7 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java
@@ -97,7 +97,6 @@ public class ConfigManagerImpl implements ConfigManager {
private ConfigObjectImpl object;
public ConfigManagerImpl() {
- Jankson jankson = Jankson.builder().build();
AutoConfig.register(ConfigObjectImpl.class, (definition, configClass) -> new JanksonConfigSerializer<>(definition, configClass, buildJankson(Jankson.builder())));
GuiRegistry guiRegistry = AutoConfig.getGuiRegistry(ConfigObjectImpl.class);
guiRegistry.registerPredicateProvider((i13n, field, config, defaults, guiProvider) -> {
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/RecipeDisplayExporter.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/RecipeDisplayExporter.java
index be3967b6d..0a544ffeb 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/RecipeDisplayExporter.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/RecipeDisplayExporter.java
@@ -35,7 +35,6 @@ import me.shedaniel.rei.impl.client.gui.toast.ExportRecipeIdentifierToast;
import me.shedaniel.rei.impl.display.DisplaySpec;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.ApiStatus;
@@ -48,13 +47,11 @@ import java.util.Date;
import java.util.List;
@ApiStatus.Internal
-public final class RecipeDisplayExporter extends Widget {
- private static final RecipeDisplayExporter INSTANCE = new RecipeDisplayExporter();
-
+public final class RecipeDisplayExporter {
private RecipeDisplayExporter() {}
public static void exportRecipeDisplay(Rectangle rectangle, DisplaySpec display, List<Widget> widgets, boolean toast) {
- INSTANCE.exportRecipe(rectangle, display, widgets);
+ exportRecipe(rectangle, display, widgets);
if (toast) {
ExportRecipeIdentifierToast.addToast(I18n.get("msg.rei.exported_recipe"), I18n.get("msg.rei.exported_recipe.desc"));
}
@@ -78,7 +75,7 @@ public final class RecipeDisplayExporter extends Widget {
}
}
- private void exportRecipe(Rectangle rectangle, DisplaySpec display, List<Widget> widgets) {
+ private static void exportRecipe(Rectangle rectangle, DisplaySpec display, List<Widget> widgets) {
RenderSystem.pushMatrix();
Minecraft client = Minecraft.getInstance();
Window window = client.getWindow();
@@ -113,7 +110,7 @@ public final class RecipeDisplayExporter extends Widget {
}
Util.ioPool().execute(() -> {
try {
- File export = new File(minecraft.gameDirectory, "rei_exports/" + display.provideInternalDisplay().getCategoryIdentifier().toString().replace('/', '_').replace(':', '_'));
+ File export = new File(Minecraft.getInstance().gameDirectory, "rei_exports/" + display.provideInternalDisplay().getCategoryIdentifier().toString().replace('/', '_').replace(':', '_'));
export.mkdirs();
strippedImage.writeToFile(getExportFilename(display, export));
} catch (IOException e) {
@@ -125,14 +122,4 @@ public final class RecipeDisplayExporter extends Widget {
}
});
}
-
- @Override
- public void render(PoseStack matrixStack, int mouseY, int i, float f) {
-
- }
-
- @Override
- public List<? extends GuiEventListener> children() {
- return null;
- }
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
index 8da0a8cf6..7041b6a1a 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
@@ -76,18 +76,13 @@ import me.shedaniel.rei.impl.client.gui.widget.entrylist.PaginatedEntryListWidge
import me.shedaniel.rei.impl.client.gui.widget.entrylist.ScrolledEntryListWidget;
import me.shedaniel.rei.impl.client.gui.widget.favorites.FavoritesListWidget;
import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField;
-import me.shedaniel.rei.impl.common.util.Weather;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.chat.NarratorChatListener;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
-import net.minecraft.client.multiplayer.ClientLevel;
-import net.minecraft.client.multiplayer.PlayerInfo;
import net.minecraft.client.renderer.entity.ItemRenderer;
-import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
@@ -95,7 +90,6 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
-import net.minecraft.world.level.GameType;
import net.minecraft.world.level.block.Blocks;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
@@ -221,14 +215,6 @@ public class ScreenOverlayImpl extends ScreenOverlay {
}
@ApiStatus.Internal
- @Nullable
- public Menu getOverlayMenu() {
- if (isMenuOpened(Menu.SUBSETS))
- return this.overlayMenu.menu;
- throw new IllegalStateException("Subsets menu accessed when subsets are not opened!");
- }
-
- @ApiStatus.Internal
@Override
public void closeOverlayMenu() {
OverlayMenu tmpOverlayMenu = this.overlayMenu;
@@ -255,10 +241,6 @@ public class ScreenOverlayImpl extends ScreenOverlay {
return !this.bounds.isEmpty();
}
- public void init(boolean useless) {
- init();
- }
-
public void init() {
draggingStack.set(DraggableComponentProvider.from(ScreenRegistry.getInstance()::getDraggableComponentProviders),
DraggableComponentVisitor.from(ScreenRegistry.getInstance()::getDraggableComponentVisitors));
@@ -384,17 +366,6 @@ public class ScreenOverlayImpl extends ScreenOverlay {
})
)
));
- Rectangle subsetsButtonBounds = getSubsetsButtonBounds();
- if (ConfigObject.getInstance().isSubsetsEnabled()) {
- widgets.add(InternalWidgets.wrapLateRenderable(Widgets.createButton(subsetsButtonBounds, ClientHelperImpl.getInstance().isAprilFools.get() ? new TranslatableComponent("text.rei.tiny_potato") : new TranslatableComponent("text.rei.subsets"))
- .onClick(button -> {
- proceedOpenMenuOrElse(Menu.SUBSETS, () -> {
- openMenu(Menu.SUBSETS, Menu.createSubsetsMenuFromRegistry(subsetsButtonBounds), point -> true, point -> ConfigObject.getInstance().isSubsetsEnabled());
- }, menu -> {
- closeOverlayMenu();
- });
- })));
- }
if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) {
widgets.add(Widgets.createClickableLabel(new Point(bounds.x + ((bounds.width - 18) / 2), bounds.y + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + 10), NarratorChatListener.NO_TITLE, label -> {
if (!Screen.hasShiftDown()) {
@@ -515,63 +486,16 @@ public class ScreenOverlayImpl extends ScreenOverlay {
);
}
- private Rectangle getSubsetsButtonBounds() {
- if (ConfigObject.getInstance().isSubsetsEnabled()) {
- ScreenRegistry registry = ScreenRegistry.getInstance();
- Rectangle screenBounds = registry.getScreenBounds(minecraft.screen);
- return new Rectangle(screenBounds.x, 3, screenBounds.width, 18);
- }
- return null;
- }
-
- private Weather getNextWeather() {
- try {
- Weather current = getCurrentWeather();
- int next = current.getId() + 1;
- if (next >= 3)
- next = 0;
- return Weather.byId(next);
- } catch (Exception e) {
- return Weather.CLEAR;
- }
- }
-
- private Weather getCurrentWeather() {
- ClientLevel world = Minecraft.getInstance().level;
- if (world.isThundering())
- return Weather.THUNDER;
- if (world.getLevelData().isRaining())
- return Weather.RAIN;
- return Weather.CLEAR;
- }
-
- private String getGameModeShortText(GameType gameMode) {
- return I18n.get("text.rei.short_gamemode." + gameMode.getName());
- }
-
- private String getGameModeText(GameType gameMode) {
- return I18n.get("selectWorld.gameMode." + gameMode.getName());
- }
-
- private GameType getCurrentGameMode() {
- PlayerInfo info = Minecraft.getInstance().getConnection().getPlayerInfo(Minecraft.getInstance().player.getGameProfile().getId());
- return info == null ? GameType.SURVIVAL : info.getGameMode();
- }
-
private Rectangle getSearchFieldArea() {
int widthRemoved = 1;
if (ConfigObject.getInstance().isCraftableFilterEnabled()) widthRemoved += 22;
if (ConfigObject.getInstance().isLowerConfigButton()) widthRemoved += 22;
SearchFieldLocation searchFieldLocation = REIRuntime.getInstance().getContextualSearchFieldLocation();
- switch (searchFieldLocation) {
- case TOP_SIDE:
- return getTopSideSearchFieldArea(widthRemoved);
- case BOTTOM_SIDE:
- return getBottomSideSearchFieldArea(widthRemoved);
- default:
- case CENTER:
- return getCenterSearchFieldArea(widthRemoved);
- }
+ return switch (searchFieldLocation) {
+ case TOP_SIDE -> getTopSideSearchFieldArea(widthRemoved);
+ case BOTTOM_SIDE -> getBottomSideSearchFieldArea(widthRemoved);
+ case CENTER -> getCenterSearchFieldArea(widthRemoved);
+ };
}
private Rectangle getTopSideSearchFieldArea(int widthRemoved) {
@@ -608,10 +532,6 @@ public class ScreenOverlayImpl extends ScreenOverlay {
return new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getGuiScaledWidth() - 30 : 10, 10, 20, 20);
}
- private String getCheatModeText() {
- return I18n.get(String.format("%s%s", "text.rei.", ClientHelper.getInstance().isCheating() ? "cheat" : "nocheat"));
- }
-
@Override
public Rectangle getBounds() {
return bounds;
@@ -672,17 +592,7 @@ public class ScreenOverlayImpl extends ScreenOverlay {
this.renderWidgets(matrices, mouseX, mouseY, delta);
if (ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) {
Screen screen = Minecraft.getInstance().screen;
- ClickArea.ClickAreaContext<Screen> context = new ClickArea.ClickAreaContext<Screen>() {
- @Override
- public Screen getScreen() {
- return screen;
- }
-
- @Override
- public Point getMousePosition() {
- return new Point(mouseX, mouseY);
- }
- };
+ ClickArea.ClickAreaContext<Screen> context = createClickAreaContext(mouseX, mouseY, screen);
List<Component> clickAreaTooltips = ScreenRegistry.getInstance().getClickAreaTooltips((Class<Screen>) screen.getClass(), context);
if (clickAreaTooltips != null && !clickAreaTooltips.isEmpty()) {
Tooltip.create(clickAreaTooltips).queue();
@@ -690,6 +600,20 @@ public class ScreenOverlayImpl extends ScreenOverlay {
}
}
+ private ClickArea.ClickAreaContext<Screen> createClickAreaContext(double mouseX, double mouseY, Screen screen) {
+ return new ClickArea.ClickAreaContext<>() {
+ @Override
+ public Screen getScreen() {
+ return screen;
+ }
+
+ @Override
+ public Point getMousePosition() {
+ return new Point(mouseX, mouseY);
+ }
+ };
+ }
+
private static Rectangle calculateOverlayBounds() {
Rectangle bounds = ScreenRegistry.getInstance().getOverlayBounds(ConfigObject.getInstance().getDisplayPanelLocation(), Minecraft.getInstance().screen);
@@ -731,7 +655,6 @@ public class ScreenOverlayImpl extends ScreenOverlay {
choosePageWidget.render(matrices, mouseX, mouseY, delta);
}
}
- Screen currentScreen = Minecraft.getInstance().screen;
if (choosePageWidget == null) {
TOOLTIPS.stream().filter(Objects::nonNull)
.reduce((tooltip, tooltip2) -> tooltip2)
@@ -941,17 +864,7 @@ public class ScreenOverlayImpl extends ScreenOverlay {
}
if (ConfigObject.getInstance().areClickableRecipeArrowsEnabled()) {
Screen screen = Minecraft.getInstance().screen;
- ClickArea.ClickAreaContext<Screen> context = new ClickArea.ClickAreaContext<Screen>() {
- @Override
- public Screen getScreen() {
- return screen;
- }
-
- @Override
- public Point getMousePosition() {
- return new Point(mouseX, mouseY);
- }
- };
+ ClickArea.ClickAreaContext<Screen> context = createClickAreaContext(mouseX, mouseY, screen);
if (ScreenRegistry.getInstance().executeClickArea((Class<Screen>) screen.getClass(), context)) {
return true;
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/Menu.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/Menu.java
index 2f7e57bb3..a343975bb 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/Menu.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/Menu.java
@@ -24,41 +24,26 @@
package me.shedaniel.rei.impl.client.gui.modules;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.clothconfig2.ClothConfigInitializer;
import me.shedaniel.clothconfig2.api.ScissorsHandler;
import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
-import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.client.REIRuntime;
import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds;
-import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
-import me.shedaniel.rei.api.client.subsets.SubsetsRegistry;
-import me.shedaniel.rei.api.common.entry.EntryStack;
-import me.shedaniel.rei.api.common.util.CollectionUtils;
-import me.shedaniel.rei.api.common.util.EntryStacks;
-import me.shedaniel.rei.impl.client.gui.modules.entries.EntryStackSubsetsMenuEntry;
import me.shedaniel.rei.impl.client.gui.modules.entries.SubMenuEntry;
-import me.shedaniel.rei.impl.client.gui.modules.entries.SubSubsetsMenuEntry;
import me.shedaniel.rei.impl.client.gui.widget.LateRenderable;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.resources.language.I18n;
-import net.minecraft.core.Registry;
-import net.minecraft.network.chat.TranslatableComponent;
-import net.minecraft.world.item.CreativeModeTab;
-import net.minecraft.world.item.Item;
-import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.ApiStatus;
-import java.util.*;
-import java.util.stream.Collectors;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.List;
+import java.util.UUID;
@ApiStatus.Internal
public class Menu extends WidgetWithBounds implements LateRenderable {
- public static final UUID SUBSETS = UUID.randomUUID();
public static final UUID WEATHER = UUID.randomUUID();
public static final UUID GAME_TYPE = UUID.randomUUID();
@@ -106,96 +91,6 @@ public class Menu extends WidgetWithBounds implements LateRenderable {
this.menuStartPoint = new Point(x, y);
}
- public static Menu createSubsetsMenuFromRegistry(Rectangle menuStart) {
- EntryRegistry instance = EntryRegistry.getInstance();
- List<? extends EntryStack<?>> stacks = instance.getEntryStacks().collect(Collectors.toList());
- Map<String, Object> entries = Maps.newHashMap();
- {
- // All Entries group
- Map<String, Object> allEntries = getOrCreateSubEntryInMap(entries, "roughlyenoughitems:all_entries");
- for (EntryStack<?> stack : stacks) {
- putEntryInMap(allEntries, stack);
- }
- }
- {
- // Item Groups group
- Map<String, Object> itemGroups = getOrCreateSubEntryInMap(entries, "roughlyenoughitems:item_groups");
- for (Item item : Registry.ITEM) {
- CreativeModeTab group = item.getItemCategory();
- if (group == null)
- continue;
- List<ItemStack> list;
- try {
- list = instance.appendStacksForItem(item);
- Map<String, Object> groupMenu = getOrCreateSubEntryInMap(itemGroups, "_item_group_" + group.langId);
- for (ItemStack stack : list) {
- putEntryInMap(groupMenu, EntryStacks.of(stack));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- Set<String> paths = SubsetsRegistry.getInstance().getPaths();
- for (String path : paths) {
- Map<String, Object> lastMap = entries;
- String[] pathSegments = path.split("/");
- for (String pathSegment : pathSegments) {
- lastMap = getOrCreateSubEntryInMap(lastMap, pathSegment);
- }
- for (EntryStack<?> entry : SubsetsRegistry.getInstance().getPathEntries(path)) {
- EntryStack<?> firstStack = CollectionUtils.findFirstOrNullEqualsExact(stacks, entry);
- if (firstStack != null) {
- putEntryInMap(lastMap, firstStack);
- }
- }
- }
- return new Menu(menuStart, buildEntries(entries), true);
- }
-
- private static Map<String, Object> getOrCreateSubEntryInMap(Map<String, Object> parent, String pathSegment) {
- putEntryInMap(parent, pathSegment);
- return (Map<String, Object>) parent.get(pathSegment);
- }
-
- private static void putEntryInMap(Map<String, Object> parent, String pathSegment) {
- if (!parent.containsKey(pathSegment)) {
- parent.put(pathSegment, Maps.newHashMap());
- }
- }
-
- private static void putEntryInMap(Map<String, Object> parent, EntryStack<?> stack) {
- Set<EntryStack<?>> items = (Set<EntryStack<?>>) parent.get("items");
- if (items == null) {
- items = Sets.newLinkedHashSet();
- parent.put("items", items);
- }
- items.add(stack);
- }
-
- private static List<MenuEntry> buildEntries(Map<String, Object> map) {
- List<MenuEntry> entries = Lists.newArrayList();
- for (Map.Entry<String, Object> entry : map.entrySet()) {
- if (entry.getKey().equals("items")) {
- Set<EntryStack<?>> items = (Set<EntryStack<?>>) entry.getValue();
- for (EntryStack<?> item : items) {
- entries.add(new EntryStackSubsetsMenuEntry(item));
- }
- } else {
- Map<String, Object> entryMap = (Map<String, Object>) entry.getValue();
- if (entry.getKey().startsWith("_item_group_")) {
- entries.add(new SubSubsetsMenuEntry(new TranslatableComponent(entry.getKey().replace("_item_group_", "itemGroup.")), buildEntries(entryMap)));
- } else {
- String translationKey = "subsets.rei." + entry.getKey().replace(':', '.');
- if (!I18n.exists(translationKey))
- RoughlyEnoughItemsCore.LOGGER.warn("Subsets menu " + translationKey + " does not have a translation");
- entries.add(new SubSubsetsMenuEntry(new TranslatableComponent(translationKey), buildEntries(entryMap)));
- }
- }
- }
- return entries;
- }
-
@SuppressWarnings("deprecation")
private void buildEntries(Collection<MenuEntry> entries, boolean sort) {
this.entries.clear();
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/EntryStackSubsetsMenuEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/EntryStackSubsetsMenuEntry.java
deleted file mode 100644
index dfe6fac94..000000000
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/EntryStackSubsetsMenuEntry.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.impl.client.gui.modules.entries;
-
-import com.mojang.blaze3d.vertex.PoseStack;
-import me.shedaniel.math.Point;
-import me.shedaniel.math.Rectangle;
-import me.shedaniel.rei.RoughlyEnoughItemsCoreClient;
-import me.shedaniel.rei.api.client.REIRuntime;
-import me.shedaniel.rei.api.client.config.ConfigManager;
-import me.shedaniel.rei.api.client.config.ConfigObject;
-import me.shedaniel.rei.api.client.config.entry.EntryStackProvider;
-import me.shedaniel.rei.api.client.gui.widgets.TooltipContext;
-import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
-import me.shedaniel.rei.api.common.entry.EntryStack;
-import me.shedaniel.rei.api.common.util.EntryStacks;
-import me.shedaniel.rei.impl.client.REIRuntimeImpl;
-import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
-import me.shedaniel.rei.impl.client.gui.modules.AbstractMenuEntry;
-import me.shedaniel.rei.impl.client.gui.modules.Menu;
-import me.shedaniel.rei.impl.client.gui.modules.MenuEntry;
-import net.minecraft.client.gui.components.events.GuiEventListener;
-import net.minecraft.client.resources.sounds.SimpleSoundInstance;
-import net.minecraft.sounds.SoundEvents;
-import org.jetbrains.annotations.ApiStatus;
-
-import java.util.Collections;
-import java.util.List;
-
-@ApiStatus.Experimental
-@ApiStatus.Internal
-public class EntryStackSubsetsMenuEntry extends AbstractMenuEntry {
- final EntryStack<?> stack;
- private boolean clickedLast = false;
- private Boolean isFiltered = null;
-
- public EntryStackSubsetsMenuEntry(EntryStack<?> stack) {
- this.stack = stack;
- }
-
- @Override
- public int getEntryWidth() {
- return 18;
- }
-
- @Override
- public int getEntryHeight() {
- return 18;
- }
-
- @Override
- public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
- if (isFiltered()) {
- fill(matrices, getX(), getY(), getX() + getWidth(), getY() + 18, isSelected() ? -26215 : -65536);
- } else if (isSelected()) {
- fill(matrices, getX(), getY(), getX() + getWidth(), getY() + 18, 1174405119);
- }
- if (containsMouse() && mouseX >= getX() + (getWidth() / 2) - 8 && mouseX <= getX() + (getWidth() / 2) + 8 && mouseY >= getY() + 1 && mouseY <= getY() + 17) {
- REIRuntime.getInstance().queueTooltip(stack.getTooltip(TooltipContext.of(new Point(mouseX, mouseY))));
- if (RoughlyEnoughItemsCoreClient.isLeftMousePressed && !clickedLast) {
- clickedLast = true;
- if (getParent().scrolling.getScissorBounds().contains(mouseX, mouseY)) {
- minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
- List<EntryStackProvider<?>> filteredStacks = ConfigObject.getInstance().getFilteredStackProviders();
- if (isFiltered()) {
- filteredStacks.removeIf(next -> EntryStacks.equalsExact(next.provide(), stack));
- } else {
- filteredStacks.add(EntryStackProvider.ofStack(stack.normalize()));
- }
- Menu menu = ((ScreenOverlayImpl) REIRuntime.getInstance().getOverlay().get()).getOverlayMenu();
- if (menu != null)
- recalculateFilter(menu);
- ConfigManager.getInstance().saveConfig();
- EntryRegistry.getInstance().refilter();
- if (REIRuntimeImpl.getSearchField() != null) {
- ScreenOverlayImpl.getEntryListWidget().updateSearch(REIRuntimeImpl.getSearchField().getText(), true);
- }
- }
- } else if (!RoughlyEnoughItemsCoreClient.isLeftMousePressed) clickedLast = false;
- } else clickedLast = false;
- stack.render(matrices, new Rectangle(getX() + (getWidth() / 2) - 8, getY() + 1, 16, 16), mouseX, mouseY, delta);
- }
-
- void recalculateFilter(Menu menu) {
- for (MenuEntry child : menu.children()) {
- if (child instanceof SubSubsetsMenuEntry && ((SubSubsetsMenuEntry) child).getChildMenu() != null) {
- recalculateFilter(((SubSubsetsMenuEntry) child).getChildMenu());
- } else if (child instanceof EntryStackSubsetsMenuEntry && EntryStacks.equalsExact(((EntryStackSubsetsMenuEntry) child).stack, stack)) {
- ((EntryStackSubsetsMenuEntry) child).isFiltered = null;
- }
- }
- }
-
- @Override
- public boolean mouseClicked(double mouseX, double mouseY, int button) {
- return isRendering() && mouseX >= getX() && mouseX <= getX() + getWidth() && mouseY >= getY() && mouseY <= getY() + getEntryHeight();
- }
-
- @Override
- public List<? extends GuiEventListener> children() {
- return Collections.emptyList();
- }
-
- public boolean isFiltered() {
- if (isFiltered == null) {
- isFiltered = false;
- List<EntryStackProvider<?>> filteredStacks = ConfigObject.getInstance().getFilteredStackProviders();
- for (EntryStackProvider<?> provider : filteredStacks) {
- if (EntryStacks.equalsExact(provider.provide(), stack))
- return isFiltered = true;
- }
- }
- return isFiltered;
- }
-}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/SubSubsetsMenuEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/SubSubsetsMenuEntry.java
deleted file mode 100644
index 04df18b12..000000000
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/SubSubsetsMenuEntry.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.impl.client.gui.modules.entries;
-
-import com.mojang.blaze3d.vertex.PoseStack;
-import me.shedaniel.rei.api.client.REIRuntime;
-import me.shedaniel.rei.api.client.config.ConfigManager;
-import me.shedaniel.rei.api.client.config.ConfigObject;
-import me.shedaniel.rei.api.client.config.entry.EntryStackProvider;
-import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
-import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
-import me.shedaniel.rei.api.common.util.EntryStacks;
-import me.shedaniel.rei.impl.client.REIRuntimeImpl;
-import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
-import me.shedaniel.rei.impl.client.gui.modules.Menu;
-import me.shedaniel.rei.impl.client.gui.modules.MenuEntry;
-import net.minecraft.client.resources.sounds.SimpleSoundInstance;
-import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.TextComponent;
-import net.minecraft.sounds.SoundEvents;
-import net.minecraft.util.Mth;
-import net.minecraft.util.Tuple;
-import org.jetbrains.annotations.ApiStatus;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.function.Supplier;
-
-@ApiStatus.Internal
-public class SubSubsetsMenuEntry extends SubMenuEntry {
- private Tuple<Integer, Integer> filteredRatio = null;
- private long lastListHash = -1;
- private boolean clickedBefore = false;
-
- public SubSubsetsMenuEntry(Component text) {
- t