aboutsummaryrefslogtreecommitdiff
path: root/fabric/src/main/java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-08-28 18:50:24 +0900
committershedaniel <daniel@shedaniel.me>2022-08-28 18:50:24 +0900
commit94e323f75c17e297c33fba1d3afb5c47ae66a8ad (patch)
tree3c6cb6c1721fbda792050b96707fad50d1db64e9 /fabric/src/main/java
parentf5061d043cac7f0217bbe9d4c041b77f9ef911a1 (diff)
downloadRoughlyEnoughItems-94e323f75c17e297c33fba1d3afb5c47ae66a8ad.tar.gz
RoughlyEnoughItems-94e323f75c17e297c33fba1d3afb5c47ae66a8ad.tar.bz2
RoughlyEnoughItems-94e323f75c17e297c33fba1d3afb5c47ae66a8ad.zip
Separate EntryListWidget and FavoritesListWidget more
Diffstat (limited to 'fabric/src/main/java')
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java25
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/TooltipRendererImpl.java (renamed from fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java)24
2 files changed, 19 insertions, 30 deletions
diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
index c1abbce5f..a355183c3 100644
--- a/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
+++ b/fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java
@@ -23,28 +23,20 @@
package me.shedaniel.rei.fabric;
-import com.google.common.base.Suppliers;
import dev.architectury.platform.Platform;
import dev.architectury.utils.Env;
import me.shedaniel.rei.RoughlyEnoughItemsState;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.common.plugins.*;
-import me.shedaniel.rei.impl.client.ClientInternals;
import me.shedaniel.rei.impl.init.PluginDetector;
import me.shedaniel.rei.impl.init.PrimitivePlatformAdapter;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
-import net.minecraft.client.gui.screens.Screen;
-import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
-import net.minecraft.world.inventory.tooltip.TooltipComponent;
import org.apache.commons.lang3.tuple.Pair;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.*;
-import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@@ -144,23 +136,6 @@ public class PluginDetectorImpl implements PluginDetector {
public Supplier<Runnable> detectClientPlugins() {
return () -> () -> {
loadPlugin(REIClientPlugin.class, ((PluginView<REIClientPlugin>) PluginManager.getClientInstance())::registerPlugin);
- Supplier<Method> method = Suppliers.memoize(() -> {
- String methodName = FabricLoader.getInstance().getMappingResolver().mapMethodName("intermediary", "net.minecraft.class_437", "method_32635", "(Ljava/util/List;Lnet/minecraft/class_5632;)V");
- try {
- Method declaredMethod = Screen.class.getDeclaredMethod(methodName, List.class, TooltipComponent.class);
- if (declaredMethod != null) declaredMethod.setAccessible(true);
- return declaredMethod;
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- }
- });
- ClientInternals.attachInstance((BiConsumer<List<ClientTooltipComponent>, TooltipComponent>) (lines, component) -> {
- try {
- method.get().invoke(null, lines, component);
- } catch (IllegalAccessException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }, "clientTooltipComponentProvider");
};
}
}
diff --git a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java b/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/TooltipRendererImpl.java
index 10c3865ae..df7fdaddb 100644
--- a/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/ScreenOverlayImplFabric.java
+++ b/fabric/src/main/java/me/shedaniel/rei/impl/client/gui/fabric/TooltipRendererImpl.java
@@ -23,11 +23,12 @@
package me.shedaniel.rei.impl.client.gui.fabric;
+import com.google.common.base.Suppliers;
import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
-import me.shedaniel.rei.impl.client.ClientInternals;
-import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
import me.shedaniel.rei.impl.client.gui.widget.TooltipImpl;
+import me.shedaniel.rei.impl.client.provider.TooltipRenderer;
+import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
@@ -37,13 +38,26 @@ import net.minecraft.network.chat.Style;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.world.inventory.tooltip.TooltipComponent;
+import java.lang.reflect.Method;
import java.util.List;
+import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-public class ScreenOverlayImplFabric extends ScreenOverlayImpl {
+public class TooltipRendererImpl implements TooltipRenderer {
+ private final Supplier<Method> method = Suppliers.memoize(() -> {
+ String methodName = FabricLoader.getInstance().getMappingResolver().mapMethodName("intermediary", "net.minecraft.class_437", "method_32635", "(Ljava/util/List;Lnet/minecraft/class_5632;)V");
+ try {
+ Method declaredMethod = Screen.class.getDeclaredMethod(methodName, List.class, TooltipComponent.class);
+ if (declaredMethod != null) declaredMethod.setAccessible(true);
+ return declaredMethod;
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ });
+
@Override
- public void renderTooltipInner(Screen screen, PoseStack matrices, Tooltip tooltip, int mouseX, int mouseY) {
+ public void renderTooltip(Screen screen, PoseStack matrices, Tooltip tooltip, int mouseX, int mouseY) {
List<ClientTooltipComponent> lines = tooltip.entries().stream()
.flatMap(component -> {
if (component.isText()) {
@@ -65,7 +79,7 @@ public class ScreenOverlayImplFabric extends ScreenOverlayImpl {
if (component instanceof ClientTooltipComponent) break;
try {
- ClientInternals.getClientTooltipComponent(lines, component);
+ method.get().invoke(lines, component);
} catch (Throwable exception) {
throw new IllegalArgumentException("Failed to add tooltip component! " + component + ", Class: " + (component == null ? null : component.getClass().getCanonicalName()), exception);
}