diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/item/MinigunItemModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/item/MinigunItemModel.java index 3bc3e821e..193471d42 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/item/MinigunItemModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/item/MinigunItemModel.java @@ -51,7 +51,7 @@ public class MinigunItemModel extends GeoModel { 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)); diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index 251568e68..a94f5da9e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java @@ -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) { diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/DefaultGunData.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/DefaultGunData.java index 6e50e5c04..36ea1723c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/DefaultGunData.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/DefaultGunData.java @@ -67,4 +67,7 @@ public class DefaultGunData { @SerializedName("ExplosionRadius") public double explosionRadius; + @SerializedName("ShootDelay") + public double shootDelay = 0; + } diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java index 5aabbabb1..431643a66 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/data/GunData.java @@ -277,6 +277,10 @@ public class GunData { return defaultGunData().burstAmount; } + public double shootDelay() { + return defaultGunData().shootDelay; + } + public enum AmmoConsumeType { PLAYER_AMMO, ITEM, TAG, INVALID, } diff --git a/src/main/resources/data/superbwarfare/guns/minigun.json b/src/main/resources/data/superbwarfare/guns/minigun.json index 4aa46ed5e..e66be486d 100644 --- a/src/main/resources/data/superbwarfare/guns/minigun.json +++ b/src/main/resources/data/superbwarfare/guns/minigun.json @@ -9,5 +9,6 @@ "BypassesArmor": 0.3, "SoundRadius": 14, "RPM": 1200, - "AmmoType": "@RifleAmmo" + "AmmoType": "@RifleAmmo", + "ShootDelay": 20 } \ No newline at end of file