Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/main/java/com/tacz/guns/client/input/AimKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,50 @@ public static void onAimPress(InputEvent.MouseButton.Post event) {
}
}

/**
* 该监听器能正确处理 按住瞄准模式 下的
* 1.预输入(典型:按住瞄准切换武器后,能保持瞄准状态)
* 2.键盘按键输入
*
* 建议将按下切换瞄准也支持 键盘按键输入
* */
@SubscribeEvent
public static void onAimHoldingPreInput(ClientTickEvent event) {
if (!KeyConfig.HOLD_TO_AIM.get()) {
return;
}
Minecraft mc = Minecraft.getInstance();
boolean press = false;
if(AimKey.AIM_KEY.getKey().getValue()<0) {
return;
}
if (AimKey.AIM_KEY.getKey().getValue() >= GLFW.GLFW_KEY_SPACE) {
press = press || GLFW.glfwGetKey(mc.getWindow().getWindow(), AimKey.AIM_KEY.getKey().getValue()) == GLFW.GLFW_PRESS;
} else {
press = GLFW.glfwGetMouseButton(mc.getWindow().getWindow(), AimKey.AIM_KEY.getKey().getValue()) == GLFW.GLFW_PRESS;
}
if (InputExtraCheck.isInGame()) {
LocalPlayer player = mc.player;
if (player == null || player.isSpectator()) {
return;
}
if (!(player instanceof IClientPlayerGunOperator operator)) {
return;
}
if (operator.isAim() && press) {
return;
}
if (!operator.isAim()) {
if (!press) {
return;
}
}
if (IGun.mainHandHoldGun(player)) {
IClientPlayerGunOperator.fromLocalPlayer(player).aim(press);
}
}
}

public static boolean onAimControllerPress(boolean isPress) {
if (!isInGame()) {
return false;
Expand Down