Improved Range Combat While Eye Tracking

Adjusted the dynamic camera sensitivity while using an item intended to be used at a distance: the bow, crossbow, trident, and splash potion. The deadzone is now ignored, making slight adjustments to aim a little easier. The deadzone was meant to assist mining and building, but it is a hindrance in ranged combat.
This commit is contained in:
Kabliz
2024-03-17 12:04:24 -07:00
parent 43ffd89a61
commit 8a30b5ee73
2 changed files with 12 additions and 3 deletions

View File

@@ -115,8 +115,15 @@ public abstract class MouseMixin implements MouseAccessor {
cursorXSmoother.clear(); cursorXSmoother.clear();
cursorYSmoother.clear(); cursorYSmoother.clear();
} }
net.minecraft.item.ItemStack items = client.player != null ? client.player.getActiveItem() : net.minecraft.item.ItemStack.EMPTY;
boolean isUsingLongRangedTool = (leftButtonClicked &&
items.getUseAction() == net.minecraft.util.UseAction.BOW &&
items.getUseAction() == net.minecraft.util.UseAction.CROSSBOW &&
items.getUseAction() == net.minecraft.util.UseAction.SPEAR)
||
items.getItem() instanceof net.minecraft.item.ThrowablePotionItem;
EyeTrackerHandler.updateMouseWithEyeTracking(x + cursorDeltaX, y + cursorDeltaY, client, EyeTrackerHandler.updateMouseWithEyeTracking(x + cursorDeltaX, y + cursorDeltaY, client,
lastMouseUpdateTime, leftButtonClicked, cursorXSmoother, cursorYSmoother); lastMouseUpdateTime, leftButtonClicked, isUsingLongRangedTool, cursorXSmoother, cursorYSmoother);
lastMouseUpdateTime = GlfwUtil.getTime(); lastMouseUpdateTime = GlfwUtil.getTime();
cursorDeltaX = 0.0; cursorDeltaX = 0.0;
cursorDeltaY = 0.0; cursorDeltaY = 0.0;

View File

@@ -15,6 +15,7 @@ public class EyeTrackerHandler {
MinecraftClient client, MinecraftClient client,
double lastMouseUpdateTime, double lastMouseUpdateTime,
boolean holdingLeftMouseButton, boolean holdingLeftMouseButton,
boolean usingLongRangedTool,
SmoothUtil smoothX, SmoothUtil smoothX,
SmoothUtil smoothY SmoothUtil smoothY
) { ) {
@@ -45,7 +46,7 @@ public class EyeTrackerHandler {
} else { } else {
frameScalar = moveScalar; frameScalar = moveScalar;
} }
if(holdingLeftMouseButton){ if(holdingLeftMouseButton && !usingLongRangedTool) {
frameScalar *= 0.5; //Don't move the camera so much while mining. It's annoying. frameScalar *= 0.5; //Don't move the camera so much while mining. It's annoying.
} }
@@ -68,7 +69,8 @@ public class EyeTrackerHandler {
if (client.options.getInvertYMouse().getValue()) { if (client.options.getInvertYMouse().getValue()) {
invertY = -1.0; invertY = -1.0;
} }
if (client.player != null && moveMagnitude > MidnightControlsConfig.eyeTrackerDeadzone) { boolean notInDeadzone = (moveMagnitude > MidnightControlsConfig.eyeTrackerDeadzone) && !usingLongRangedTool;
if (client.player != null && notInDeadzone) {
client.player.changeLookDirection(moveX, moveY * invertY); client.player.changeLookDirection(moveX, moveY * invertY);
client.getTutorialManager().onUpdateMouse(moveX, moveY); client.getTutorialManager().onUpdateMouse(moveX, moveY);
} }