优化近战相关代码
This commit is contained in:
parent
e93114b911
commit
8145f027c5
5 changed files with 20 additions and 12 deletions
|
@ -25,8 +25,6 @@ public class DefaultGunData {
|
|||
public double spread;
|
||||
@SerializedName("Damage")
|
||||
public double damage;
|
||||
@SerializedName("MeleeDamage")
|
||||
public double meleeDamage;
|
||||
@SerializedName("Headshot")
|
||||
public double headshot = 1.5;
|
||||
@SerializedName("Velocity")
|
||||
|
@ -34,6 +32,13 @@ public class DefaultGunData {
|
|||
@SerializedName("Magazine")
|
||||
public int magazine;
|
||||
|
||||
@SerializedName("MeleeDamage")
|
||||
public double meleeDamage;
|
||||
@SerializedName("MeleeDuration")
|
||||
public int meleeDuration = 26;
|
||||
@SerializedName("MeleeDamageTime")
|
||||
public int meleeDamageTime = 6;
|
||||
|
||||
@SerializedName("Projectile")
|
||||
public ProjectileInfo projectile = new ProjectileInfo();
|
||||
|
||||
|
|
|
@ -164,6 +164,14 @@ public class GunData {
|
|||
return defaultGunData().meleeDamage;
|
||||
}
|
||||
|
||||
public int meleeDuration() {
|
||||
return Math.max(0, defaultGunData().meleeDuration);
|
||||
}
|
||||
|
||||
public int meleeDamageTime() {
|
||||
return Math.min(meleeDuration(), defaultGunData().meleeDamageTime);
|
||||
}
|
||||
|
||||
public double explosionDamage() {
|
||||
return defaultGunData().explosionDamage;
|
||||
}
|
||||
|
|
|
@ -419,11 +419,11 @@ public class ClientEventHandler {
|
|||
&& !data.reloading()
|
||||
&& !data.charging() && !player.getCooldowns().isOnCooldown(stack.getItem())
|
||||
) {
|
||||
gunMelee = 36;
|
||||
cantFireTime = 40;
|
||||
player.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, 1f, 1);
|
||||
gunMelee = data.meleeDuration();
|
||||
cantFireTime = gunMelee + 4;
|
||||
}
|
||||
if (gunMelee == 22) {
|
||||
if (gunMelee == data.meleeDuration() - data.meleeDamageTime()) {
|
||||
player.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, 1f, 1);
|
||||
Entity lookingEntity = TraceTool.findMeleeEntity(player, player.entityInteractionRange());
|
||||
if (lookingEntity != null) {
|
||||
PacketDistributor.sendToServer(new MeleeAttackMessage(lookingEntity.getUUID()));
|
||||
|
|
|
@ -312,7 +312,7 @@ public abstract class GunItem extends Item implements CustomRendererItem {
|
|||
* @param stack 武器物品
|
||||
*/
|
||||
public boolean hasMeleeAttack(ItemStack stack) {
|
||||
return false;
|
||||
return GunData.from(stack).meleeDamage() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -179,11 +179,6 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, EnergyStorag
|
|||
return Optional.of(new SecondaryCataclysmImageComponent(pStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMeleeAttack(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAmmoDisplayName(GunData data) {
|
||||
return "40mm Grenade";
|
||||
|
|
Loading…
Add table
Reference in a new issue