Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit ac8754d

Browse files
committed
Scrollable Tooltips
1 parent 80ad363 commit ac8754d

File tree

6 files changed

+158
-1
lines changed

6 files changed

+158
-1
lines changed

src/main/java/io/github/axolotlclient/AxolotlClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.github.axolotlclient.modules.hypixel.HypixelMods;
1212
import io.github.axolotlclient.modules.hypixel.nickhider.NickHider;
1313
import io.github.axolotlclient.modules.motionblur.MotionBlur;
14+
import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips;
1415
import io.github.axolotlclient.modules.zoom.Zoom;
1516
import io.github.axolotlclient.util.DiscordRPC;
1617
import io.github.axolotlclient.util.Util;
@@ -47,7 +48,7 @@ public class AxolotlClient implements ModInitializer {
4748

4849
public static final OptionCategory config = new OptionCategory(new Identifier("storedOptions"), "storedOptions");
4950
public static final BooleanOption someNiceBackground = new BooleanOption("defNoSecret", false);
50-
public static final HashMap<Identifier, AbstractModule> modules= new HashMap<>();
51+
public static final HashMap<Identifier, AbstractModule> modules = new HashMap<>();
5152

5253
public static Integer tickTime = 0;
5354

@@ -85,6 +86,7 @@ public static void getModules(){
8586
modules.put(HudManager.ID, HudManager.getINSTANCE());
8687
modules.put(HypixelMods.ID, HypixelMods.INSTANCE);
8788
modules.put(MotionBlur.ID, new MotionBlur());
89+
modules.put(ScrollableTooltips.ID, ScrollableTooltips.Instance);
8890
}
8991

9092
public static boolean isUsingClient(UUID uuid){
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.github.axolotlclient.mixin;
2+
3+
import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips;
4+
import net.minecraft.client.gui.screen.ingame.HandledScreen;
5+
import net.minecraft.inventory.slot.Slot;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.Shadow;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Inject;
10+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11+
12+
@Mixin(HandledScreen.class)
13+
public abstract class HandledScreenMixin {
14+
15+
@Shadow private Slot focusedSlot;
16+
private Slot cachedSlot;
17+
18+
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;popMatrix()V"))
19+
public void resetScrollOnSlotChange(int mouseX, int mouseY, float tickDelta, CallbackInfo ci){
20+
21+
if(ScrollableTooltips.Instance.enabled.get() && cachedSlot != focusedSlot){
22+
cachedSlot = focusedSlot;
23+
ScrollableTooltips.Instance.resetScroll();
24+
}
25+
26+
}
27+
28+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package io.github.axolotlclient.mixin;
2+
3+
import io.github.axolotlclient.modules.scrollableTooltips.ScrollableTooltips;
4+
import net.minecraft.client.MinecraftClient;
5+
import net.minecraft.client.gui.screen.Screen;
6+
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
7+
import net.minecraft.item.itemgroup.ItemGroup;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.ModifyArgs;
11+
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
12+
13+
@Mixin(Screen.class)
14+
public abstract class ScreenMixin {
15+
16+
@ModifyArgs(method = "renderTooltip(Lnet/minecraft/item/ItemStack;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;renderTooltip(Ljava/util/List;II)V"))
17+
public void modifyTooltipPosition(Args args){
18+
if(ScrollableTooltips.Instance.enabled.get()) {
19+
20+
if((MinecraftClient.getInstance().currentScreen instanceof CreativeInventoryScreen) &&
21+
((CreativeInventoryScreen)MinecraftClient.getInstance().currentScreen).getSelectedTab() != ItemGroup.INVENTORY.getIndex()){
22+
return;
23+
}
24+
25+
ScrollableTooltips.Instance.onRenderTooltip();
26+
args.set(1, (int)args.get(1) + ScrollableTooltips.Instance.tooltipOffsetX);
27+
args.set(2, (int)args.get(2) + ScrollableTooltips.Instance.tooltipOffsetY);
28+
}
29+
}
30+
31+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package io.github.axolotlclient.modules.scrollableTooltips;
2+
3+
import io.github.axolotlclient.AxolotlClient;
4+
import io.github.axolotlclient.config.options.BooleanOption;
5+
import io.github.axolotlclient.config.options.IntegerOption;
6+
import io.github.axolotlclient.config.options.OptionCategory;
7+
import io.github.axolotlclient.modules.AbstractModule;
8+
import net.legacyfabric.fabric.api.client.keybinding.v1.KeyBindingHelper;
9+
import net.minecraft.client.gui.screen.Screen;
10+
import net.minecraft.client.options.KeyBinding;
11+
import net.minecraft.util.Identifier;
12+
import org.lwjgl.input.Keyboard;
13+
import org.lwjgl.input.Mouse;
14+
15+
public class ScrollableTooltips extends AbstractModule {
16+
17+
public static Identifier ID = new Identifier("scrollabletooltips");
18+
19+
public int tooltipOffsetX;
20+
public int tooltipOffsetY;
21+
22+
protected KeyBinding key = new KeyBinding("scrollHorizontally", Keyboard.KEY_LSHIFT, "category.axolotlclient");
23+
24+
public static ScrollableTooltips Instance = new ScrollableTooltips();
25+
26+
private final OptionCategory category = new OptionCategory("scrollableTooltips");
27+
28+
public final BooleanOption enabled = new BooleanOption("enabled", false);
29+
public final BooleanOption enableShiftHorizontalScroll = new BooleanOption("shiftHorizontalScroll", true);
30+
protected final IntegerOption scrollAmount = new IntegerOption("scrollAmount", 5, 1, 20);
31+
32+
@Override
33+
public void init() {
34+
35+
category.add(enabled);
36+
category.add(enableShiftHorizontalScroll);
37+
category.add(scrollAmount);
38+
39+
AxolotlClient.CONFIG.rendering.addSubCategory(category);
40+
41+
KeyBindingHelper.registerKeyBinding(key);
42+
43+
}
44+
45+
public void onRenderTooltip(){
46+
if(enabled.get()) {
47+
48+
int i = Mouse.getDWheel();
49+
if (i != 0) {
50+
51+
if (i < 0) {
52+
onScroll(false);
53+
}
54+
55+
if (i > 0) {
56+
onScroll(true);
57+
}
58+
}
59+
}
60+
}
61+
62+
public void onScroll(boolean reverse){
63+
64+
if ((Screen.hasShiftDown() && key.getCode() == Keyboard.KEY_LSHIFT) || key.isPressed()) {
65+
if(reverse){
66+
tooltipOffsetX -= scrollAmount.get();
67+
68+
} else {
69+
tooltipOffsetX += scrollAmount.get();
70+
71+
}
72+
73+
} else {
74+
if (reverse) {
75+
tooltipOffsetY -= scrollAmount.get();
76+
77+
} else {
78+
tooltipOffsetY += scrollAmount.get();
79+
80+
}
81+
}
82+
}
83+
84+
public void resetScroll(){
85+
tooltipOffsetY = tooltipOffsetX = 0;
86+
}
87+
88+
}

src/main/resources/assets/axolotlclient/lang/en_US.lang

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ timeChanger=Time Changer
4848
time=Time
4949
blockOutlines=Block Outlines
5050
outlineWidth=Outline Width
51+
scrollableTooltips=Scrollable Tooltips
52+
shiftHorizontalScroll=Scroll Horizontal (if key pressed)
53+
shiftHorizontalScroll.tooltip=Allow scrolling horizontally if the specific key <br>is pressed. <br>The key is changeable in the Controls Menu.
54+
scrollAmount=Scroll Amount
55+
scrollAmount.tooltip=On scrolling, move the tooltip around this amount.
5156

5257
nametagOptions=Nametag Options
5358
showOwnNametag=Show Own Nametag
@@ -96,6 +101,7 @@ cpskeybind=CPS from Keybinds
96101
rightcps=Show Rightclick Cps
97102
fpshud=FPS HUD
98103
armorhud=Armor HUD
104+
showProtectionLevel=Show Protection Level
99105
potionshud=Potion HUD
100106
keystrokehud=Keystrokes
101107
speedhud=Speed HUD

src/main/resources/axolotlclient.mixins.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"BiPedModelMixin",
1717
"DebugHudMixin",
1818
"GlStateManagerMixin",
19+
"HandledScreenMixin",
1920
"ChatScreenMixin",
2021
"ClientBrandRetrieverMixin",
2122
"AddServerScreenMixin",
@@ -34,6 +35,7 @@
3435
"PlayerListHudMixin",
3536
"PlayerRendererMixin",
3637
"ReloadableResourceManagerImplMixin",
38+
"ScreenMixin",
3739
"SelectWorldScreenMixin",
3840
"TextureManagerMixin",
3941
"TitleScreenMixin",

0 commit comments

Comments
 (0)