aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMona <59416038+meowora@users.noreply.github.com>2025-07-26 01:13:55 +0200
committerGitHub <noreply@github.com>2025-07-25 19:13:55 -0400
commit8e4cce107291b65ac6f4a6b16d895e196a694db9 (patch)
tree5d5265f4cff5f0710d40129c3baa3e9b8ee07e64
parent07d56084e9e21bd000ef492cab7b632920302dfb (diff)
downloadSkyblocker-8e4cce107291b65ac6f4a6b16d895e196a694db9.tar.gz
Skyblocker-8e4cce107291b65ac6f4a6b16d895e196a694db9.tar.bz2
Skyblocker-8e4cce107291b65ac6f4a6b16d895e196a694db9.zip
fix: some mixin injections preventing things in cases they shouldn't (#1495)
* fix: some mixin injections preventing things in cases they shouldn't * isblank * changes * coding is so difficult :c
-rw-r--r--src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java59
1 files changed, 45 insertions, 14 deletions
diff --git a/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java
index b3812afc..11aa83ea 100644
--- a/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java
+++ b/src/main/java/de/hysky/skyblocker/mixins/HandledScreenMixin.java
@@ -1,6 +1,8 @@
package de.hysky.skyblocker.mixins;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
+import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
+import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
@@ -23,18 +25,24 @@ import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.container.ContainerSolver;
import de.hysky.skyblocker.utils.container.ContainerSolverManager;
import net.fabricmc.fabric.api.client.screen.v1.Screens;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.inventory.SimpleInventory;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraft.item.tooltip.TooltipData;
+import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.text.Text;
+import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;
@@ -194,28 +202,45 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
@SuppressWarnings("DataFlowIssue")
// makes intellij be quiet about this.focusedSlot maybe being null. It's already null checked in mixined method.
- @Inject(method = "drawMouseoverTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;Ljava/util/Optional;IILnet/minecraft/util/Identifier;)V"), cancellable = true)
- public void skyblocker$drawMouseOverTooltip(DrawContext context, int x, int y, CallbackInfo ci, @Local(ordinal = 0) ItemStack stack) {
- if (!Utils.isOnSkyblock()) return;
+ @WrapOperation(method = "drawMouseoverTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;Ljava/util/Optional;IILnet/minecraft/util/Identifier;)V"))
+ public void skyblocker$drawMouseOverTooltip(
+ DrawContext instance,
+ TextRenderer textRenderer,
+ List<Text> text,
+ Optional<TooltipData> data,
+ int x,
+ int y,
+ Identifier texture,
+ Operation<Void> original,
+ @Local(ordinal = 0) ItemStack stack
+ ) {
+ if (!Utils.isOnSkyblock() || text.isEmpty()) {
+ original.call(instance, textRenderer, text, data, x, y, texture);
+ return;
+ }
+
+ var name = text.getFirst().getString();
// Hide Empty Tooltips
- if (SkyblockerConfigManager.get().uiAndVisuals.hideEmptyTooltips && stack.getName().getString().equals(" ")) {
- ci.cancel();
+ if (SkyblockerConfigManager.get().uiAndVisuals.hideEmptyTooltips && name.isBlank()) {
+ return;
}
// Backpack Preview
boolean shiftDown = SkyblockerConfigManager.get().uiAndVisuals.backpackPreviewWithoutShift ^ Screen.hasShiftDown();
- if (shiftDown && getTitle().getString().equals("Storage") && focusedSlot.inventory != client.player.getInventory() && BackpackPreview.renderPreview(context, this, focusedSlot.getIndex(), x, y)) {
- ci.cancel();
+ if (shiftDown && getTitle().getString().equals("Storage") && focusedSlot.inventory != client.player.getInventory() && BackpackPreview.renderPreview(instance, this, focusedSlot.getIndex(), x, y)) {
+ return;
}
// Compactor Preview
if (SkyblockerConfigManager.get().uiAndVisuals.compactorDeletorPreview) {
Matcher matcher = CompactorDeletorPreview.NAME.matcher(ItemUtils.getItemId(stack));
- if (matcher.matches() && CompactorDeletorPreview.drawPreview(context, stack, getTooltipFromItem(stack), matcher.group("type"), matcher.group("size"), x, y)) {
- ci.cancel();
+ if (matcher.matches() && CompactorDeletorPreview.drawPreview(instance, stack, getTooltipFromItem(stack), matcher.group("type"), matcher.group("size"), x, y)) {
+ return;
}
}
+
+ original.call(instance, textRenderer, text, data, x, y, texture);
}
@ModifyVariable(method = "drawMouseoverTooltip", at = @At(value = "STORE"))
@@ -272,8 +297,16 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
ContainerSolver currentSolver = ContainerSolverManager.getCurrentSolver();
ItemStack stack = skyblocker$experimentSolvers$getStack(slot, slot.getStack(), currentSolver);
+ boolean isTitleEmptyOrFiller = FILLER_ITEMS.contains(stack.getName().getString());
+ if (isTitleEmptyOrFiller) {
+ var tooltip = stack.getTooltip(Item.TooltipContext.DEFAULT, MinecraftClient.getInstance().player, TooltipType.BASIC).stream().map(Text::getString).toList();
+ String lore = String.join("\n", tooltip);
+ isTitleEmptyOrFiller = lore.isBlank() || FILLER_ITEMS.contains(tooltip.getFirst());
+ }
+
+
// Prevent clicks on filler items
- if (SkyblockerConfigManager.get().uiAndVisuals.hideEmptyTooltips && FILLER_ITEMS.contains(stack.getName().getString()) &&
+ if (SkyblockerConfigManager.get().uiAndVisuals.hideEmptyTooltips && isTitleEmptyOrFiller &&
// Allow clicks in Ultrasequencer and Superpairs
(!UltrasequencerSolver.INSTANCE.test(title) || SkyblockerConfigManager.get().helpers.experiments.enableUltrasequencerSolver)) {
ci.cancel();
@@ -315,10 +348,8 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
}
}
- case GenericContainerScreenHandler genericContainerScreenHandler when title.equals(MuseumItemCache.DONATION_CONFIRMATION_SCREEN_TITLE) -> {
- //Museum Item Cache donation tracking
- MuseumItemCache.handleClick(slot, slotId, genericContainerScreenHandler.slots);
- }
+ //Museum Item Cache donation tracking
+ case GenericContainerScreenHandler genericContainerScreenHandler when title.equals(MuseumItemCache.DONATION_CONFIRMATION_SCREEN_TITLE) -> MuseumItemCache.handleClick(slot, slotId, genericContainerScreenHandler.slots);
case null, default -> {}
}