添加低帧率下的开火次数补偿
This commit is contained in:
parent
505943621c
commit
d878aa6ec9
1 changed files with 22 additions and 8 deletions
|
@ -564,7 +564,7 @@ public class ClientEventHandler {
|
||||||
double rps = (double) rpm / 60;
|
double rps = (double) rpm / 60;
|
||||||
|
|
||||||
// cooldown in ms
|
// cooldown in ms
|
||||||
int cooldown = (int) (1000 / rps);
|
int cooldown = (int) Math.round(1000 / rps);
|
||||||
|
|
||||||
//左轮类
|
//左轮类
|
||||||
if (clientTimer.getProgress() == 0 && stack.is(ModTags.Items.REVOLVER) && ((holdFire && !data.DA.get())
|
if (clientTimer.getProgress() == 0 && stack.is(ModTags.Items.REVOLVER) && ((holdFire && !data.DA.get())
|
||||||
|
@ -604,12 +604,19 @@ public class ClientEventHandler {
|
||||||
if (!clientTimer.started()) {
|
if (!clientTimer.started()) {
|
||||||
clientTimer.start();
|
clientTimer.start();
|
||||||
// 首发瞬间发射
|
// 首发瞬间发射
|
||||||
clientTimer.setProgress((cooldown + 1));
|
clientTimer.setProgress(cooldown + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientTimer.getProgress() >= cooldown) {
|
if (clientTimer.getProgress() >= cooldown) {
|
||||||
shootClient(player);
|
var newProgress = clientTimer.getProgress();
|
||||||
clientTimer.setProgress((clientTimer.getProgress() - cooldown));
|
|
||||||
|
// 低帧率下的开火次数补偿
|
||||||
|
do {
|
||||||
|
shootClient(player);
|
||||||
|
newProgress -= cooldown;
|
||||||
|
} while (newProgress - cooldown > 0);
|
||||||
|
|
||||||
|
clientTimer.setProgress(newProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,7 +840,7 @@ public class ClientEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
double rps = (double) rpm / 60;
|
double rps = (double) rpm / 60;
|
||||||
int cooldown = (int) (1000 / rps);
|
int cooldown = (int) Math.round(1000 / rps);
|
||||||
|
|
||||||
if ((holdFireVehicle)) {
|
if ((holdFireVehicle)) {
|
||||||
if (!clientTimerVehicle.started()) {
|
if (!clientTimerVehicle.started()) {
|
||||||
|
@ -843,10 +850,17 @@ public class ClientEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientTimerVehicle.getProgress() >= cooldown) {
|
if (clientTimerVehicle.getProgress() >= cooldown) {
|
||||||
PacketDistributor.sendToServer(new VehicleFireMessage(pVehicle.getSeatIndex(player)));
|
var newProgress = clientTimerVehicle.getProgress();
|
||||||
|
|
||||||
playVehicleClientSounds(player, iVehicle, pVehicle.getSeatIndex(player));
|
// 低帧率下的开火次数补偿
|
||||||
clientTimerVehicle.setProgress((clientTimerVehicle.getProgress() - cooldown));
|
do {
|
||||||
|
PacketDistributor.sendToServer(new VehicleFireMessage(pVehicle.getSeatIndex(player)));
|
||||||
|
playVehicleClientSounds(player, iVehicle, pVehicle.getSeatIndex(player));
|
||||||
|
|
||||||
|
newProgress -= cooldown;
|
||||||
|
} while (newProgress - cooldown > 0);
|
||||||
|
|
||||||
|
clientTimerVehicle.setProgress(newProgress);
|
||||||
}
|
}
|
||||||
} else if (clientTimerVehicle.getProgress() >= cooldown) {
|
} else if (clientTimerVehicle.getProgress() >= cooldown) {
|
||||||
clientTimerVehicle.stop();
|
clientTimerVehicle.stop();
|
||||||
|
|
Loading…
Add table
Reference in a new issue