提取开火延迟

This commit is contained in:
Atsuishio 2025-04-19 00:26:47 +08:00 committed by Light_Quanta
parent 45386b0fd8
commit de14246988
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
5 changed files with 27 additions and 12 deletions

View file

@ -51,7 +51,7 @@ public class MinigunItemModel extends GeoModel<MinigunItem> {
int rpm = GunData.from(stack).rpm();
gun.setRotZ(gun.getRotZ() + times * -0.07f * ((float) rpm / 1200) * ClientEventHandler.miniGunRot);
gun.setRotZ((float) (gun.getRotZ() + times * -0.07f * ((float) rpm / 1200) * ClientEventHandler.shootDelay));
shen.setPosX((float) (0.75f * ClientEventHandler.recoilHorizon * fpz * fp));
shen.setPosY((float) (-0.03f * fp - 0.06f * fr));

View file

@ -141,7 +141,7 @@ public class ClientEventHandler {
public static double chamberRot = 0;
public static double actionMove = 0;
public static int miniGunRot = 0;
public static double shootDelay = 0;
public static double revolverPreTime = 0;
public static double revolverWheelPreTime = 0;
@ -230,12 +230,19 @@ public class ClientEventHandler {
ItemStack stack = player.getMainHandItem();
final var tag = NBTTool.getTag(stack);
if (stack.is(ModItems.MINIGUN.get())) {
// 射击延迟
if (stack.is(ModTags.Items.GUN)) {
var data = GunData.from(stack);
if (holdFire || zoom) {
miniGunRot = Math.min(miniGunRot + 5, 21);
float rpm = (float) data.rpm() / 3600;
player.playSound(ModSounds.MINIGUN_ROT.get(), 1, 0.7f + rpm);
if (holdFire || (zoom && stack.is(ModItems.MINIGUN.get()))) {
shootDelay = Math.min(shootDelay + 2, data.shootDelay() + 1);
// 加特林特有的旋转音效
if (stack.is(ModItems.MINIGUN.get())) {
float rpm = (float) data.rpm() / 3600;
player.playSound(ModSounds.MINIGUN_ROT.get(), 1, 0.7f + rpm);
}
}
}
@ -385,8 +392,8 @@ public class ClientEventHandler {
}
private static void handleVariableDecrease() {
if (miniGunRot > 0) {
miniGunRot--;
if (shootDelay > 0) {
shootDelay = Math.max(shootDelay - 1, 0);
}
if (dismountCountdown > 0) {
@ -571,7 +578,7 @@ public class ClientEventHandler {
var cap = player.getData(ModAttachments.PLAYER_VARIABLE);
if ((holdFire || burstFireAmount > 0)
if (((holdFire || burstFireAmount > 0) && shootDelay >= data.shootDelay())
&& !(player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
&& !holdFireVehicle
&& (stack.is(ModTags.Items.NORMAL_GUN)
@ -589,7 +596,7 @@ public class ClientEventHandler {
|| (stack.is(ModItems.MINIGUN.get())
&& !player.isSprinting()
&& tag.getDouble("overheat") == 0
&& !player.getCooldowns().isOnCooldown(stack.getItem()) && miniGunRot >= 20
&& !player.getCooldowns().isOnCooldown(stack.getItem())
&& data.hasBackupAmmo(player)
))) {
if (mode == 0) {

View file

@ -67,4 +67,7 @@ public class DefaultGunData {
@SerializedName("ExplosionRadius")
public double explosionRadius;
@SerializedName("ShootDelay")
public double shootDelay = 0;
}

View file

@ -277,6 +277,10 @@ public class GunData {
return defaultGunData().burstAmount;
}
public double shootDelay() {
return defaultGunData().shootDelay;
}
public enum AmmoConsumeType {
PLAYER_AMMO, ITEM, TAG, INVALID,
}

View file

@ -9,5 +9,6 @@
"BypassesArmor": 0.3,
"SoundRadius": 14,
"RPM": 1200,
"AmmoType": "@RifleAmmo"
"AmmoType": "@RifleAmmo",
"ShootDelay": 20
}