diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-10-26 10:49:27 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-10-29 14:02:27 +0800 |
| commit | 9ea4a22e9a194fd8fdc2fb03226ab38ee175a6cc (patch) | |
| tree | b4db2569bc4a90d7bb835ff451fe5e11e86e8968 /RoughlyEnoughItems-runtime/src | |
| parent | b7f8fc61dcaa6d202809651d46cf0946b63beef7 (diff) | |
| download | RoughlyEnoughItems-9ea4a22e9a194fd8fdc2fb03226ab38ee175a6cc.tar.gz RoughlyEnoughItems-9ea4a22e9a194fd8fdc2fb03226ab38ee175a6cc.tar.bz2 RoughlyEnoughItems-9ea4a22e9a194fd8fdc2fb03226ab38ee175a6cc.zip | |
Favorites Dragging
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'RoughlyEnoughItems-runtime/src')
21 files changed, 1509 insertions, 331 deletions
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 2bb94e36e..9ea31b888 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -25,11 +25,17 @@ package me.shedaniel.rei; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import me.shedaniel.cloth.api.client.events.v0.ClothClientHooks; +import me.shedaniel.clothconfig2.api.LazyResettable; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.math.api.Executor; import me.shedaniel.rei.api.*; +import me.shedaniel.rei.api.favorites.FavoriteEntry; +import me.shedaniel.rei.api.favorites.FavoriteEntryType; +import me.shedaniel.rei.api.favorites.FavoriteMenuEntry; import me.shedaniel.rei.api.fluid.FluidSupportProvider; import me.shedaniel.rei.api.fractions.Fraction; import me.shedaniel.rei.api.plugins.REIPluginV0; @@ -66,6 +72,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; import net.minecraft.network.chat.TextComponent; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.GsonHelper; import net.minecraft.world.InteractionResult; import net.minecraft.world.inventory.CraftingMenu; import net.minecraft.world.inventory.Slot; @@ -77,6 +84,7 @@ import net.minecraft.world.level.material.Fluid; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; @@ -88,6 +96,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.function.BiFunction; import java.util.function.Function; +import java.util.function.Supplier; import java.util.stream.Stream; import static me.shedaniel.rei.impl.Internals.attachInstance; @@ -180,6 +189,94 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { return new FillRectangleDrawableConsumer(rectangle, color); } }, Internals.WidgetsProvider.class); + attachInstance((Supplier<FavoriteEntryType.Registry>) FavoriteEntryTypeRegistryImpl::getInstance, "favoriteEntryTypeRegistry"); + attachInstance((BiFunction<Supplier<FavoriteEntry>, Supplier<JsonObject>, FavoriteEntry>) (supplier, toJson) -> new FavoriteEntry() { + LazyResettable<FavoriteEntry> value = new LazyResettable<>(supplier); + + @Override + public FavoriteEntry getUnwrapped() { + FavoriteEntry entry = value.get(); + if (entry == null) { + value.reset(); + } + return Objects.requireNonNull(entry).getUnwrapped(); + } + + @Override + public UUID getUuid() { + return getUnwrapped().getUuid(); + } + + @Override + public boolean isInvalid() { + try { + return getUnwrapped().isInvalid(); + } catch (Exception e) { + return true; + } + } + + @Override + public EntryStack getWidget(boolean showcase) { + return getUnwrapped().getWidget(showcase); + } + + @Override + public boolean doAction(int button) { + return getUnwrapped().doAction(button); + } + + @Override + public @NotNull Optional<Supplier<Collection<@NotNull FavoriteMenuEntry>>> getMenuEntries() { + return getUnwrapped().getMenuEntries(); + } + + @Override + public int hashIgnoreAmount() { + return getUnwrapped().hashIgnoreAmount(); + } + + @Override + public FavoriteEntry copy() { + return FavoriteEntry.delegate(supplier, toJson); + } + + @Override + public ResourceLocation getType() { + return getUnwrapped().getType(); + } + + @Override + public @NotNull JsonObject toJson(@NotNull JsonObject to) { + if (toJson == null) { + return getUnwrapped().toJson(to); + } + + JsonObject object = toJson.get(); + for (Map.Entry<String, JsonElement> entry : object.entrySet()) { + to.add(entry.getKey(), entry.getValue()); + } + return to; + } + + @Override + public boolean isSame(FavoriteEntry other) { + return getUnwrapped().isSame(other.getUnwrapped()); + } + }, "delegateFavoriteEntry"); + attachInstance((Function<JsonObject, FavoriteEntry>) (object) -> { + String type = GsonHelper.getAsString(object, FavoriteEntry.TYPE_KEY); + switch (type) { + case "stack": + case "item": + case "fluid": + case "empty": + return FavoriteEntry.fromEntryStack(EntryStack.readFromJson(object)); + default: + ResourceLocation id = new ResourceLocation(type); + return Objects.requireNonNull(Objects.requireNonNull(FavoriteEntryType.registry().get(id)).fromJson(object)); + } + }, "favoriteEntryFromJson"); attachInstance((BiFunction<@Nullable Point, Collection<Component>, Tooltip>) QueuedTooltip::create, "tooltipProvider"); attachInstance((Function<@Nullable Boolean, ClickAreaHandler.Result>) successful -> new ClickAreaHandler.Result() { private List<ResourceLocation> categories = Lists.newArrayList(); @@ -189,12 +286,12 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { this.categories.add(category); return this; } - + @Override public boolean isSuccessful() { return successful; } - + @Override public Stream<ResourceLocation> getCategories() { return categories.stream(); @@ -387,6 +484,13 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { if (isDebugModeEnabled()) { registerPlugin(new REITestPlugin()); } + if (FabricLoader.getInstance().isModLoaded("libblockattributes-fluids")) { + try { + registerPlugin((REIPluginEntry) Class.forName("me.shedaniel.rei.compat.LBASupportPlugin").getConstructor().newInstance()); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + } } private boolean shouldReturn(Screen screen) { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/compat/LBASupportPlugin.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/compat/LBASupportPlugin.java new file mode 100644 index 000000000..d2e31a6f7 --- /dev/null +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/compat/LBASupportPlugin.java @@ -0,0 +1,59 @@ +/* + * 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.compat; + +import alexiil.mc.lib.attributes.fluid.FluidAttributes; +import alexiil.mc.lib.attributes.fluid.GroupedFluidInvView; +import alexiil.mc.lib.attributes.fluid.amount.FluidAmount; +import me.shedaniel.rei.api.EntryStack; +import me.shedaniel.rei.api.RecipeHelper; +import me.shedaniel.rei.api.fluid.FluidSupportProvider; +import me.shedaniel.rei.api.fractions.Fraction; +import me.shedaniel.rei.api.plugins.REIPluginV0; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.InteractionResultHolder; + +import java.util.stream.Stream; + +public class LBASupportPlugin implements REIPluginV0 { + @Override + public ResourceLocation getPluginIdentifier() { + return new ResourceLocation("roughlyenoughitems", "lba_support"); + } + + @Override + public void registerOthers(RecipeHelper recipeHelper) { + FluidSupportProvider.getInstance().registerProvider(itemStack -> { + GroupedFluidInvView view = FluidAttributes.GROUPED_INV_VIEW.get(itemStack.getItemStack()); + if (view.getStoredFluids().size() > 0) + return InteractionResultHolder.success(view.getStoredFluids().stream() + .filter(fluidKey -> !fluidKey.isEmpty() && fluidKey.getRawFluid() != null) + .map(fluidKey -> { + FluidAmount amount = view.getAmount_F(fluidKey); + return EntryStack.create(fluidKey.getRawFluid(), Fraction.of(amount.whole, amount.numerator, amount.denominator)); + })); + return InteractionResultHolder.pass(Stream.empty()); + }); + } +} diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index 4e0a5e06b..08132ae85 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -35,6 +35,7 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.*; +import me.shedaniel.rei.api.favorites.FavoriteEntry; import me.shedaniel.rei.api.widgets.Button; import me.shedaniel.rei.api.widgets.Tooltip; import me.shedaniel.rei.api.widgets.Widgets; @@ -72,11 +73,12 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; +import java.util.function.Consumer; +import java.util.function.Predicate; import java.util.stream.Collectors; @ApiStatus.Internal public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverlay { - private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); private static final List<Tooltip> TOOLTIPS = Lists.newArrayList(); private static final List<Runnable> AFTER_RENDER = Lists.newArrayList(); @@ -120,22 +122,9 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl private Button leftButton, rightButton; @ApiStatus.Experimental private Rectangle subsetsButtonBounds; - @ApiStatus.Experimental - @Nullable - private Menu subsetsMenu = null; - private Widget wrappedSubsetsMenu = null; @Nullable - private Menu weatherMenu = null; - private Widget wrappedWeatherMenu = null; - private boolean renderWeatherMenu = false; - private Button weatherButton = null; - - @Nullable - private Menu gameModeMenu = null; - private Widget wrappedGameModeMenu = null; - private boolean renderGameModeMenu = false; - private Button gameModeButton = null; + private ContainerScreenOverlay.OverlayMenu overlayMenu = null; public static EntryListWidget getEntryListWidget() { return ENTRY_LIST_WIDGET; @@ -146,26 +135,67 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl return favoritesListWidget; } - @ApiStatus.Experimental - @Nullable - public Menu getSubsetsMenu() { - return subsetsMenu; + private static class OverlayMenu { + @NotNull + private UUID uuid; + @NotNull + private Menu menu; + @NotNull + private Widget wrappedMenu; + @NotNull + private Predicate<Point> inBounds; + + public OverlayMenu(@NotNull UUID uuid, @NotNull Menu menu, @NotNull Widget wrappedMenu, @NotNull Predicate<Point> inBounds) { + this.uuid = uuid; + this.menu = menu; + this.wrappedMenu = wrappedMenu; + this.inBounds = inBounds.or(point -> menu.getBounds().contains(point)); + } + } + + public boolean isMenuOpened(UUID uuid) { + return overlayMenu != null && overlayMenu.uuid.equals(uuid); + } + + public boolean isAnyMenuOpened() { + return overlayMenu != null; } - public void removeWeatherMenu() { - this.renderWeatherMenu = false; - Widget tmpWeatherMenu = wrappedWeatherMenu; - AFTER_RENDER.add(() -> this.widgets.remove(tmpWeatherMenu)); - this.weatherMenu = null; - this.wrappedWeatherMenu = null; + public boolean isMenuInBounds(UUID uuid) { + return isMenuOpened(uuid) && overlayMenu.inBounds.test(PointHelper.ofMouse()); } - public void removeGameModeMenu() { - this.renderGameModeMenu = false; - Widget tmpGameModeMenu = wrappedGameModeMenu; - AFTER_RENDER.add(() -> this.widgets.remove(tmpGameModeMenu)); - this.gameModeMenu = null; - this.wrappedGameModeMenu = null; + private void proceedOpenMenu(UUID uuid, Runnable runnable) { + proceedOpenMenuOrElse(uuid, runnable, menu -> {}); + } + + private void proceedOpenMenuOrElse(UUID uuid, Runnable runnable, Consumer<OverlayMenu> orElse) { + if (overlayMenu == null || !overlayMenu.uuid.equals(uuid)) { + removeOverlayMenu(); + runnable.run(); + } else { + orElse.accept(this.overlayMenu); + } + } + + public void openMenu(UUID uuid, Menu menu, Predicate<Point> inPoint) { + this.overlayMenu = new OverlayMenu(uuid, menu, InternalWidgets.wrapTranslate(menu, 0, 0, 400), inPoint); + } + + @ApiStatus.Internal + @Nullable + public Menu getSubsetsMenu() { + if (isMenuOpened(Menu.SUBSETS)) + return this.overlayMenu.menu; + throw new IllegalStateException("Subsets menu accessed when subsets are not opened!"); + } + + @ApiStatus.Internal + public void removeOverlayMenu() { + OverlayMenu tmpOverlayMenu = this.overlayMenu; + if (tmpOverlayMenu != null) + AFTER_RENDER.add(() -> this.widgets.remove(tmpOverlayMenu.wrappedMenu)); + this.overlayMenu = null; } @Override @@ -181,17 +211,14 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl this.shouldReInit = false; //Update Variables this.children().clear(); - this.wrappedSubsetsMenu = null; - this.subsetsMenu = null; - this.weatherMenu = null; - this.renderWeatherMenu = false; - this.weatherButton = null; + this.removeOverlayMenu(); this.window = Minecraft.getInstance().getWindow(); this.bounds = DisplayHelper.getInstance().getOverlayBounds(ConfigObject.getInstance().getDisplayPanelLocation(), Minecraft.getInstance().screen); widgets.add(ENTRY_LIST_WIDGET); if (ConfigObject.getInstance().isFavoritesEnabled()) { if (favoritesListWidget == null) favoritesListWidget = new FavoritesListWidget(); +// favoritesListWidget.favoritePanel.resetRows(); widgets.add(favoritesListWidget); } ENTRY_LIST_WIDGET.updateArea(ScreenHelper.getSearchField() == null ? "" : null); @@ -268,20 +295,21 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl )); tmp.setZ(600); if (ConfigObject.getInstance().doesShowUtilsButtons()) { - widgets.add(gameModeButton = Widgets.createButton(ConfigObject.getInstance().isLowerConfigButton() ? new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getGuiScaledWidth() - 30 : 10, 10, 20, 20) : new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getGuiScaledWidth() - 55 : 35, 10, 20, 20), NarratorChatListener.NO_TITLE) + widgets.add(Widgets.createButton(ConfigObject.getInstance().isLowerConfigButton() ? new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getGuiScaledWidth() - 30 : 10, 10, 20, 20) : new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getGuiScaledWidth() - 55 : 35, 10, 20, 20), NarratorChatListener.NO_TITLE) .onRender((matrices, button) -> { - boolean tmpRender = renderGameModeMenu; - renderGameModeMenu = !renderWeatherMenu && (button.isFocused() || button.containsMouse(PointHelper.ofMouse()) || (wrappedGameModeMenu != null && wrappedGameModeMenu.containsMouse(PointHelper.ofMouse()))); - if (tmpRender != renderGameModeMenu) { - if (renderGameModeMenu) { - this.gameModeMenu = new Menu(new Point(button.getBounds().x, button.getBounds().getMaxY()), - CollectionUtils.filterAndMap(Arrays.asList(GameType.values()), mode -> mode != GameType.NOT_SET, GameModeMenuEntry::new)); - if (ConfigObject.getInstance().isLeftHandSidePanel()) - this.gameModeMenu.menuStartPoint.x -= this.gameModeMenu.getBounds().width - this.gameModeButton.getBounds().width; - this.wrappedGameModeMenu = InternalWidgets.wrapTranslate(InternalWidgets.wrapLateRenderable(gameModeMenu), 0, 0, 600); - AFTER_RENDER.add(() -> this.widgets.add(wrappedGameModeMenu)); - } else { - removeGameModeMenu(); + boolean isOpened = isMenuOpened(Menu.GAME_TYPE); + if (isOpened || !isAnyMenuOpened()) { + boolean inBounds = (button.isFocused() || button.containsMouse(PointHelper.ofMouse())) || isMenuInBounds(Menu.GAME_TYPE); + if (isOpened != inBounds) { + if (inBounds) { + Menu menu = new Menu(new Point(button.getBounds().x, button.getBounds().getMaxY()), + CollectionUtils.filterAndMap(Arrays.asList(GameType.values()), mode -> mode != GameType.NOT_SET, GameModeMenuEntry::new)); + if (ConfigObject.getInstance().isLeftHandSidePanel()) + menu.menuStartPoint.x -= menu.getBounds().width - button.getBounds().width; + openMenu(Menu.GAME_TYPE, menu, point -> button.isFocused() && button.containsMouse(PointHelper.ofMouse())); + } else { + removeOverlayMenu(); + } } } button.setText(new TextComponent(getGameModeShortText(getCurrentGameMode()))); @@ -289,20 +317,22 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl .focusable(false) .tooltipLine(I18n.get("text.rei.gamemode_button.tooltip.all")) .containsMousePredicate((button, point) -> button.getBounds().contains(point) && isNotInExclusionZones(point.x, point.y))); + Button weatherButton; widgets.add(weatherButton = Widgets.createButton(new Rectangle(ConfigObject.getInstance().isLeftHandSidePanel() ? window.getGuiScaledWidth() - 30 : 10, 35, 20, 20), NarratorChatListener.NO_TITLE) .onRender((matrices, button) -> { - boolean tmpRender = renderWeatherMenu; - renderWeatherMenu = !renderGameModeMenu && (button.isFocused() || button.containsMouse(PointHelper.ofMouse()) || (wrappedWeatherMenu != null && wrappedWeatherMenu.containsMouse(PointHelper.ofMouse()))); - if (tmpRender != renderWeatherMenu) { - if (renderWeatherMenu) { - this.weatherMenu = new Menu(new Point(button.getBounds().x, button.getBounds().getMaxY()), - CollectionUtils.map(Weather.values(), WeatherMenuEntry::new)); - if (ConfigObject.getInstance().isLeftHandSidePanel()) - this.weatherMenu.menuStartPoint.x -= this.weatherMenu.getBounds().width - this.weatherButton.getBounds().width; - this.wrappedWeatherMenu = InternalWidgets.wrapTranslate(InternalWidgets.wrapLateRenderable(weatherMenu), 0, 0, 400); - AFTER_RENDER.add(() -> this.widgets.add(wrappedWeatherMenu)); - } else { - removeWeatherMenu(); + boolean isOpened = isMenuOpened(Menu.WEATHER); + if (isOpened || !isAnyMenuOpened()) { + boolean inBounds = (button.isFocused() || button.containsMouse(PointHelper.ofMouse())) || isMenuInBounds(Menu.WEATHER); + if (isOpened != inBounds) { + if (inBounds) { + Menu menu = new Menu(new Point(button.getBounds().x, button.getBounds().getMaxY()), + CollectionUtils.map(Weather.values(), WeatherMenuEntry::new)); + if (ConfigObject.getInstance().isLeftHandSidePanel()) + menu.menuStartPoint.x -= menu.getBounds().width - button.getBounds().width; + openMenu(Menu.WEATHER, menu, point -> button.isFocused() && button.containsMouse(PointHelper.ofMouse())); + } else { + removeOverlayMenu(); + } } } }) @@ -319,14 +349,11 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl if (ConfigObject.getInstance().isSubsetsEnabled()) { widgets.add(InternalWidgets.wrapLateRenderable(InternalWidgets.wrapTranslate(Widgets.createButton(subsetsButtonBounds, ClientHelperImpl.getInstance().isAprilFools.get() ? new TranslatableComponent("text.rei.tiny_potato") : new TranslatableComponent("text.rei.subsets")) .onClick(button -> { - if (subsetsMenu == null) { - wrappedSubsetsMenu = InternalWidgets.wrapTranslate(InternalWidgets.wrapLateRenderable(this.subsetsMenu = Menu.createSubsetsMenuFromRegistry(new Point(this.subsetsButtonBounds.x, this.subsetsButtonBounds.getMaxY()))), 0, 0, 400); - this.widgets.add(this.wrappedSubsetsMenu); - } else { - this.widgets.remove(this.wrappedSubsetsMenu); - this.subsetsMenu = null; - this.wrappedSubsetsMenu = null; - } + proceedOpenMenuOrElse(Menu.SUBSETS, () -> { + openMenu(Menu.SUBSETS, Menu.createSubsetsMenuFromRegistry(new Point(this.subsetsButtonBounds.x, this.subsetsButtonBounds.getMaxY())), point -> true); + }, menu -> { + removeOverlayMenu(); + }); }), 0, 0, 600))); } if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) { @@ -559,24 +586,15 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl if (ScreenHelper.isOverlayVisible()) { ScreenHelper.getSearchField().laterRender(matrices, mouseX, mouseY, delta); for (Widget widget : widgets) { - if (widget instanceof LateRenderable && wrappedSubsetsMenu != widget && wrappedWeatherMenu != widget && wrappedGameModeMenu != widget) + if (widget instanceof LateRenderable && (overlayMenu == null || overlayMenu.wrappedMenu != widget)) widget.render(matrices, mouseX, mouseY, delta); } } - if (wrappedWeatherMenu != null) { - if (wrappedWeatherMenu.containsMouse(mouseX, mouseY)) { + if (overlayMenu != null) { + if (overlayMenu.wrappedMenu.containsMouse(mouseX, mouseY)) { TOOLTIPS.clear(); } - wrappedWeatherMenu.render(matrices, mouseX, mouseY, delta); - } else if (wrappedGameModeMenu != null) { - if (wrappedGameModeMenu.containsMouse(mouseX, mouseY)) { - TOOLTIPS.clear(); - } - wrappedGameModeMenu.render(matrices, mouseX, mouseY, delta); - } - if (wrappedSubsetsMenu != null) { - TOOLTIPS.clear(); - wrappedSubsetsMenu.render(matrices, mouseX, mouseY, delta); + overlayMenu.wrappedMenu.render(matrices, mouseX, mouseY, delta); } Screen currentScreen = Minecraft.getInstance().screen; if (!(currentScreen instanceof RecipeViewingScreen) || !((RecipeViewingScreen) currentScreen).choosePageActivated) @@ -633,11 +651,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl public boolean mouseScrolled(double mouseX, double mouseY, double amount) { if (!ScreenHelper.isOverlayVisible()) return false; - if (wrappedSubsetsMenu != null && wrappedSubsetsMenu.mouseScrolled(mouseX, mouseY, amount)) - return true; - if (wrappedWeatherMenu != null && wrappedWeatherMenu.mouseScrolled(mouseX, mouseY, amount)) - return true; - if (wrappedGameModeMenu != null && wrappedGameModeMenu.mouseScrolled(mouseX, mouseY, amount)) + if (overlayMenu != null && overlayMenu.wrappedMenu.mouseScrolled(mouseX, mouseY, amount)) return true; if (isInside(PointHelper.ofMouse())) { if (!ConfigObject.getInstance().isEntryListWidgetScrolled()) { @@ -657,9 +671,7 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl } for (Widget widget : widgets) if (widget != ENTRY_LIST_WIDGET && (favoritesListWidget == null || widget != favoritesListWidget) - && (wrappedSubsetsMenu == null || widget != wrappedSubsetsMenu) - && (wrappedWeatherMenu == null || widget != wrappedWeatherMenu) - && (wrappedGameModeMenu == null || widget != wrappedGameModeMenu) + && (overlayMenu == null || widget != overlayMenu.wrappedMenu) && widget.mouseScrolled(mouseX, mouseY, amount)) return true; return false; @@ -686,9 +698,9 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl } else if (ConfigObject.getInstance().getUsageKeybind().matchesKey(keyCode, scanCode)) { return ClientHelper.getInstance().openView(ClientHelper.ViewSearchBuilder.builder().addUsagesFor(stack).setInputNotice(stack).fillPreferredOpenedCategory()); } else if (ConfigObject.getInstance().getFavoriteKeyCode().matchesKey(keyCode, scanCode)) { - stack.setAmount(127); - if (!CollectionUtils.anyMatchEqualsEntryIgnoreAmount(ConfigObject.getInstance().getFavorites(), stack)) - ConfigObject.getInstance().getFavorites().add(stack); + FavoriteEntry favoriteEntry = FavoriteEntry.fromEntryStack(stack); + if (!ConfigObject.getInstance().getFavoriteEntries().contains(favoriteEntry)) + ConfigObject.getInstance().getFavoriteEntries().add(favoriteEntry); ConfigManager.getInstance().saveConfig(); FavoritesListWidget favoritesListWidget = ContainerScreenOverlay.getFavoritesListWidget(); if (favoritesListWidget != null) @@ -739,9 +751,9 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl } else if (ConfigObject.getInstance().getUsageKeybind().matchesMouse(button)) { return ClientHelper.getInstance().openView(ClientHelper.ViewSearchBuilder.builder().addUsagesFor(stack).setInputNotice(stack).fillPreferredOpenedCategory()); } else if (ConfigObject.getInstance().getFavoriteKeyCode().matchesMouse(button)) { - stack.setAmount(127); - if (!CollectionUtils.anyMatchEqualsEntryIgnoreAmount(ConfigObject.getInstance().getFavorites(), stack)) - ConfigObject.getInstance().getFavorites().add(stack); + FavoriteEntry favoriteEntry = FavoriteEntry.fromEntryStack(stack); + if (!ConfigObject.getInstance().getFavoriteEntries().contains(favoriteEntry)) + ConfigObject.getInstance().getFavoriteEntries().add(favoriteEntry); ConfigManager.getInstance().saveConfig(); FavoritesListWidget favoritesListWidget = ContainerScreenOverlay.getFavoritesListWidget(); if (favoritesListWidget != null) @@ -751,33 +763,16 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl } if (!ScreenHelper.isOverlayVisible()) return false; - if (wrappedSubsetsMenu != null && wrappedSubsetsMenu.mouseClicked(mouseX, mouseY, button)) { |
