aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-05-27 18:51:52 +0800
committershedaniel <daniel@shedaniel.me>2022-05-27 18:51:52 +0800
commit0557246d6a3fa48133272c7fcb532ffd41181437 (patch)
tree8210f8768ae494c54155f756e1e8dfc643270d69
parent68b4c256d113b49a0857515f6edf41496e4920e1 (diff)
parentb4fadc725c2a470f635c04d12a5eec9fb79edd0f (diff)
downloadRoughlyEnoughItems-0557246d6a3fa48133272c7fcb532ffd41181437.tar.gz
RoughlyEnoughItems-0557246d6a3fa48133272c7fcb532ffd41181437.tar.bz2
RoughlyEnoughItems-0557246d6a3fa48133272c7fcb532ffd41181437.zip
Merge remote-tracking branch 'origin/8.x-1.18.2' into 9.x-1.19
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java12
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java5
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/ForwardingEntryRenderer.java9
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/DisplayRenderer.java1
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/Renderer.java8
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidget.java31
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TooltipContext.java53
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java18
-rw-r--r--api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java6
-rw-r--r--forge/build.gradle3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/entry/type/types/RenderingEntryDefinition.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/EntryStackSubsetsMenuEntry.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/DisplayedEntryWidget.java11
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TooltipContextImpl.java54
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListWidget.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java4
-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/search/argument/type/TooltipArgumentType.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/types/EmptyEntryDefinition.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/FluidEntryDefinition.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/entry/ItemEntryDefinition.java9
25 files changed, 239 insertions, 41 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java
index ea79db26a..c51309603 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java
@@ -27,6 +27,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
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.impl.ClientInternals;
import net.fabricmc.api.EnvType;
@@ -53,7 +54,16 @@ public interface EntryRenderer<T> extends EntryRendererProvider<T> {
@Nullable
@Environment(EnvType.CLIENT)
- Tooltip getTooltip(EntryStack<T> entry, Point mouse);
+ @Deprecated(forRemoval = true, since = "8.3")
+ default Tooltip getTooltip(EntryStack<T> entry, Point mouse) {
+ return null;
+ }
+
+ @Nullable
+ @Environment(EnvType.CLIENT)
+ default Tooltip getTooltip(EntryStack<T> entry, TooltipContext context) {
+ return getTooltip(entry, context.getPoint());
+ }
@ApiStatus.NonExtendable
default <O> EntryRenderer<O> cast() {
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java
index 4becfa174..efb3882d1 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java
@@ -25,6 +25,7 @@ package me.shedaniel.rei.api.client.entry.renderer;
import me.shedaniel.math.Point;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
+import me.shedaniel.rei.api.client.gui.widgets.TooltipContext;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.entry.type.EntryType;
@@ -50,8 +51,8 @@ public interface EntryRendererRegistry extends Reloadable<REIClientPlugin> {
return new ForwardingEntryRenderer<T>(last) {
@Override
@Nullable
- public Tooltip getTooltip(EntryStack<T> entry, Point mouse) {
- return transformer.transform(entry, mouse, super.getTooltip(entry, mouse));
+ public Tooltip getTooltip(EntryStack<T> entry, TooltipContext context) {
+ return transformer.transform(entry, context.getPoint(), super.getTooltip(entry, context));
}
};
});
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/ForwardingEntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/ForwardingEntryRenderer.java
index bdd0bf214..229020ad4 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/ForwardingEntryRenderer.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/ForwardingEntryRenderer.java
@@ -27,6 +27,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
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 org.jetbrains.annotations.Nullable;
@@ -45,6 +46,12 @@ public abstract class ForwardingEntryRenderer<T> implements EntryRenderer<T> {
@Override
@Nullable
public Tooltip getTooltip(EntryStack<T> entry, Point mouse) {
- return this.next.getTooltip(entry, mouse);
+ return this.next.getTooltip(entry, TooltipContext.of(mouse));
+ }
+
+ @Override
+ @Nullable
+ public Tooltip getTooltip(EntryStack<T> entry, TooltipContext context) {
+ return this.next.getTooltip(entry, context);
}
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/DisplayRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/DisplayRenderer.java
index 8f8f0e0f4..9540c1ef6 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/DisplayRenderer.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/DisplayRenderer.java
@@ -25,6 +25,7 @@ package me.shedaniel.rei.api.client.gui;
import me.shedaniel.math.Point;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
+import me.shedaniel.rei.api.client.gui.widgets.TooltipContext;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.jetbrains.annotations.ApiStatus;
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/Renderer.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/Renderer.java
index c352d5933..c0a40c0ec 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/Renderer.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/Renderer.java
@@ -27,6 +27,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
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.WidgetWithBounds;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -40,10 +41,17 @@ public interface Renderer {
@Nullable
@Environment(EnvType.CLIENT)
+ @Deprecated(forRemoval = true)
default Tooltip getTooltip(Point mouse) {
return null;
}
+ @Nullable
+ @Environment(EnvType.CLIENT)
+ default Tooltip getTooltip(TooltipContext context) {
+ return getTooltip(context.getPoint());
+ }
+
@Environment(EnvType.CLIENT)
int getZ();
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidget.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidget.java
index 4e25b06b8..19c73516e 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidget.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/DelegateWidget.java
@@ -90,4 +90,35 @@ public class DelegateWidget extends WidgetWithBounds {
public boolean isDragging() {
return true;
}
+
+ @Override
+ public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
+ return widget.mouseScrolled(mouseX, mouseY, amount);
+ }
+
+ @Override
+ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
+ return widget.keyPressed(keyCode, scanCode, modifiers);
+ }
+
+ @Override
+ public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
+ return widget.keyReleased(keyCode, scanCode, modifiers);
+ }
+
+ @Override
+ public boolean charTyped(char character, int modifiers) {
+ return widget.charTyped(character, modifiers);
+ }
+
+ @Override
+ public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
+ return widget.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
+ }
+
+ @Override
+ public boolean mouseReleased(double mouseX, double mouseY, int button) {
+ this.setDragging(false);
+ return widget.mouseReleased(mouseX, mouseY, button);
+ }
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TooltipContext.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TooltipContext.java
new file mode 100644
index 000000000..7bc2ecd15
--- /dev/null
+++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TooltipContext.java
@@ -0,0 +1,53 @@
+/*
+ * 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.api.client.gui.widgets;
+
+import me.shedaniel.math.Point;
+import me.shedaniel.math.impl.PointHelper;
+import me.shedaniel.rei.impl.ClientInternals;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.world.item.TooltipFlag;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Nullable;
+
+@Environment(EnvType.CLIENT)
+@ApiStatus.NonExtendable
+public interface TooltipContext {
+ static TooltipContext of(Point point) {
+ return TooltipContext.of(point, null);
+ }
+
+ static TooltipContext of(Point point, @Nullable TooltipFlag flag) {
+ return ClientInternals.createTooltipContext(point, flag);
+ }
+
+ static TooltipContext ofMouse() {
+ return TooltipContext.of(PointHelper.ofMouse());
+ }
+
+ TooltipFlag getFlag();
+
+ Point getPoint();
+}
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java
index 3212d097a..1067ff6d3 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java
@@ -31,6 +31,7 @@ import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer;
import me.shedaniel.rei.api.client.entry.renderer.EntryRendererRegistry;
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.type.EntryDefinition;
import me.shedaniel.rei.api.common.entry.type.EntryType;
import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry;
@@ -97,7 +98,13 @@ public interface EntryStack<T> extends TextRepresentable, Renderer {
@Nullable
@Environment(EnvType.CLIENT)
- Tooltip getTooltip(Point mouse, boolean appendModName);
+ default Tooltip getTooltip(Point mouse, boolean appendModName) {
+ return getTooltip(TooltipContext.of(mouse), appendModName);
+ }
+
+ @Nullable
+ @Environment(EnvType.CLIENT)
+ Tooltip getTooltip(TooltipContext context, boolean appendModName);
@Override
@Nullable
@@ -105,6 +112,12 @@ public interface EntryStack<T> extends TextRepresentable, Renderer {
return getTooltip(mouse, ConfigObject.getInstance().shouldAppendModNames());
}
+ @Override
+ @Nullable
+ default Tooltip getTooltip(TooltipContext context) {
+ return getTooltip(context, ConfigObject.getInstance().shouldAppendModNames());
+ }
+
EntryDefinition<T> getDefinition();
default EntryType<T> getType() {
@@ -197,8 +210,7 @@ public interface EntryStack<T> extends TextRepresentable, Renderer {
<R> R get(Settings<R> settings);
- @Nullable
- <R> R getNullable(Settings<R> settings);
+ @Nullable <R> R getNullable(Settings<R> settings);
@Environment(EnvType.CLIENT)
default EntryStack<T> tooltip(Component... tooltips) {
diff --git a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java
index 4341771d1..10b29150f 100644
--- a/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java
+++ b/api/src/main/java/me/shedaniel/rei/impl/ClientInternals.java
@@ -46,6 +46,7 @@ import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.tooltip.TooltipComponent;
+import net.minecraft.world.item.TooltipFlag;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
@@ -69,6 +70,7 @@ public final class ClientInternals {
private static Function<Boolean, ClickArea.Result> clickAreaHandlerResult = (result) -> throwNotSetup();
private static BiConsumer<List<ClientTooltipComponent>, TooltipComponent> clientTooltipComponentProvider = (tooltip, result) -> throwNotSetup();
private static BiFunction<@Nullable Point, Collection<Tooltip.Entry>, Tooltip> tooltipProvider = (point, texts) -> throwNotSetup();
+ private static BiFunction<Point, @Nullable TooltipFlag, TooltipContext> tooltipContextProvider = (point, texts) -> throwNotSetup();
private static Function<Object, Tooltip.Entry> tooltipEntryProvider = (component) -> throwNotSetup();
private static Supplier<List<String>> jeiCompatMods = ClientInternals::throwNotSetup;
private static Supplier<Object> builtinClientPlugin = ClientInternals::throwNotSetup;
@@ -130,6 +132,10 @@ public final class ClientInternals {
return tooltipProvider.apply(point, texts);
}
+ public static TooltipContext createTooltipContext(Point point, @Nullable TooltipFlag flag) {
+ return tooltipContextProvider.apply(point, flag);
+ }
+
public static Tooltip.Entry createTooltipEntry(Object component) {
return tooltipEntryProvider.apply(component);
}
diff --git a/forge/build.gradle b/forge/build.gradle
index 260be545a..1294d5347 100644
--- a/forge/build.gradle
+++ b/forge/build.gradle
@@ -129,13 +129,14 @@ dependencies {
// modRuntime("curse.maven:natures-aura-306626:3587798")
// modRuntime("curse.maven:integrated-dynamics-236307:3631804")
// modRuntime("curse.maven:common-capabilities-247007:3614900")
- modRuntime("curse.maven:evilcraft-74610:3795956")
+ // modRuntime("curse.maven:evilcraft-74610:3795956")
modRuntime("curse.maven:cyclops-core-236307:3778682")
// modRuntime("curse.maven:elemental-craft-395158:3593428")
// modRuntime("curse.maven:datapack-anvil-432817:3569515")
// modRuntime("curse.maven:assemblylinemachines-388282:3623609")
// modRuntime("curse.maven:mystical-agriculture-246640:3645812")
modRuntime("curse.maven:oreberries-replanted-454062:3776180")
+ modRuntime("curse.maven:farmers-delight-398521:3784851")
}
def modRuntime(str) {
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