Skip to content

Commit aa858a7

Browse files
committed
Add support for debugging multiple hexes at once
1 parent 2fe3560 commit aa858a7

File tree

21 files changed

+485
-232
lines changed

21 files changed

+485
-232
lines changed

Common/src/main/java/gay/object/hexdebug/mixin/MixinMsgShiftScrollC2S.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,32 @@
22

33
import at.petrak.hexcasting.common.msgs.MsgShiftScrollC2S;
44
import gay.object.hexdebug.items.DebuggerItem;
5+
import gay.object.hexdebug.items.EvaluatorItem;
56
import net.minecraft.server.level.ServerPlayer;
67
import net.minecraft.world.InteractionHand;
8+
import org.spongepowered.asm.mixin.Final;
79
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.Shadow;
811
import org.spongepowered.asm.mixin.injection.At;
912
import org.spongepowered.asm.mixin.injection.Inject;
1013
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1114

1215
// server side
1316
@Mixin(MsgShiftScrollC2S.class)
1417
public class MixinMsgShiftScrollC2S {
18+
@Final
19+
@Shadow(remap = false)
20+
private boolean isCtrl;
21+
1522
@Inject(method = "handleForHand", at = @At("HEAD"))
1623
private void hexdebug$handleForHand(ServerPlayer sender, InteractionHand hand, double delta, CallbackInfo ci) {
1724
if (delta != 0) {
1825
var stack = sender.getItemInHand(hand);
1926
var item = stack.getItem();
2027
if (item instanceof DebuggerItem debugger) {
21-
debugger.handleShiftScroll(sender, stack, delta);
28+
debugger.handleShiftScroll(sender, stack, delta, isCtrl);
29+
} else if (item instanceof EvaluatorItem evaluator) {
30+
evaluator.handleShiftScroll(sender, stack, delta, isCtrl);
2231
}
2332
}
2433
}

Common/src/main/java/gay/object/hexdebug/mixin/MixinShiftScrollListener.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ public abstract class MixinShiftScrollListener {
2828

2929
@Inject(method = "IsScrollableItem", at = @At("RETURN"), cancellable = true)
3030
private static void hexdebug$IsScrollableItem(Item item, CallbackInfoReturnable<Boolean> cir) {
31-
if (item == HexDebugItems.DEBUGGER.getValue()) {
31+
if (
32+
item == HexDebugItems.DEBUGGER.getValue()
33+
// evaluator only scrolls thread id, so don't consume the scroll if we're not holding sprint
34+
|| (item == HexDebugItems.EVALUATOR.getValue() && Minecraft.getInstance().options.keySprint.isDown())
35+
) {
3236
cir.setReturnValue(true);
3337
}
3438
}
@@ -44,8 +48,8 @@ public abstract class MixinShiftScrollListener {
4448
&& !player.isSpectator()
4549
// additional logic
4650
&& HexDebugClientConfig.getConfig().getSmartDebuggerSneakScroll()
47-
&& !DebuggerItem.isDebugging()
4851
&& player.getMainHandItem().getItem() == HexDebugItems.DEBUGGER.getValue()
52+
&& !DebuggerItem.isDebugging(player.getMainHandItem())
4953
&& hexdebug$invokeIsScrollableItem(player.getOffhandItem().getItem())
5054
) {
5155
offHandDelta += delta;

0 commit comments

Comments
 (0)