diff options
Diffstat (limited to 'runtime/src/main/java/me')
15 files changed, 101 insertions, 33 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java index 5c32d389b..4eb7de768 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java @@ -40,6 +40,7 @@ import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.favorites.FavoriteEntryType; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.client.overlay.ScreenOverlay; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; @@ -63,6 +64,7 @@ import me.shedaniel.rei.impl.client.favorites.FavoriteEntryTypeRegistryImpl; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.widget.InternalWidgets; import me.shedaniel.rei.impl.client.gui.widget.QueuedTooltip; +import me.shedaniel.rei.impl.client.gui.widget.TooltipContextImpl; import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField; import me.shedaniel.rei.impl.client.registry.category.CategoryRegistryImpl; import me.shedaniel.rei.impl.client.registry.display.DisplayRegistryImpl; @@ -95,6 +97,7 @@ import net.minecraft.world.inventory.CraftingMenu; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.crafting.Ingredient; import org.apache.commons.lang3.mutable.MutableLong; import org.jetbrains.annotations.ApiStatus; @@ -140,6 +143,7 @@ public class RoughlyEnoughItemsCoreClient { return entryType.read(object); }, "favoriteEntryFromJson"); ClientInternals.attachInstance((BiFunction<@Nullable Point, Collection<Tooltip.Entry>, Tooltip>) QueuedTooltip::impl, "tooltipProvider"); + ClientInternals.attachInstance((BiFunction<Point, @Nullable TooltipFlag, TooltipContext>) TooltipContextImpl::new, "tooltipContextProvider"); ClientInternals.attachInstance((Function<Object, Tooltip.Entry>) QueuedTooltip.TooltipEntryImpl::new, "tooltipEntryProvider"); ClientInternals.attachInstance((Function<@Nullable Boolean, ClickArea.Result>) successful -> new ClickArea.Result() { private List<CategoryIdentifier<?>> categories = Lists.newArrayList(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/type/types/RenderingEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/type/types/RenderingEntryDefinition.java index e109abd12..919a2c1c6 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/type/types/RenderingEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/entry/type/types/RenderingEntryDefinition.java @@ -31,6 +31,7 @@ import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.entry.type.BuiltinClientEntryTypes; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.type.EntryDefinition; import me.shedaniel.rei.impl.common.entry.type.types.BuiltinEntryDefinition; @@ -46,7 +47,7 @@ public class RenderingEntryDefinition { public static final EntryDefinition<Renderer> RENDERING = new BuiltinEntryDefinition<Renderer>(Renderer.class, BuiltinClientEntryTypes.RENDERING, false, RenderingEntryDefinition::throwRendering, () -> () -> DeferredRenderer.INSTANCE) { @Override public Component asFormattedText(EntryStack<Renderer> entry, Renderer value) { - Tooltip tooltip = value.getTooltip(PointHelper.ofMouse()); + Tooltip tooltip = value.getTooltip(TooltipContext.ofMouse()); if (tooltip != null) { for (Tooltip.Entry e : tooltip.entries()) { if (e.isText()) { @@ -72,8 +73,8 @@ public class RenderingEntryDefinition { @Override @Nullable - public Tooltip getTooltip(EntryStack<Renderer> entry, Point mouse) { - return entry.getValue().getTooltip(mouse); + public Tooltip getTooltip(EntryStack<Renderer> entry, TooltipContext context) { + return entry.getValue().getTooltip(context.getPoint()); } } } 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 index d6029865f..dfe6fac94 100644 --- 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 @@ -31,6 +31,7 @@ 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; @@ -76,7 +77,7 @@ public class EntryStackSubsetsMenuEntry extends AbstractMenuEntry { 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(new Point(mouseX, mouseY))); + REIRuntime.getInstance().queueTooltip(stack.getTooltip(TooltipContext.of(new Point(mouseX, mouseY)))); if (RoughlyEnoughItemsCoreClient.isLeftMousePressed && !clickedLast) { clickedLast = true; if (getParent().scrolling.getScissorBounds().contains(mouseX, mouseY)) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java index 990eab297..823060f26 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java @@ -34,10 +34,7 @@ import me.shedaniel.math.impl.PointHelper; import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.DisplayRenderer; -import me.shedaniel.rei.api.client.gui.widgets.Button; -import me.shedaniel.rei.api.client.gui.widgets.Tooltip; -import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.gui.widgets.*; import me.shedaniel.rei.api.client.registry.category.ButtonArea; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; @@ -370,7 +367,7 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen if (buttonList.get(i).getBounds().getMaxY() > scrollListBounds.getMinY() && buttonList.get(i).getBounds().getMinY() < scrollListBounds.getMaxY()) { displayRenderers.get(i).setZ(1); displayRenderers.get(i).render(matrices, buttonList.get(i).getBounds(), mouseX, mouseY, delta); - Optional.ofNullable(displayRenderers.get(i).getTooltip(new Point(mouseX, mouseY))).ifPresent(Tooltip::queue); + Optional.ofNullable(displayRenderers.get(i).getTooltip(TooltipContext.of(new Point(mouseX, mouseY)))).ifPresent(Tooltip::queue); } } scrolling.renderScrollBar(0, scrollBarAlpha, REIRuntime.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayedEntryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayedEntryWidget.java index d0643c592..58f46abaf 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayedEntryWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayedEntryWidget.java @@ -68,8 +68,15 @@ public abstract class DisplayedEntryWidget extends EntryWidget { EntryStack<ItemStack> cheatsAs = entry.cheatsAs(); entry = cheatsAs.isEmpty() ? entry : cheatsAs; } - if (entry.getValueType() == ItemStack.class) - entry.<ItemStack>castValue().setCount(button != 1 && !Screen.hasShiftDown() == (ConfigObject.getInstance().getItemCheatingMode() == ItemCheatingMode.REI_LIKE) ? 1 : entry.<ItemStack>castValue().getMaxStackSize()); + if (entry.getValueType() == ItemStack.class) { + boolean all; + if (ConfigObject.getInstance().getItemCheatingMode() == ItemCheatingMode.REI_LIKE) { + all = button == 1 || Screen.hasShiftDown(); + } else { + all = button != 1 || Screen.hasShiftDown(); + } + entry.<ItemStack>castValue().setCount(!all ? 1 : entry.<ItemStack>castValue().getMaxStackSize()); + } return ClientHelper.getInstance().tryCheatingEntry(entry); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java index 41d2f1e0e..a62e63373 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java @@ -297,6 +297,10 @@ public class EntryWidget extends Slot implements DraggableStackProviderWidget { private TransferHandler _getTransferHandler() { lastCheckTime = Util.getMillis(); + if (PluginManager.areAnyReloading()) { + return null; + } + for (List<Display> displays : DisplayRegistry.getInstance().getAll().values()) { for (Display display : displays) { if (ViewsImpl.isRecipesFor(getEntries(), display)) { @@ -410,7 +414,7 @@ public class EntryWidget extends Slot implements DraggableStackProviderWidget { @Override @Nullable - public Tooltip getCurrentTooltip(me.shedaniel.math.Point point) { + public Tooltip getCurrentTooltip(Point point) { Tooltip tooltip = getCurrentEntry().getTooltip(point); if (tooltip != null && !ClientHelper.getInstance().isCheating() && getTransferHandler() != null diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TooltipContextImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TooltipContextImpl.java new file mode 100644 index 000000000..0b91481ac --- /dev/null +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TooltipContextImpl.java @@ -0,0 +1,54 @@ +/* + * 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.widget; + +import me.shedaniel.math.Point; +import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; +import net.minecraft.client.Minecraft; +import net.minecraft.world.item.TooltipFlag; +import org.jetbrains.annotations.Nullable; + +import java.util.Objects; + +public class TooltipContextImpl implements TooltipContext { + private final Point point; + @Nullable + private final TooltipFlag flag; + + public TooltipContextImpl(Point point, @Nullable TooltipFlag flag) { + this.point = Objects.requireNonNull(point); + this.flag = flag; + } + + @Override + public TooltipFlag getFlag() { + return flag == null ? (Minecraft.getInstance().options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL) + : flag; + } + + @Override + public Point getPoint() { + return point; + } +} diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListWidget.java index 542004a20..3e16da5c5 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListWidget.java @@ -46,6 +46,7 @@ import me.shedaniel.rei.api.client.gui.drag.DraggedAcceptorResult; import me.shedaniel.rei.api.client.gui.drag.DraggingContext; import me.shedaniel.rei.api.client.gui.screen.DisplayScreen; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; import me.shedaniel.rei.api.client.overlay.OverlayListWidget; @@ -300,8 +301,8 @@ public class EntryListWidget extends WidgetWithBounds implements OverlayListWidg @Override @Nullable - public Tooltip getTooltip(EntryStack<Object> entry, Point mouse) { - return stack.getDefinition().getRenderer().getTooltip(entry.cast(), mouse); + public Tooltip getTooltip(EntryStack<Object> entry, TooltipContext context) { + return stack.getDefinition().getRenderer().getTooltip(entry.cast(), context); } }); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java index 846047157..1a9fcd097 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java @@ -172,7 +172,7 @@ public class DisplayEntry extends WidgetWithBounds { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (containsMouse(mouseX, mouseY)) { + if (containsMouse(mouseX + xOffset, mouseY)) { for (Widget widget : widgets.get()) { if (widget.mouseClicked(transformMouseX(mouseX), transformMouseY(mouseY), button)) { return true; @@ -185,7 +185,7 @@ public class DisplayEntry extends WidgetWithBounds { @Override public boolean mouseReleased(double mouseX, double mouseY, int button) { - if (containsMouse(mouseX, mouseY)) { + if (containsMouse(mouseX + xOffset, mouseY)) { for (Widget widget : widgets.get()) { if (widget.mouseReleased(transformMouseX(mouseX), transformMouseY(mouseY), button)) { return true; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/Argument.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/Argument.java index 227d09b4d..f8ffecc4e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/Argument.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/Argument.java @@ -295,7 +295,7 @@ public class Argument<T, R> { if (async) { try { - CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get(10, TimeUnit.SECONDS); + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get(30, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { e.printStackTrace(); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/type/TooltipArgumentType.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/type/TooltipArgumentType.java index 99e967456..4557ddeae 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/type/TooltipArgumentType.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/type/TooltipArgumentType.java @@ -27,12 +27,14 @@ import me.shedaniel.math.Point; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.config.SearchMode; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.common.entry.EntryStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.network.chat.Style; import net.minecraft.network.chat.TextColor; import net.minecraft.util.Unit; +import net.minecraft.world.item.TooltipFlag; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -44,7 +46,8 @@ import java.util.StringJoiner; @Environment(EnvType.CLIENT) public final class TooltipArgumentType extends ArgumentType<Unit, String> { public static final TooltipArgumentType INSTANCE = new TooltipArgumentType(); - public static final String INVALID = "INVALID_PIECE_OF_TOOLTIP_I_DONT_THINK_PEOPLE_WILL_EXACTLY_HAVE_THIS_REI_REI_REI"; + private static final TooltipContext CONTEXT = TooltipContext.of(new Point(), TooltipFlag.Default.NORMAL); + public static String INVALID = "INVALID_PIECE_OF_TOOLTIP_I_DONT_THINK_PEOPLE_WILL_EXACTLY_HAVE_THIS_REI_REI_REI"; private static final Style STYLE = Style.EMPTY.withColor(TextColor.fromRgb(0xffe0ad)); @Override @@ -85,7 +88,7 @@ public final class TooltipArgumentType extends ArgumentType<Unit, String> { @Nullable public static String tryGetEntryStackTooltip(EntryStack<?> stack, int attempt) { try { - Tooltip tooltip = stack.getTooltip(new Point(), false); + Tooltip tooltip = stack.getTooltip(CONTEXT, false); if (tooltip != null) { StringJoiner joiner = new StringJoiner("\n"); for (Tooltip.Entry entry : tooltip.entries()) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java index 4599afc1e..66aff5e0d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java @@ -32,6 +32,7 @@ import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.ClientHelper; import me.shedaniel.rei.api.client.gui.Renderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.settings.EntrySettingsAdapterRegistry; import me.shedaniel.rei.api.common.util.EntryStacks; @@ -206,9 +207,9 @@ public abstract class AbstractEntryStack<A> implements EntryStack<A>, Renderer { @Override @Nullable - public Tooltip getTooltip(Point mouse, boolean appendModName) { + public Tooltip getTooltip(TooltipContext context, boolean appendModName) { try { - Mutable<Tooltip> tooltip = new MutableObject<>(getRenderer().<A>cast().getTooltip(this, mouse)); + Mutable<Tooltip> tooltip = new MutableObject<>(getRenderer().<A>cast().getTooltip(this, context)); if (tooltip.getValue() == null) return null; tooltip.getValue().withContextStack(this); tooltip.getValue().addAllTexts(get(Settings.TOOLTIP_APPEND_EXTRA).apply(this)); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/EmptyEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/EmptyEntryDefinition.java index 2859b5660..b4456c634 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/EmptyEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/EmptyEntryDefinition.java @@ -47,11 +47,5 @@ public class EmptyEntryDefinition { public void render(EntryStack<Unit> entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { } - - @Override - @Nullable - public Tooltip getTooltip(EntryStack<Unit> entry, Point mouse) { - return null; - } } } diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java index 53345584e..4f3838fdb 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java @@ -31,12 +31,12 @@ import dev.architectury.hooks.fluid.FluidStackHooks; import dev.architectury.platform.Platform; import dev.architectury.utils.Env; import dev.architectury.utils.EnvExecutor; -import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.entry.renderer.AbstractEntryRenderer; import me.shedaniel.rei.api.client.entry.renderer.BatchedEntryRenderer; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.client.util.SpriteRenderer; import me.shedaniel.rei.api.common.entry.EntrySerializer; import me.shedaniel.rei.api.common.entry.EntryStack; @@ -283,7 +283,7 @@ public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntryS @Override @Nullable - public Tooltip getTooltip(EntryStack<FluidStack> entry, Point mouse) { + public Tooltip getTooltip(EntryStack<FluidStack> entry, TooltipContext context) { if (entry.isEmpty()) return null; List<Component> toolTip = Lists.newArrayList(entry.asFormattedText()); diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java index 0eff4b75e..3afa5ae64 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java @@ -38,6 +38,7 @@ import me.shedaniel.rei.api.client.entry.renderer.AbstractEntryRenderer; import me.shedaniel.rei.api.client.entry.renderer.BatchedEntryRenderer; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; +import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.common.entry.EntrySerializer; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.comparison.ComparisonContext; @@ -202,10 +203,10 @@ public class ItemEntryDefinition implements EntryDefinition<ItemStack>, EntrySer } @Environment(EnvType.CLIENT) - private List<Component> tryGetItemStackToolTip(EntryStack<ItemStack> entry, ItemStack value, boolean careAboutAdvanced) { + private List<Component> tryGetItemStackToolTip(EntryStack<ItemStack> entry, ItemStack value, TooltipContext context) { if (!SEARCH_BLACKLISTED.contains(value.getItem())) try { - return value.getTooltipLines(Minecraft.getInstance().player, careAboutAdvanced && Minecraft.getInstance().options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL); + return value.getTooltipLines(Minecraft.getInstance().player, context.getFlag()); } catch (Throwable e) { e.printStackTrace(); SEARCH_BLACKLISTED.add(value.getItem()); @@ -344,12 +345,12 @@ public class ItemEntryDefinition implements EntryDefinition<ItemStack>, EntrySer @Override @Nullable - public Tooltip getTooltip(EntryStack<ItemStack> entry, Point mouse) { + public Tooltip getTooltip(EntryStack<ItemStack> entry, TooltipContext context) { if (entry.isEmpty()) return null; Tooltip tooltip = Tooltip.create(); Optional<TooltipComponent> component = entry.getValue().getTooltipImage(); - List<Component> components = tryGetItemStackToolTip(entry, entry.getValue(), true); + List<Component> components = tryGetItemStackToolTip(entry, entry.getValue(), context); if (!components.isEmpty()) { tooltip.add(components.get(0)); } |
