diff options
| author | shedaniel <daniel@shedaniel.me> | 2023-06-01 17:30:55 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2024-04-16 00:38:18 +0900 |
| commit | 8c941dd229712cee6f7d2fefb0bc5ca2e0d10d19 (patch) | |
| tree | ee10eea2cb8fa0600eefc7e2fb4814f11c3d9b4c /runtime/src | |
| parent | 4d6bcee0dc0354c3778ad44157e1afe27e36d5fd (diff) | |
| download | RoughlyEnoughItems-8c941dd229712cee6f7d2fefb0bc5ca2e0d10d19.tar.gz RoughlyEnoughItems-8c941dd229712cee6f7d2fefb0bc5ca2e0d10d19.tar.bz2 RoughlyEnoughItems-8c941dd229712cee6f7d2fefb0bc5ca2e0d10d19.zip | |
Add the full display to the tooltip of the minimised display
Diffstat (limited to 'runtime/src')
| -rw-r--r-- | runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java index cdbec40ac..ade1addce 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/DefaultClientRuntimePlugin.java @@ -23,6 +23,7 @@ package me.shedaniel.rei.plugin.client.runtime; +import com.google.common.base.Suppliers; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.serialization.DataResult; @@ -66,6 +67,7 @@ import me.shedaniel.rei.impl.client.REIRuntimeImpl; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.screen.DefaultDisplayViewingScreen; import me.shedaniel.rei.impl.client.gui.widget.DisplayCompositeWidget; +import me.shedaniel.rei.impl.client.gui.widget.DisplayTooltipComponent; import me.shedaniel.rei.impl.client.gui.widget.favorites.FavoritesListWidget; import me.shedaniel.rei.impl.client.search.method.DefaultInputMethod; import me.shedaniel.rei.impl.client.search.method.unihan.*; @@ -77,6 +79,7 @@ import me.shedaniel.rei.plugin.autocrafting.DefaultCategoryHandler; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -85,6 +88,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.function.Function; +import java.util.function.Supplier; @Environment(EnvType.CLIENT) @ApiStatus.Internal @@ -324,6 +328,7 @@ public class DefaultClientRuntimePlugin implements REIClientPlugin { private static class DisplayFavoriteEntry extends FavoriteEntry { private static final Function<EntryStack<?>, String> CANCEL_FLUID_AMOUNT = s -> null; + private final Supplier<DisplayTooltipComponent> tooltipComponent; private final Display display; private final UUID uuid; private final long hash; @@ -332,6 +337,7 @@ public class DefaultClientRuntimePlugin implements REIClientPlugin { this.display = display; this.uuid = uuid; this.hash = uuid.hashCode(); + this.tooltipComponent = Suppliers.memoize(() -> new DisplayTooltipComponent(display)); } @Override @@ -371,6 +377,14 @@ public class DefaultClientRuntimePlugin implements REIClientPlugin { matrices.popPose(); } } + + @Override + @Nullable + public Tooltip getTooltip(TooltipContext context) { + Tooltip tooltip = Tooltip.create(context.getPoint()); + tooltip.add((ClientTooltipComponent) tooltipComponent.get()); + return tooltip; + } }; } |
