修复不能跑射的bug

This commit is contained in:
Atsuishio 2025-04-11 01:33:49 +08:00 committed by Light_Quanta
parent d585e9852d
commit 9540027c19
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
2 changed files with 13 additions and 9 deletions

View file

@ -224,6 +224,10 @@ public class ClickHandler {
PacketDistributor.sendToServer(new EditModeMessage(0)); PacketDistributor.sendToServer(new EditModeMessage(0));
} }
if (key == ModKeyMappings.BREATH.getKey().getValue() && !exhaustion && zoom) {
breath = true;
}
if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) { if (player.getData(ModAttachments.PLAYER_VARIABLE).edit) {
if (!(stack.getItem() instanceof GunItem gunItem)) return; if (!(stack.getItem() instanceof GunItem gunItem)) return;
if (ModKeyMappings.EDIT_GRIP.getKeyModifier().isActive(KeyConflictContext.IN_GAME)) { if (ModKeyMappings.EDIT_GRIP.getKeyModifier().isActive(KeyConflictContext.IN_GAME)) {
@ -272,6 +276,12 @@ public class ClickHandler {
handleWeaponZoomPress(player, stack); handleWeaponZoomPress(player, stack);
switchZoom = !switchZoom; switchZoom = !switchZoom;
} }
if (event.getAction() == GLFW.GLFW_RELEASE) {
if (key == ModKeyMappings.BREATH.getKey().getValue()) {
breath = false;
}
}
} }
} else { } else {
@ -317,7 +327,6 @@ public class ClickHandler {
if (stack.getItem() instanceof GunItem gunItem && !(player.getVehicle() != null if (stack.getItem() instanceof GunItem gunItem && !(player.getVehicle() != null
&& player.getVehicle() instanceof CannonEntity) && player.getVehicle() instanceof CannonEntity)
&& clientTimer.getProgress() == 0 && clientTimer.getProgress() == 0
&& cantFireTime == 0
&& !notInGame() && !notInGame()
) { ) {
var data = GunData.from(stack); var data = GunData.from(stack);
@ -341,6 +350,7 @@ public class ClickHandler {
} }
} else { } else {
ClientEventHandler.holdFire = true; ClientEventHandler.holdFire = true;
player.setSprinting(false);
} }
} }
} }

View file

@ -294,10 +294,6 @@ public class ClientEventHandler {
return; return;
} }
if (!exhaustion && zoom) {
breath = ModKeyMappings.BREATH.isDown();
}
tacticalSprint = !exhaustion && !zoom && isMoving() && player.isSprinting() && player.getVehicle() == null && player.onGround(); tacticalSprint = !exhaustion && !zoom && isMoving() && player.isSprinting() && player.getVehicle() == null && player.onGround();
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
@ -335,9 +331,7 @@ public class ClientEventHandler {
switchTime = Math.max(switchTime - 0.15, 0); switchTime = Math.max(switchTime - 0.15, 0);
} }
if (!zoom) { if (zoom) {
breath = false;
} else {
tacticalSprint = false; tacticalSprint = false;
} }
@ -526,7 +520,7 @@ public class ClientEventHandler {
double weight = data.weight(); double weight = data.weight();
double speed = 1 - (0.04 * weight); double speed = 1 - (0.04 * weight);
if (ClientEventHandler.cantSprint == 0 && player.isSprinting() && !zoom) { if (ClientEventHandler.cantSprint == 0 && player.isSprinting() && !zoom && !holdFire) {
cantFireTime = Mth.clamp(cantFireTime + 3 * times, 0, 24); cantFireTime = Mth.clamp(cantFireTime + 3 * times, 0, 24);
} else { } else {
cantFireTime = Mth.clamp(cantFireTime - 6 * speed * times, 0, 40); cantFireTime = Mth.clamp(cantFireTime - 6 * speed * times, 0, 40);