Merge pull request #272 from kabliz/eye_tracking_range_combat

Improved Range Combat While Eye Tracking
This commit is contained in:
Martin Prokoph
2024-04-29 20:05:21 +02:00
committed by GitHub
2 changed files with 12 additions and 3 deletions

View File

@@ -115,8 +115,15 @@ public abstract class MouseMixin implements MouseAccessor {
cursorXSmoother.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,
glfwTime, leftButtonClicked, cursorXSmoother, cursorYSmoother);
glfwTime, leftButtonClicked, isUsingLongRangedTool, cursorXSmoother, cursorYSmoother);
glfwTime = GlfwUtil.getTime();
cursorDeltaX = 0.0;
cursorDeltaY = 0.0;

View File

@@ -15,6 +15,7 @@ public class EyeTrackerHandler {
MinecraftClient client,
double lastMouseUpdateTime,
boolean holdingLeftMouseButton,
boolean usingLongRangedTool,
SmoothUtil smoothX,
SmoothUtil smoothY
) {
@@ -45,7 +46,7 @@ public class EyeTrackerHandler {
} else {
frameScalar = moveScalar;
}
if(holdingLeftMouseButton){
if(holdingLeftMouseButton && !usingLongRangedTool) {
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()) {
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.getTutorialManager().onUpdateMouse(moveX, moveY);
}