提取开火延迟
This commit is contained in:
parent
45386b0fd8
commit
de14246988
5 changed files with 27 additions and 12 deletions
|
@ -51,7 +51,7 @@ public class MinigunItemModel extends GeoModel<MinigunItem> {
|
||||||
|
|
||||||
int rpm = GunData.from(stack).rpm();
|
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.setPosX((float) (0.75f * ClientEventHandler.recoilHorizon * fpz * fp));
|
||||||
shen.setPosY((float) (-0.03f * fp - 0.06f * fr));
|
shen.setPosY((float) (-0.03f * fp - 0.06f * fr));
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class ClientEventHandler {
|
||||||
public static double chamberRot = 0;
|
public static double chamberRot = 0;
|
||||||
public static double actionMove = 0;
|
public static double actionMove = 0;
|
||||||
|
|
||||||
public static int miniGunRot = 0;
|
public static double shootDelay = 0;
|
||||||
|
|
||||||
public static double revolverPreTime = 0;
|
public static double revolverPreTime = 0;
|
||||||
public static double revolverWheelPreTime = 0;
|
public static double revolverWheelPreTime = 0;
|
||||||
|
@ -230,13 +230,20 @@ public class ClientEventHandler {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
final var tag = NBTTool.getTag(stack);
|
final var tag = NBTTool.getTag(stack);
|
||||||
|
|
||||||
if (stack.is(ModItems.MINIGUN.get())) {
|
// 射击延迟
|
||||||
|
if (stack.is(ModTags.Items.GUN)) {
|
||||||
var data = GunData.from(stack);
|
var data = GunData.from(stack);
|
||||||
if (holdFire || zoom) {
|
|
||||||
miniGunRot = Math.min(miniGunRot + 5, 21);
|
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;
|
float rpm = (float) data.rpm() / 3600;
|
||||||
player.playSound(ModSounds.MINIGUN_ROT.get(), 1, 0.7f + rpm);
|
player.playSound(ModSounds.MINIGUN_ROT.get(), 1, 0.7f + rpm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notInGame() && !ClickHandler.switchZoom) {
|
if (notInGame() && !ClickHandler.switchZoom) {
|
||||||
|
@ -385,8 +392,8 @@ public class ClientEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleVariableDecrease() {
|
private static void handleVariableDecrease() {
|
||||||
if (miniGunRot > 0) {
|
if (shootDelay > 0) {
|
||||||
miniGunRot--;
|
shootDelay = Math.max(shootDelay - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dismountCountdown > 0) {
|
if (dismountCountdown > 0) {
|
||||||
|
@ -571,7 +578,7 @@ public class ClientEventHandler {
|
||||||
|
|
||||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE);
|
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))
|
&& !(player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
||||||
&& !holdFireVehicle
|
&& !holdFireVehicle
|
||||||
&& (stack.is(ModTags.Items.NORMAL_GUN)
|
&& (stack.is(ModTags.Items.NORMAL_GUN)
|
||||||
|
@ -589,7 +596,7 @@ public class ClientEventHandler {
|
||||||
|| (stack.is(ModItems.MINIGUN.get())
|
|| (stack.is(ModItems.MINIGUN.get())
|
||||||
&& !player.isSprinting()
|
&& !player.isSprinting()
|
||||||
&& tag.getDouble("overheat") == 0
|
&& tag.getDouble("overheat") == 0
|
||||||
&& !player.getCooldowns().isOnCooldown(stack.getItem()) && miniGunRot >= 20
|
&& !player.getCooldowns().isOnCooldown(stack.getItem())
|
||||||
&& data.hasBackupAmmo(player)
|
&& data.hasBackupAmmo(player)
|
||||||
))) {
|
))) {
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
|
|
|
@ -67,4 +67,7 @@ public class DefaultGunData {
|
||||||
@SerializedName("ExplosionRadius")
|
@SerializedName("ExplosionRadius")
|
||||||
public double explosionRadius;
|
public double explosionRadius;
|
||||||
|
|
||||||
|
@SerializedName("ShootDelay")
|
||||||
|
public double shootDelay = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,6 +277,10 @@ public class GunData {
|
||||||
return defaultGunData().burstAmount;
|
return defaultGunData().burstAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double shootDelay() {
|
||||||
|
return defaultGunData().shootDelay;
|
||||||
|
}
|
||||||
|
|
||||||
public enum AmmoConsumeType {
|
public enum AmmoConsumeType {
|
||||||
PLAYER_AMMO, ITEM, TAG, INVALID,
|
PLAYER_AMMO, ITEM, TAG, INVALID,
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,6 @@
|
||||||
"BypassesArmor": 0.3,
|
"BypassesArmor": 0.3,
|
||||||
"SoundRadius": 14,
|
"SoundRadius": 14,
|
||||||
"RPM": 1200,
|
"RPM": 1200,
|
||||||
"AmmoType": "@RifleAmmo"
|
"AmmoType": "@RifleAmmo",
|
||||||
|
"ShootDelay": 20
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue